From c2ad9e380121d43f8ac066b590f9929a56bd1b0f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 17 Feb 2010 16:41:30 +0100 Subject: util: new util_format_get_nr_components helper --- src/gallium/auxiliary/util/u_format.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 2fbbb83d4b..6345a11a8c 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -404,6 +404,23 @@ util_format_has_alpha(enum pipe_format format) } } +/** + * Return the number of components stored. + * Formats with block size != 1x1 will always have 1 component (the block). + */ +static INLINE unsigned +util_format_get_nr_components(enum pipe_format format) +{ + const struct util_format_description *desc = util_format_description(format); + unsigned chan; + unsigned nr_comp = 0; + for (chan = 0; chan < 4; chan++) { + if (desc->channel[chan].size != 0) { + nr_comp++; + } + } + return nr_comp; +} /* * Format access functions. -- cgit v1.2.3 From 464a72dd4154f314e08c9d0c4d07417e2bf255f0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 17 Feb 2010 16:44:38 +0100 Subject: gallium: remove redundant nr_components field from pipe_vertex_element This is a property of the associated src_format pipe format. Hence use util_format_get_nr_components to query this when necessary instead. --- progs/gallium/python/retrace/interpreter.py | 1 - src/gallium/auxiliary/draw/draw_pt.c | 5 ++--- src/gallium/auxiliary/util/u_draw_quad.c | 1 - src/gallium/auxiliary/util/u_dump_state.c | 1 - src/gallium/auxiliary/vl/vl_compositor.c | 2 -- src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 8 ------- src/gallium/drivers/i965/brw_draw_upload.c | 5 ++++- src/gallium/drivers/nv50/nv50_vbo.c | 27 ++++++++++++++---------- src/gallium/drivers/trace/tr_dump_state.c | 1 - src/gallium/include/pipe/p_state.h | 1 - src/gallium/state_trackers/vega/polygon.c | 1 - src/mesa/state_tracker/st_draw.c | 3 --- src/mesa/state_tracker/st_draw_feedback.c | 1 - 13 files changed, 22 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/progs/gallium/python/retrace/interpreter.py b/progs/gallium/python/retrace/interpreter.py index 2db71a212f..52c08abdd3 100755 --- a/progs/gallium/python/retrace/interpreter.py +++ b/progs/gallium/python/retrace/interpreter.py @@ -551,7 +551,6 @@ class Context(Object): data = vbuf.buffer.read() values = unpack_from(format, data, offset) sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n') - assert len(values) == velem.nr_components sys.stdout.write('\t},\n') sys.stdout.flush() diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 341353f628..51beba50e4 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -309,9 +309,8 @@ draw_arrays_instanced(struct draw_context *draw, tgsi_dump(draw->vs.vertex_shader->state.tokens, 0); debug_printf("Elements:\n"); for (i = 0; i < draw->pt.nr_vertex_elements; i++) { - debug_printf(" format=%s comps=%u\n", - util_format_name(draw->pt.vertex_element[i].src_format), - draw->pt.vertex_element[i].nr_components); + debug_printf(" format=%s\n", + util_format_name(draw->pt.vertex_element[i].src_format)); } debug_printf("Buffers:\n"); for (i = 0; i < draw->pt.nr_vertex_buffers; i++) { diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index 14506e8451..36e9a4941f 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -64,7 +64,6 @@ util_draw_vertex_buffer(struct pipe_context *pipe, velements[i].instance_divisor = 0; velements[i].vertex_buffer_index = 0; velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - velements[i].nr_components = 4; } pipe->set_vertex_elements(pipe, num_attribs, velements); diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index eaf4ec90f2..196c5e06e9 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -701,7 +701,6 @@ util_dump_vertex_element(struct os_stream *stream, const struct pipe_vertex_elem util_dump_member(stream, uint, state, src_offset); util_dump_member(stream, uint, state, vertex_buffer_index); - util_dump_member(stream, uint, state, nr_components); util_dump_member(stream, format, state, src_format); diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index ba23435f69..5d61423f9d 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -317,7 +317,6 @@ init_buffers(struct vl_compositor *c) c->vertex_elems[0].src_offset = 0; c->vertex_elems[0].instance_divisor = 0; c->vertex_elems[0].vertex_buffer_index = 0; - c->vertex_elems[0].nr_components = 2; c->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; /* @@ -347,7 +346,6 @@ init_buffers(struct vl_compositor *c) c->vertex_elems[1].src_offset = 0; c->vertex_elems[1].instance_divisor = 0; c->vertex_elems[1].vertex_buffer_index = 1; - c->vertex_elems[1].nr_components = 2; c->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; /* diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index f323de0ea5..6b9ecd4268 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -892,56 +892,48 @@ init_buffers(struct vl_mpeg12_mc_renderer *r) r->vertex_elems[0].src_offset = 0; r->vertex_elems[0].instance_divisor = 0; r->vertex_elems[0].vertex_buffer_index = 0; - r->vertex_elems[0].nr_components = 2; r->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; /* Luma, texcoord element */ r->vertex_elems[1].src_offset = sizeof(struct vertex2f); r->vertex_elems[1].instance_divisor = 0; r->vertex_elems[1].vertex_buffer_index = 0; - r->vertex_elems[1].nr_components = 2; r->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; /* Chroma Cr texcoord element */ r->vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2; r->vertex_elems[2].instance_divisor = 0; r->vertex_elems[2].vertex_buffer_index = 0; - r->vertex_elems[2].nr_components = 2; r->vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; /* Chroma Cb texcoord element */ r->vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3; r->vertex_elems[3].instance_divisor = 0; r->vertex_elems[3].vertex_buffer_index = 0; - r->vertex_elems[3].nr_components = 2; r->vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT; /* First ref surface top field texcoord element */ r->vertex_elems[4].src_offset = 0; r->vertex_elems[4].instance_divisor = 0; r->vertex_elems[4].vertex_buffer_index = 1; - r->vertex_elems[4].nr_components = 2; r->vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT; /* First ref surface bottom field texcoord element */ r->vertex_elems[5].src_offset = sizeof(struct vertex2f); r->vertex_elems[5].instance_divisor = 0; r->vertex_elems[5].vertex_buffer_index = 1; - r->vertex_elems[5].nr_components = 2; r->vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT; /* Second ref surface top field texcoord element */ r->vertex_elems[6].src_offset = 0; r->vertex_elems[6].instance_divisor = 0; r->vertex_elems[6].vertex_buffer_index = 2; - r->vertex_elems[6].nr_components = 2; r->vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT; /* Second ref surface bottom field texcoord element */ r->vertex_elems[7].src_offset = sizeof(struct vertex2f); r->vertex_elems[7].instance_divisor = 0; r->vertex_elems[7].vertex_buffer_index = 2; - r->vertex_elems[7].nr_components = 2; r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT; r->vs_const_buf = pipe_buffer_create diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c index d59261557b..9eafdd4085 100644 --- a/src/gallium/drivers/i965/brw_draw_upload.c +++ b/src/gallium/drivers/i965/brw_draw_upload.c @@ -30,6 +30,7 @@ #include "util/u_upload_mgr.h" #include "util/u_math.h" +#include "util/u_format.h" #include "brw_draw.h" #include "brw_defines.h" @@ -352,13 +353,15 @@ static int brw_emit_vertex_elements(struct brw_context *brw) OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr * 2) - 2)); for (i = 0; i < nr; i++) { const struct pipe_vertex_element *input = &brw->curr.vertex_element[i]; + unsigned nr_components = util_format_get_nr_components(input->src_format); + uint32_t format = brw_translate_surface_format( input->src_format ); uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC; uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC; uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC; uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC; - switch (input->nr_components) { + switch (nr_components) { case 0: comp0 = BRW_VE1_COMPONENT_STORE_0; case 1: comp1 = BRW_VE1_COMPONENT_STORE_0; case 2: comp2 = BRW_VE1_COMPONENT_STORE_0; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 1c8ee0b9ad..909d323e05 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -139,15 +139,16 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve) uint32_t hw_type, hw_size; enum pipe_format pf = ve->src_format; const struct util_format_description *desc; - unsigned size; + unsigned size, nr_components; desc = util_format_description(pf); assert(desc); size = util_format_get_component_bits(pf, UTIL_FORMAT_COLORSPACE_RGB, 0); + nr_components = util_format_get_nr_components(pf); hw_type = nv50_vbo_type_to_hw(pf); - hw_size = nv50_vbo_size_to_hw(size, ve->nr_components); + hw_size = nv50_vbo_size_to_hw(size, nr_components); if (!hw_type || !hw_size) { NOUVEAU_ERR("unsupported vbo format: %s\n", util_format_name(pf)); @@ -222,11 +223,13 @@ nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_channel *chan = tesla->channel; float v[4]; + unsigned nr_components = util_format_get_nr_components(nv50->vtxelt[i].src_format); + util_format_read_4f(nv50->vtxelt[i].src_format, v, 0, data, 0, 0, 0, 1, 1); - switch (nv50->vtxelt[i].nr_components) { + switch (nr_components) { case 4: BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_4F_X(i), 4); OUT_RINGf (chan, v[0]); @@ -726,6 +729,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, struct nouveau_bo *bo = nouveau_bo(vb->buffer); float v[4]; int ret; + unsigned nr_components = util_format_get_nr_components(ve->src_format); ret = nouveau_bo_map(bo, NOUVEAU_BO_RD); if (ret) @@ -738,7 +742,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, if (!so) *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); - switch (ve->nr_components) { + switch (nr_components) { case 4: so_method(so, tesla, NV50TCL_VTX_ATTR_4F_X(attrib), 4); so_data (so, fui(v[0])); @@ -1019,7 +1023,7 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, for (i = 0; i < nv50->vtxelt_nr; ++i) { struct pipe_vertex_element *ve; struct pipe_vertex_buffer *vb; - unsigned n, size; + unsigned n, size, nr_components; const struct util_format_description *desc; ve = &nv50->vtxelt[i]; @@ -1038,8 +1042,9 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, size = util_format_get_component_bits( ve->src_format, UTIL_FORMAT_COLORSPACE_RGB, 0); + nr_components = util_format_get_nr_components(ve->src_format); - assert(ve->nr_components > 0 && ve->nr_components <= 4); + assert(nr_components > 0 && nr_components <= 4); /* It shouldn't be necessary to push the implicit 1s * for case 3 and size 8 cases 1, 2, 3. @@ -1049,25 +1054,25 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, NOUVEAU_ERR("unsupported vtxelt size: %u\n", size); return FALSE; case 32: - switch (ve->nr_components) { + switch (nr_components) { case 1: emit->push[n] = emit_b32_1; break; case 2: emit->push[n] = emit_b32_2; break; case 3: emit->push[n] = emit_b32_3; break; case 4: emit->push[n] = emit_b32_4; break; } - emit->vtx_dwords += ve->nr_components; + emit->vtx_dwords += nr_components; break; case 16: - switch (ve->nr_components) { + switch (nr_components) { case 1: emit->push[n] = emit_b16_1; break; case 2: emit->push[n] = emit_b32_1; break; case 3: emit->push[n] = emit_b16_3; break; case 4: emit->push[n] = emit_b32_2; break; } - emit->vtx_dwords += (ve->nr_components + 1) >> 1; + emit->vtx_dwords += (nr_components + 1) >> 1; break; case 8: - switch (ve->nr_components) { + switch (nr_components) { case 1: emit->push[n] = emit_b08_1; break; case 2: emit->push[n] = emit_b16_1; break; case 3: emit->push[n] = emit_b08_3; break; diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 6da186a655..b9ccc0ca69 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -480,7 +480,6 @@ void trace_dump_vertex_element(const struct pipe_vertex_element *state) trace_dump_member(uint, state, src_offset); trace_dump_member(uint, state, vertex_buffer_index); - trace_dump_member(uint, state, nr_components); trace_dump_member(format, state, src_format); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 5ac5c87813..5670f7a088 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -383,7 +383,6 @@ struct pipe_vertex_element * this attribute live in? */ unsigned vertex_buffer_index:8; - unsigned nr_components:8; enum pipe_format src_format; /**< PIPE_FORMAT_* */ }; diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index c06dbf5206..96fbbfc85a 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -296,7 +296,6 @@ static void draw_polygon(struct vg_context *ctx, velement.instance_divisor = 0; velement.vertex_buffer_index = 0; velement.src_format = PIPE_FORMAT_R32G32_FLOAT; - velement.nr_components = COMPONENTS; pipe->set_vertex_elements(pipe, 1, &velement); /* draw */ diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4b48c168e9..397dddbb47 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -368,7 +368,6 @@ setup_interleaved_attribs(GLcontext *ctx, (unsigned) (arrays[mesaAttr]->Ptr - offset0); velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = 0; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, @@ -458,7 +457,6 @@ setup_non_interleaved_attribs(GLcontext *ctx, vbuffer[attr].max_index = max_index; velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = attr; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, @@ -596,7 +594,6 @@ st_draw_vbo(GLcontext *ctx, for (i = 0; i < num_velements; i++) { printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index); printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); - printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components); printf("vlements[%d].format = %s\n", i, util_format_name(velements[i].src_format)); } } diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 087f2f22bb..26a5b3fcd6 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -178,7 +178,6 @@ st_feedback_draw_vbo(GLcontext *ctx, vbuffers[attr].max_index = max_index; velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = attr; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, -- cgit v1.2.3 From 51d139f03898e5e46af6363c6bba131455738cc4 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 18 Feb 2010 16:36:25 +0100 Subject: gallium: use cso state handling for pipe_vertex_element state --- src/gallium/auxiliary/cso_cache/cso_cache.c | 21 ++++++++ src/gallium/auxiliary/cso_cache/cso_cache.h | 11 +++- src/gallium/auxiliary/cso_cache/cso_context.c | 74 +++++++++++++++++++++++++++ src/gallium/auxiliary/cso_cache/cso_context.h | 7 ++- src/gallium/include/pipe/p_context.h | 9 ++-- 5 files changed, 117 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c index a6a07e72c2..900c64df4b 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.c +++ b/src/gallium/auxiliary/cso_cache/cso_cache.c @@ -43,6 +43,7 @@ struct cso_cache { struct cso_hash *vs_hash; struct cso_hash *rasterizer_hash; struct cso_hash *sampler_hash; + struct cso_hash *velements_hash; int max_size; cso_sanitize_callback sanitize_cb; @@ -108,6 +109,9 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_ case CSO_VERTEX_SHADER: hash = sc->vs_hash; break; + case CSO_VELEMENTS: + hash = sc->velements_hash; + break; } return hash; @@ -161,6 +165,13 @@ static void delete_vs_state(void *state, void *data) FREE(state); } +static void delete_velements(void *state, void *data) +{ + struct cso_velements *cso = (struct cso_velements *)state; + if (cso->delete_state) + cso->delete_state(cso->context, cso->data); + FREE(state); +} static INLINE void delete_cso(void *state, enum cso_cache_type type) { @@ -183,6 +194,9 @@ static INLINE void delete_cso(void *state, enum cso_cache_type type) case CSO_VERTEX_SHADER: delete_vs_state(state, 0); break; + case CSO_VELEMENTS: + delete_velements(state, 0); + break; default: assert(0); FREE(state); @@ -294,6 +308,7 @@ 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->velements_hash = cso_hash_create(); sc->sanitize_cb = sanitize_cb; sc->sanitize_data = 0; @@ -325,6 +340,9 @@ void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type, case CSO_VERTEX_SHADER: hash = sc->vs_hash; break; + case CSO_VELEMENTS: + hash = sc->velements_hash; + break; } iter = cso_hash_first_node(hash); @@ -351,6 +369,7 @@ void cso_cache_delete(struct cso_cache *sc) cso_for_each_state(sc, CSO_VERTEX_SHADER, delete_vs_state, 0); cso_for_each_state(sc, CSO_RASTERIZER, delete_rasterizer_state, 0); cso_for_each_state(sc, CSO_SAMPLER, delete_sampler_state, 0); + cso_for_each_state(sc, CSO_VELEMENTS, delete_velements, 0); cso_hash_delete(sc->blend_hash); cso_hash_delete(sc->sampler_hash); @@ -358,6 +377,7 @@ void cso_cache_delete(struct cso_cache *sc) cso_hash_delete(sc->rasterizer_hash); cso_hash_delete(sc->fs_hash); cso_hash_delete(sc->vs_hash); + cso_hash_delete(sc->velements_hash); FREE(sc); } @@ -372,6 +392,7 @@ void cso_set_maximum_cache_size(struct cso_cache *sc, int number) 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); + sanitize_hash(sc, sc->velements_hash, CSO_VELEMENTS, sc->max_size); } int cso_maximum_cache_size(const struct cso_cache *sc) diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h index eea60b940b..d884d5410f 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.h +++ b/src/gallium/auxiliary/cso_cache/cso_cache.h @@ -53,6 +53,7 @@ * - rasterizer (old setup) * - sampler * - vertex shader + * - vertex elements * * Things that are not constant state objects include: * - blend_color @@ -90,7 +91,8 @@ enum cso_cache_type { CSO_DEPTH_STENCIL_ALPHA, CSO_RASTERIZER, CSO_FRAGMENT_SHADER, - CSO_VERTEX_SHADER + CSO_VERTEX_SHADER, + CSO_VELEMENTS }; typedef void (*cso_state_callback)(void *ctx, void *obj); @@ -144,6 +146,13 @@ struct cso_sampler { struct pipe_context *context; }; +struct cso_velements { + struct pipe_vertex_element state[PIPE_MAX_ATTRIBS]; + void *data; + cso_state_callback delete_state; + struct pipe_context *context; +}; + unsigned cso_construct_key(void *item, int item_size); struct cso_cache *cso_cache_create(void); diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index b5241fa64c..95e3c18e53 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -89,6 +89,7 @@ struct cso_context { void *rasterizer, *rasterizer_saved; void *fragment_shader, *fragment_shader_saved, *geometry_shader; void *vertex_shader, *vertex_shader_saved, *geometry_shader_saved; + void *velements, *velements_saved; struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; @@ -171,6 +172,20 @@ static boolean delete_vs_state(struct cso_context *ctx, void *state) return FALSE; } +static boolean delete_vertex_elements(struct cso_context *ctx, + void *state) +{ + struct cso_velements *cso = (struct cso_velements *)state; + + if (ctx->velements == cso->data) + return FALSE; + + if (cso->delete_state) + cso->delete_state(cso->context, cso->data); + FREE(state); + return TRUE; +} + static INLINE boolean delete_cso(struct cso_context *ctx, void *state, enum cso_cache_type type) @@ -194,6 +209,9 @@ static INLINE boolean delete_cso(struct cso_context *ctx, case CSO_VERTEX_SHADER: return delete_vs_state(ctx, state); break; + case CSO_VELEMENTS: + return delete_vertex_elements(ctx, state); + break; default: assert(0); FREE(state); @@ -1126,3 +1144,59 @@ void cso_restore_geometry_shader(struct cso_context *ctx) } ctx->geometry_shader_saved = NULL; } + +enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, + unsigned count, + const struct pipe_vertex_element *states) +{ + unsigned key_size, hash_key; + struct cso_hash_iter iter; + void *handle; + + key_size = sizeof(struct pipe_vertex_element) * count; + hash_key = cso_construct_key((void*)states, key_size); + iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS, (void*)states, key_size); + + if (cso_hash_iter_is_null(iter)) { + struct cso_velements *cso = MALLOC(sizeof(struct cso_velements)); + if (!cso) + return PIPE_ERROR_OUT_OF_MEMORY; + + memcpy(&cso->state, states, key_size); + cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, count, &cso->state[0]); + cso->delete_state = (cso_state_callback)ctx->pipe->delete_vertex_elements_state; + cso->context = ctx->pipe; + + iter = cso_insert_state(ctx->cache, hash_key, CSO_VELEMENTS, cso); + if (cso_hash_iter_is_null(iter)) { + FREE(cso); + return PIPE_ERROR_OUT_OF_MEMORY; + } + + handle = cso->data; + } + else { + handle = ((struct cso_velements *)cso_hash_iter_data(iter))->data; + } + + if (ctx->velements != handle) { + ctx->velements = handle; + ctx->pipe->bind_vertex_elements_state(ctx->pipe, handle); + } + return PIPE_OK; +} + +void cso_save_vertex_elements(struct cso_context *ctx) +{ + assert(!ctx->velements); + ctx->velements_saved = ctx->velements; +} + +void cso_restore_vertex_elements(struct cso_context *ctx) +{ + if (ctx->velements != ctx->velements_saved) { + ctx->velements = ctx->velements_saved; + ctx->pipe->bind_vertex_elements_state(ctx->pipe, ctx->velements_saved); + } + ctx->velements_saved = NULL; +} \ No newline at end of file diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 707b3c2cee..2caa587516 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -122,6 +122,12 @@ void cso_restore_vertex_sampler_textures(struct cso_context *cso); +enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, + unsigned count, + const struct pipe_vertex_element *states); +void cso_save_vertex_elements(struct cso_context *ctx); +void cso_restore_vertex_elements(struct cso_context *ctx); + /* These aren't really sensible -- most of the time the api provides * object semantics for shaders anyway, and the cases where it doesn't @@ -157,7 +163,6 @@ void cso_save_geometry_shader(struct cso_context *cso); void cso_restore_geometry_shader(struct cso_context *cso); - enum pipe_error cso_set_framebuffer(struct cso_context *cso, const struct pipe_framebuffer_state *fb); void cso_save_framebuffer(struct cso_context *cso); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f82b77903e..376b01aa69 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -177,6 +177,12 @@ struct pipe_context { void (*bind_gs_state)(struct pipe_context *, void *); void (*delete_gs_state)(struct pipe_context *, void *); + void * (*create_vertex_elements_state)(struct pipe_context *, + unsigned num_elements, + const struct pipe_vertex_element *); + void (*bind_vertex_elements_state)(struct pipe_context *, void *); + void (*delete_vertex_elements_state)(struct pipe_context *, void *); + /*@}*/ /** @@ -220,9 +226,6 @@ struct pipe_context { unsigned num_buffers, const struct pipe_vertex_buffer * ); - void (*set_vertex_elements)( struct pipe_context *, - unsigned num_elements, - const struct pipe_vertex_element * ); /*@}*/ -- cgit v1.2.3 From 63cb6f59eac91ba34cf80ff3736568e40b094fe1 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 22 Feb 2010 21:36:22 +0100 Subject: gallium: Remove bypass_vs_clip_and_viewport from rasteriser state. Needs testing. --- src/gallium/auxiliary/draw/draw_context.c | 8 +- src/gallium/auxiliary/draw/draw_pt.c | 4 +- .../auxiliary/draw/draw_pt_fetch_shade_emit.c | 3 +- .../auxiliary/draw/draw_pt_fetch_shade_pipeline.c | 15 +- src/gallium/auxiliary/util/u_blit.c | 15 +- src/gallium/auxiliary/util/u_blitter.c | 1 - src/gallium/auxiliary/util/u_dump_state.c | 1 - src/gallium/auxiliary/util/u_gen_mipmap.c | 39 ++- src/gallium/docs/source/cso/rasterizer.rst | 12 - src/gallium/drivers/nv30/nv30_context.h | 1 - src/gallium/drivers/nv30/nv30_state_viewport.c | 58 +---- src/gallium/drivers/nv40/nv40_context.h | 1 - src/gallium/drivers/nv40/nv40_state_viewport.c | 57 +---- src/gallium/drivers/nv50/nv50_context.h | 1 - src/gallium/drivers/nv50/nv50_state_validate.c | 62 ++--- src/gallium/drivers/r300/r300_context.h | 2 - src/gallium/drivers/r300/r300_emit.c | 46 ++-- src/gallium/drivers/r300/r300_state.c | 5 +- src/gallium/drivers/r300/r300_state_derived.c | 8 +- src/gallium/drivers/softpipe/sp_video_context.c | 1 - src/gallium/drivers/svga/svga_state_framebuffer.c | 285 ++++++++++----------- src/gallium/drivers/svga/svga_state_need_swtnl.c | 3 +- src/gallium/drivers/trace/tr_dump_state.c | 1 - src/gallium/include/pipe/p_state.h | 10 - src/mesa/state_tracker/st_cb_clear.c | 44 ++-- 25 files changed, 271 insertions(+), 412 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index d5ddc4a6a9..bb0988543f 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -128,9 +128,7 @@ void draw_set_rasterizer_state( struct draw_context *draw, draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); draw->rasterizer = raster; - draw->bypass_clipping = - ((draw->rasterizer && draw->rasterizer->bypass_vs_clip_and_viewport) || - draw->driver.bypass_clipping); + draw->bypass_clipping = draw->driver.bypass_clipping; } @@ -140,9 +138,7 @@ void draw_set_driver_clipping( struct draw_context *draw, draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE ); draw->driver.bypass_clipping = bypass_clipping; - draw->bypass_clipping = - ((draw->rasterizer && draw->rasterizer->bypass_vs_clip_and_viewport) || - draw->driver.bypass_clipping); + draw->bypass_clipping = draw->driver.bypass_clipping; } diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 341353f628..6d90a6c42f 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -87,9 +87,7 @@ draw_pt_arrays(struct draw_context *draw, opt |= PT_CLIPTEST; } - if (!draw->rasterizer->bypass_vs_clip_and_viewport) { - opt |= PT_SHADE; - } + opt |= PT_SHADE; } if (opt == 0) diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c index c5dfbcfa3c..1aecb51077 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c @@ -100,8 +100,7 @@ static void fse_prepare( struct draw_pt_middle_end *middle, fse->key.nr_elements = MAX2(fse->key.nr_outputs, /* outputs - translate to hw format */ fse->key.nr_inputs); /* inputs - fetch from api format */ - fse->key.viewport = (!draw->rasterizer->bypass_vs_clip_and_viewport && - !draw->identity_viewport); + fse->key.viewport = !draw->identity_viewport; fse->key.clip = !draw->bypass_clipping; fse->key.const_vbuffers = 0; diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c index 56b69354b2..da5106463a 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline.c @@ -96,8 +96,7 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle, */ draw_pt_post_vs_prepare( fpme->post_vs, (boolean)draw->bypass_clipping, - (boolean)(draw->identity_viewport || - draw->rasterizer->bypass_vs_clip_and_viewport), + (boolean)draw->identity_viewport, (boolean)draw->rasterizer->gl_rasterization_rules, (draw->vs.edgeflag_output ? true : false) ); @@ -154,9 +153,7 @@ static void fetch_pipeline_run( struct draw_pt_middle_end *middle, (char *)pipeline_verts ); /* Run the shader, note that this overwrites the data[] parts of - * the pipeline verts. If there is no shader, eg if - * bypass_vs_clip_and_viewport, then the inputs == outputs, and are - * already in the correct place. + * the pipeline verts. */ if (opt & PT_SHADE) { @@ -239,9 +236,7 @@ static void fetch_pipeline_linear_run( struct draw_pt_middle_end *middle, (char *)pipeline_verts ); /* Run the shader, note that this overwrites the data[] parts of - * the pipeline verts. If there is no shader, ie if - * bypass_vs_clip_and_viewport, then the inputs == outputs, and are - * already in the correct place. + * the pipeline verts. */ if (opt & PT_SHADE) { @@ -319,9 +314,7 @@ static boolean fetch_pipeline_linear_run_elts( struct draw_pt_middle_end *middle (char *)pipeline_verts ); /* Run the shader, note that this overwrites the data[] parts of - * the pipeline verts. If there is no shader, ie if - * bypass_vs_clip_and_viewport, then the inputs == outputs, and are - * already in the correct place. + * the pipeline verts. */ if (opt & PT_SHADE) { diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index f0bc58a558..90a3230a0f 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -101,7 +101,6 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); ctx->rasterizer.front_winding = PIPE_WINDING_CW; ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; - ctx->rasterizer.bypass_vs_clip_and_viewport = 1; ctx->rasterizer.gl_rasterization_rules = 1; /* samplers */ @@ -114,7 +113,6 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) ctx->sampler.mag_img_filter = 0; /* set later */ ctx->sampler.normalized_coords = 1; - /* vertex shader - still required to provide the linkage between * fragment shader input semantics and vertex_element/buffers. */ @@ -407,6 +405,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_save_rasterizer(ctx->cso); cso_save_samplers(ctx->cso); cso_save_sampler_textures(ctx->cso); + cso_save_viewport(ctx->cso); cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); @@ -422,6 +421,17 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_single_sampler(ctx->cso, 0, &ctx->sampler); cso_single_sampler_done(ctx->cso); + /* viewport */ + ctx->viewport.scale[0] = 0.5f * dst->width; + ctx->viewport.scale[1] = 0.5f * dst->height; + ctx->viewport.scale[2] = 1.0f; + ctx->viewport.scale[3] = 1.0f; + ctx->viewport.translate[0] = 0.5f * dst->width; + ctx->viewport.translate[1] = 0.5f * dst->height; + ctx->viewport.translate[2] = 0.0f; + ctx->viewport.translate[3] = 0.0f; + cso_set_viewport(ctx->cso, &ctx->viewport); + /* texture */ cso_set_sampler_textures(ctx->cso, 1, &tex); @@ -461,6 +471,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_rasterizer(ctx->cso); cso_restore_samplers(ctx->cso); cso_restore_sampler_textures(ctx->cso); + cso_restore_viewport(ctx->cso); cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 18f8606818..50877f6b01 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -160,7 +160,6 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) memset(&rs_state, 0, sizeof(rs_state)); rs_state.front_winding = PIPE_WINDING_CW; rs_state.cull_mode = PIPE_WINDING_NONE; - rs_state.bypass_vs_clip_and_viewport = 1; rs_state.gl_rasterization_rules = 1; rs_state.flatshade = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c index eaf4ec90f2..ae7afd7311 100644 --- a/src/gallium/auxiliary/util/u_dump_state.c +++ b/src/gallium/auxiliary/util/u_dump_state.c @@ -318,7 +318,6 @@ util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterize util_dump_member(stream, uint, state, line_stipple_factor); util_dump_member(stream, uint, state, line_stipple_pattern); util_dump_member(stream, bool, state, line_last_pixel); - util_dump_member(stream, bool, state, bypass_vs_clip_and_viewport); util_dump_member(stream, bool, state, flatshade_first); util_dump_member(stream, bool, state, gl_rasterization_rules); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 1d7329d422..4f9ff1d961 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1296,7 +1296,6 @@ util_create_gen_mipmap(struct pipe_context *pipe, memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); ctx->rasterizer.front_winding = PIPE_WINDING_CW; ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; - ctx->rasterizer.bypass_vs_clip_and_viewport = 1; ctx->rasterizer.gl_rasterization_rules = 1; /* sampler state */ @@ -1361,25 +1360,25 @@ get_next_slot(struct gen_mipmap_state *ctx) static unsigned set_vertex_data(struct gen_mipmap_state *ctx, enum pipe_texture_target tex_target, - uint face, float width, float height) + uint face) { unsigned offset; /* vert[0].position */ - ctx->vertices[0][0][0] = 0.0f; /*x*/ - ctx->vertices[0][0][1] = 0.0f; /*y*/ + ctx->vertices[0][0][0] = -1.0f; /*x*/ + ctx->vertices[0][0][1] = -1.0f; /*y*/ /* vert[1].position */ - ctx->vertices[1][0][0] = width; - ctx->vertices[1][0][1] = 0.0f; + ctx->vertices[1][0][0] = 1.0f; + ctx->vertices[1][0][1] = -1.0f; /* vert[2].position */ - ctx->vertices[2][0][0] = width; - ctx->vertices[2][0][1] = height; + ctx->vertices[2][0][0] = 1.0f; + ctx->vertices[2][0][1] = 1.0f; /* vert[3].position */ - ctx->vertices[3][0][0] = 0.0f; - ctx->vertices[3][0][1] = height; + ctx->vertices[3][0][0] = -1.0f; + ctx->vertices[3][0][1] = 1.0f; /* Setup vertex texcoords. This is a little tricky for cube maps. */ if (tex_target == PIPE_TEXTURE_CUBE) { @@ -1499,6 +1498,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_viewport(ctx->cso); /* bind our state */ cso_set_blend(ctx->cso, &ctx->blend); @@ -1522,6 +1522,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, */ for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { const uint srcLevel = dstLevel - 1; + struct pipe_viewport_state vp; struct pipe_surface *surf = screen->get_tex_surface(screen, pt, face, dstLevel, zslice, @@ -1535,6 +1536,17 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, fb.height = u_minify(pt->height0, dstLevel); cso_set_framebuffer(ctx->cso, &fb); + /* viewport */ + vp.scale[0] = 0.5f * fb.width; + vp.scale[1] = 0.5f * fb.height; + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * fb.width; + vp.translate[1] = 0.5f * fb.height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; + cso_set_viewport(ctx->cso, &vp); + /* * Setup sampler state * Note: we should only have to set the min/max LOD clamps to ensure @@ -1549,12 +1561,10 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_set_sampler_textures(ctx->cso, 1, &pt); - /* quad coords in window coords (bypassing vs, clip and viewport) */ + /* quad coords in clip coords */ offset = set_vertex_data(ctx, pt->target, - face, - (float) u_minify(pt->width0, dstLevel), - (float) u_minify(pt->height0, dstLevel)); + face); util_draw_vertex_buffer(ctx->pipe, ctx->vbuf, @@ -1578,4 +1588,5 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_viewport(ctx->cso); } diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst index 24cc78c68d..ccd9136a2e 100644 --- a/src/gallium/docs/source/cso/rasterizer.rst +++ b/src/gallium/docs/source/cso/rasterizer.rst @@ -10,18 +10,6 @@ multisample state, scissoring and flat/smooth shading. Members ------- -bypass_vs_clip_and_viewport -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Whether the entire TCL pipeline should be bypassed. This implies that -vertices are pre-transformed for the viewport, and will not be run -through the vertex shader. - -.. note:: - - Implementations may still clip away vertices that are not in the viewport - when this is set. - flatshade ^^^^^^^^^ diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index ca3d6aca7f..ea259aadf3 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -101,7 +101,6 @@ struct nv30_blend_state { struct nv30_state { unsigned scissor_enabled; unsigned stipple_enabled; - unsigned viewport_bypass; unsigned fp_samplers; uint64_t dirty; diff --git a/src/gallium/drivers/nv30/nv30_state_viewport.c b/src/gallium/drivers/nv30/nv30_state_viewport.c index 2d7781292b..6fccd6b60e 100644 --- a/src/gallium/drivers/nv30/nv30_state_viewport.c +++ b/src/gallium/drivers/nv30/nv30_state_viewport.c @@ -5,55 +5,25 @@ nv30_state_viewport_validate(struct nv30_context *nv30) { struct pipe_viewport_state *vpt = &nv30->viewport; struct nouveau_stateobj *so; - unsigned bypass; - - if (/*nv30->render_mode == HW &&*/ - !nv30->rasterizer->pipe.bypass_vs_clip_and_viewport) - bypass = 0; - else - bypass = 1; if (nv30->state.hw[NV30_STATE_VIEWPORT] && - (bypass || !(nv30->dirty & NV30_NEW_VIEWPORT)) && - nv30->state.viewport_bypass == bypass) + !(nv30->dirty & NV30_NEW_VIEWPORT)) return FALSE; - nv30->state.viewport_bypass = bypass; so = so_new(3, 10, 0); - if (!bypass) { - so_method(so, nv30->screen->rankine, - NV34TCL_VIEWPORT_TRANSLATE_X, 8); - so_data (so, fui(vpt->translate[0])); - so_data (so, fui(vpt->translate[1])); - so_data (so, fui(vpt->translate[2])); - so_data (so, fui(vpt->translate[3])); - so_data (so, fui(vpt->scale[0])); - so_data (so, fui(vpt->scale[1])); - so_data (so, fui(vpt->scale[2])); - so_data (so, fui(vpt->scale[3])); -/* so_method(so, nv30->screen->rankine, 0x1d78, 1); - so_data (so, 1); -*/ } else { - so_method(so, nv30->screen->rankine, - NV34TCL_VIEWPORT_TRANSLATE_X, 8); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(1.0)); - so_data (so, fui(1.0)); - so_data (so, fui(1.0)); - so_data (so, fui(0.0)); - /* Not entirely certain what this is yet. The DDX uses this - * value also as it fixes rendering when you pass - * pre-transformed vertices to the GPU. My best gusss is that - * this bypasses some culling/clipping stage. Might be worth - * noting that points/lines are uneffected by whatever this - * value fixes, only filled polygons are effected. - */ -/* so_method(so, nv30->screen->rankine, 0x1d78, 1); - so_data (so, 0x110); -*/ } + so_method(so, nv30->screen->rankine, + NV34TCL_VIEWPORT_TRANSLATE_X, 8); + so_data (so, fui(vpt->translate[0])); + so_data (so, fui(vpt->translate[1])); + so_data (so, fui(vpt->translate[2])); + so_data (so, fui(vpt->translate[3])); + so_data (so, fui(vpt->scale[0])); + so_data (so, fui(vpt->scale[1])); + so_data (so, fui(vpt->scale[2])); + so_data (so, fui(vpt->scale[3])); +/* so_method(so, nv30->screen->rankine, 0x1d78, 1); + so_data (so, 1); +*/ /* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */ so_method(so, nv30->screen->rankine, 0x1d78, 1); so_data (so, 1); diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 4861924dac..97fb6a2ef9 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -101,7 +101,6 @@ struct nv40_blend_state { struct nv40_state { unsigned scissor_enabled; unsigned stipple_enabled; - unsigned viewport_bypass; unsigned fp_samplers; uint64_t dirty; diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c index 9919ba1d0b..3aacb00f99 100644 --- a/src/gallium/drivers/nv40/nv40_state_viewport.c +++ b/src/gallium/drivers/nv40/nv40_state_viewport.c @@ -5,55 +5,24 @@ nv40_state_viewport_validate(struct nv40_context *nv40) { struct pipe_viewport_state *vpt = &nv40->viewport; struct nouveau_stateobj *so; - unsigned bypass; - - if (nv40->render_mode == HW && - !nv40->rasterizer->pipe.bypass_vs_clip_and_viewport) - bypass = 0; - else - bypass = 1; if (nv40->state.hw[NV40_STATE_VIEWPORT] && - (bypass || !(nv40->dirty & NV40_NEW_VIEWPORT)) && - nv40->state.viewport_bypass == bypass) + !(nv40->dirty & NV40_NEW_VIEWPORT)) return FALSE; - nv40->state.viewport_bypass = bypass; so = so_new(2, 9, 0); - if (!bypass) { - so_method(so, nv40->screen->curie, - NV40TCL_VIEWPORT_TRANSLATE_X, 8); - so_data (so, fui(vpt->translate[0])); - so_data (so, fui(vpt->translate[1])); - so_data (so, fui(vpt->translate[2])); - so_data (so, fui(vpt->translate[3])); - so_data (so, fui(vpt->scale[0])); - so_data (so, fui(vpt->scale[1])); - so_data (so, fui(vpt->scale[2])); - so_data (so, fui(vpt->scale[3])); - so_method(so, nv40->screen->curie, 0x1d78, 1); - so_data (so, 1); - } else { - so_method(so, nv40->screen->curie, - NV40TCL_VIEWPORT_TRANSLATE_X, 8); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(0.0)); - so_data (so, fui(1.0)); - so_data (so, fui(1.0)); - so_data (so, fui(1.0)); - so_data (so, fui(0.0)); - /* Not entirely certain what this is yet. The DDX uses this - * value also as it fixes rendering when you pass - * pre-transformed vertices to the GPU. My best gusss is that - * this bypasses some culling/clipping stage. Might be worth - * noting that points/lines are uneffected by whatever this - * value fixes, only filled polygons are effected. - */ - so_method(so, nv40->screen->curie, 0x1d78, 1); - so_data (so, 0x110); - } + so_method(so, nv40->screen->curie, + NV40TCL_VIEWPORT_TRANSLATE_X, 8); + so_data (so, fui(vpt->translate[0])); + so_data (so, fui(vpt->translate[1])); + so_data (so, fui(vpt->translate[2])); + so_data (so, fui(vpt->translate[3])); + so_data (so, fui(vpt->scale[0])); + so_data (so, fui(vpt->scale[1])); + so_data (so, fui(vpt->scale[2])); + so_data (so, fui(vpt->scale[3])); + so_method(so, nv40->screen->curie, 0x1d78, 1); + so_data (so, 1); so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]); so_ref(NULL, &so); diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index b4de3e2ba5..c540594b94 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -127,7 +127,6 @@ struct nv50_state { struct nouveau_stateobj *scissor; unsigned scissor_enabled; struct nouveau_stateobj *viewport; - unsigned viewport_bypass; struct nouveau_stateobj *tsc_upload; struct nouveau_stateobj *tic_upload; unsigned miptree_nr[PIPE_SHADER_TYPES]; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index efab94cab7..a91b31015e 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -375,50 +375,32 @@ nv50_state_validate(struct nv50_context *nv50) scissor_uptodate: if (nv50->dirty & (NV50_NEW_VIEWPORT | NV50_NEW_RASTERIZER)) { - unsigned bypass; - - if (!nv50->rasterizer->pipe.bypass_vs_clip_and_viewport) - bypass = 0; - else - bypass = 1; - if (nv50->state.viewport && - (bypass || !(nv50->dirty & NV50_NEW_VIEWPORT)) && - nv50->state.viewport_bypass == bypass) + !(nv50->dirty & NV50_NEW_VIEWPORT)) goto viewport_uptodate; - nv50->state.viewport_bypass = bypass; so = so_new(5, 9, 0); - if (!bypass) { - so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); - so_data (so, fui(nv50->viewport.translate[0])); - so_data (so, fui(nv50->viewport.translate[1])); - so_data (so, fui(nv50->viewport.translate[2])); - so_method(so, tesla, NV50TCL_VIEWPORT_SCALE_X(0), 3); - so_data (so, fui(nv50->viewport.scale[0])); - so_data (so, fui(nv50->viewport.scale[1])); - so_data (so, fui(nv50->viewport.scale[2])); - - so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1); - so_data (so, 1); - /* 0x0000 = remove whole primitive only (xyz) - * 0x1018 = remove whole primitive only (xy), clamp z - * 0x1080 = clip primitive (xyz) - * 0x1098 = clip primitive (xy), clamp z - */ - so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1); - so_data (so, 0x1080); - /* no idea what 0f90 does */ - so_method(so, tesla, 0x0f90, 1); - so_data (so, 0); - } else { - so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1); - so_data (so, 0); - so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1); - so_data (so, 0x0000); - so_method(so, tesla, 0x0f90, 1); - so_data (so, 1); - } + so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); + so_data (so, fui(nv50->viewport.translate[0])); + so_data (so, fui(nv50->viewport.translate[1])); + so_data (so, fui(nv50->viewport.translate[2])); + so_method(so, tesla, NV50TCL_VIEWPORT_SCALE_X(0), 3); + so_data (so, fui(nv50->viewport.scale[0])); + so_data (so, fui(nv50->viewport.scale[1])); + so_data (so, fui(nv50->viewport.scale[2])); + + so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1); + so_data (so, 1); + /* 0x0000 = remove whole primitive only (xyz) + * 0x1018 = remove whole primitive only (xy), clamp z + * 0x1080 = clip primitive (xyz) + * 0x1098 = clip primitive (xy), clamp z + */ + so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1); + so_data (so, 0x1080); + /* no idea what 0f90 does */ + so_method(so, tesla, 0x0f90, 1); + so_data (so, 0); so_ref(so, &nv50->state.viewport); so_ref(NULL, &so); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 443af4ec2e..2f056aafcb 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -337,8 +337,6 @@ struct r300_context { uint32_t dirty_state; /* Flag indicating whether or not the HW is dirty. */ uint32_t dirty_hw; - /* Whether the TCL engine should be in bypass mode. */ - boolean tcl_bypass; /* Whether polygon offset is enabled. */ boolean polygon_offset_enabled; /* Z buffer bit depth. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index f7dcd8dc52..37ebe6c49d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -170,23 +170,15 @@ static const float * get_shader_constant( break; case RC_STATE_R300_VIEWPORT_SCALE: - if (r300->tcl_bypass) { - vec[0] = 1; - vec[1] = 1; - vec[2] = 1; - } else { - vec[0] = viewport->xscale; - vec[1] = viewport->yscale; - vec[2] = viewport->zscale; - } + vec[0] = viewport->xscale; + vec[1] = viewport->yscale; + vec[2] = viewport->zscale; break; case RC_STATE_R300_VIEWPORT_OFFSET: - if (!r300->tcl_bypass) { - vec[0] = viewport->xoffset; - vec[1] = viewport->yoffset; - vec[2] = viewport->zoffset; - } + vec[0] = viewport->xoffset; + vec[1] = viewport->yoffset; + vec[2] = viewport->zoffset; break; default: @@ -936,22 +928,16 @@ void r300_emit_viewport_state(struct r300_context* r300, void* state) struct r300_viewport_state* viewport = (struct r300_viewport_state*)state; CS_LOCALS(r300); - if (r300->tcl_bypass) { - BEGIN_CS(2); - OUT_CS_REG(R300_VAP_VTE_CNTL, 0); - END_CS; - } else { - BEGIN_CS(9); - OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); - OUT_CS_32F(viewport->xscale); - OUT_CS_32F(viewport->xoffset); - OUT_CS_32F(viewport->yscale); - OUT_CS_32F(viewport->yoffset); - OUT_CS_32F(viewport->zscale); - OUT_CS_32F(viewport->zoffset); - OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); - END_CS; - } + BEGIN_CS(9); + OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); + OUT_CS_32F(viewport->xscale); + OUT_CS_32F(viewport->xoffset); + OUT_CS_32F(viewport->yscale); + OUT_CS_32F(viewport->yoffset); + OUT_CS_32F(viewport->zscale); + OUT_CS_32F(viewport->zoffset); + OUT_CS_REG(R300_VAP_VTE_CNTL, viewport->vte_control); + END_CS; } void r300_emit_texture_count(struct r300_context* r300) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 34bf81c193..3550c69c46 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -711,8 +711,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL. * Else, enable HW TCL and force Draw's TCL off. */ - if (state->bypass_vs_clip_and_viewport || - !r300screen->caps->has_tcl) { + if (!r300screen->caps->has_tcl) { rs->vap_control_status |= R300_VAP_TCL_BYPASS; } @@ -824,10 +823,8 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) } if (rs) { - r300->tcl_bypass = rs->rs.bypass_vs_clip_and_viewport; r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; } else { - r300->tcl_bypass = FALSE; r300->polygon_offset_enabled = FALSE; } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 2cbce9210a..778eaaacd9 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -114,13 +114,7 @@ static void r300_vertex_psc(struct r300_context* r300) int identity[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int* stream_tab; - /* If TCL is bypassed, map vertex streams to equivalent VS output - * locations. */ - if (r300->tcl_bypass) { - stream_tab = r300->vs->stream_loc_notcl; - } else { - stream_tab = identity; - } + stream_tab = identity; /* Vertex shaders have no semantics on their inputs, * so PSC should just route stuff based on the vertex elements, diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index 7a3a636167..8e4867a904 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -174,7 +174,6 @@ init_pipe_state(struct sp_mpeg12_context *ctx) rast.line_stipple_factor = 0; rast.line_stipple_pattern = 0; rast.line_last_pixel = 0; - rast.bypass_vs_clip_and_viewport = 0; rast.line_width = 1; rast.point_smooth = 0; rast.point_quad_rasterization = 0; diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index b4cafb8f21..4d0c06bd77 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -120,174 +120,153 @@ static int emit_viewport( struct svga_context *svga, float fb_width = svga->curr.framebuffer.width; float fb_height = svga->curr.framebuffer.height; - memset( &prescale, 0, sizeof(prescale) ); - - if (svga->curr.rast->templ.bypass_vs_clip_and_viewport) { - - /* Avoid POSITIONT as it has a non trivial implementation outside the D3D - * API. Always generate a vertex shader. - */ - rect.x = 0; - rect.y = 0; - rect.w = svga->curr.framebuffer.width; - rect.h = svga->curr.framebuffer.height; - - prescale.scale[0] = 2.0 / (float)rect.w; - prescale.scale[1] = - 2.0 / (float)rect.h; - prescale.scale[2] = 1.0; - prescale.scale[3] = 1.0; - prescale.translate[0] = -1.0f; - prescale.translate[1] = 1.0f; - prescale.translate[2] = 0; - prescale.translate[3] = 0; - prescale.enabled = TRUE; - } else { - - /* Examine gallium viewport transformation and produce a screen - * rectangle and possibly vertex shader pre-transformation to - * get the same results. - */ - float fx = viewport->scale[0] * -1.0 + viewport->translate[0]; - float fy = flip * viewport->scale[1] * -1.0 + viewport->translate[1]; - float fw = viewport->scale[0] * 2; - float fh = flip * viewport->scale[1] * 2; - - SVGA_DBG(DEBUG_VIEWPORT, - "\ninitial %f,%f %fx%f\n", - fx, - fy, - fw, - fh); - - prescale.scale[0] = 1.0; - prescale.scale[1] = 1.0; - prescale.scale[2] = 1.0; - prescale.scale[3] = 1.0; - prescale.translate[0] = 0; - prescale.translate[1] = 0; - prescale.translate[2] = 0; - prescale.translate[3] = 0; - prescale.enabled = TRUE; - - - - if (fw < 0) { - prescale.scale[0] *= -1.0; - prescale.translate[0] += -fw; - fw = -fw; - fx = viewport->scale[0] * 1.0 + viewport->translate[0]; - } + float fx = viewport->scale[0] * -1.0 + viewport->translate[0]; + float fy = flip * viewport->scale[1] * -1.0 + viewport->translate[1]; + float fw = viewport->scale[0] * 2; + float fh = flip * viewport->scale[1] * 2; - if (fh < 0) { - prescale.scale[1] *= -1.0; - prescale.translate[1] += -fh; - fh = -fh; - fy = flip * viewport->scale[1] * 1.0 + viewport->translate[1]; - } + memset( &prescale, 0, sizeof(prescale) ); - if (fx < 0) { - prescale.translate[0] += fx; - prescale.scale[0] *= fw / (fw + fx); - fw += fx; - fx = 0; - } + /* Examine gallium viewport transformation and produce a screen + * rectangle and possibly vertex shader pre-transformation to + * get the same results. + */ - if (fy < 0) { - prescale.translate[1] += fy; - prescale.scale[1] *= fh / (fh + fy); - fh += fy; - fy = 0; - } + SVGA_DBG(DEBUG_VIEWPORT, + "\ninitial %f,%f %fx%f\n", + fx, + fy, + fw, + fh); + + prescale.scale[0] = 1.0; + prescale.scale[1] = 1.0; + prescale.scale[2] = 1.0; + prescale.scale[3] = 1.0; + prescale.translate[0] = 0; + prescale.translate[1] = 0; + prescale.translate[2] = 0; + prescale.translate[3] = 0; + prescale.enabled = TRUE; + + + + if (fw < 0) { + prescale.scale[0] *= -1.0; + prescale.translate[0] += -fw; + fw = -fw; + fx = viewport->scale[0] * 1.0 + viewport->translate[0]; + } - if (fx + fw > fb_width) { - prescale.scale[0] *= fw / (fb_width - fx); - prescale.translate[0] -= fx * (fw / (fb_width - fx)); - prescale.translate[0] += fx; - fw = fb_width - fx; - - } + if (fh < 0) { + prescale.scale[1] *= -1.0; + prescale.translate[1] += -fh; + fh = -fh; + fy = flip * viewport->scale[1] * 1.0 + viewport->translate[1]; + } - if (fy + fh > fb_height) { - prescale.scale[1] *= fh / (fb_height - fy); - prescale.translate[1] -= fy * (fh / (fb_height - fy)); - prescale.translate[1] += fy; - fh = fb_height - fy; - } + if (fx < 0) { + prescale.translate[0] += fx; + prescale.scale[0] *= fw / (fw + fx); + fw += fx; + fx = 0; + } - if (fw < 0 || fh < 0) { - fw = fh = fx = fy = 0; - degenerate = TRUE; - goto out; - } + if (fy < 0) { + prescale.translate[1] += fy; + prescale.scale[1] *= fh / (fh + fy); + fh += fy; + fy = 0; + } + if (fx + fw > fb_width) { + prescale.scale[0] *= fw / (fb_width - fx); + prescale.translate[0] -= fx * (fw / (fb_width - fx)); + prescale.translate[0] += fx; + fw = fb_width - fx; + + } - /* D3D viewport is integer space. Convert fx,fy,etc. to - * integers. - * - * TODO: adjust pretranslate correct for any subpixel error - * introduced converting to integers. - */ - rect.x = fx; - rect.y = fy; - rect.w = fw; - rect.h = fh; + if (fy + fh > fb_height) { + prescale.scale[1] *= fh / (fb_height - fy); + prescale.translate[1] -= fy * (fh / (fb_height - fy)); + prescale.translate[1] += fy; + fh = fb_height - fy; + } - SVGA_DBG(DEBUG_VIEWPORT, - "viewport error %f,%f %fx%f\n", - fabs((float)rect.x - fx), - fabs((float)rect.y - fy), - fabs((float)rect.w - fw), - fabs((float)rect.h - fh)); + if (fw < 0 || fh < 0) { + fw = fh = fx = fy = 0; + degenerate = TRUE; + goto out; + } - SVGA_DBG(DEBUG_VIEWPORT, - "viewport %d,%d %dx%d\n", - rect.x, - rect.y, - rect.w, - rect.h); - - /* Finally, to get GL rasterization rules, need to tweak the - * screen-space coordinates slightly relative to D3D which is - * what hardware implements natively. - */ - if (svga->curr.rast->templ.gl_rasterization_rules) { - float adjust_x = 0.0; - float adjust_y = 0.0; - - switch (svga->curr.reduced_prim) { - case PIPE_PRIM_LINES: - adjust_x = -0.5; - adjust_y = 0; - break; - case PIPE_PRIM_POINTS: - case PIPE_PRIM_TRIANGLES: - adjust_x = -0.375; - adjust_y = -0.5; - break; - } - - prescale.translate[0] += adjust_x; - prescale.translate[1] += adjust_y; - prescale.translate[2] = 0.5; /* D3D clip space */ - prescale.scale[2] = 0.5; /* D3D clip space */ + /* D3D viewport is integer space. Convert fx,fy,etc. to + * integers. + * + * TODO: adjust pretranslate correct for any subpixel error + * introduced converting to integers. + */ + rect.x = fx; + rect.y = fy; + rect.w = fw; + rect.h = fh; + + SVGA_DBG(DEBUG_VIEWPORT, + "viewport error %f,%f %fx%f\n", + fabs((float)rect.x - fx), + fabs((float)rect.y - fy), + fabs((float)rect.w - fw), + fabs((float)rect.h - fh)); + + SVGA_DBG(DEBUG_VIEWPORT, + "viewport %d,%d %dx%d\n", + rect.x, + rect.y, + rect.w, + rect.h); + + + /* Finally, to get GL rasterization rules, need to tweak the + * screen-space coordinates slightly relative to D3D which is + * what hardware implements natively. + */ + if (svga->curr.rast->templ.gl_rasterization_rules) { + float adjust_x = 0.0; + float adjust_y = 0.0; + + switch (svga->curr.reduced_prim) { + case PIPE_PRIM_LINES: + adjust_x = -0.5; + adjust_y = 0; + break; + case PIPE_PRIM_POINTS: + case PIPE_PRIM_TRIANGLES: + adjust_x = -0.375; + adjust_y = -0.5; + break; } + prescale.translate[0] += adjust_x; + prescale.translate[1] += adjust_y; + prescale.translate[2] = 0.5; /* D3D clip space */ + prescale.scale[2] = 0.5; /* D3D clip space */ + } - range_min = viewport->scale[2] * -1.0 + viewport->translate[2]; - range_max = viewport->scale[2] * 1.0 + viewport->translate[2]; - /* D3D (and by implication SVGA) doesn't like dealing with zmax - * less than zmin. Detect that case, flip the depth range and - * invert our z-scale factor to achieve the same effect. - */ - if (range_min > range_max) { - float range_tmp; - range_tmp = range_min; - range_min = range_max; - range_max = range_tmp; - prescale.scale[2] = -prescale.scale[2]; - } + range_min = viewport->scale[2] * -1.0 + viewport->translate[2]; + range_max = viewport->scale[2] * 1.0 + viewport->translate[2]; + + /* D3D (and by implication SVGA) doesn't like dealing with zmax + * less than zmin. Detect that case, flip the depth range and + * invert our z-scale factor to achieve the same effect. + */ + if (range_min > range_max) { + float range_tmp; + range_tmp = range_min; + range_min = range_max; + range_max = range_tmp; + prescale.scale[2] = -prescale.scale[2]; } if (prescale.enabled) { diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index dd13a89d24..a6ed18599c 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -129,8 +129,7 @@ static int update_need_pipeline( struct svga_context *svga, /* SVGA_NEW_CLIP */ - if (!svga->curr.rast->templ.bypass_vs_clip_and_viewport && - svga->curr.clip.nr) { + if (svga->curr.clip.nr) { SVGA_DBG(DEBUG_SWTNL, "%s: userclip\n", __FUNCTION__); need_pipeline = TRUE; } diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c index 6da186a655..f97d963dba 100644 --- a/src/gallium/drivers/trace/tr_dump_state.c +++ b/src/gallium/drivers/trace/tr_dump_state.c @@ -112,7 +112,6 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state) 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_vs_clip_and_viewport); trace_dump_member(bool, state, flatshade_first); trace_dump_member(bool, state, gl_rasterization_rules); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 5ac5c87813..02558520bf 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -113,16 +113,6 @@ struct pipe_rasterizer_state unsigned line_stipple_pattern:16; unsigned line_last_pixel:1; - /** - * Vertex coordinates are pre-transformed to screen space. Skip - * the vertex shader, clipping and viewport processing. Note that - * a vertex shader is still needed though, to indicate the mapping - * from vertex elements to fragment shader input semantics. - * - * XXX: considered for removal. - */ - unsigned bypass_vs_clip_and_viewport:1; - /** * Use the first vertex of a primitive as the provoking vertex for * flat shading. diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 898c32293d..5edab55cca 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -65,9 +65,6 @@ st_init_clear(struct st_context *st) memset(&st->clear.raster, 0, sizeof(st->clear.raster)); st->clear.raster.gl_rasterization_rules = 1; - /* rasterizer state: bypass vertex shader, clipping and viewport */ - st->clear.raster.bypass_vs_clip_and_viewport = 1; - /* fragment shader state: color pass-through program */ st->clear.fs = util_make_fragment_passthrough_shader(pipe); @@ -104,9 +101,7 @@ st_destroy_clear(struct st_context *st) /** * Draw a screen-aligned quadrilateral. - * Coords are window coords with y=0=bottom. These will be passed - * through unmodified to the rasterizer as we have set - * rasterizer->bypass_vs_clip_and_viewport. + * Coords are clip coords with y=0=bottom. */ static void draw_quad(GLcontext *ctx, @@ -192,18 +187,13 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; - const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; - const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; - GLfloat y0, y1; - - if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - y0 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax); - y1 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin); - } - else { - y0 = (GLfloat) ctx->DrawBuffer->_Ymin; - y1 = (GLfloat) ctx->DrawBuffer->_Ymax; - } + const struct gl_framebuffer *fb = ctx->DrawBuffer; + const GLfloat fb_width = (GLfloat) fb->Width; + const GLfloat fb_height = (GLfloat) fb->Height; + const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f; + const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f; + const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f; + const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f; /* printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__, @@ -218,6 +208,7 @@ clear_with_quad(GLcontext *ctx, cso_save_stencil_ref(st->cso_context); cso_save_depth_stencil_alpha(st->cso_context); cso_save_rasterizer(st->cso_context); + cso_save_viewport(st->cso_context); cso_save_fragment_shader(st->cso_context); cso_save_vertex_shader(st->cso_context); @@ -273,6 +264,21 @@ clear_with_quad(GLcontext *ctx, cso_set_rasterizer(st->cso_context, &st->clear.raster); + /* viewport state: viewport matching window dims */ + { + const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); + struct pipe_viewport_state vp; + vp.scale[0] = 0.5f * fb_width; + vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f); + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * fb_width; + vp.translate[1] = 0.5f * fb_height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; + cso_set_viewport(st->cso_context, &vp); + } + cso_set_fragment_shader_handle(st->cso_context, st->clear.fs); cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); @@ -284,9 +290,9 @@ clear_with_quad(GLcontext *ctx, cso_restore_stencil_ref(st->cso_context); cso_restore_depth_stencil_alpha(st->cso_context); cso_restore_rasterizer(st->cso_context); + cso_restore_viewport(st->cso_context); cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); - } -- cgit v1.2.3 From 6da07e45b3e5cb37b63afafb650569d3d275e608 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 22 Feb 2010 23:23:57 -0800 Subject: draw: Remove dead code. --- src/gallium/auxiliary/draw/draw_pipe_offset.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c index e829492423..8e321946ce 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_offset.c +++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c @@ -161,7 +161,7 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw ) { struct offset_stage *offset = CALLOC_STRUCT(offset_stage); if (offset == NULL) - goto fail; + return NULL; draw_alloc_temp_verts( &offset->stage, 3 ); @@ -176,10 +176,4 @@ struct draw_stage *draw_offset_stage( struct draw_context *draw ) offset->stage.destroy = offset_destroy; return &offset->stage; - - fail: - if (offset) - offset->stage.destroy( &offset->stage ); - - return NULL; } -- cgit v1.2.3 From a0fe36a39b92780efd2374b66f16b39e541f1172 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 22 Feb 2010 23:32:43 -0800 Subject: i965g: Add fallthrough comments in switch statement. Silences warnings about missing break statements in static analysis. --- src/gallium/drivers/i965/brw_draw_upload.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c index d59261557b..9f136eec71 100644 --- a/src/gallium/drivers/i965/brw_draw_upload.c +++ b/src/gallium/drivers/i965/brw_draw_upload.c @@ -359,9 +359,9 @@ static int brw_emit_vertex_elements(struct brw_context *brw) uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC; switch (input->nr_components) { - case 0: comp0 = BRW_VE1_COMPONENT_STORE_0; - case 1: comp1 = BRW_VE1_COMPONENT_STORE_0; - case 2: comp2 = BRW_VE1_COMPONENT_STORE_0; + case 0: comp0 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ + case 1: comp1 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ + case 2: comp2 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT; break; } -- cgit v1.2.3 From 58a72cd65e352849a5ce7be473fc5a2a7fc32e79 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 22 Feb 2010 21:56:58 +0800 Subject: st/egl: Unify surface creation. Add a new function egl_g3d_create_surface and use it to create window, pixmap, buffer, and screen surfaces. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 204 +++++++++++------------- 1 file changed, 97 insertions(+), 107 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index d769d253ac..13a7487ea8 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -687,131 +687,143 @@ egl_g3d_destroy_context(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) return EGL_TRUE; } -static EGLBoolean -init_surface_geometry(_EGLSurface *surf) -{ - struct egl_g3d_surface *gsurf = egl_g3d_surface(surf); - - return gsurf->native->validate(gsurf->native, 0x0, - &gsurf->sequence_number, NULL, - &gsurf->base.Width, &gsurf->base.Height); -} +struct egl_g3d_create_surface_arg { + EGLint type; + union { + EGLNativeWindowType win; + EGLNativePixmapType pix; + } u; +}; static _EGLSurface * -egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativeWindowType win, - const EGLint *attribs) +egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, + struct egl_g3d_create_surface_arg *arg, + const EGLint *attribs) { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_config *gconf = egl_g3d_config(conf); struct egl_g3d_surface *gsurf; + struct native_surface *nsurf; + const char *err; + + switch (arg->type) { + case EGL_WINDOW_BIT: + err = "eglCreateWindowSurface"; + break; + case EGL_PIXMAP_BIT: + err = "eglCreatePixmapSurface"; + break; + case EGL_PBUFFER_BIT: + err = "eglCreatePBufferSurface"; + break; +#ifdef EGL_MESA_screen_surface + case EGL_SCREEN_BIT_MESA: + err = "eglCreateScreenSurface"; + break; +#endif + default: + err = "eglCreateUnknownSurface"; + break; + } gsurf = CALLOC_STRUCT(egl_g3d_surface); if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreateWindowSurface"); + _eglError(EGL_BAD_ALLOC, err); return NULL; } - if (!_eglInitSurface(&gsurf->base, dpy, EGL_WINDOW_BIT, conf, attribs)) { + if (!_eglInitSurface(&gsurf->base, dpy, arg->type, conf, attribs)) { free(gsurf); return NULL; } - gsurf->native = - gdpy->native->create_window_surface(gdpy->native, win, gconf->native); - if (!gsurf->native) { + /* create the native surface */ + switch (arg->type) { + case EGL_WINDOW_BIT: + nsurf = gdpy->native->create_window_surface(gdpy->native, + arg->u.win, gconf->native); + break; + case EGL_PIXMAP_BIT: + nsurf = gdpy->native->create_pixmap_surface(gdpy->native, + arg->u.pix, gconf->native); + break; + case EGL_PBUFFER_BIT: + nsurf = gdpy->native->create_pbuffer_surface(gdpy->native, + gconf->native, gsurf->base.Width, gsurf->base.Height); + break; +#ifdef EGL_MESA_screen_surface + case EGL_SCREEN_BIT_MESA: + /* prefer back buffer (move to _eglInitSurface?) */ + gsurf->base.RenderBuffer = EGL_BACK_BUFFER; + nsurf = gdpy->native->modeset->create_scanout_surface(gdpy->native, + gconf->native, gsurf->base.Width, gsurf->base.Height); + break; +#endif + default: + nsurf = NULL; + break; + } + + if (!nsurf) { free(gsurf); return NULL; } - - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); + /* initialize the geometry */ + if (!nsurf->validate(nsurf, 0x0, &gsurf->sequence_number, NULL, + &gsurf->base.Width, &gsurf->base.Height)) { + nsurf->destroy(nsurf); free(gsurf); return NULL; } - gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER || - !gconf->native->mode.doubleBufferMode) ? + gsurf->native = nsurf; + + gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) ? NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; + if (!gconf->native->mode.doubleBufferMode) + gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; return &gsurf->base; } static _EGLSurface * -egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLConfig *conf, EGLNativePixmapType pix, +egl_g3d_create_window_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativeWindowType win, const EGLint *attribs) { - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; + struct egl_g3d_create_surface_arg arg; - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePixmapSurface"); - return NULL; - } + memset(&arg, 0, sizeof(arg)); + arg.type = EGL_WINDOW_BIT; + arg.u.win = win; - if (!_eglInitSurface(&gsurf->base, dpy, EGL_PIXMAP_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pixmap_surface(gdpy->native, pix, gconf->native); - if (!gsurf->native) { - free(gsurf); - return NULL; - } + return egl_g3d_create_surface(drv, dpy, conf, &arg, attribs); +} - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } +static _EGLSurface * +egl_g3d_create_pixmap_surface(_EGLDriver *drv, _EGLDisplay *dpy, + _EGLConfig *conf, EGLNativePixmapType pix, + const EGLint *attribs) +{ + struct egl_g3d_create_surface_arg arg; - gsurf->render_att = NATIVE_ATTACHMENT_FRONT_LEFT; + memset(&arg, 0, sizeof(arg)); + arg.type = EGL_PIXMAP_BIT; + arg.u.pix = pix; - return &gsurf->base; + return egl_g3d_create_surface(drv, dpy, conf, &arg, attribs); } static _EGLSurface * egl_g3d_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attribs) { - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } - - if (!_eglInitSurface(&gsurf->base, dpy, EGL_PBUFFER_BIT, conf, attribs)) { - free(gsurf); - return NULL; - } - - gsurf->native = - gdpy->native->create_pbuffer_surface(gdpy->native, gconf->native, - gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } + struct egl_g3d_create_surface_arg arg; - if (!init_surface_geometry(&gsurf->base)) { - gsurf->native->destroy(gsurf->native); - free(gsurf); - return NULL; - } + memset(&arg, 0, sizeof(arg)); + arg.type = EGL_PBUFFER_BIT; - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; + return egl_g3d_create_surface(drv, dpy, conf, &arg, attribs); } /** @@ -1171,34 +1183,12 @@ static _EGLSurface * egl_g3d_create_screen_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, const EGLint *attribs) { - struct egl_g3d_display *gdpy = egl_g3d_display(dpy); - struct egl_g3d_config *gconf = egl_g3d_config(conf); - struct egl_g3d_surface *gsurf; - - gsurf = CALLOC_STRUCT(egl_g3d_surface); - if (!gsurf) { - _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); - return NULL; - } + struct egl_g3d_create_surface_arg arg; - if (!_eglInitSurface(&gsurf->base, dpy, - EGL_SCREEN_BIT_MESA, conf, attribs)) { - free(gsurf); - return NULL; - } + memset(&arg, 0, sizeof(arg)); + arg.type = EGL_SCREEN_BIT_MESA; - gsurf->native = - gdpy->native->modeset->create_scanout_surface(gdpy->native, - gconf->native, gsurf->base.Width, gsurf->base.Height); - if (!gsurf->native) { - free(gsurf); - return NULL; - } - - gsurf->render_att = (!gconf->native->mode.doubleBufferMode) ? - NATIVE_ATTACHMENT_FRONT_LEFT : NATIVE_ATTACHMENT_BACK_LEFT; - - return &gsurf->base; + return egl_g3d_create_surface(drv, dpy, conf, &arg, attribs); } static EGLBoolean -- cgit v1.2.3 From 9f4f87893b4d3555204a1a66d108f8f9185e3d14 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Feb 2010 08:50:15 -0800 Subject: pipebuffer: avoid assert due to increasing a zeroed refcnt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cache manager stores buffers with a reference count that dropped to 0. pipe_reference asserts in this case on debug builds, so use pipe_reference_init instead. Signed-off-by: José Fonseca --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 53bc019a20..86f9266c95 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -294,7 +294,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, LIST_DEL(&buf->head); pipe_mutex_unlock(mgr->mutex); /* Increase refcount */ - pipe_reference(NULL, &buf->base.base.reference); + pipe_reference_init(&buf->base.base.reference, 1); return &buf->base; } -- cgit v1.2.3 From c36b912e09a12b60d26fd1ebe0939b457514d800 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Feb 2010 08:55:38 -0800 Subject: pipebuffer: fix inverted signalled checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A return of 0 means the fence is signalled. Signed-off-by: José Fonseca --- src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 95eb5f6563..d97f749b6e 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -696,7 +696,7 @@ fenced_buffer_map(struct pb_buffer *buf, * Don't wait for the GPU to finish accessing it, if blocking is forbidden. */ if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) && - ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { + ops->fence_signalled(ops, fenced_buf->fence, 0) != 0) { goto done; } -- cgit v1.2.3 From 2f5beb4b530d47d6b4a7cf0effeaec0d2c1b6ea4 Mon Sep 17 00:00:00 2001 From: Luca Barbieri Date: Tue, 23 Feb 2010 08:55:24 -0800 Subject: pipebuffer: slab: if size < alignment, use alignment to find bucket MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the size is lower than the alignment, we must use the alignment to select the bucket. Otherwise, the selected bucket won't be able to satisfy our request and will fail. Signed-off-by: José Fonseca --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index c445cb578b..24e2820f88 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -483,11 +483,15 @@ pb_slab_range_manager_create_buffer(struct pb_manager *_mgr, { struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr); pb_size bufSize; + pb_size reqSize = size; unsigned i; + if(desc->alignment > reqSize) + reqSize = desc->alignment; + bufSize = mgr->minBufSize; for (i = 0; i < mgr->numBuckets; ++i) { - if(bufSize >= size) + if(bufSize >= reqSize) return mgr->buckets[i]->create_buffer(mgr->buckets[i], size, desc); bufSize *= 2; } -- cgit v1.2.3 From 232f6e176192d112fbdf9bd7de2d0f36ee16a246 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 23 Feb 2010 09:08:28 +0100 Subject: r300g: fix texture swizzling for the SRGB formats --- src/gallium/drivers/r300/r300_texture.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index ed2be06254..7b116b30e5 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -70,6 +70,19 @@ static uint32_t r300_translate_texformat(enum pipe_format format) R300_TX_FORMAT_B_SHIFT, R300_TX_FORMAT_A_SHIFT }; + const uint32_t swizzle_arith[4] = { + R300_TX_FORMAT_X, + R300_TX_FORMAT_Y, + R300_TX_FORMAT_Z, + R300_TX_FORMAT_W + }; + const uint32_t swizzle_array[4] = { + R300_TX_FORMAT_W, + R300_TX_FORMAT_Z, + R300_TX_FORMAT_Y, + R300_TX_FORMAT_X + }; + const uint32_t *swizzle; const uint32_t sign_bit[4] = { R300_TX_FORMAT_SIGNED_X, R300_TX_FORMAT_SIGNED_Y, @@ -115,20 +128,23 @@ static uint32_t r300_translate_texformat(enum pipe_format format) } /* Add swizzle. */ + swizzle = desc->layout == UTIL_FORMAT_LAYOUT_ARITH ? + swizzle_arith : swizzle_array; + for (i = 0; i < 4; i++) { switch (desc->swizzle[i]) { case UTIL_FORMAT_SWIZZLE_X: case UTIL_FORMAT_SWIZZLE_NONE: - result |= R300_TX_FORMAT_X << swizzle_shift[i]; + result |= swizzle[0] << swizzle_shift[i]; break; case UTIL_FORMAT_SWIZZLE_Y: - result |= R300_TX_FORMAT_Y << swizzle_shift[i]; + result |= swizzle[1] << swizzle_shift[i]; break; case UTIL_FORMAT_SWIZZLE_Z: - result |= R300_TX_FORMAT_Z << swizzle_shift[i]; + result |= swizzle[2] << swizzle_shift[i]; break; case UTIL_FORMAT_SWIZZLE_W: - result |= R300_TX_FORMAT_W << swizzle_shift[i]; + result |= swizzle[3] << swizzle_shift[i]; break; case UTIL_FORMAT_SWIZZLE_0: result |= R300_TX_FORMAT_ZERO << swizzle_shift[i]; -- cgit v1.2.3 From c8aaa24f2da4e4da3d726e0a58459c7d9cb64b93 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Feb 2010 18:07:38 -0700 Subject: llvmpipe: added some assertions --- src/gallium/drivers/llvmpipe/lp_scene.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index b7116297ec..cba0e21298 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -100,6 +100,9 @@ lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y) struct cmd_block *block; struct cmd_block *tmp; + assert(x < TILES_X); + assert(y < TILES_Y); + for (block = list->head; block != list->tail; block = tmp) { tmp = block->next; FREE(block); -- cgit v1.2.3 From 049b4c340575ebc788d9a009829980fafa587eff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Feb 2010 18:10:16 -0700 Subject: llvmpipe: added assertions to verify that scene is empty --- src/gallium/drivers/llvmpipe/lp_rast.c | 3 +++ src/gallium/drivers/llvmpipe/lp_setup.c | 2 ++ 2 files changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 6dbcb3c9b3..bbd63aec2b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -603,6 +603,9 @@ release_scene( struct lp_rasterizer *rast, util_unreference_framebuffer_state( &scene->fb ); lp_scene_reset( scene ); + + assert(lp_scene_is_empty(scene)); + lp_scene_enqueue( rast->empty_scenes, scene ); rast->curr_scene = NULL; } diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index cb873667a2..3aec9de373 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -64,6 +64,8 @@ lp_setup_get_current_scene(struct setup_context *setup) */ setup->scene = lp_scene_dequeue(setup->empty_scenes, TRUE); + assert(lp_scene_is_empty(setup->scene)); + if(0)lp_scene_reset( setup->scene ); /* XXX temporary? */ lp_scene_set_framebuffer_size(setup->scene, -- cgit v1.2.3 From f7830dc3916b355452f656dba955804fd7535544 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Feb 2010 18:23:15 -0700 Subject: st/glx: added PIPE_FORMAT_Z24S8_UNORM code --- src/gallium/state_trackers/glx/xlib/xm_api.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 4aac08a108..1798faa0f3 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -376,7 +376,8 @@ create_xmesa_buffer(Drawable d, BufferType type, #endif if (vis->mesa_visual.stencilBits == 8) { - if (depthFormat == PIPE_FORMAT_S8Z24_UNORM) + if (depthFormat == PIPE_FORMAT_S8Z24_UNORM || + depthFormat == PIPE_FORMAT_Z24S8_UNORM) stencilFormat = depthFormat; else stencilFormat = PIPE_FORMAT_S8_UNORM; @@ -388,6 +389,10 @@ create_xmesa_buffer(Drawable d, BufferType type, /* use 24-bit Z, undefined stencil channel */ depthFormat = PIPE_FORMAT_X8Z24_UNORM; } + else if (depthFormat == PIPE_FORMAT_Z24S8_UNORM) { + /* use 24-bit Z, undefined stencil channel */ + depthFormat = PIPE_FORMAT_Z24X8_UNORM; + } } -- cgit v1.2.3 From a84575cdc0c8193b2c7858734e2ec6b1ec4511b2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Feb 2010 18:55:28 -0700 Subject: st/glx: improved depth/stencil format selection code Actually ask the gallium screen what Z/stencil format is supported. This will let us remove some hacks in the llvmpipe driver. --- src/gallium/state_trackers/glx/xlib/glx_api.c | 5 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 106 ++++++++++++++++---------- src/gallium/state_trackers/glx/xlib/xm_api.h | 3 + 3 files changed, 71 insertions(+), 43 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 656a69131e..08bf624b5c 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -689,6 +689,8 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) int desiredVisualID = -1; int numAux = 0; + xmesa_init(); + parselist = list; while (*parselist) { @@ -941,9 +943,6 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) /* give the visual some useful GLX attributes */ double_flag = GL_TRUE; rgb_flag = GL_TRUE; - depth_size = default_depth_bits(); - stencil_size = STENCIL_BITS; - /* XXX accum??? */ } } else if (level==0) { diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 1798faa0f3..188b885f68 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -319,6 +319,51 @@ choose_pixel_format(XMesaVisual v) +/** + * Query the default gallium screen for a Z/Stencil format that + * at least matches the given depthBits and stencilBits. + */ +static void +xmesa_choose_z_stencil_format(int depthBits, int stencilBits, + enum pipe_format *depthFormat, + enum pipe_format *stencilFormat) +{ + const enum pipe_texture_target target = PIPE_TEXTURE_2D; + const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; + const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | + PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); + static enum pipe_format formats[] = { + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_Z32_UNORM + }; + int i; + + assert(screen); + + *depthFormat = *stencilFormat = PIPE_FORMAT_NONE; + + /* search for supported format */ + for (i = 0; i < Elements(formats); i++) { + if (screen->is_format_supported(screen, formats[i], + target, tex_usage, geom_flags)) { + *depthFormat = formats[i]; + break; + } + } + + if (stencilBits) { + *stencilFormat = *depthFormat; + } + + /* XXX we should check that he chosen format has at least as many bits + * as what was requested. + */ +} + + + /**********************************************************************/ /***** Linked list of XMesaBuffers *****/ /**********************************************************************/ @@ -361,39 +406,9 @@ create_xmesa_buffer(Drawable d, BufferType type, /* determine PIPE_FORMATs for buffers */ colorFormat = choose_pixel_format(vis); - if (vis->mesa_visual.depthBits == 0) - depthFormat = PIPE_FORMAT_NONE; -#ifdef GALLIUM_CELL /* XXX temporary for Cell! */ - else - depthFormat = PIPE_FORMAT_S8Z24_UNORM; -#else - else if (vis->mesa_visual.depthBits <= 16) - depthFormat = PIPE_FORMAT_Z16_UNORM; - else if (vis->mesa_visual.depthBits <= 24) - depthFormat = PIPE_FORMAT_S8Z24_UNORM; - else - depthFormat = PIPE_FORMAT_Z32_UNORM; -#endif - - if (vis->mesa_visual.stencilBits == 8) { - if (depthFormat == PIPE_FORMAT_S8Z24_UNORM || - depthFormat == PIPE_FORMAT_Z24S8_UNORM) - stencilFormat = depthFormat; - else - stencilFormat = PIPE_FORMAT_S8_UNORM; - } - else { - /* no stencil */ - stencilFormat = PIPE_FORMAT_NONE; - if (depthFormat == PIPE_FORMAT_S8Z24_UNORM) { - /* use 24-bit Z, undefined stencil channel */ - depthFormat = PIPE_FORMAT_X8Z24_UNORM; - } - else if (depthFormat == PIPE_FORMAT_Z24S8_UNORM) { - /* use 24-bit Z, undefined stencil channel */ - depthFormat = PIPE_FORMAT_Z24X8_UNORM; - } - } + xmesa_choose_z_stencil_format(vis->mesa_visual.depthBits, + vis->mesa_visual.stencilBits, + &depthFormat, &stencilFormat); get_drawable_size(vis->display, d, &width, &height); @@ -658,6 +673,8 @@ XMesaVisual XMesaCreateVisual( Display *display, XMesaVisual v; GLint red_bits, green_bits, blue_bits, alpha_bits; + xmesa_init(); + /* For debugging only */ if (_mesa_getenv("MESA_XSYNC")) { /* This makes debugging X easier. @@ -753,6 +770,21 @@ void XMesaDestroyVisual( XMesaVisual v ) } +/** + * Do one-time initializations. + */ +void +xmesa_init(void) +{ + static GLboolean firstTime = GL_TRUE; + if (firstTime) { + pipe_mutex_init(_xmesa_lock); + _screen = driver.create_pipe_screen(); + screen = trace_screen_create( _screen ); + firstTime = GL_FALSE; + } +} + /** * Create a new XMesaContext. @@ -764,18 +796,12 @@ void XMesaDestroyVisual( XMesaVisual v ) PUBLIC XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) { - static GLboolean firstTime = GL_TRUE; struct pipe_context *pipe = NULL; XMesaContext c; GLcontext *mesaCtx; uint pf; - if (firstTime) { - pipe_mutex_init(_xmesa_lock); - _screen = driver.create_pipe_screen(); - screen = trace_screen_create( _screen ); - firstTime = GL_FALSE; - } + xmesa_init(); /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */ c = (XMesaContext) CALLOC_STRUCT(xmesa_context); diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 63a329cbe0..004cb260dc 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -366,6 +366,9 @@ xmesa_buffer(GLframebuffer *fb) } +extern void +xmesa_init(void); + extern void xmesa_delete_framebuffer(struct gl_framebuffer *fb); -- cgit v1.2.3 From 0e7c22ff3c8532dad35a08f8b350be78383bfb0d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Feb 2010 18:56:24 -0700 Subject: llvmpipe: Z16 format is not supported --- src/gallium/drivers/llvmpipe/lp_screen.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 1cd3ea9a84..ad5a484959 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -233,6 +233,10 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB && format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) return FALSE; + + /* not supported yet */ + if (format == PIPE_FORMAT_Z16_UNORM) + return FALSE; } return TRUE; -- cgit v1.2.3 From cd25e436ef8cc355109ba302621533e522f2f50b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Feb 2010 18:56:58 -0700 Subject: llvmpipe: remove Z16 format override hack --- src/gallium/drivers/llvmpipe/lp_texture.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 022bf92cb4..7f45635542 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -124,12 +124,6 @@ llvmpipe_texture_create(struct pipe_screen *_screen, pipe_reference_init(&lpt->base.reference, 1); lpt->base.screen = &screen->base; - /* XXX: The xlib state tracker is brain-dead and will request - * PIPE_FORMAT_Z16_UNORM no matter how much we tell it we don't support it. - */ - if (lpt->base.format == PIPE_FORMAT_Z16_UNORM) - lpt->base.format = PIPE_FORMAT_Z32_UNORM; - if (lpt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | PIPE_TEXTURE_USAGE_PRIMARY)) { if (!llvmpipe_displaytarget_layout(screen, lpt)) -- cgit v1.2.3 From 5e321280c14fa376c44c3eeef67b27160419fc56 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Feb 2010 15:18:49 -0700 Subject: llvmpipe: whole image tile/untile functions --- src/gallium/drivers/llvmpipe/lp_tile_image.c | 126 +++++++++++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_tile_image.h | 57 ++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 src/gallium/drivers/llvmpipe/lp_tile_image.c create mode 100644 src/gallium/drivers/llvmpipe/lp_tile_image.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.c b/src/gallium/drivers/llvmpipe/lp_tile_image.c new file mode 100644 index 0000000000..c1980b316d --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.c @@ -0,0 +1,126 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. 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 THE AUTHORS 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 "lp_tile_soa.h" +#include "lp_tile_image.h" + + +#define BYTES_PER_TILE (TILE_SIZE * TILE_SIZE * 4) + + +/** + * Convert a tiled image into a linear image. + * \param src_stride source row stride in bytes (bytes per row of tiles) + * \param dst_stride dest row stride in bytes + */ +void +lp_tiled_to_linear(const uint8_t *src, + uint8_t *dst, + unsigned width, unsigned height, + enum pipe_format format, + unsigned src_stride, + unsigned dst_stride) +{ + const unsigned tiles_per_row = src_stride / BYTES_PER_TILE; + unsigned i, j; + + for (j = 0; j < height; j += TILE_SIZE) { + for (i = 0; i < width; i += TILE_SIZE) { + unsigned tile_offset = + ((j / TILE_SIZE) * tiles_per_row + i / TILE_SIZE); + unsigned byte_offset = tile_offset * BYTES_PER_TILE; + const uint8_t *src_tile = src + byte_offset; + + lp_tile_write_4ub(format, + src_tile, + dst, + dst_stride, + i, j, TILE_SIZE, TILE_SIZE); + } + } +} + + +/** + * Convert a linear image into a tiled image. + * \param src_stride source row stride in bytes + * \param dst_stride dest row stride in bytes (bytes per row of tiles) + */ +void +lp_linear_to_tiled(const uint8_t *src, + uint8_t *dst, + unsigned width, unsigned height, + enum pipe_format format, + unsigned src_stride, + unsigned dst_stride) +{ + const unsigned tiles_per_row = dst_stride / BYTES_PER_TILE; + unsigned i, j; + + for (j = 0; j < height; j += TILE_SIZE) { + for (i = 0; i < width; i += TILE_SIZE) { + unsigned tile_offset = + ((j / TILE_SIZE) * tiles_per_row + i / TILE_SIZE); + unsigned byte_offset = tile_offset * BYTES_PER_TILE; + uint8_t *dst_tile = dst + byte_offset; + + lp_tile_read_4ub(format, + dst_tile, + src, + src_stride, + i, j, TILE_SIZE, TILE_SIZE); + } + } +} + + +/** + * For testing only. + */ +void +test_tiled_linear_conversion(uint8_t *data, + enum pipe_format format, + unsigned width, unsigned height, + unsigned stride) +{ + /* size in tiles */ + unsigned wt = (width + TILE_SIZE - 1) / TILE_SIZE; + unsigned ht = (height + TILE_SIZE - 1) / TILE_SIZE; + + uint8_t *tiled = malloc(wt * ht * TILE_SIZE * TILE_SIZE * 4); + + unsigned tiled_stride = wt * TILE_SIZE * TILE_SIZE * 4; + + lp_linear_to_tiled(data, tiled, width, height, format, + stride, tiled_stride); + + lp_tiled_to_linear(tiled, data, width, height, format, + tiled_stride, stride); + + free(tiled); +} + diff --git a/src/gallium/drivers/llvmpipe/lp_tile_image.h b/src/gallium/drivers/llvmpipe/lp_tile_image.h new file mode 100644 index 0000000000..60d472e8c5 --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_tile_image.h @@ -0,0 +1,57 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. 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 THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef LP_TILE_IMAGE_H +#define LP_TILE_IMAGE_H + + +void +lp_tiled_to_linear(const uint8_t *src, + uint8_t *dst, + unsigned width, unsigned height, + enum pipe_format format, + unsigned src_stride, + unsigned dst_stride); + + +void +lp_linear_to_tiled(const uint8_t *src, + uint8_t *dst, + unsigned width, unsigned height, + enum pipe_format format, + unsigned src_stride, + unsigned dst_stride); + + +void +test_tiled_linear_conversion(uint8_t *data, + enum pipe_format format, + unsigned width, unsigned height, + unsigned stride); + + +#endif /* LP_TILE_IMAGE_H */ -- cgit v1.2.3 From 1eec90d660052a597db08332141f1ffee1570209 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 22 Feb 2010 15:19:45 -0700 Subject: llvmpipe: add lp_tile_image.c to sources --- src/gallium/drivers/llvmpipe/Makefile | 1 + src/gallium/drivers/llvmpipe/SConscript | 1 + 2 files changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 3173251437..41ac1cee72 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -37,6 +37,7 @@ C_SOURCES = \ lp_surface.c \ lp_tex_sample_llvm.c \ lp_texture.c \ + lp_tile_image.c \ lp_tile_soa.c CPP_SOURCES = \ diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index a39283e5e8..9084c97079 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -52,6 +52,7 @@ llvmpipe = env.ConvenienceLibrary( 'lp_surface.c', 'lp_tex_sample_llvm.c', 'lp_texture.c', + 'lp_tile_image.c', 'lp_tile_soa.c', ]) -- cgit v1.2.3 From 402f54b0d1f69a2231e42b726ebaf8a726efa307 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Feb 2010 21:16:18 -0700 Subject: gallivm: added clamp and int_to_float functions --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 41 ++++++++++++++++++++++++++++- src/gallium/auxiliary/gallivm/lp_bld_arit.h | 10 +++++++ 2 files changed, 50 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 54b31befe6..bbce31f9eb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -613,6 +613,22 @@ lp_build_max(struct lp_build_context *bld, } +/** + * Generate clamp(a, min, max) + * Do checks for special cases. + */ +LLVMValueRef +lp_build_clamp(struct lp_build_context *bld, + LLVMValueRef a, + LLVMValueRef min, + LLVMValueRef max) +{ + a = lp_build_min(bld, a, max); + a = lp_build_max(bld, a, min); + return a; +} + + /** * Generate abs(a) */ @@ -693,6 +709,29 @@ lp_build_sgn(struct lp_build_context *bld, } +/** + * Convert vector of int to vector of float. + */ +LLVMValueRef +lp_build_int_to_float(struct lp_build_context *bld, + LLVMValueRef a) +{ + const struct lp_type type = bld->type; + + assert(type.floating); + /*assert(lp_check_value(type, a));*/ + + { + LLVMTypeRef vec_type = lp_build_vec_type(type); + /*LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);*/ + LLVMValueRef res; + res = LLVMBuildSIToFP(bld->builder, a, vec_type, ""); + return res; + } +} + + + enum lp_build_round_sse41_mode { LP_BUILD_ROUND_SSE41_NEAREST = 0, @@ -819,7 +858,7 @@ lp_build_ceil(struct lp_build_context *bld, /** * Convert to integer, through whichever rounding method that's fastest, - * typically truncating to zero. + * typically truncating toward zero. */ LLVMValueRef lp_build_itrunc(struct lp_build_context *bld, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 62be4b9aee..da84b7ca02 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -106,6 +106,12 @@ lp_build_max(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b); +LLVMValueRef +lp_build_clamp(struct lp_build_context *bld, + LLVMValueRef a, + LLVMValueRef min, + LLVMValueRef max); + LLVMValueRef lp_build_abs(struct lp_build_context *bld, LLVMValueRef a); @@ -114,6 +120,10 @@ LLVMValueRef lp_build_sgn(struct lp_build_context *bld, LLVMValueRef a); +LLVMValueRef +lp_build_int_to_float(struct lp_build_context *bld, + LLVMValueRef a); + LLVMValueRef lp_build_round(struct lp_build_context *bld, LLVMValueRef a); -- cgit v1.2.3 From 5dce9b252b65102ed69956fdd47862d5cb1c4af1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 23 Feb 2010 19:51:42 +0000 Subject: util: Store more derived data in the the format description. --- src/gallium/auxiliary/util/u_format.h | 18 ++++++++++++++++++ src/gallium/auxiliary/util/u_format_parse.py | 24 ++++++++++++++++++++++++ src/gallium/auxiliary/util/u_format_table.py | 6 ++++++ 3 files changed, 48 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 2fbbb83d4b..7054a07b2d 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -138,8 +138,26 @@ struct util_format_description const char *name; struct util_format_block block; enum util_format_layout layout; + + /** + * The number of channels. + */ + unsigned nr_channels:3; + + /** + * Whether all channels have the same number of whole bytes. + */ + unsigned is_array:1; + + /** + * Whether channels have mixed types (ignoring UTIL_FORMAT_TYPE_VOID). + */ + unsigned is_mixed:1; + struct util_format_channel_description channel[4]; + unsigned char swizzle[4]; + enum util_format_colorspace colorspace; }; diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 493aff7112..5d49fc7652 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -83,6 +83,30 @@ class Format: size += type.size return size + def nr_channels(self): + nr_channels = 0 + for type in self.in_types: + if type.size: + nr_channels += 1 + return nr_channels + + def is_array(self): + ref_type = self.in_types[0] + for type in self.in_types[1:]: + if type.size and (type.size != ref_type.size or type.size % 8): + return False + return True + + def is_mixed(self): + ref_type = self.in_types[0] + for type in self.in_types[1:]: + if type.kind != VOID: + if type.kind != ref_type.kind: + return True + if type.norm != ref_type.norm: + return True + return False + def stride(self): return self.block_size()/8 diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 571cab55dc..05e176d567 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -94,6 +94,9 @@ def write_format_table(formats): print " \"PIPE_FORMAT_NONE\"," print " {0, 0, 0}," print " 0," + print " 0," + print " 0," + print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," print " 0" @@ -104,6 +107,9 @@ def write_format_table(formats): print " \"%s\"," % (format.name,) print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): type = format.in_types[i] -- cgit v1.2.3 From 4e526b42b0fdcb9144292598458137076514fe04 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 23 Feb 2010 20:19:50 +0000 Subject: llvmpipe: Kill unused UTIL_FORMAT_LAYOUT_SCALAR. --- src/gallium/drivers/llvmpipe/lp_screen.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index ad5a484959..0e5750ce11 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -194,8 +194,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && - format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + if(format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) return FALSE; @@ -224,8 +223,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && - format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + if(format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) return FALSE; -- cgit v1.2.3 From 573a8002d540eebf6a39733ba8cdba1569eeab82 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 23 Feb 2010 20:20:19 +0000 Subject: util: Kill unused UTIL_FORMAT_LAYOUT_SCALAR. --- src/gallium/auxiliary/util/u_format.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 7054a07b2d..7792aa0673 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -55,11 +55,6 @@ extern "C" { * XXX: This should be renamed to something like util_format_pack. */ enum util_format_layout { - /** - * Single scalar component. - */ - UTIL_FORMAT_LAYOUT_SCALAR = 0, - /** * One or more components of mixed integer formats, arithmetically encoded * in a word up to 32bits. @@ -392,7 +387,6 @@ util_format_has_alpha(enum pipe_format format) } switch (desc->layout) { - case UTIL_FORMAT_LAYOUT_SCALAR: case UTIL_FORMAT_LAYOUT_ARITH: case UTIL_FORMAT_LAYOUT_ARRAY: /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */ -- cgit v1.2.3 From 227ae7b968c1351921babdbf6f052239766ffce4 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 24 Feb 2010 15:16:54 +0100 Subject: cso: Track clip state with cso context. --- src/gallium/auxiliary/cso_cache/cso_context.c | 54 +++++++++++++++++++++++++++ src/gallium/auxiliary/cso_cache/cso_context.h | 13 +++++++ 2 files changed, 67 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index b5241fa64c..a7335c340c 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -90,6 +90,9 @@ struct cso_context { void *fragment_shader, *fragment_shader_saved, *geometry_shader; void *vertex_shader, *vertex_shader_saved, *geometry_shader_saved; + struct pipe_clip_state clip; + struct pipe_clip_state clip_saved; + struct pipe_framebuffer_state fb, fb_saved; struct pipe_viewport_state vp, vp_saved; struct pipe_blend_color blend_color; @@ -1126,3 +1129,54 @@ void cso_restore_geometry_shader(struct cso_context *ctx) } ctx->geometry_shader_saved = NULL; } + + +/* clip state */ + +static INLINE void +clip_state_cpy(struct pipe_clip_state *dst, + const struct pipe_clip_state *src) +{ + dst->nr = src->nr; + if (src->nr) { + memcpy(dst->ucp, src->ucp, src->nr * sizeof(src->ucp[0])); + } +} + +static INLINE int +clip_state_cmp(const struct pipe_clip_state *a, + const struct pipe_clip_state *b) +{ + if (a->nr != b->nr) { + return 1; + } + if (a->nr) { + return memcmp(a->ucp, b->ucp, a->nr * sizeof(a->ucp[0])); + } + return 0; +} + +void +cso_set_clip(struct cso_context *ctx, + const struct pipe_clip_state *clip) +{ + if (clip_state_cmp(&ctx->clip, clip)) { + clip_state_cpy(&ctx->clip, clip); + ctx->pipe->set_clip_state(ctx->pipe, clip); + } +} + +void +cso_save_clip(struct cso_context *ctx) +{ + clip_state_cpy(&ctx->clip_saved, &ctx->clip); +} + +void +cso_restore_clip(struct cso_context *ctx) +{ + if (clip_state_cmp(&ctx->clip, &ctx->clip_saved)) { + clip_state_cpy(&ctx->clip, &ctx->clip_saved); + ctx->pipe->set_clip_state(ctx->pipe, &ctx->clip_saved); + } +} diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 707b3c2cee..251a9a644f 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -180,6 +180,19 @@ void cso_save_stencil_ref(struct cso_context *cso); void cso_restore_stencil_ref(struct cso_context *cso); +/* clip state */ + +void +cso_set_clip(struct cso_context *cso, + const struct pipe_clip_state *clip); + +void +cso_save_clip(struct cso_context *cso); + +void +cso_restore_clip(struct cso_context *cso); + + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 5b3f8369c693e75d1dbc7587e4e0d77934c0cd77 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 24 Feb 2010 15:48:30 +0100 Subject: util: Reset clip state when doing blitting. --- src/gallium/auxiliary/util/u_blit.c | 8 +++++++- src/gallium/auxiliary/util/u_gen_mipmap.c | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 90a3230a0f..95567d00fe 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -62,6 +62,7 @@ struct blit_state struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; + struct pipe_clip_state clip; void *vs; void *fs[TGSI_WRITEMASK_XYZW + 1]; @@ -264,7 +265,6 @@ regions_overlap(int srcX0, int srcY0, * \param writemask controls which channels in the dest surface are sourced * from the src surface. Disabled channels are sourced * from (0,0,0,1). - * XXX what about clipping??? * XXX need some control over blitting Z and/or stencil. */ void @@ -409,11 +409,13 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_clip(ctx->cso); /* set misc state we care about */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_clip(ctx->cso, &ctx->clip); /* sampler */ ctx->sampler.min_img_filter = filter; @@ -475,6 +477,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_clip(ctx->cso); pipe_texture_reference(&tex, NULL); } @@ -558,11 +561,13 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_clip(ctx->cso); /* set misc state we care about */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_clip(ctx->cso, &ctx->clip); /* sampler */ ctx->sampler.min_img_filter = filter; @@ -607,4 +612,5 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_clip(ctx->cso); } diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 4f9ff1d961..f423882ca2 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -61,6 +61,7 @@ struct gen_mipmap_state struct pipe_depth_stencil_alpha_state depthstencil; struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; + struct pipe_clip_state clip; void *vs; void *fs2d, *fsCube; @@ -1499,11 +1500,13 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); cso_save_viewport(ctx->cso); + cso_save_clip(ctx->cso); /* bind our state */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_clip(ctx->cso, &ctx->clip); cso_set_fragment_shader_handle(ctx->cso, fs); cso_set_vertex_shader_handle(ctx->cso, ctx->vs); @@ -1589,4 +1592,5 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); cso_restore_viewport(ctx->cso); + cso_restore_clip(ctx->cso); } -- cgit v1.2.3 From b57d80da7765b2f06ba37758c05819456c27d0b9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 13:47:42 +0000 Subject: util: Allow '#' comments in u_format.csv. --- src/gallium/auxiliary/util/u_format_parse.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 5d49fc7652..37336029d8 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -137,7 +137,15 @@ def parse(filename): stream = open(filename) formats = [] for line in stream: - line = line.rstrip() + try: + comment = line.index('#') + except ValueError: + pass + else: + line = line[:comment] + line = line.strip() + if not line: + continue fields = [field.strip() for field in line.split(',')] name = fields[0] layout = fields[1] -- cgit v1.2.3 From ba7ce0ccd4e160dc4f2322ce03e01a315938d37e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 14:15:09 +0000 Subject: util: Organize formats in groups. Add comments. --- src/gallium/auxiliary/util/u_format.csv | 96 +++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 01f7931aed..2d83d169e9 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -1,3 +1,4 @@ +# Typical rendertarget formats PIPE_FORMAT_A8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb PIPE_FORMAT_X8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb PIPE_FORMAT_B8G8R8A8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb @@ -6,13 +7,33 @@ PIPE_FORMAT_A1R5G5B5_UNORM , arith , 1, 1, un5 , un5 , un5 , un1 , zyxw, PIPE_FORMAT_A4R4G4B4_UNORM , arith , 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_R5G6B5_UNORM , arith , 1, 1, un5 , un6 , un5 , , zyx1, rgb PIPE_FORMAT_A2B10G10R10_UNORM , arith , 1, 1, un10, un10, un10, un2 , xyzw, rgb + +# Luminance/Intensity/Alpha formats PIPE_FORMAT_L8_UNORM , arith , 1, 1, un8 , , , , xxx1, rgb PIPE_FORMAT_A8_UNORM , arith , 1, 1, un8 , , , , 000x, rgb PIPE_FORMAT_I8_UNORM , arith , 1, 1, un8 , , , , xxxx, rgb PIPE_FORMAT_A8L8_UNORM , arith , 1, 1, un8 , un8 , , , xxxy, rgb PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1, rgb -PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv -PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv + +# SRGB formats +PIPE_FORMAT_L8_SRGB , arith , 1, 1, u8 , , , , xxx1, srgb +PIPE_FORMAT_A8L8_SRGB , arith , 1, 1, u8 , u8 , , , xxxy, srgb +PIPE_FORMAT_R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , , xyz1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, srgb +PIPE_FORMAT_R8G8B8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb + +# Signed formats (typically used for bump map textures) +PIPE_FORMAT_A8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , wzy1, rgb +PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb + +# Depth-stencil formats +PIPE_FORMAT_S8_UNORM , array , 1, 1, un8 , , , , _x__, zs PIPE_FORMAT_Z16_UNORM , array , 1, 1, un16, , , , x___, zs PIPE_FORMAT_Z32_UNORM , array , 1, 1, un32, , , , x___, zs PIPE_FORMAT_Z32_FLOAT , array , 1, 1, f32 , , , , x___, zs @@ -20,7 +41,26 @@ PIPE_FORMAT_S8Z24_UNORM , arith , 1, 1, un24, un8 , , , xy__, PIPE_FORMAT_Z24S8_UNORM , arith , 1, 1, un8 , un24, , , yx__, zs PIPE_FORMAT_X8Z24_UNORM , arith , 1, 1, un24, un8 , , , x___, zs PIPE_FORMAT_Z24X8_UNORM , arith , 1, 1, un8 , un24, , , y___, zs -PIPE_FORMAT_S8_UNORM , array , 1, 1, un8 , , , , _x__, zs + +# YUV formats +PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv + +# Compressed formats +PIPE_FORMAT_DXT1_RGB , dxt , 4, 4, x64 , , , , xyz1, rgb +PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb +PIPE_FORMAT_DXT3_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT5_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT1_SRGB , dxt , 4, 4, x64 , , , , xyz1, srgb +PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb +PIPE_FORMAT_DXT3_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_DXT5_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb + +# Old vector formats +# XXX: Swizzle notation is reversed for these! +# See also: +# - src/gallium/auxiliary/translate/translate_generic.c +# - src/mesa/state_tracker/st_draw.c PIPE_FORMAT_R64_FLOAT , array , 1, 1, f64 , , , , x001, rgb PIPE_FORMAT_R64G64_FLOAT , array , 1, 1, f64 , f64 , , , xy01, rgb PIPE_FORMAT_R64G64B64_FLOAT , array , 1, 1, f64 , f64 , f64 , , xyz1, rgb @@ -45,6 +85,10 @@ PIPE_FORMAT_R32_SSCALED , array , 1, 1, s32 , , , , x001, PIPE_FORMAT_R32G32_SSCALED , array , 1, 1, s32 , s32 , , , xy01, rgb PIPE_FORMAT_R32G32B32_SSCALED , array , 1, 1, s32 , s32 , s32 , , xyz1, rgb PIPE_FORMAT_R32G32B32A32_SSCALED , array , 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb +PIPE_FORMAT_R32_FIXED , array , 1, 1, h32 , , , , x001, rgb +PIPE_FORMAT_R32G32_FIXED , array , 1, 1, h32 , h32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_FIXED , array , 1, 1, h32 , h32 , h32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_FIXED , array , 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb PIPE_FORMAT_R16_UNORM , array , 1, 1, un16, , , , x001, rgb PIPE_FORMAT_R16G16_UNORM , array , 1, 1, un16, un16, , , xy01, rgb PIPE_FORMAT_R16G16B16_UNORM , array , 1, 1, un16, un16, un16, , xyz1, rgb @@ -62,48 +106,30 @@ PIPE_FORMAT_R16G16_SSCALED , array , 1, 1, s16 , s16 , , , xy01, PIPE_FORMAT_R16G16B16_SSCALED , array , 1, 1, s16 , s16 , s16 , , xyz1, rgb PIPE_FORMAT_R16G16B16A16_SSCALED , array , 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb PIPE_FORMAT_R8_UNORM , array , 1, 1, un8 , , , , x001, rgb -PIPE_FORMAT_R8G8_UNORM , array , 1, 1, un8 , un8 , , , yx01, rgb -PIPE_FORMAT_R8G8B8_UNORM , array , 1, 1, un8 , un8 , un8 , , zyx1, rgb -PIPE_FORMAT_R8G8B8A8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -PIPE_FORMAT_R8G8B8X8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_R8G8_UNORM , array , 1, 1, un8 , un8 , , , xy01, rgb PIPE_FORMAT_R8_USCALED , array , 1, 1, u8 , , , , x001, rgb PIPE_FORMAT_R8G8_USCALED , array , 1, 1, u8 , u8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_USCALED , array , 1, 1, u8 , u8 , u8 , , xyz1, rgb PIPE_FORMAT_R8G8B8A8_USCALED , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb -PIPE_FORMAT_R8G8B8X8_USCALED , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, rgb PIPE_FORMAT_R8_SNORM , array , 1, 1, sn8 , , , , x001, rgb PIPE_FORMAT_R8G8_SNORM , array , 1, 1, sn8 , sn8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb PIPE_FORMAT_R8G8B8A8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb -PIPE_FORMAT_R8G8B8X8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb -PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb -PIPE_FORMAT_A8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb PIPE_FORMAT_R8_SSCALED , array , 1, 1, s8 , , , , x001, rgb PIPE_FORMAT_R8G8_SSCALED , array , 1, 1, s8 , s8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_SSCALED , array , 1, 1, s8 , s8 , s8 , , xyz1, rgb PIPE_FORMAT_R8G8B8A8_SSCALED , array , 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb + +# Ambiguous formats +# FIXME: They are used with different meanings in different places!!! +PIPE_FORMAT_R8G8B8_UNORM , array , 1, 1, un8 , un8 , un8 , , zyx1, rgb +PIPE_FORMAT_R8G8B8A8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb + +# Unused formats +# XXX: Couldn't find any state tracker using them!! +PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb +PIPE_FORMAT_R8G8B8X8_USCALED , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, rgb PIPE_FORMAT_R8G8B8X8_SSCALED , array , 1, 1, s8 , s8 , s8 , s8 , xyz1, rgb -PIPE_FORMAT_R32_FIXED , array , 1, 1, h32 , , , , x001, rgb -PIPE_FORMAT_R32G32_FIXED , array , 1, 1, h32 , h32 , , , xy01, rgb -PIPE_FORMAT_R32G32B32_FIXED , array , 1, 1, h32 , h32 , h32 , , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_FIXED , array , 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb -PIPE_FORMAT_L8_SRGB , arith , 1, 1, u8 , , , , xxx1, srgb -PIPE_FORMAT_A8L8_SRGB , arith , 1, 1, u8 , u8 , , , xxxy, srgb -PIPE_FORMAT_R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , , xyz1, srgb -PIPE_FORMAT_R8G8B8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, srgb -PIPE_FORMAT_R8G8B8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, srgb -PIPE_FORMAT_A8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb -PIPE_FORMAT_B8G8R8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb -PIPE_FORMAT_X8UB8UG8SR8S_NORM , array , 1, 1, sn8 , sn8 , un8 , x8 , wzy1, rgb -PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb -PIPE_FORMAT_DXT1_RGB , dxt , 4, 4, x64 , , , , xyz1, rgb -PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb -PIPE_FORMAT_DXT3_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT5_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT1_SRGB , dxt , 4, 4, x64 , , , , xyz1, srgb -PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb -PIPE_FORMAT_DXT3_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb -PIPE_FORMAT_DXT5_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb +# XXX: This one is mentioned in mesa and r300, but not anywhere else. Not sure it is actually needed +PIPE_FORMAT_R8G8B8X8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -- cgit v1.2.3 From 55f02ba364ba4fa01b2a8596bf8a4914414a3087 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 14:33:45 +0000 Subject: util: Fix swizzles for SRGB formats. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on Marek Olšák's fix 8-bits-per-channel formats swizzles, with the exception that the notation for several formats (the vector formats) is actually reversed so they should be left alone. --- src/gallium/auxiliary/util/u_format.csv | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 2d83d169e9..37f831d509 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -18,18 +18,18 @@ PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1, # SRGB formats PIPE_FORMAT_L8_SRGB , arith , 1, 1, u8 , , , , xxx1, srgb PIPE_FORMAT_A8L8_SRGB , arith , 1, 1, u8 , u8 , , , xxxy, srgb -PIPE_FORMAT_R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , , xyz1, srgb -PIPE_FORMAT_R8G8B8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, srgb -PIPE_FORMAT_R8G8B8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, srgb -PIPE_FORMAT_A8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb -PIPE_FORMAT_B8G8R8A8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , array , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb +PIPE_FORMAT_R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , , zyx1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , wzyx, srgb +PIPE_FORMAT_R8G8B8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , wzy1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb # Signed formats (typically used for bump map textures) -PIPE_FORMAT_A8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb -PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , wzy1, rgb +PIPE_FORMAT_A8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats -- cgit v1.2.3 From 5caa0048293b9791f0db24e6a91126a7c2cae577 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 14:36:54 +0000 Subject: util: Minor tweaks to ambigous/unused format descriptions. --- src/gallium/auxiliary/util/u_format.csv | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 37f831d509..e8765f2351 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -122,14 +122,14 @@ PIPE_FORMAT_R8G8B8A8_SSCALED , array , 1, 1, s8 , s8 , s8 , s8 , xyzw, # Ambiguous formats # FIXME: They are used with different meanings in different places!!! -PIPE_FORMAT_R8G8B8_UNORM , array , 1, 1, un8 , un8 , un8 , , zyx1, rgb -PIPE_FORMAT_R8G8B8A8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb +PIPE_FORMAT_R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , , zyx1, rgb +PIPE_FORMAT_R8G8B8A8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb # Unused formats # XXX: Couldn't find any state tracker using them!! PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb -PIPE_FORMAT_R8G8B8X8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb -PIPE_FORMAT_R8G8B8X8_USCALED , array , 1, 1, u8 , u8 , u8 , u8 , xyz1, rgb -PIPE_FORMAT_R8G8B8X8_SSCALED , array , 1, 1, s8 , s8 , s8 , s8 , xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_USCALED , arith , 1, 1, u8 , u8 , u8 , u8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_SSCALED , arith , 1, 1, s8 , s8 , s8 , s8 , wzy1, rgb # XXX: This one is mentioned in mesa and r300, but not anywhere else. Not sure it is actually needed -PIPE_FORMAT_R8G8B8X8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -- cgit v1.2.3 From 395b335fa4d0e5b069b8fb69b7fda7b2e76c3138 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 14:51:31 +0000 Subject: util: Handle correctly 24bit formats. --- src/gallium/auxiliary/util/u_format_access.py | 125 +++++++++++++------------- 1 file changed, 64 insertions(+), 61 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 0b05ddb931..83f7a1b6f3 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -81,25 +81,26 @@ def is_format_supported(format): def native_type(format): '''Get the native appropriate for a format.''' - if format.layout == ARITH: - # For arithmetic pixel formats return the integer type that matches the whole pixel - return 'uint%u_t' % format.block_size() - elif format.layout == ARRAY: - # For array pixel formats return the integer type that matches the color channel - type = format.in_types[0] - if type.kind == UNSIGNED: - return 'uint%u_t' % type.size - elif type.kind == SIGNED: - return 'int%u_t' % type.size - elif type.kind == FLOAT: - if type.size == 32: - return 'float' - elif type.size == 64: - return 'double' + if format.layout in (ARITH, ARRAY): + if not format.is_array(): + # For arithmetic pixel formats return the integer type that matches the whole pixel + return 'uint%u_t' % format.block_size() + else: + # For array pixel formats return the integer type that matches the color channel + type = format.in_types[0] + if type.kind == UNSIGNED: + return 'uint%u_t' % type.size + elif type.kind == SIGNED: + return 'int%u_t' % type.size + elif type.kind == FLOAT: + if type.size == 32: + return 'float' + elif type.size == 64: + return 'double' + else: + assert False else: assert False - else: - assert False else: assert False @@ -291,29 +292,30 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): else: assert False - if format.layout == ARITH: - print ' %s pixel = *src_pixel++;' % src_native_type - shift = 0; - for i in range(4): - src_type = format.in_types[i] - width = src_type.size - if names[i]: - value = 'pixel' - mask = (1 << width) - 1 - if shift: - value = '(%s >> %u)' % (value, shift) - if shift + width < format.block_size(): - value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) - shift += width - elif format.layout == ARRAY: - for i in range(4): - src_type = format.in_types[i] - if names[i]: - value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) + if format.layout in (ARITH, ARRAY): + if not format.is_array(): + print ' %s pixel = *src_pixel++;' % src_native_type + shift = 0; + for i in range(4): + src_type = format.in_types[i] + width = src_type.size + if names[i]: + value = 'pixel' + mask = (1 << width) - 1 + if shift: + value = '(%s >> %u)' % (value, shift) + if shift + width < format.block_size(): + value = '(%s & 0x%x)' % (value, mask) + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' %s %s = %s;' % (dst_native_type, names[i], value) + shift += width + else: + for i in range(4): + src_type = format.in_types[i] + if names[i]: + value = '(*src_pixel++)' + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False @@ -376,27 +378,28 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): else: assert False - if format.layout == ARITH: - print ' %s pixel = 0;' % dst_native_type - shift = 0; - for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size - if inv_swizzle[i] is not None: - value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) - if shift: - value = '(%s << %u)' % (value, shift) - print ' pixel |= %s;' % value - shift += width - print ' *dst_pixel++ = pixel;' - elif format.layout == ARRAY: - for i in range(4): - dst_type = format.in_types[i] - if inv_swizzle[i] is not None: - value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' *dst_pixel++ = %s;' % value + if format.layout in (ARITH, ARRAY): + if not format.is_array(): + print ' %s pixel = 0;' % dst_native_type + shift = 0; + for i in range(4): + dst_type = format.in_types[i] + width = dst_type.size + if inv_swizzle[i] is not None: + value = 'src_pixel[%u]' % inv_swizzle[i] + value = conversion_expr(src_type, dst_type, dst_native_type, value) + if shift: + value = '(%s << %u)' % (value, shift) + print ' pixel |= %s;' % value + shift += width + print ' *dst_pixel++ = pixel;' + else: + for i in range(4): + dst_type = format.in_types[i] + if inv_swizzle[i] is not None: + value = 'src_pixel[%u]' % inv_swizzle[i] + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' *dst_pixel++ = %s;' % value else: assert False print ' src_pixel += 4;' -- cgit v1.2.3 From a9395360f2fd113beac759ca642d48588e0846f9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 14:51:47 +0000 Subject: llvmpipe: Handle correctly 24bit formats. --- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 90 +++++++++++++++-------------- 1 file changed, 46 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 5d53689a3d..7d5ded2f02 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -76,29 +76,30 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): else: assert False - if format.layout == ARITH: - print ' %s pixel = *src_pixel++;' % src_native_type - shift = 0; - for i in range(4): - src_type = format.in_types[i] - width = src_type.size - if names[i]: - value = 'pixel' - mask = (1 << width) - 1 - if shift: - value = '(%s >> %u)' % (value, shift) - if shift + width < format.block_size(): - value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) - shift += width - elif format.layout == ARRAY: - for i in range(4): - src_type = format.in_types[i] - if names[i]: - value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' %s %s = %s;' % (dst_native_type, names[i], value) + if format.layout in (ARITH, ARRAY): + if not format.is_array(): + print ' %s pixel = *src_pixel++;' % src_native_type + shift = 0; + for i in range(4): + src_type = format.in_types[i] + width = src_type.size + if names[i]: + value = 'pixel' + mask = (1 << width) - 1 + if shift: + value = '(%s >> %u)' % (value, shift) + if shift + width < format.block_size(): + value = '(%s & 0x%x)' % (value, mask) + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' %s %s = %s;' % (dst_native_type, names[i], value) + shift += width + else: + for i in range(4): + src_type = format.in_types[i] + if names[i]: + value = '(*src_pixel++)' + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False @@ -222,27 +223,28 @@ def emit_tile_pixel_write_code(format, src_type): print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()) print ' for (x = 0; x < w; ++x) {' - if format.layout == ARITH: - print ' %s pixel = 0;' % dst_native_type - shift = 0; - for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size - if inv_swizzle[i] is not None: - value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) - if shift: - value = '(%s << %u)' % (value, shift) - print ' pixel |= %s;' % value - shift += width - print ' *dst_pixel++ = pixel;' - elif format.layout == ARRAY: - for i in range(4): - dst_type = format.in_types[i] - if inv_swizzle[i] is not None: - value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) - print ' *dst_pixel++ = %s;' % value + if format.layout in (ARITH, ARRAY): + if not format.is_array(): + print ' %s pixel = 0;' % dst_native_type + shift = 0; + for i in range(4): + dst_type = format.in_types[i] + width = dst_type.size + if inv_swizzle[i] is not None: + value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] + value = conversion_expr(src_type, dst_type, dst_native_type, value) + if shift: + value = '(%s << %u)' % (value, shift) + print ' pixel |= %s;' % value + shift += width + print ' *dst_pixel++ = pixel;' + else: + for i in range(4): + dst_type = format.in_types[i] + if inv_swizzle[i] is not None: + value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] + value = conversion_expr(src_type, dst_type, dst_native_type, value) + print ' *dst_pixel++ = %s;' % value else: assert False -- cgit v1.2.3 From 943314f38f1224d4929b41acc9ef8fde81ef9dbe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 15:10:46 +0000 Subject: util: Factor out the code to shorten a format name. --- src/gallium/auxiliary/util/u_format_access.py | 19 ++++--------------- src/gallium/auxiliary/util/u_format_parse.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 83f7a1b6f3..ca0c9765c2 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -42,17 +42,6 @@ import sys from u_format_parse import * -def short_name(format): - '''Make up a short norm for a format, suitable to be used as suffix in - function names.''' - - name = format.name - if name.startswith('PIPE_FORMAT_'): - name = name[len('PIPE_FORMAT_'):] - name = name.lower() - return name - - def is_format_supported(format): '''Determines whether we actually have the plumbing necessary to generate the to read/write to/from this format.''' @@ -262,7 +251,7 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): def generate_format_read(format, dst_type, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' - name = short_name(format) + name = format.short_name() src_native_type = native_type(format) @@ -350,7 +339,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): def generate_format_write(format, src_type, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' - name = short_name(format) + name = format.short_name() dst_native_type = native_type(format) @@ -427,7 +416,7 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &util_format_%s_read_%s;' % (short_name(format), dst_suffix) + print ' func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix) print ' break;' print ' default:' print ' debug_printf("unsupported format\\n");' @@ -454,7 +443,7 @@ def generate_write(formats, src_type, src_native_type, src_suffix): for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &util_format_%s_write_%s;' % (short_name(format), src_suffix) + print ' func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix) print ' break;' print ' default:' print ' debug_printf("unsupported format\\n");' diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 37336029d8..248a26ea8c 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -77,6 +77,16 @@ class Format: def __str__(self): return self.name + def short_name(self): + '''Make up a short norm for a format, suitable to be used as suffix in + function names.''' + + name = self.name + if name.startswith('PIPE_FORMAT_'): + name = name[len('PIPE_FORMAT_'):] + name = name.lower() + return name + def block_size(self): size = 0 for type in self.in_types: -- cgit v1.2.3 From 3c45c4bc44310c1af4f0c06d29eb0a9d39a38837 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 15:11:28 +0000 Subject: util: Cope with the fact that formats in u_format.csv are not ordered. --- src/gallium/auxiliary/Makefile | 1 - src/gallium/auxiliary/SConscript | 1 - src/gallium/auxiliary/util/u_format.c | 45 ----------------- src/gallium/auxiliary/util/u_format_table.py | 75 +++++++++++++++++----------- 4 files changed, 47 insertions(+), 75 deletions(-) delete mode 100644 src/gallium/auxiliary/util/u_format.c (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 916f5f6c91..2d41fb3dca 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -105,7 +105,6 @@ C_SOURCES = \ util/u_cpu_detect.c \ util/u_dl.c \ util/u_draw_quad.c \ - util/u_format.c \ util/u_format_access.c \ util/u_format_table.c \ util/u_gen_mipmap.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index b531ad2dbd..8d2859fa71 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -140,7 +140,6 @@ source = [ 'util/u_dump_state.c', 'util/u_dl.c', 'util/u_draw_quad.c', - 'util/u_format.c', 'util/u_format_access.c', 'util/u_format_table.c', 'util/u_gen_mipmap.c', diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c deleted file mode 100644 index e0724a1a8b..0000000000 --- a/src/gallium/auxiliary/util/u_format.c +++ /dev/null @@ -1,45 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 Vmware, Inc. - * 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 VMWARE 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 "u_format.h" - - -const struct util_format_description * -util_format_description(enum pipe_format format) -{ - const struct util_format_description *desc; - - if (format >= PIPE_FORMAT_COUNT) { - return NULL; - } - - desc = &util_format_description_table[format]; - assert(desc->format == format); - - return desc; -} diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 05e176d567..3d0e3a0349 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -87,39 +87,39 @@ def write_format_table(formats): print '#include "u_format.h"' print print 'const struct util_format_description' - print 'util_format_description_table[] = ' - print "{" - print " {" - print " PIPE_FORMAT_NONE," - print " \"PIPE_FORMAT_NONE\"," - print " {0, 0, 0}," - print " 0," - print " 0," - print " 0," - print " 0," - print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," - print " {0, 0, 0, 0}," - print " 0" - print " }," + print 'util_format_none_description = {' + print " PIPE_FORMAT_NONE," + print " \"PIPE_FORMAT_NONE\"," + print " {0, 0, 0}," + print " 0," + print " 0," + print " 0," + print " 0," + print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," + print " {0, 0, 0, 0}," + print " 0" + print "};" + print for format in formats: + print 'const struct util_format_description' + print 'util_format_%s_description = {' % (format.short_name(),) + print " %s," % (format.name,) + print " \"%s\"," % (format.name,) + print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) + print " %s," % (layout_map(format.layout),) + print " %u,\t/* nr_channels */" % (format.nr_channels(),) + print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" - print " %s," % (format.name,) - print " \"%s\"," % (format.name,) - print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) - print " %s," % (layout_map(format.layout),) - print " %u,\t/* nr_channels */" % (format.nr_channels(),) - print " %s,\t/* is_array */" % (bool_map(format.is_array()),) - print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) - print " {" for i in range(4): type = format.in_types[i] if i < 3: sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) - print " }," - print " {" + print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) + print " }," + print " {" for i in range(4): swizzle = format.out_swizzle[i] if i < 3: @@ -130,11 +130,30 @@ def write_format_table(formats): comment = colorspace_channels_map[format.colorspace][i] except (KeyError, IndexError): comment = 'ignored' - print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) - print " }," - print " %s," % (colorspace_map(format.colorspace),) + print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment) print " }," + print " %s," % (colorspace_map(format.colorspace),) + print "};" + print + print "const struct util_format_description *" + print "util_format_description(enum pipe_format format)" + print "{" + print " if (format >= PIPE_FORMAT_COUNT) {" + print " return NULL;" + print " }" + print + print " switch (format) {" + print " case PIPE_FORMAT_NONE:" + print " return &util_format_none_description;" + for format in formats: + print " case %s:" % format.name + print " return &util_format_%s_description;" % (format.short_name(),) + print " default:" + print " assert(0);" + print " return NULL;" + print " }" print "};" + print def main(): -- cgit v1.2.3 From 1dbb5f02aeca89626c4479c53828ea7957989892 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 15:41:24 +0000 Subject: util: Refactor some code. --- src/gallium/auxiliary/util/u_format_access.py | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index ca0c9765c2..fb85215d20 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -248,6 +248,24 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): assert False +def compute_inverse_swizzle(format): + '''Return an array[4] of inverse swizzle terms''' + inv_swizzle = [None]*4 + if format.colorspace == 'rgb': + for i in range(4): + swizzle = format.out_swizzle[i] + if swizzle < 4: + inv_swizzle[swizzle] = i + elif format.colorspace == 'zs': + swizzle = format.out_swizzle[0] + if swizzle < 4: + inv_swizzle[swizzle] = 0 + else: + assert False + + return inv_swizzle + + def generate_format_read(format, dst_type, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -330,7 +348,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print ' }' print ' src_row += src_stride;' - print ' dst_row += dst_stride/sizeof(%s);' % dst_native_type + print ' dst_row += dst_stride/sizeof(*dst_row);' print ' }' print '}' print @@ -354,18 +372,7 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' const %s *src_pixel = src_row;' %src_native_type print ' for (x = 0; x < w; ++x) {' - inv_swizzle = [None]*4 - if format.colorspace == 'rgb': - for i in range(4): - swizzle = format.out_swizzle[i] - if swizzle < 4: - inv_swizzle[swizzle] = i - elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] - if swizzle < 4: - inv_swizzle[swizzle] = 0 - else: - assert False + inv_swizzle = compute_inverse_swizzle(format) if format.layout in (ARITH, ARRAY): if not format.is_array(): @@ -395,7 +402,7 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' }' print ' dst_row += dst_stride;' - print ' src_row += src_stride/sizeof(%s);' % src_native_type + print ' src_row += src_stride/sizeof(*src_row);' print ' }' print '}' print -- cgit v1.2.3 From 085810542f40f71d93d84d4198166e915df4d384 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 15:45:11 +0000 Subject: llvmpipe: Fix breakeage. Due to the u_format.csv changes the unrolled code generator was being used for formats it didn't support. Bring some bugfixes from u_format_access.py too. --- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 37 ++++++++++------------------- 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 7d5ded2f02..0b9631f871 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -48,7 +48,7 @@ from u_format_access import * def generate_format_read(format, dst_type, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' - name = short_name(format) + name = format.short_name() src_native_type = native_type(format) @@ -111,14 +111,14 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): elif swizzle == SWIZZLE_0: value = '0' elif swizzle == SWIZZLE_1: - value = '1' + value = get_one(dst_type) else: assert False elif format.colorspace == 'zs': if i < 3: value = 'z' else: - value = '1' + value = get_one(dst_type) else: assert False print ' TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i]) @@ -130,21 +130,6 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print -def compute_inverse_swizzle(format): - '''Return an array[4] of inverse swizzle terms''' - inv_swizzle = [None]*4 - if format.colorspace == 'rgb': - for i in range(4): - swizzle = format.out_swizzle[i] - if swizzle < 4: - inv_swizzle[swizzle] = i - elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] - if swizzle < 4: - inv_swizzle[swizzle] = 0 - return inv_swizzle - - def pack_rgba(format, src_type, r, g, b, a): """Return an expression for packing r, g, b, a into a pixel of the given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)' @@ -154,7 +139,7 @@ def pack_rgba(format, src_type, r, g, b, a): shift = 0 expr = None for i in range(4): - # choose r, g, b, or a depending on the inverse swizzle term + # choose r, g, b, or a depending on the inverse swizzle term if inv_swizzle[i] == 0: value = r elif inv_swizzle[i] == 1: @@ -185,7 +170,7 @@ def emit_unrolled_write_code(format, src_type): '''Emit code for writing a block based on unrolled loops. This is considerably faster than the TILE_PIXEL-based code below. ''' - dst_native_type = native_type(format) + dst_native_type = intermediate_native_type(format.block_size(), False) print ' const unsigned dstpix_stride = dst_stride / %d;' % format.stride() print ' %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type) print ' unsigned int qx, qy, i;' @@ -256,12 +241,16 @@ def emit_tile_pixel_write_code(format, src_type): def generate_format_write(format, src_type, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' - name = short_name(format) + name = format.short_name() print 'static void' print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type) print '{' - if format.layout == ARITH and format.colorspace == 'rgb': + if format.layout in (ARITH, ARRAY) \ + and format.colorspace == 'rgb' \ + and format.block_size() <= 32 \ + and not format.is_mixed() \ + and format.in_types[0].kind == UNSIGNED: emit_unrolled_write_code(format, src_type) else: emit_tile_pixel_write_code(format, src_type) @@ -284,7 +273,7 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &lp_tile_%s_read_%s;' % (short_name(format), dst_suffix) + print ' func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix) print ' break;' print ' default:' print ' debug_printf("unsupported format\\n");' @@ -311,7 +300,7 @@ def generate_write(formats, src_type, src_native_type, src_suffix): for format in formats: if is_format_supported(format): print ' case %s:' % format.name - print ' func = &lp_tile_%s_write_%s;' % (short_name(format), src_suffix) + print ' func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix) print ' break;' print ' default:' print ' debug_printf("unsupported format\\n");' -- cgit v1.2.3 From fb1834cdfdfece763f3125aa2b05e1231f560168 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 08:52:03 -0700 Subject: gallium/docs: clean up texture usage text, added texture geom info --- src/gallium/docs/source/screen.rst | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst index 27f65522b6..e78634e59e 100644 --- a/src/gallium/docs/source/screen.rst +++ b/src/gallium/docs/source/screen.rst @@ -147,16 +147,30 @@ These flags determine the possible roles a texture may be used for during its lifetime. Texture usage flags are cumulative and may be combined to create a texture that can be used as multiple things. -* ``RENDER_TARGET``: A colorbuffer or pixelbuffer. +* ``RENDER_TARGET``: A color buffer or pixel buffer which will be rendered to. * ``DISPLAY_TARGET``: A sharable buffer that can be given to another process. -* ``PRIMARY``: A frontbuffer or scanout buffer. -* ``DEPTH_STENCIL``: A depthbuffer, stencilbuffer, or Z buffer. Gallium does - not explicitly provide for stencil-only buffers, so any stencilbuffer - validated here is implicitly also a depthbuffer. +* ``PRIMARY``: A front color buffer or scanout buffer. +* ``DEPTH_STENCIL``: A depth (Z) buffer or stencil buffer. Gallium does + not explicitly provide for stencil-only buffers, so any stencil buffer + validated here is implicitly also a depth buffer. * ``SAMPLER``: A texture that may be sampled from in a fragment or vertex shader. * ``DYNAMIC``: A texture that will be mapped frequently. + +PIPE_TEXTURE_GEOM +^^^^^^^^^^^^^^^^^ + +These flags are used when querying whether a particular pipe_format is +supported by the driver (with the `is_format_supported` function). +Some formats may only be supported for certain kinds of textures. +For example, a compressed format might only be used for POT textures. + +* ``PIPE_TEXTURE_GEOM_NON_SQUARE``: The texture may not be square +* ``PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO``: The texture dimensions may not be + powers of two. + + Methods ------- -- cgit v1.2.3 From b64b78e7c3d3354933dffd250c996f387243152b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 08:52:20 -0700 Subject: i915g: fix a comment --- src/gallium/drivers/i915/i915_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index e101c8683e..7ba222c78b 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -223,7 +223,7 @@ i915_miptree_layout_2d(struct i915_texture *tex) if (i915_scanout_layout(tex)) return; - /* for shared buffers we use some very like scanout */ + /* for shared buffers we use something very like scanout */ if (pt->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) if (i915_display_target_layout(tex)) return; -- cgit v1.2.3 From 816d23505abbcd789e7390c515178bc0df8e49c4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 16:09:44 +0000 Subject: util: Kill array vs arith layouts. Revamp UTIL_FORMAT_LAYOUT_xxx. Too confusing. I now can get the same information through other means. --- src/gallium/auxiliary/util/u_format.csv | 218 +++++++++++++------------- src/gallium/auxiliary/util/u_format.h | 114 ++++++-------- src/gallium/auxiliary/util/u_format_access.py | 8 +- src/gallium/auxiliary/util/u_format_parse.py | 3 +- 4 files changed, 163 insertions(+), 180 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index e8765f2351..50341e9752 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -1,135 +1,135 @@ # Typical rendertarget formats -PIPE_FORMAT_A8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb -PIPE_FORMAT_X8R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb -PIPE_FORMAT_B8G8R8A8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb -PIPE_FORMAT_B8G8R8X8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb -PIPE_FORMAT_A1R5G5B5_UNORM , arith , 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb -PIPE_FORMAT_A4R4G4B4_UNORM , arith , 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb -PIPE_FORMAT_R5G6B5_UNORM , arith , 1, 1, un5 , un6 , un5 , , zyx1, rgb -PIPE_FORMAT_A2B10G10R10_UNORM , arith , 1, 1, un10, un10, un10, un2 , xyzw, rgb +PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb +PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb +PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb +PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb +PIPE_FORMAT_A2B10G10R10_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb # Luminance/Intensity/Alpha formats -PIPE_FORMAT_L8_UNORM , arith , 1, 1, un8 , , , , xxx1, rgb -PIPE_FORMAT_A8_UNORM , arith , 1, 1, un8 , , , , 000x, rgb -PIPE_FORMAT_I8_UNORM , arith , 1, 1, un8 , , , , xxxx, rgb -PIPE_FORMAT_A8L8_UNORM , arith , 1, 1, un8 , un8 , , , xxxy, rgb -PIPE_FORMAT_L16_UNORM , arith , 1, 1, un16, , , , xxx1, rgb +PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb +PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb +PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb +PIPE_FORMAT_A8L8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb +PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb # SRGB formats -PIPE_FORMAT_L8_SRGB , arith , 1, 1, u8 , , , , xxx1, srgb -PIPE_FORMAT_A8L8_SRGB , arith , 1, 1, u8 , u8 , , , xxxy, srgb -PIPE_FORMAT_R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , , zyx1, srgb -PIPE_FORMAT_R8G8B8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , wzyx, srgb -PIPE_FORMAT_R8G8B8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , wzy1, srgb -PIPE_FORMAT_A8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb -PIPE_FORMAT_B8G8R8A8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , arith , 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb +PIPE_FORMAT_L8_SRGB , plain, 1, 1, u8 , , , , xxx1, srgb +PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, u8 , u8 , , , xxxy, srgb +PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , , zyx1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , wzyx, srgb +PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , wzy1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb # Signed formats (typically used for bump map textures) -PIPE_FORMAT_A8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb -PIPE_FORMAT_X8UB8UG8SR8S_NORM , arith , 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb -PIPE_FORMAT_B6UG5SR5S_NORM , arith , 1, 1, sn5 , sn5 , un6 , , xyz1, rgb +PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_X8UB8UG8SR8S_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb +PIPE_FORMAT_B6UG5SR5S_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats -PIPE_FORMAT_S8_UNORM , array , 1, 1, un8 , , , , _x__, zs -PIPE_FORMAT_Z16_UNORM , array , 1, 1, un16, , , , x___, zs -PIPE_FORMAT_Z32_UNORM , array , 1, 1, un32, , , , x___, zs -PIPE_FORMAT_Z32_FLOAT , array , 1, 1, f32 , , , , x___, zs -PIPE_FORMAT_S8Z24_UNORM , arith , 1, 1, un24, un8 , , , xy__, zs -PIPE_FORMAT_Z24S8_UNORM , arith , 1, 1, un8 , un24, , , yx__, zs -PIPE_FORMAT_X8Z24_UNORM , arith , 1, 1, un24, un8 , , , x___, zs -PIPE_FORMAT_Z24X8_UNORM , arith , 1, 1, un8 , un24, , , y___, zs +PIPE_FORMAT_S8_UNORM , plain, 1, 1, un8 , , , , _x__, zs +PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs +PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs +PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs +PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs +PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un24, un8 , , , x___, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un8 , un24, , , y___, zs # YUV formats -PIPE_FORMAT_YCBCR , yuv , 2, 1, x32 , , , , xyz1, yuv -PIPE_FORMAT_YCBCR_REV , yuv , 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_YCBCR , subsampled, 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_YCBCR_REV , subsampled, 2, 1, x32 , , , , xyz1, yuv # Compressed formats -PIPE_FORMAT_DXT1_RGB , dxt , 4, 4, x64 , , , , xyz1, rgb -PIPE_FORMAT_DXT1_RGBA , dxt , 4, 4, x64 , , , , xyzw, rgb -PIPE_FORMAT_DXT3_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT5_RGBA , dxt , 4, 4, x128, , , , xyzw, rgb -PIPE_FORMAT_DXT1_SRGB , dxt , 4, 4, x64 , , , , xyz1, srgb -PIPE_FORMAT_DXT1_SRGBA , dxt , 4, 4, x64 , , , , xyzw, srgb -PIPE_FORMAT_DXT3_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb -PIPE_FORMAT_DXT5_SRGBA , dxt , 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_DXT1_RGB , compressed, 4, 4, x64 , , , , xyz1, rgb +PIPE_FORMAT_DXT1_RGBA , compressed, 4, 4, x64 , , , , xyzw, rgb +PIPE_FORMAT_DXT3_RGBA , compressed, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT5_RGBA , compressed, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_DXT1_SRGB , compressed, 4, 4, x64 , , , , xyz1, srgb +PIPE_FORMAT_DXT1_SRGBA , compressed, 4, 4, x64 , , , , xyzw, srgb +PIPE_FORMAT_DXT3_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_DXT5_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb # Old vector formats # XXX: Swizzle notation is reversed for these! # See also: # - src/gallium/auxiliary/translate/translate_generic.c # - src/mesa/state_tracker/st_draw.c -PIPE_FORMAT_R64_FLOAT , array , 1, 1, f64 , , , , x001, rgb -PIPE_FORMAT_R64G64_FLOAT , array , 1, 1, f64 , f64 , , , xy01, rgb -PIPE_FORMAT_R64G64B64_FLOAT , array , 1, 1, f64 , f64 , f64 , , xyz1, rgb -PIPE_FORMAT_R64G64B64A64_FLOAT , array , 1, 1, f64 , f64 , f64 , f64 , xyzw, rgb -PIPE_FORMAT_R32_FLOAT , array , 1, 1, f32 , , , , x001, rgb -PIPE_FORMAT_R32G32_FLOAT , array , 1, 1, f32 , f32 , , , xy01, rgb -PIPE_FORMAT_R32G32B32_FLOAT , array , 1, 1, f32 , f32 , f32 , , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_FLOAT , array , 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb -PIPE_FORMAT_R32_UNORM , array , 1, 1, un32, , , , x001, rgb -PIPE_FORMAT_R32G32_UNORM , array , 1, 1, un32, un32, , , xy01, rgb -PIPE_FORMAT_R32G32B32_UNORM , array , 1, 1, un32, un32, un32, , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_UNORM , array , 1, 1, un32, un32, un32, un32, xyzw, rgb -PIPE_FORMAT_R32_USCALED , array , 1, 1, u32 , , , , x001, rgb -PIPE_FORMAT_R32G32_USCALED , array , 1, 1, u32 , u32 , , , xy01, rgb -PIPE_FORMAT_R32G32B32_USCALED , array , 1, 1, u32 , u32 , u32 , , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_USCALED , array , 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb -PIPE_FORMAT_R32_SNORM , array , 1, 1, sn32, , , , x001, rgb -PIPE_FORMAT_R32G32_SNORM , array , 1, 1, sn32, sn32, , , xy01, rgb -PIPE_FORMAT_R32G32B32_SNORM , array , 1, 1, sn32, sn32, sn32, , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_SNORM , array , 1, 1, sn32, sn32, sn32, sn32, xyzw, rgb -PIPE_FORMAT_R32_SSCALED , array , 1, 1, s32 , , , , x001, rgb -PIPE_FORMAT_R32G32_SSCALED , array , 1, 1, s32 , s32 , , , xy01, rgb -PIPE_FORMAT_R32G32B32_SSCALED , array , 1, 1, s32 , s32 , s32 , , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_SSCALED , array , 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb -PIPE_FORMAT_R32_FIXED , array , 1, 1, h32 , , , , x001, rgb -PIPE_FORMAT_R32G32_FIXED , array , 1, 1, h32 , h32 , , , xy01, rgb -PIPE_FORMAT_R32G32B32_FIXED , array , 1, 1, h32 , h32 , h32 , , xyz1, rgb -PIPE_FORMAT_R32G32B32A32_FIXED , array , 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb -PIPE_FORMAT_R16_UNORM , array , 1, 1, un16, , , , x001, rgb -PIPE_FORMAT_R16G16_UNORM , array , 1, 1, un16, un16, , , xy01, rgb -PIPE_FORMAT_R16G16B16_UNORM , array , 1, 1, un16, un16, un16, , xyz1, rgb -PIPE_FORMAT_R16G16B16A16_UNORM , array , 1, 1, un16, un16, un16, un16, xyzw, rgb -PIPE_FORMAT_R16_USCALED , array , 1, 1, u16 , , , , x001, rgb -PIPE_FORMAT_R16G16_USCALED , array , 1, 1, u16 , u16 , , , xy01, rgb -PIPE_FORMAT_R16G16B16_USCALED , array , 1, 1, u16 , u16 , u16 , , xyz1, rgb -PIPE_FORMAT_R16G16B16A16_USCALED , array , 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb -PIPE_FORMAT_R16_SNORM , array , 1, 1, sn16, , , , x001, rgb -PIPE_FORMAT_R16G16_SNORM , array , 1, 1, sn16, sn16, , , xy01, rgb -PIPE_FORMAT_R16G16B16_SNORM , array , 1, 1, sn16, sn16, sn16, , xyz1, rgb -PIPE_FORMAT_R16G16B16A16_SNORM , array , 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb -PIPE_FORMAT_R16_SSCALED , array , 1, 1, s16 , , , , x001, rgb -PIPE_FORMAT_R16G16_SSCALED , array , 1, 1, s16 , s16 , , , xy01, rgb -PIPE_FORMAT_R16G16B16_SSCALED , array , 1, 1, s16 , s16 , s16 , , xyz1, rgb -PIPE_FORMAT_R16G16B16A16_SSCALED , array , 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb -PIPE_FORMAT_R8_UNORM , array , 1, 1, un8 , , , , x001, rgb -PIPE_FORMAT_R8G8_UNORM , array , 1, 1, un8 , un8 , , , xy01, rgb -PIPE_FORMAT_R8_USCALED , array , 1, 1, u8 , , , , x001, rgb -PIPE_FORMAT_R8G8_USCALED , array , 1, 1, u8 , u8 , , , xy01, rgb -PIPE_FORMAT_R8G8B8_USCALED , array , 1, 1, u8 , u8 , u8 , , xyz1, rgb -PIPE_FORMAT_R8G8B8A8_USCALED , array , 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb -PIPE_FORMAT_R8_SNORM , array , 1, 1, sn8 , , , , x001, rgb -PIPE_FORMAT_R8G8_SNORM , array , 1, 1, sn8 , sn8 , , , xy01, rgb -PIPE_FORMAT_R8G8B8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb -PIPE_FORMAT_R8G8B8A8_SNORM , array , 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb -PIPE_FORMAT_R8_SSCALED , array , 1, 1, s8 , , , , x001, rgb -PIPE_FORMAT_R8G8_SSCALED , array , 1, 1, s8 , s8 , , , xy01, rgb -PIPE_FORMAT_R8G8B8_SSCALED , array , 1, 1, s8 , s8 , s8 , , xyz1, rgb -PIPE_FORMAT_R8G8B8A8_SSCALED , array , 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb +PIPE_FORMAT_R64_FLOAT , plain, 1, 1, f64 , , , , x001, rgb +PIPE_FORMAT_R64G64_FLOAT , plain, 1, 1, f64 , f64 , , , xy01, rgb +PIPE_FORMAT_R64G64B64_FLOAT , plain, 1, 1, f64 , f64 , f64 , , xyz1, rgb +PIPE_FORMAT_R64G64B64A64_FLOAT , plain, 1, 1, f64 , f64 , f64 , f64 , xyzw, rgb +PIPE_FORMAT_R32_FLOAT , plain, 1, 1, f32 , , , , x001, rgb +PIPE_FORMAT_R32G32_FLOAT , plain, 1, 1, f32 , f32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_FLOAT , plain, 1, 1, f32 , f32 , f32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_FLOAT , plain, 1, 1, f32 , f32 , f32 , f32 , xyzw, rgb +PIPE_FORMAT_R32_UNORM , plain, 1, 1, un32, , , , x001, rgb +PIPE_FORMAT_R32G32_UNORM , plain, 1, 1, un32, un32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_UNORM , plain, 1, 1, un32, un32, un32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_UNORM , plain, 1, 1, un32, un32, un32, un32, xyzw, rgb +PIPE_FORMAT_R32_USCALED , plain, 1, 1, u32 , , , , x001, rgb +PIPE_FORMAT_R32G32_USCALED , plain, 1, 1, u32 , u32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_USCALED , plain, 1, 1, u32 , u32 , u32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_USCALED , plain, 1, 1, u32 , u32 , u32 , u32 , xyzw, rgb +PIPE_FORMAT_R32_SNORM , plain, 1, 1, sn32, , , , x001, rgb +PIPE_FORMAT_R32G32_SNORM , plain, 1, 1, sn32, sn32, , , xy01, rgb +PIPE_FORMAT_R32G32B32_SNORM , plain, 1, 1, sn32, sn32, sn32, , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_SNORM , plain, 1, 1, sn32, sn32, sn32, sn32, xyzw, rgb +PIPE_FORMAT_R32_SSCALED , plain, 1, 1, s32 , , , , x001, rgb +PIPE_FORMAT_R32G32_SSCALED , plain, 1, 1, s32 , s32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_SSCALED , plain, 1, 1, s32 , s32 , s32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_SSCALED , plain, 1, 1, s32 , s32 , s32 , s32 , xyzw, rgb +PIPE_FORMAT_R32_FIXED , plain, 1, 1, h32 , , , , x001, rgb +PIPE_FORMAT_R32G32_FIXED , plain, 1, 1, h32 , h32 , , , xy01, rgb +PIPE_FORMAT_R32G32B32_FIXED , plain, 1, 1, h32 , h32 , h32 , , xyz1, rgb +PIPE_FORMAT_R32G32B32A32_FIXED , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, rgb +PIPE_FORMAT_R16_UNORM , plain, 1, 1, un16, , , , x001, rgb +PIPE_FORMAT_R16G16_UNORM , plain, 1, 1, un16, un16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_UNORM , plain, 1, 1, un16, un16, un16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_UNORM , plain, 1, 1, un16, un16, un16, un16, xyzw, rgb +PIPE_FORMAT_R16_USCALED , plain, 1, 1, u16 , , , , x001, rgb +PIPE_FORMAT_R16G16_USCALED , plain, 1, 1, u16 , u16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_USCALED , plain, 1, 1, u16 , u16 , u16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_USCALED , plain, 1, 1, u16 , u16 , u16 , u16 , xyzw, rgb +PIPE_FORMAT_R16_SNORM , plain, 1, 1, sn16, , , , x001, rgb +PIPE_FORMAT_R16G16_SNORM , plain, 1, 1, sn16, sn16, , , xy01, rgb +PIPE_FORMAT_R16G16B16_SNORM , plain, 1, 1, sn16, sn16, sn16, , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_SNORM , plain, 1, 1, sn16, sn16, sn16, sn16, xyzw, rgb +PIPE_FORMAT_R16_SSCALED , plain, 1, 1, s16 , , , , x001, rgb +PIPE_FORMAT_R16G16_SSCALED , plain, 1, 1, s16 , s16 , , , xy01, rgb +PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, rgb +PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb +PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb +PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb +PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb +PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , xyzw, rgb +PIPE_FORMAT_R8_SNORM , plain, 1, 1, sn8 , , , , x001, rgb +PIPE_FORMAT_R8G8_SNORM , plain, 1, 1, sn8 , sn8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb +PIPE_FORMAT_R8_SSCALED , plain, 1, 1, s8 , , , , x001, rgb +PIPE_FORMAT_R8G8_SSCALED , plain, 1, 1, s8 , s8 , , , xy01, rgb +PIPE_FORMAT_R8G8B8_SSCALED , plain, 1, 1, s8 , s8 , s8 , , xyz1, rgb +PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb # Ambiguous formats # FIXME: They are used with different meanings in different places!!! -PIPE_FORMAT_R8G8B8_UNORM , arith , 1, 1, un8 , un8 , un8 , , zyx1, rgb -PIPE_FORMAT_R8G8B8A8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb +PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , zyx1, rgb +PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb # Unused formats # XXX: Couldn't find any state tracker using them!! -PIPE_FORMAT_B6G5R5_SNORM , arith , 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb -PIPE_FORMAT_R8G8B8X8_SNORM , arith , 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb -PIPE_FORMAT_R8G8B8X8_USCALED , arith , 1, 1, u8 , u8 , u8 , u8 , wzy1, rgb -PIPE_FORMAT_R8G8B8X8_SSCALED , arith , 1, 1, s8 , s8 , s8 , s8 , wzy1, rgb +PIPE_FORMAT_B6G5R5_SNORM , plain, 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , wzy1, rgb # XXX: This one is mentioned in mesa and r300, but not anywhere else. Not sure it is actually needed -PIPE_FORMAT_R8G8B8X8_UNORM , arith , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 7792aa0673..e8fa0022b5 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2009 Vmware, Inc. + * Copyright 2009-2010 Vmware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -39,42 +39,32 @@ extern "C" { /** - * Describe how to best pack/unpack pixels into/from the prescribed format. + * Describe how to pack/unpack pixels into/from the prescribed format. * - * These are used for automatic code generation of pixel packing and unpacking - * routines (in compile time, e.g., u_format_access.py, or in runtime, like - * llvmpipe does). - * - * Thumb rule is: if you're not code generating pixel packing/unpacking then - * these are irrelevant for you. - * - * Note that this can be deduced from other values in util_format_description - * structure. This is by design, to make code generation of pixel - * packing/unpacking/sampling routines simple and efficient. - * - * XXX: This should be renamed to something like util_format_pack. + * XXX: This could be renamed to something like util_format_pack, or broke down + * in flags inside util_format_block that said exactly what we want. */ enum util_format_layout { /** - * One or more components of mixed integer formats, arithmetically encoded - * in a word up to 32bits. + * Formats with util_format_block::width == util_format_block::height == 1 + * that can be described as an ordinary data structure. */ - UTIL_FORMAT_LAYOUT_ARITH = 1, + UTIL_FORMAT_LAYOUT_PLAIN = 0, /** - * One or more components, no mixed formats, each with equal power of two - * number of bytes. + * Formats with sub-sampled channels. + * + * This is for formats like YV12 where there is less than one sample per + * pixel. + * + * XXX: This could actually b */ - UTIL_FORMAT_LAYOUT_ARRAY = 2, + UTIL_FORMAT_LAYOUT_SUBSAMPLED = 3, /** - * XXX: Not used yet. These might go away and be replaced by a single entry, - * for formats where multiple pixels have to be - * read in order to determine a single pixel value (i.e., block.width > 1 - * || block.height > 1) + * An unspecified compression algorithm. */ - UTIL_FORMAT_LAYOUT_YUV = 3, - UTIL_FORMAT_LAYOUT_DXT = 4 + UTIL_FORMAT_LAYOUT_COMPRESSED = 4 }; @@ -131,7 +121,12 @@ struct util_format_description { enum pipe_format format; const char *name; + + /** + * Pixel block dimensions. + */ struct util_format_block block; + enum util_format_layout layout; /** @@ -140,7 +135,7 @@ struct util_format_description unsigned nr_channels:3; /** - * Whether all channels have the same number of whole bytes. + * Whether all channels have the same number of (whole) bytes. */ unsigned is_array:1; @@ -149,10 +144,27 @@ struct util_format_description */ unsigned is_mixed:1; + /** + * Input channel description. + * + * Only valid for UTIL_FORMAT_LAYOUT_PLAIN formats. + */ struct util_format_channel_description channel[4]; + /** + * Output channel swizzle. + * + * The order is either: + * - RGBA + * - YUV(A) + * - ZS + * depending on the colorspace. + */ unsigned char swizzle[4]; + /** + * Colorspace transformation. + */ enum util_format_colorspace colorspace; }; @@ -192,7 +204,7 @@ util_format_is_compressed(enum pipe_format format) return FALSE; } - return desc->layout == UTIL_FORMAT_LAYOUT_DXT ? TRUE : FALSE; + return desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED ? TRUE : FALSE; } static INLINE boolean @@ -266,14 +278,7 @@ util_format_get_blockwidth(enum pipe_format format) return 1; } - switch (desc->layout) { - case UTIL_FORMAT_LAYOUT_YUV: - return 2; - case UTIL_FORMAT_LAYOUT_DXT: - return 4; - default: - return 1; - } + return desc->block.width; } static INLINE uint @@ -286,12 +291,7 @@ util_format_get_blockheight(enum pipe_format format) return 1; } - switch (desc->layout) { - case UTIL_FORMAT_LAYOUT_DXT: - return 4; - default: - return 1; - } + return desc->block.height; } static INLINE unsigned @@ -386,30 +386,14 @@ util_format_has_alpha(enum pipe_format format) return FALSE; } - switch (desc->layout) { - case UTIL_FORMAT_LAYOUT_ARITH: - case UTIL_FORMAT_LAYOUT_ARRAY: - /* FIXME: pf_get_component_bits( PIPE_FORMAT_A8L8_UNORM, PIPE_FORMAT_COMP_A ) should not return 0 right? */ - if (format == PIPE_FORMAT_A8_UNORM || - format == PIPE_FORMAT_A8L8_UNORM || - format == PIPE_FORMAT_A8L8_SRGB) { - return TRUE; - } - return util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) != 0; - case UTIL_FORMAT_LAYOUT_YUV: + switch (desc->colorspace) { + case UTIL_FORMAT_COLORSPACE_RGB: + case UTIL_FORMAT_COLORSPACE_SRGB: + return desc->swizzle[3] != UTIL_FORMAT_SWIZZLE_1; + case UTIL_FORMAT_COLORSPACE_YUV: + return FALSE; + case UTIL_FORMAT_COLORSPACE_ZS: return FALSE; - case UTIL_FORMAT_LAYOUT_DXT: - switch (format) { - case PIPE_FORMAT_DXT1_RGBA: - case PIPE_FORMAT_DXT3_RGBA: - case PIPE_FORMAT_DXT5_RGBA: - case PIPE_FORMAT_DXT1_SRGBA: - case PIPE_FORMAT_DXT3_SRGBA: - case PIPE_FORMAT_DXT5_SRGBA: - return TRUE; - default: - return FALSE; - } default: assert(0); return FALSE; diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index fb85215d20..f7a92f62a8 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -52,7 +52,7 @@ def is_format_supported(format): if format.colorspace not in ('rgb', 'zs'): return False - if format.layout not in (ARITH, ARRAY): + if format.layout != PLAIN: return False for i in range(4): @@ -70,7 +70,7 @@ def is_format_supported(format): def native_type(format): '''Get the native appropriate for a format.''' - if format.layout in (ARITH, ARRAY): + if format.layout == PLAIN: if not format.is_array(): # For arithmetic pixel formats return the integer type that matches the whole pixel return 'uint%u_t' % format.block_size() @@ -299,7 +299,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): else: assert False - if format.layout in (ARITH, ARRAY): + if format.layout == PLAIN: if not format.is_array(): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; @@ -374,7 +374,7 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): inv_swizzle = compute_inverse_swizzle(format) - if format.layout in (ARITH, ARRAY): + if format.layout == PLAIN: if not format.is_array(): print ' %s pixel = 0;' % dst_native_type shift = 0; diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 248a26ea8c..983c3a90fc 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -37,8 +37,7 @@ VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) -ARITH = 'arith' -ARRAY = 'array' +PLAIN = 'plain' class Type: -- cgit v1.2.3 From e5a43ac594e7b4c072b90310f7193c341b015f6b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 16:10:06 +0000 Subject: gallivm: Update for UTIL_FORMAT_LAYOUT_xxx changes. --- src/gallium/auxiliary/gallivm/lp_bld_depth.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_format_aos.c | 6 +++--- src/gallium/auxiliary/gallivm/lp_bld_format_soa.c | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.c b/src/gallium/auxiliary/gallivm/lp_bld_depth.c index d438c0e63d..f08f8eb6d8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.c @@ -171,7 +171,7 @@ lp_build_depth_test(LLVMBuilderRef builder, unsigned padding_right; unsigned chan; - assert(format_desc->layout == UTIL_FORMAT_LAYOUT_ARITH); + assert(format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); assert(format_desc->channel[z_swizzle].type == UTIL_FORMAT_TYPE_UNSIGNED); assert(format_desc->channel[z_swizzle].size <= format_desc->block.bits); assert(format_desc->channel[z_swizzle].normalized); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c index dfa080b853..a07f7418f2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_aos.c @@ -70,7 +70,7 @@ lp_build_unpack_rgba_aos(LLVMBuilderRef builder, unsigned i; /* FIXME: Support more formats */ - assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH); + assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); assert(desc->block.width == 1); assert(desc->block.height == 1); assert(desc->block.bits <= 32); @@ -189,7 +189,7 @@ lp_build_unpack_rgba8_aos(LLVMBuilderRef builder, lp_build_context_init(&bld, builder, type); /* FIXME: Support more formats */ - assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH); + assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); assert(desc->block.width == 1); assert(desc->block.height == 1); assert(desc->block.bits <= 32); @@ -303,7 +303,7 @@ lp_build_pack_rgba_aos(LLVMBuilderRef builder, unsigned shift; unsigned i, j; - assert(desc->layout == UTIL_FORMAT_LAYOUT_ARITH); + assert(desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); assert(desc->block.width == 1); assert(desc->block.height == 1); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c index 64151d169d..abb27e4c32 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_format_soa.c @@ -92,9 +92,7 @@ lp_build_unpack_rgba_soa(LLVMBuilderRef builder, unsigned chan; /* FIXME: Support more formats */ - assert(format_desc->layout == UTIL_FORMAT_LAYOUT_ARITH || - (format_desc->layout == UTIL_FORMAT_LAYOUT_ARRAY && - format_desc->block.bits == format_desc->channel[0].size)); + assert(format_desc->layout == UTIL_FORMAT_LAYOUT_PLAIN); assert(format_desc->block.width == 1); assert(format_desc->block.height == 1); assert(format_desc->block.bits <= 32); -- cgit v1.2.3 From 83686b3f92f29208e35b971c118e179c14e120db Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 16:10:14 +0000 Subject: llvmpipe: Update for UTIL_FORMAT_LAYOUT_xxx changes. --- src/gallium/drivers/llvmpipe/lp_screen.c | 6 ++---- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 6 +++--- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 0e5750ce11..1950f14135 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -194,8 +194,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && - format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) + if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) return FALSE; if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && @@ -223,8 +222,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, format_desc->block.height != 1) return FALSE; - if(format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && - format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) + if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) return FALSE; if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 0b9631f871..a66a846f8e 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -76,7 +76,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): else: assert False - if format.layout in (ARITH, ARRAY): + if format.layout == PLAIN: if not format.is_array(): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; @@ -208,7 +208,7 @@ def emit_tile_pixel_write_code(format, src_type): print ' %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()) print ' for (x = 0; x < w; ++x) {' - if format.layout in (ARITH, ARRAY): + if format.layout == PLAIN: if not format.is_array(): print ' %s pixel = 0;' % dst_native_type shift = 0; @@ -246,7 +246,7 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print 'static void' print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type) print '{' - if format.layout in (ARITH, ARRAY) \ + if format.layout == PLAIN \ and format.colorspace == 'rgb' \ and format.block_size() <= 32 \ and not format.is_mixed() \ -- cgit v1.2.3 From f9f4f3df422334aee31f9041c374c72d0f97ba39 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 24 Feb 2010 16:11:08 +0000 Subject: r300: Update for UTIL_FORMAT_LAYOUT_xxx changes. --- src/gallium/drivers/r300/r300_state_inlines.h | 6 ++---- src/gallium/drivers/r300/r300_texture.c | 14 ++------------ 2 files changed, 4 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 0e1cb328d1..2f3a56e1fb 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -384,8 +384,7 @@ r300_translate_vertex_data_type(enum pipe_format format) { desc = util_format_description(format); - if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH && - desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) { + if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { debug_printf("r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); assert(0); @@ -458,8 +457,7 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { assert(format); - if (desc->layout != UTIL_FORMAT_LAYOUT_ARITH && - desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) { + if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) { debug_printf("r300: Bad format %s in %s:%d\n", util_format_name(format), __FUNCTION__, __LINE__); return 0; diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7b116b30e5..7c3b781c0b 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -70,19 +70,12 @@ static uint32_t r300_translate_texformat(enum pipe_format format) R300_TX_FORMAT_B_SHIFT, R300_TX_FORMAT_A_SHIFT }; - const uint32_t swizzle_arith[4] = { + const uint32_t swizzle[4] = { R300_TX_FORMAT_X, R300_TX_FORMAT_Y, R300_TX_FORMAT_Z, R300_TX_FORMAT_W }; - const uint32_t swizzle_array[4] = { - R300_TX_FORMAT_W, - R300_TX_FORMAT_Z, - R300_TX_FORMAT_Y, - R300_TX_FORMAT_X - }; - const uint32_t *swizzle; const uint32_t sign_bit[4] = { R300_TX_FORMAT_SIGNED_X, R300_TX_FORMAT_SIGNED_Y, @@ -128,9 +121,6 @@ static uint32_t r300_translate_texformat(enum pipe_format format) } /* Add swizzle. */ - swizzle = desc->layout == UTIL_FORMAT_LAYOUT_ARITH ? - swizzle_arith : swizzle_array; - for (i = 0; i < 4; i++) { switch (desc->swizzle[i]) { case UTIL_FORMAT_SWIZZLE_X: @@ -158,7 +148,7 @@ static uint32_t r300_translate_texformat(enum pipe_format format) } /* Compressed formats. */ - if (desc->layout == UTIL_FORMAT_LAYOUT_DXT) { + if (desc->layout == UTIL_FORMAT_LAYOUT_COMPRESSED) { switch (format) { case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: -- cgit v1.2.3 From ba929471989f9670fba80fc786ed9b4e7f8185c8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 10:43:30 -0700 Subject: llvmpipe: vertex shader textures not supported yet --- src/gallium/drivers/llvmpipe/lp_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 1950f14135..89869faeb9 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -83,7 +83,7 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: return PIPE_MAX_SAMPLERS; case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - return PIPE_MAX_VERTEX_SAMPLERS; + return 0; case PIPE_CAP_MAX_COMBINED_SAMPLERS: return PIPE_MAX_SAMPLERS + PIPE_MAX_VERTEX_SAMPLERS; case PIPE_CAP_NPOT_TEXTURES: -- cgit v1.2.3 From f8978f186ec38b3f9021d0c96fed11d10157face Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 10:47:58 -0700 Subject: llvmpipe: SRGB textures not supported yet --- src/gallium/drivers/llvmpipe/lp_screen.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 89869faeb9..f84ede675b 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -226,7 +226,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, return FALSE; if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && - format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB && format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) return FALSE; -- cgit v1.2.3 From 9f6990120ace5725e16ee2dd9a59da76fe1041cc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 08:59:49 -0700 Subject: gallium: comment/document usage flags --- src/gallium/include/pipe/p_screen.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 48625bf312..e4a9222809 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -121,7 +121,9 @@ struct pipe_screen { void (*texture_destroy)(struct pipe_texture *pt); - /** Get a surface which is a "view" into a texture */ + /** Get a 2D surface which is a "view" into a texture + * \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags + */ struct pipe_surface *(*get_tex_surface)(struct pipe_screen *, struct pipe_texture *texture, unsigned face, unsigned level, -- cgit v1.2.3 From ccd78fed880c4c8f1fccf1d10fc46442fa146359 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 12:03:51 -0700 Subject: gallium: remove $(DEFINES) from cc/c++ command lines The $(DEFINES) is already in $(CFLAG)S and (CXXFLAGS). This prevents all the -D args appearing twice in the compilation commands. --- src/gallium/Makefile.template | 8 ++++---- src/gallium/winsys/xlib/Makefile | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 5d9d2db786..3274c8e0c3 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -54,16 +54,16 @@ install: ##### RULES ##### %.s: %.c - $(CC) -S $(INCLUDES) $(DEFINES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CC) -S $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ %.o: %.c - $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ %.o: %.cpp - $(CXX) -c $(INCLUDES) $(DEFINES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@ %.o: %.S - $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@ sinclude depend diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 9482e8f9b1..824c666ae3 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -50,10 +50,10 @@ LIBS = \ .SUFFIXES : .cpp .c.o: - $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ .cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(DEFINES) $(CXXFLAGS) $< -o $@ + $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ -- cgit v1.2.3 From ab71a5e4c918eee19b518603a2db11d2793b2c91 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 13:23:10 -0700 Subject: llvmpipe: added some assertions --- src/gallium/drivers/llvmpipe/lp_rast_tri.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c b/src/gallium/drivers/llvmpipe/lp_rast_tri.c index 0334705ef7..bbc95c399a 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c @@ -130,6 +130,9 @@ do_block_4( struct lp_rasterizer_task *rast_task, int c2, int c3 ) { + assert(x >= 0); + assert(y >= 0); + lp_rast_shade_quads(rast_task->rast, rast_task->thread_index, &tri->inputs, @@ -155,6 +158,8 @@ do_block_16( struct lp_rasterizer_task *rast_task, int c[3]; int i, j; + assert(x >= 0); + assert(y >= 0); assert(x % 16 == 0); assert(y % 16 == 0); -- cgit v1.2.3 From 1c9db3c57f1538e21b839df0989b958be3465a36 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 13:30:57 -0700 Subject: llvmpipe: pass fewer parameters to rasterization functions --- src/gallium/drivers/llvmpipe/lp_rast.c | 5 ++--- src/gallium/drivers/llvmpipe/lp_rast_priv.h | 11 +++++------ src/gallium/drivers/llvmpipe/lp_rast_tri.c | 8 ++------ 3 files changed, 9 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index bbd63aec2b..159ef0d55d 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -396,14 +396,13 @@ void lp_rast_shade_tile( struct lp_rasterizer *rast, * Compute shading for a 4x4 block of pixels. * This is a bin command called during bin processing. */ -void lp_rast_shade_quads( struct lp_rasterizer *rast, - unsigned thread_index, +void lp_rast_shade_quads( struct lp_rasterizer_task *task, const struct lp_rast_shader_inputs *inputs, unsigned x, unsigned y, int32_t c1, int32_t c2, int32_t c3) { - struct lp_rasterizer_task *task = &rast->tasks[thread_index]; const struct lp_rast_state *state = task->current_state; + struct lp_rasterizer *rast = task->rast; struct lp_rast_tile *tile = &task->tile; uint8_t *color[PIPE_MAX_COLOR_BUFS]; void *depth; diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 5c5497e092..382e169c1c 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -121,8 +121,7 @@ struct lp_rasterizer }; -void lp_rast_shade_quads( struct lp_rasterizer *rast, - unsigned thread_index, +void lp_rast_shade_quads( struct lp_rasterizer_task *task, const struct lp_rast_shader_inputs *inputs, unsigned x, unsigned y, int32_t c1, int32_t c2, int32_t c3); @@ -159,13 +158,13 @@ lp_rast_depth_pointer( struct lp_rasterizer *rast, * \param x, y location of 4x4 block in window coords */ static INLINE void -lp_rast_shade_quads_all( struct lp_rasterizer *rast, - unsigned thread_index, +lp_rast_shade_quads_all( struct lp_rasterizer_task *task, const struct lp_rast_shader_inputs *inputs, unsigned x, unsigned y ) { - const struct lp_rast_state *state = rast->tasks[thread_index].current_state; - struct lp_rast_tile *tile = &rast->tasks[thread_index].tile; + struct lp_rasterizer *rast = task->rast; + const struct lp_rast_state *state = task->current_state; + struct lp_rast_tile *tile = &task->tile; const unsigned ix = x % TILE_SIZE, iy = y % TILE_SIZE; uint8_t *color[PIPE_MAX_COLOR_BUFS]; void *depth; diff --git a/src/gallium/drivers/llvmpipe/lp_rast_tri.c b/src/gallium/drivers/llvmpipe/lp_rast_tri.c index bbc95c399a..90325aedb8 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_rast_tri.c @@ -93,10 +93,7 @@ block_full_4( struct lp_rasterizer_task *rast_task, const struct lp_rast_triangle *tri, int x, int y ) { - lp_rast_shade_quads_all(rast_task->rast, - rast_task->thread_index, - &tri->inputs, - x, y); + lp_rast_shade_quads_all(rast_task, &tri->inputs, x, y); } @@ -133,8 +130,7 @@ do_block_4( struct lp_rasterizer_task *rast_task, assert(x >= 0); assert(y >= 0); - lp_rast_shade_quads(rast_task->rast, - rast_task->thread_index, + lp_rast_shade_quads(rast_task, &tri->inputs, x, y, -c1, -c2, -c3); -- cgit v1.2.3 From 5046f2c1950c44129f6098a7aae14dd50ee1f8a4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 13:53:30 -0700 Subject: llvmpipe: more lp_rasterizer_task parameter passing --- src/gallium/drivers/llvmpipe/lp_rast.c | 119 +++++++++++++---------------- src/gallium/drivers/llvmpipe/lp_rast.h | 24 +++--- src/gallium/drivers/llvmpipe/lp_rast_tri.c | 57 ++++++-------- src/gallium/drivers/llvmpipe/lp_scene.h | 3 +- 4 files changed, 89 insertions(+), 114 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 159ef0d55d..07817efd74 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -156,14 +156,13 @@ lp_rast_end( struct lp_rasterizer *rast ) * \param y window Y position of the tile, in pixels */ static void -lp_rast_start_tile( struct lp_rasterizer *rast, - unsigned thread_index, - unsigned x, unsigned y ) +lp_rast_start_tile(struct lp_rasterizer_task *task, + unsigned x, unsigned y) { LP_DBG(DEBUG_RAST, "%s %d,%d\n", __FUNCTION__, x, y); - rast->tasks[thread_index].x = x; - rast->tasks[thread_index].y = y; + task->x = x; + task->y = y; } @@ -171,12 +170,13 @@ lp_rast_start_tile( struct lp_rasterizer *rast, * Clear the rasterizer's current color tile. * This is a bin command called during bin processing. */ -void lp_rast_clear_color( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg ) +void +lp_rast_clear_color(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { + struct lp_rasterizer *rast = task->rast; const uint8_t *clear_color = arg.clear_color; - uint8_t **color_tile = rast->tasks[thread_index].tile.color; + uint8_t **color_tile = task->tile.color; unsigned i; LP_DBG(DEBUG_RAST, "%s 0x%x,0x%x,0x%x,0x%x\n", __FUNCTION__, @@ -225,11 +225,11 @@ void lp_rast_clear_color( struct lp_rasterizer *rast, * Clear the rasterizer's current z/stencil tile. * This is a bin command called during bin processing. */ -void lp_rast_clear_zstencil( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg) +void +lp_rast_clear_zstencil(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { - struct lp_rasterizer_task *task = &rast->tasks[thread_index]; + struct lp_rasterizer *rast = task->rast; const unsigned tile_x = task->x; const unsigned tile_y = task->y; const unsigned height = TILE_SIZE/TILE_VECTOR_HEIGHT; @@ -288,13 +288,12 @@ void lp_rast_clear_zstencil( struct lp_rasterizer *rast, * Load tile color from the framebuffer surface. * This is a bin command called during bin processing. */ -void lp_rast_load_color( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg) +void +lp_rast_load_color(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { - struct lp_rasterizer_task *task = &rast->tasks[thread_index]; - const unsigned x = task->x; - const unsigned y = task->y; + struct lp_rasterizer *rast = task->rast; + const unsigned x = task->x, y = task->y; unsigned i; LP_DBG(DEBUG_RAST, "%s at %u, %u\n", __FUNCTION__, x, y); @@ -304,10 +303,7 @@ void lp_rast_load_color( struct lp_rasterizer *rast, int w = TILE_SIZE; int h = TILE_SIZE; - if (x >= transfer->width) - continue; - - if (y >= transfer->height) + if (x >= transfer->width || y >= transfer->height) continue; assert(w >= 0); @@ -327,16 +323,16 @@ void lp_rast_load_color( struct lp_rasterizer *rast, } -void lp_rast_set_state( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg ) +void +lp_rast_set_state(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { const struct lp_rast_state *state = arg.set_state; LP_DBG(DEBUG_RAST, "%s %p\n", __FUNCTION__, (void *) state); /* just set the current state pointer for this rasterizer */ - rast->tasks[thread_index].current_state = state; + task->current_state = state; } @@ -346,16 +342,15 @@ void lp_rast_set_state( struct lp_rasterizer *rast, * completely contained inside a triangle. * This is a bin command called during bin processing. */ -void lp_rast_shade_tile( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg ) +void +lp_rast_shade_tile(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { - struct lp_rasterizer_task *task = &rast->tasks[thread_index]; + struct lp_rasterizer *rast = task->rast; const struct lp_rast_state *state = task->current_state; struct lp_rast_tile *tile = &task->tile; const struct lp_rast_shader_inputs *inputs = arg.shade_tile; - const unsigned tile_x = task->x; - const unsigned tile_y = task->y; + const unsigned tile_x = task->x, tile_y = task->y; unsigned x, y; LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); @@ -514,12 +509,11 @@ outline_subtiles(uint8_t *tile) /** * Write the rasterizer's color tile to the framebuffer. */ -static void lp_rast_store_color( struct lp_rasterizer *rast, - unsigned thread_index) +static void +lp_rast_store_color(struct lp_rasterizer_task *task) { - struct lp_rasterizer_task *task = &rast->tasks[thread_index]; - const unsigned x = task->x; - const unsigned y = task->y; + struct lp_rasterizer *rast = task->rast; + const unsigned x = task->x, y = task->y; unsigned i; for (i = 0; i < rast->state.fb.nr_cbufs; i++) { @@ -534,7 +528,7 @@ static void lp_rast_store_color( struct lp_rasterizer *rast, continue; LP_DBG(DEBUG_RAST, "%s [%u] %d,%d %dx%d\n", __FUNCTION__, - thread_index, x, y, w, h); + task->thread_index, x, y, w, h); if (LP_DEBUG & DEBUG_SHOW_SUBTILES) outline_subtiles(task->tile.color[i]); @@ -557,13 +551,14 @@ static void lp_rast_store_color( struct lp_rasterizer *rast, * Write the rasterizer's tiles to the framebuffer. */ static void -lp_rast_end_tile( struct lp_rasterizer *rast, - unsigned thread_index ) +lp_rast_end_tile(struct lp_rasterizer_task *task) { + struct lp_rasterizer *rast = task->rast; + LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); if (rast->state.write_color) - lp_rast_store_color(rast, thread_index); + lp_rast_store_color(task); } @@ -571,9 +566,9 @@ lp_rast_end_tile( struct lp_rasterizer *rast, * Signal on a fence. This is called during bin execution/rasterization. * Called per thread. */ -void lp_rast_fence( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg ) +void +lp_rast_fence(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { struct lp_fence *fence = arg.fence; @@ -617,25 +612,24 @@ release_scene( struct lp_rasterizer *rast, * Called per thread. */ static void -rasterize_bin( struct lp_rasterizer *rast, - unsigned thread_index, - const struct cmd_bin *bin, - int x, int y) +rasterize_bin(struct lp_rasterizer_task *task, + const struct cmd_bin *bin, + int x, int y) { const struct cmd_block_list *commands = &bin->commands; struct cmd_block *block; unsigned k; - lp_rast_start_tile( rast, thread_index, x, y ); + lp_rast_start_tile( task, x, y ); /* simply execute each of the commands in the block list */ for (block = commands->head; block; block = block->next) { for (k = 0; k < block->count; k++) { - block->cmd[k]( rast, thread_index, block->arg[k] ); + block->cmd[k]( task, block->arg[k] ); } } - lp_rast_end_tile( rast, thread_index ); + lp_rast_end_tile( task ); } @@ -719,10 +713,9 @@ is_empty_bin( const struct cmd_bin *bin ) * Called per thread. */ static void -rasterize_scene( struct lp_rasterizer *rast, - unsigned thread_index, +rasterize_scene(struct lp_rasterizer_task *task, struct lp_scene *scene, - bool write_depth ) + bool write_depth) { /* loop over scene bins, rasterize each */ #if 0 @@ -730,9 +723,8 @@ rasterize_scene( struct lp_rasterizer *rast, unsigned i, j; for (i = 0; i < scene->tiles_x; i++) { for (j = 0; j < scene->tiles_y; j++) { - struct cmd_bin *bin = lp_get_bin(scene, i, j); - rasterize_bin( rast, thread_index, - bin, i * TILE_SIZE, j * TILE_SIZE ); + struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); + rasterize_bin(task, bin, i * TILE_SIZE, j * TILE_SIZE); } } } @@ -744,7 +736,7 @@ rasterize_scene( struct lp_rasterizer *rast, assert(scene); while ((bin = lp_scene_bin_iter_next(scene, &x, &y))) { if (!is_empty_bin( bin )) - rasterize_bin( rast, thread_index, bin, x * TILE_SIZE, y * TILE_SIZE); + rasterize_bin(task, bin, x * TILE_SIZE, y * TILE_SIZE); } } #endif @@ -788,7 +780,7 @@ lp_rasterize_scene( struct lp_rasterizer *rast, fb->zsbuf != NULL && write_depth ); lp_scene_bin_iter_begin( scene ); - rasterize_scene( rast, 0, scene, write_depth ); + rasterize_scene( &rast->tasks[0], scene, write_depth ); release_scene( rast, scene ); @@ -862,10 +854,9 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data ) /* do work */ if (debug) debug_printf("thread %d doing work\n", task->thread_index); - rasterize_scene(rast, - task->thread_index, - rast->curr_scene, - rast->curr_scene->write_depth); + rasterize_scene(task, + rast->curr_scene, + rast->curr_scene->write_depth); /* wait for all threads to finish with this scene */ pipe_barrier_wait( &rast->barrier ); diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 875f18e0c0..1ed2700191 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -53,6 +53,9 @@ struct pipe_screen; #define FIXED_ONE (1<inputs, x, y); + lp_rast_shade_quads_all(task, &tri->inputs, x, y); } @@ -101,16 +101,16 @@ block_full_4( struct lp_rasterizer_task *rast_task, * Shade all pixels in a 16x16 block. */ static void -block_full_16( struct lp_rasterizer_task *rast_task, - const struct lp_rast_triangle *tri, - int x, int y ) +block_full_16(struct lp_rasterizer_task *task, + const struct lp_rast_triangle *tri, + int x, int y) { unsigned ix, iy; assert(x % 16 == 0); assert(y % 16 == 0); for (iy = 0; iy < 16; iy += 4) for (ix = 0; ix < 16; ix += 4) - block_full_4(rast_task, tri, x + ix, y + iy); + block_full_4(task, tri, x + ix, y + iy); } @@ -120,20 +120,15 @@ block_full_16( struct lp_rasterizer_task *rast_task, * will be done as part of the fragment shader. */ static void -do_block_4( struct lp_rasterizer_task *rast_task, - const struct lp_rast_triangle *tri, - int x, int y, - int c1, - int c2, - int c3 ) +do_block_4(struct lp_rasterizer_task *task, + const struct lp_rast_triangle *tri, + int x, int y, + int c1, int c2, int c3) { assert(x >= 0); assert(y >= 0); - lp_rast_shade_quads(rast_task, - &tri->inputs, - x, y, - -c1, -c2, -c3); + lp_rast_shade_quads(task, &tri->inputs, x, y, -c1, -c2, -c3); } @@ -142,12 +137,10 @@ do_block_4( struct lp_rasterizer_task *rast_task, * of the triangle's bounds. */ static void -do_block_16( struct lp_rasterizer_task *rast_task, - const struct lp_rast_triangle *tri, - int x, int y, - int c0, - int c1, - int c2 ) +do_block_16(struct lp_rasterizer_task *task, + const struct lp_rast_triangle *tri, + int x, int y, + int c0, int c1, int c2) { unsigned mask = 0; int eo[3]; @@ -194,7 +187,7 @@ do_block_16( struct lp_rasterizer_task *rast_task, * the triangle. It's a little faster to do it in the jit code. */ LP_COUNT(nr_non_empty_4); - do_block_4(rast_task, tri, px, py, cx1, cx2, cx3); + do_block_4(task, tri, px, py, cx1, cx2, cx3); } } @@ -204,15 +197,11 @@ do_block_16( struct lp_rasterizer_task *rast_task, * for this triangle. */ void -lp_rast_triangle( struct lp_rasterizer *rast, - unsigned thread_index, - const union lp_rast_cmd_arg arg ) +lp_rast_triangle(struct lp_rasterizer_task *task, + const union lp_rast_cmd_arg arg) { - struct lp_rasterizer_task *rast_task = &rast->tasks[thread_index]; const struct lp_rast_triangle *tri = arg.triangle; - - int x = rast_task->x; - int y = rast_task->y; + const int x = task->x, y = task->y; int ei[3], eo[3], c[3]; unsigned outmask, inmask, partial_mask; unsigned i, j; @@ -273,7 +262,7 @@ lp_rast_triangle( struct lp_rasterizer *rast, partial_mask &= ~(1 << i); LP_COUNT(nr_partially_covered_16); - do_block_16(rast_task, tri, px, py, cx1, cx2, cx3); + do_block_16(task, tri, px, py, cx1, cx2, cx3); } /* Iterate over fulls: @@ -286,6 +275,6 @@ lp_rast_triangle( struct lp_rasterizer *rast, inmask &= ~(1 << i); LP_COUNT(nr_fully_covered_16); - block_full_16(rast_task, tri, px, py); + block_full_16(task, tri, px, py); } } diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index fb478cc2eb..8d725cd437 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -56,8 +56,7 @@ /* switch to a non-pointer value for this: */ -typedef void (*lp_rast_cmd)( struct lp_rasterizer *, - unsigned thread_index, +typedef void (*lp_rast_cmd)( struct lp_rasterizer_task *, const union lp_rast_cmd_arg ); struct cmd_block { -- cgit v1.2.3 From 1332ee5487cc03955978162076ae8f37e70f06ee Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 15:09:57 -0700 Subject: gallium: remove extra -I paths from Makefile.template --- src/gallium/Makefile.template | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 3274c8e0c3..713e192a4e 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -21,9 +21,6 @@ INCLUDES = \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -I$(TOP)/src/gallium/drivers \ - -I$(GALLIUM)/src/gallium/include \ - -I$(GALLIUM)/src/gallium/auxiliary \ - -I$(GALLIUM)/src/gallium/drivers \ $(LIBRARY_INCLUDES) -- cgit v1.2.3 From 778276a4dd30d97ca9b573b090a28b22d17a6801 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 15:49:11 -0700 Subject: r300g: remove invalid .PHONY line The $(COMPILER_ARCHIVE) target is not a phony target. This solves the unconditional re-making of libr300.a --- src/gallium/drivers/r300/Makefile | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index afddcb161f..1f69daec81 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -32,7 +32,5 @@ EXTRA_OBJECTS = \ include ../../Makefile.template -.PHONY : $(COMPILER_ARCHIVE) - $(COMPILER_ARCHIVE): $(MAKE) -C $(TOP)/src/mesa/drivers/dri/r300/compiler -- cgit v1.2.3 From bc04ae21c10bedcc75d3483784d3eaf7bf090f55 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 24 Feb 2010 17:30:43 -0700 Subject: llvmpipe: clean up rasterization threads upon context destruction Fixes glean hang, bug 26536. --- src/gallium/drivers/llvmpipe/lp_rast.c | 17 +++++++++++++++++ src/gallium/drivers/llvmpipe/lp_rast_priv.h | 1 + 2 files changed, 18 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 07817efd74..82c006d78b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -826,6 +826,9 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data ) debug_printf("thread %d waiting for work\n", task->thread_index); pipe_semaphore_wait(&task->work_ready); + if (rast->exit_flag) + break; + if (task->thread_index == 0) { /* thread[0]: * - get next scene to rasterize @@ -961,6 +964,20 @@ void lp_rast_destroy( struct lp_rasterizer *rast ) align_free(rast->tasks[i].tile.color[cbuf]); } + /* Set exit_flag and signal each thread's work_ready semaphore. + * Each thread will be woken up, notice that the exit_flag is set and + * break out of its main loop. The thread will then exit. + */ + rast->exit_flag = TRUE; + for (i = 0; i < rast->num_threads; i++) { + pipe_semaphore_signal(&rast->tasks[i].work_ready); + } + + for (i = 0; i < rast->num_threads; i++) { + pipe_semaphore_destroy(&rast->tasks[i].work_ready); + pipe_semaphore_destroy(&rast->tasks[i].work_done); + } + /* for synchronizing rasterization threads */ pipe_barrier_destroy( &rast->barrier ); diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index 382e169c1c..abc5a9ad89 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -84,6 +84,7 @@ struct lp_rasterizer { boolean clipped_tile; boolean check_for_clipped_tiles; + boolean exit_flag; /* Framebuffer stuff */ -- cgit v1.2.3 From e6632b4bf7cba5fe8a77d54635a3b617fa67185f Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 22 Feb 2010 15:11:29 +0100 Subject: r300g: prevent CS overflow when emitting the draw packets Signed-off-by: Corbin Simpson --- src/gallium/drivers/r300/r300_emit.c | 29 +++++++++++------------ src/gallium/drivers/r300/r300_emit.h | 2 ++ src/gallium/drivers/r300/r300_render.c | 42 ++++++++++++++++++++++++++++++---- 3 files changed, 55 insertions(+), 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index f7dcd8dc52..2d8801c08a 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1076,16 +1076,10 @@ validate: } } -/* Emit all dirty state. */ -void r300_emit_dirty_state(struct r300_context* r300) +unsigned r300_get_num_dirty_dwords(struct r300_context *r300) { - struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_atom* atom; - unsigned i, dwords = 1024; - int dirty_tex = 0; - - /* Check the required number of dwords against the space remaining in the - * current CS object. If we need more, then flush. */ + unsigned dwords = 0; foreach(atom, &r300->atom_list) { if (atom->dirty || atom->always_dirty) { @@ -1093,12 +1087,19 @@ void r300_emit_dirty_state(struct r300_context* r300) } } - /* Make sure we have at least 2*1024 spare dwords. */ - /* XXX It would be nice to know the number of dwords we really need to - * XXX emit. */ - while (!r300->winsys->check_cs(r300->winsys, dwords)) { - r300->context.flush(&r300->context, 0, NULL); - } + /* XXX This is the compensation for the non-atomized states. */ + dwords += 2048; + + return dwords; +} + +/* Emit all dirty state. */ +void r300_emit_dirty_state(struct r300_context* r300) +{ + struct r300_screen* r300screen = r300_screen(r300->context.screen); + struct r300_atom* atom; + unsigned i; + int dirty_tex = 0; if (r300->dirty_state & R300_NEW_QUERY) { r300_emit_query_start(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 6b96d9b57c..ff709a0595 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -90,6 +90,8 @@ void r300_emit_ztop_state(struct r300_context* r300, void* state); void r300_flush_textures(struct r300_context* r300); +unsigned r300_get_num_dirty_dwords(struct r300_context *r300); + /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 648d884654..ec72d6c3b5 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -118,6 +118,18 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, return color_control; } +/* Check if the requested number of dwords is available in the CS and + * if not, flush. Return TRUE if the flush occured. */ +static boolean r300_reserve_cs_space(struct r300_context *r300, + unsigned dwords) +{ + while (!r300->winsys->check_cs(r300->winsys, dwords)) { + r300->context.flush(&r300->context, 0, NULL); + return TRUE; + } + return FALSE; +} + static boolean immd_is_good_idea(struct r300_context *r300, unsigned count) { @@ -132,7 +144,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, struct pipe_vertex_element* velem; struct pipe_vertex_buffer* vbuf; unsigned vertex_element_count = r300->vertex_element_count; - unsigned i, v, vbi, dw, elem_offset; + unsigned i, v, vbi, dw, elem_offset, dwords; /* Size of the vertex, in dwords. */ unsigned vertex_size = 0; @@ -171,9 +183,12 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, } } + dwords = 10 + count * vertex_size; + + r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); r300_emit_dirty_state(r300); - BEGIN_CS(10 + count * vertex_size); + BEGIN_CS(dwords); OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_size); @@ -400,8 +415,9 @@ void r300_draw_range_elements(struct pipe_context* pipe, goto cleanup; } + /* 128 dwords for emit_aos and emit_draw_elements */ + r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); r300_emit_dirty_state(r300); - r300_emit_aos(r300, 0); if (alt_num_verts || count <= 65535) { @@ -415,6 +431,12 @@ void r300_draw_range_elements(struct pipe_context* pipe, start += short_count; count -= short_count; + + /* 16 spare dwords are enough for emit_draw_elements. */ + if (count && r300_reserve_cs_space(r300, 16)) { + r300_emit_dirty_state(r300); + r300_emit_aos(r300, 0); + } } while (count); } @@ -461,6 +483,9 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, return; } + /* Make sure there are at least 128 spare dwords in the command buffer. + * (most of it being consumed by emit_aos) */ + r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); r300_emit_dirty_state(r300); if (alt_num_verts || count <= 65535) { @@ -474,6 +499,12 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, start += short_count; count -= short_count; + + /* Again, we emit both AOS and draw_arrays so there should be + * at least 128 spare dwords. */ + if (count && r300_reserve_cs_space(r300, 128)) { + r300_emit_dirty_state(r300); + } } while (count); } } @@ -690,6 +721,7 @@ static void r300_render_draw_arrays(struct vbuf_render* render, CS_LOCALS(r300); + r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 2); r300_emit_dirty_state(r300); DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); @@ -708,12 +740,14 @@ static void r300_render_draw(struct vbuf_render* render, struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; int i; + unsigned dwords = 2 + (count+1)/2; CS_LOCALS(r300); + r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); r300_emit_dirty_state(r300); - BEGIN_CS(2 + (count+1)/2); + BEGIN_CS(dwords); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | r300render->hwprim); -- cgit v1.2.3 From f05d4526e31bfcf238d826582317312bf0d8572d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 24 Feb 2010 19:53:47 -0800 Subject: r300g: Move CALLOCs to correct place. --- src/gallium/drivers/r300/r300_context.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index f631b4ed27..925873ad53 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -128,7 +128,14 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(vertex_format, 26); /* Some non-CSO atoms need explicit space to store the state locally. */ + r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); + r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state); r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state); + r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); + r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); + r300->vertex_format_state.state = CALLOC_STRUCT(r300_vertex_info); + r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); + r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); } struct pipe_context* r300_create_context(struct pipe_screen* screen, @@ -178,14 +185,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_setup_atoms(r300); - r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); - r300->clip_state.state = CALLOC_STRUCT(pipe_clip_state); - r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); - r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); - r300->vertex_format_state.state = CALLOC_STRUCT(r300_vertex_info); - r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); - r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); - /* Open up the OQ BO. */ r300->oqbo = screen->buffer_create(screen, 4096, PIPE_BUFFER_USAGE_VERTEX, 4096); -- cgit v1.2.3 From 686f69bd13fd2aebaa40edeb7e25e4a49b12a2bd Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 24 Feb 2010 20:02:59 -0800 Subject: r300g: Atomize vertex shader. --- src/gallium/drivers/r300/r300_blit.c | 2 +- src/gallium/drivers/r300/r300_context.c | 1 + src/gallium/drivers/r300/r300_context.h | 3 +- src/gallium/drivers/r300/r300_emit.c | 62 ++++++++++++--------------- src/gallium/drivers/r300/r300_emit.h | 3 +- src/gallium/drivers/r300/r300_state.c | 18 ++++---- src/gallium/drivers/r300/r300_state_derived.c | 25 ++++++----- src/gallium/drivers/r300/r300_vs.c | 4 +- 8 files changed, 58 insertions(+), 60 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index eb9b0beeb5..187b4bf384 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -33,7 +33,7 @@ static void r300_blitter_save_states(struct r300_context* r300) util_blitter_save_stencil_ref(r300->blitter, &(r300->stencil_ref)); util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state); util_blitter_save_fragment_shader(r300->blitter, r300->fs); - util_blitter_save_vertex_shader(r300->blitter, r300->vs); + util_blitter_save_vertex_shader(r300->blitter, r300->vs_state.state); } /* Clear currently bound buffers. */ diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 925873ad53..47883589a7 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -126,6 +126,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(viewport, 9); R300_INIT_ATOM(rs_block, 21); R300_INIT_ATOM(vertex_format, 26); + R300_INIT_ATOM(vs, 1031); /* Some non-CSO atoms need explicit space to store the state locally. */ r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 443af4ec2e..3d4f6524e5 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -155,7 +155,6 @@ struct r300_ztop_state { #define R300_ANY_NEW_SAMPLERS 0x0001fe00 #define R300_NEW_TEXTURE 0x00040000 #define R300_ANY_NEW_TEXTURES 0x03fc0000 -#define R300_NEW_VERTEX_SHADER 0x08000000 #define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 #define R300_NEW_QUERY 0x40000000 #define R300_NEW_KITCHEN_SINK 0x7fffffff @@ -315,7 +314,7 @@ struct r300_context { struct r300_texture* textures[8]; int texture_count; /* Vertex shader. */ - struct r300_vertex_shader* vs; + struct r300_atom vs_state; /* Viewport state. */ struct r300_atom viewport_state; /* ZTOP state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 2d8801c08a..3037a38989 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -843,21 +843,31 @@ void r300_emit_vertex_format_state(struct r300_context* r300, void* state) END_CS; } +static void r300_flush_pvs(struct r300_context* r300) +{ + CS_LOCALS(r300); + + BEGIN_CS(2); + OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); + END_CS; +} -void r300_emit_vertex_program_code(struct r300_context* r300, - struct r300_vertex_program_code* code) +void r300_emit_vs_state(struct r300_context* r300, void* state) { - int i; + struct r300_vertex_shader* vs = (struct r300_vertex_shader*)state; + struct r300_vertex_program_code* code = &vs->code; struct r300_screen* r300screen = r300_screen(r300->context.screen); unsigned instruction_count = code->length / 4; + unsigned i; + + unsigned vtx_mem_size = r300screen->caps->is_r500 ? 128 : 72; + unsigned input_count = MAX2(util_bitcount(code->InputsRead), 1); + unsigned output_count = MAX2(util_bitcount(code->OutputsWritten), 1); + unsigned temp_count = MAX2(code->num_temporaries, 1); - int vtx_mem_size = r300screen->caps->is_r500 ? 128 : 72; - int input_count = MAX2(util_bitcount(code->InputsRead), 1); - int output_count = MAX2(util_bitcount(code->OutputsWritten), 1); - int temp_count = MAX2(code->num_temporaries, 1); - int pvs_num_slots = MIN3(vtx_mem_size / input_count, - vtx_mem_size / output_count, 10); - int pvs_num_controllers = MIN2(vtx_mem_size / temp_count, 6); + unsigned pvs_num_slots = MIN3(vtx_mem_size / input_count, + vtx_mem_size / output_count, 10); + unsigned pvs_num_controllers = MIN2(vtx_mem_size / temp_count, 6); CS_LOCALS(r300); @@ -867,6 +877,8 @@ void r300_emit_vertex_program_code(struct r300_context* r300, return; } + r300_flush_pvs(r300); + BEGIN_CS(9 + code->length); /* R300_VAP_PVS_CODE_CNTL_0 * R300_VAP_PVS_CONST_CNTL @@ -881,8 +893,9 @@ void r300_emit_vertex_program_code(struct r300_context* r300, OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, 0); OUT_CS_ONE_REG(R300_VAP_PVS_UPLOAD_DATA, code->length); - for (i = 0; i < code->length; i++) + for (i = 0; i < code->length; i++) { OUT_CS(code->body.d[i]); + } OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(pvs_num_slots) | R300_PVS_NUM_CNTLRS(pvs_num_controllers) | @@ -892,12 +905,6 @@ void r300_emit_vertex_program_code(struct r300_context* r300, END_CS; } -void r300_emit_vertex_shader(struct r300_context* r300, - struct r300_vertex_shader* vs) -{ - r300_emit_vertex_program_code(r300, &vs->code); -} - void r300_emit_vs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants) { @@ -994,15 +1001,6 @@ void r300_flush_textures(struct r300_context* r300) END_CS; } -static void r300_flush_pvs(struct r300_context* r300) -{ - CS_LOCALS(r300); - - BEGIN_CS(2); - OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); - END_CS; -} - void r300_emit_buffer_validate(struct r300_context *r300) { struct pipe_framebuffer_state* fb = @@ -1088,7 +1086,7 @@ unsigned r300_get_num_dirty_dwords(struct r300_context *r300) } /* XXX This is the compensation for the non-atomized states. */ - dwords += 2048; + dwords += 1024; return dwords; } @@ -1160,17 +1158,13 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_flush_textures(r300); } - if (r300->dirty_state & (R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS)) { + if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS || r300->vs_state.dirty) { r300_flush_pvs(r300); } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER) { - r300_emit_vertex_shader(r300, r300->vs); - r300->dirty_state &= ~R300_NEW_VERTEX_SHADER; - } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { - r300_emit_vs_constant_buffer(r300, &r300->vs->code.constants); + struct r300_vertex_shader* vs = r300->vs_state.state; + r300_emit_vs_constant_buffer(r300, &vs->code.constants); r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS; } diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index ff709a0595..f27cf5f32d 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -79,8 +79,7 @@ void r300_emit_vertex_program_code(struct r300_context* r300, void r300_emit_vs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants); -void r300_emit_vertex_shader(struct r300_context* r300, - struct r300_vertex_shader* vs); +void r300_emit_vs_state(struct r300_context* r300, void* state); void r300_emit_viewport_state(struct r300_context* r300, void* state); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 34bf81c193..0f14ccc53e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -658,9 +658,7 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) r300->fs = fs; r300_pick_fragment_shader(r300); - if (r300->vs && r300_vertex_shader_setup_wpos(r300)) { - r300->vertex_format_state.dirty = TRUE; - } + r300->vertex_format_state.dirty = TRUE; r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS; } @@ -1107,21 +1105,23 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; if (vs == NULL) { - r300->vs = NULL; + r300->vs_state.state = NULL; return; } else if (!vs->translated) { r300_translate_vertex_shader(r300, vs); } - r300->vs = vs; + r300->vs_state.state = vs; + r300->vs_state.size = vs->code.length + 11; + r300->vs_state.dirty = TRUE; + + r300->vertex_format_state.dirty = TRUE; + if (r300->fs) { r300_vertex_shader_setup_wpos(r300); } - r300->vertex_format_state.dirty = TRUE; - - r300->dirty_state |= - R300_NEW_VERTEX_SHADER | R300_NEW_VERTEX_SHADER_CONSTANTS; + r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; } else { draw_flush(r300->draw); draw_bind_vertex_shader(r300->draw, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 2cbce9210a..b33d44990a 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -42,7 +42,8 @@ static void r300_draw_emit_attrib(struct r300_context* r300, enum interp_mode interp, int index) { - struct tgsi_shader_info* info = &r300->vs->info; + struct r300_vertex_shader* vs = r300->vs_state.state; + struct tgsi_shader_info* info = &vs->info; int output; output = draw_find_shader_output(r300->draw, @@ -55,7 +56,8 @@ static void r300_draw_emit_attrib(struct r300_context* r300, static void r300_draw_emit_all_attribs(struct r300_context* r300) { - struct r300_shader_semantics* vs_outputs = &r300->vs->outputs; + struct r300_vertex_shader* vs = r300->vs_state.state; + struct r300_shader_semantics* vs_outputs = &vs->outputs; int i, gen_count; /* Position. */ @@ -106,6 +108,7 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300) /* Update the PSC tables. */ static void r300_vertex_psc(struct r300_context* r300) { + struct r300_vertex_shader* vs = r300->vs_state.state; struct r300_vertex_info *vformat = (struct r300_vertex_info*)r300->vertex_format_state.state; uint16_t type, swizzle; @@ -117,7 +120,7 @@ static void r300_vertex_psc(struct r300_context* r300) /* If TCL is bypassed, map vertex streams to equivalent VS output * locations. */ if (r300->tcl_bypass) { - stream_tab = r300->vs->stream_loc_notcl; + stream_tab = vs->stream_loc_notcl; } else { stream_tab = identity; } @@ -127,7 +130,7 @@ static void r300_vertex_psc(struct r300_context* r300) * and not on attrib information. */ DBG(r300, DBG_DRAW, "r300: vs expects %d attribs, routing %d elements" " in psc\n", - r300->vs->info.num_inputs, + vs->info.num_inputs, r300->vertex_element_count); for (i = 0; i < r300->vertex_element_count; i++) { @@ -159,13 +162,14 @@ static void r300_vertex_psc(struct r300_context* r300) /* Update the PSC tables for SW TCL, using Draw. */ static void r300_swtcl_vertex_psc(struct r300_context* r300) { + struct r300_vertex_shader* vs = r300->vs_state.state; struct r300_vertex_info *vformat = (struct r300_vertex_info*)r300->vertex_format_state.state; struct vertex_info* vinfo = &vformat->vinfo; uint16_t type, swizzle; enum pipe_format format; unsigned i, attrib_count; - int* vs_output_tab = r300->vs->stream_loc_notcl; + int* vs_output_tab = vs->stream_loc_notcl; /* For each Draw attribute, route it to the fragment shader according * to the vs_output_tab. */ @@ -424,6 +428,7 @@ static void r300_update_rs_block(struct r300_context* r300, /* Update the shader-dependant states. */ static void r300_update_derived_shader_state(struct r300_context* r300) { + struct r300_vertex_shader* vs = r300->vs_state.state; struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_vertex_info *vformat = (struct r300_vertex_info*)r300->vertex_format_state.state; @@ -431,9 +436,9 @@ static void r300_update_derived_shader_state(struct r300_context* r300) /* Mmm, delicious hax */ memset(r300->vertex_format_state.state, 0, sizeof(struct r300_vertex_info)); - memcpy(vinfo->hwfmt, r300->vs->hwfmt, sizeof(uint)*4); + memcpy(vinfo->hwfmt, vs->hwfmt, sizeof(uint)*4); - r300_update_rs_block(r300, &r300->vs->outputs, &r300->fs->inputs); + r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs); if (r300screen->caps->has_tcl) { r300_vertex_psc(r300); @@ -519,9 +524,9 @@ static void r300_update_ztop(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { /* XXX */ - if (r300->dirty_state & - (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER) || - r300->vertex_format_state.dirty || r300->rs_state.dirty) { + if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER || + r300->vs_state.dirty || r300->vertex_format_state.dirty || + r300->rs_state.dirty) { r300_update_derived_shader_state(r300); } diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index a6786c321c..60a04bbfed 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -368,8 +368,8 @@ void r300_translate_vertex_shader(struct r300_context* r300, boolean r300_vertex_shader_setup_wpos(struct r300_context* r300) { - struct r300_vertex_shader* vs = r300->vs; - int tex_output = r300->vs->wpos_tex_output; + struct r300_vertex_shader* vs = r300->vs_state.state; + int tex_output = vs->wpos_tex_output; uint32_t tex_fmt = R300_INPUT_CNTL_TC0 << tex_output; uint32_t* hwfmt = vs->hwfmt; -- cgit v1.2.3 From 235c6bdf6dc0a687a7313f948444c4294abc0ea1 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 10:22:30 +0100 Subject: util: Fix blitter vertex and viewport setup. --- src/gallium/auxiliary/util/u_blit.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 95567d00fe..0b263a9db5 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -426,11 +426,11 @@ util_blit_pixels_writemask(struct blit_state *ctx, /* viewport */ ctx->viewport.scale[0] = 0.5f * dst->width; ctx->viewport.scale[1] = 0.5f * dst->height; - ctx->viewport.scale[2] = 1.0f; + ctx->viewport.scale[2] = 0.5f; ctx->viewport.scale[3] = 1.0f; ctx->viewport.translate[0] = 0.5f * dst->width; ctx->viewport.translate[1] = 0.5f * dst->height; - ctx->viewport.translate[2] = 0.0f; + ctx->viewport.translate[2] = 0.5f; ctx->viewport.translate[3] = 0.0f; cso_set_viewport(ctx->cso, &ctx->viewport); @@ -456,8 +456,10 @@ util_blit_pixels_writemask(struct blit_state *ctx, /* draw quad */ offset = setup_vertex_data_tex(ctx, - (float) dstX0, (float) dstY0, - (float) dstX1, (float) dstY1, + (float) dstX0 / dst->width * 2.0f - 1.0f, + (float) dstY0 / dst->height * 2.0f - 1.0f, + (float) dstX1 / dst->width * 2.0f - 1.0f, + (float) dstY1 / dst->height * 2.0f - 1.0f, s0, t0, s1, t1, z); @@ -575,6 +577,17 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_single_sampler(ctx->cso, 0, &ctx->sampler); cso_single_sampler_done(ctx->cso); + /* viewport */ + ctx->viewport.scale[0] = 0.5f * dst->width; + ctx->viewport.scale[1] = 0.5f * dst->height; + ctx->viewport.scale[2] = 0.5f; + ctx->viewport.scale[3] = 1.0f; + ctx->viewport.translate[0] = 0.5f * dst->width; + ctx->viewport.translate[1] = 0.5f * dst->height; + ctx->viewport.translate[2] = 0.5f; + ctx->viewport.translate[3] = 0.0f; + cso_set_viewport(ctx->cso, &ctx->viewport); + /* texture */ cso_set_sampler_textures(ctx->cso, 1, &tex); @@ -592,8 +605,10 @@ util_blit_pixels_tex(struct blit_state *ctx, /* draw quad */ offset = setup_vertex_data_tex(ctx, - (float) dstX0, (float) dstY0, - (float) dstX1, (float) dstY1, + (float) dstX0 / dst->width * 2.0f - 1.0f, + (float) dstY0 / dst->height * 2.0f - 1.0f, + (float) dstX1 / dst->width * 2.0f - 1.0f, + (float) dstY1 / dst->height * 2.0f - 1.0f, s0, t0, s1, t1, z); -- cgit v1.2.3 From cc7904ffa56b3f27de80bf31084dead12fb09ae0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Feb 2010 02:42:41 -0800 Subject: util: Assert that pointer is not null before dereferencing. --- src/gallium/auxiliary/util/u_inlines.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index e95d58ea86..0cb3432c6e 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -90,7 +90,10 @@ pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference) static INLINE void pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf) { - struct pipe_buffer *old_buf = *ptr; + struct pipe_buffer *old_buf; + + assert(ptr); + old_buf = *ptr; if (pipe_reference(&(*ptr)->reference, &buf->reference)) old_buf->screen->buffer_destroy(old_buf); -- cgit v1.2.3 From 545ac97f9b95e9b5ebd04d2960abb224b5adbe17 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 17 Feb 2010 23:11:31 +0800 Subject: st/egl: Add dri2InvalidateBuffers. src/glx/dri2.c will call dri2InvalidateBuffers when DRI2_InvalidateBuffers event is received. This fixes a missing symbol error, and paves the way for event-based validation. --- src/gallium/state_trackers/egl/x11/native_dri2.c | 13 ++++- src/gallium/state_trackers/egl/x11/native_x11.c | 2 +- src/gallium/state_trackers/egl/x11/x11_screen.c | 68 ++++++++++++++++++------ src/gallium/state_trackers/egl/x11/x11_screen.h | 10 +++- 4 files changed, 74 insertions(+), 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index dbd1a64992..feae025dcc 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -50,6 +50,8 @@ struct dri2_display { struct drm_api *api; struct x11_screen *xscr; int xscr_number; + const char *dri_driver; + int dri_major, dri_minor; struct dri2_config *configs; int num_configs; @@ -681,7 +683,16 @@ dri2_display_init_screen(struct native_display *ndpy) return FALSE; } - fd = x11_screen_enable_dri2(dri2dpy->xscr, driver); + dri2dpy->dri_driver = x11_screen_probe_dri2(dri2dpy->xscr, + &dri2dpy->dri_major, &dri2dpy->dri_minor); + if (!dri2dpy->dri_driver || !driver || + strcmp(dri2dpy->dri_driver, driver) != 0) { + _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", + dri2dpy->dri_driver, dri2dpy->api->name); + return FALSE; + } + + fd = x11_screen_enable_dri2(dri2dpy->xscr, NULL, NULL); if (fd < 0) return FALSE; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 55f0d4d308..3add95d0ac 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -70,7 +70,7 @@ native_create_probe(EGLNativeDisplayType dpy) xscr = x11_screen_create(xdpy, scr); if (xscr) { if (x11_screen_support(xscr, X11_SCREEN_EXTENSION_DRI2)) { - driver_name = x11_screen_probe_dri2(xscr); + driver_name = x11_screen_probe_dri2(xscr, NULL, NULL); if (driver_name) nprobe->data = strdup(driver_name); } diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c index d72bfc99d3..f409611484 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.c +++ b/src/gallium/state_trackers/egl/x11/x11_screen.c @@ -39,6 +39,9 @@ #include "glxinit.h" struct x11_screen { + /* dummy base class */ + struct __GLXDRIdisplayRec base; + Display *dpy; int number; @@ -53,6 +56,9 @@ struct x11_screen { char *dri_device; int dri_fd; + x11_drawable_invalidate_buffers dri_invalidate_buffers; + void *dri_user_data; + XVisualInfo *visuals; int num_visuals; @@ -98,6 +104,8 @@ x11_screen_destroy(struct x11_screen *xscr) Xfree(xscr->dri_device); /* xscr->glx_dpy will be destroyed with the X display */ + if (xscr->glx_dpy) + xscr->glx_dpy->dri2Display = NULL; if (xscr->visuals) XFree(xscr->visuals); @@ -247,24 +255,25 @@ x11_screen_get_glx_visuals(struct x11_screen *xscr) : NULL; } -static boolean -x11_screen_is_driver_equal(struct x11_screen *xscr, const char *driver) -{ - return (strcmp(xscr->dri_driver, driver) == 0); -} - /** * Probe the screen for the DRI2 driver name. */ const char * -x11_screen_probe_dri2(struct x11_screen *xscr) +x11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor) { + if (!x11_screen_init_dri2(xscr)) + return NULL; + /* get the driver name and the device name */ if (!xscr->dri_driver) { if (!DRI2Connect(xscr->dpy, RootWindow(xscr->dpy, xscr->number), &xscr->dri_driver, &xscr->dri_device)) xscr->dri_driver = xscr->dri_device = NULL; } + if (major) + *major = xscr->dri_major; + if (minor) + *minor = xscr->dri_minor; return xscr->dri_driver; } @@ -274,21 +283,17 @@ x11_screen_probe_dri2(struct x11_screen *xscr) * descriptor will be closed automatically when the screen is destoryed. */ int -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) +x11_screen_enable_dri2(struct x11_screen *xscr, + x11_drawable_invalidate_buffers invalidate_buffers, + void *user_data) { if (xscr->dri_fd < 0) { int fd; drm_magic_t magic; /* get the driver name and the device name first */ - if (!x11_screen_probe_dri2(xscr)) - return -1; - - if (!x11_screen_is_driver_equal(xscr, driver)) { - _eglLog(_EGL_WARNING, "Driver mismatch: %s != %s", - xscr->dri_driver, driver); + if (!x11_screen_probe_dri2(xscr, NULL, NULL)) return -1; - } fd = open(xscr->dri_device, O_RDWR); if (fd < 0) { @@ -310,6 +315,22 @@ x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver) return -1; } + if (!x11_screen_init_glx(xscr)) { + _eglLog(_EGL_WARNING, "failed to initialize GLX"); + close(fd); + return -1; + } + if (xscr->glx_dpy->dri2Display) { + _eglLog(_EGL_WARNING, + "display is already managed by another x11 screen"); + close(fd); + return -1; + } + + xscr->glx_dpy->dri2Display = (__GLXDRIdisplay *) xscr; + xscr->dri_invalidate_buffers = invalidate_buffers; + xscr->dri_user_data = user_data; + xscr->dri_fd = fd; } @@ -451,3 +472,20 @@ x11_context_modes_count(const __GLcontextModes *modes) count++; return count; } + +/** + * This is called from src/glx/dri2.c. + */ +void +dri2InvalidateBuffers(Display *dpy, XID drawable) +{ + __GLXdisplayPrivate *priv = __glXInitialize(dpy); + struct x11_screen *xscr = NULL; + + if (priv && priv->dri2Display) + xscr = (struct x11_screen *) priv->dri2Display; + if (!xscr || !xscr->dri_invalidate_buffers) + return; + + xscr->dri_invalidate_buffers(xscr, drawable, xscr->dri_user_data); +} diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h index 5432858ac3..37e8d5a40e 100644 --- a/src/gallium/state_trackers/egl/x11/x11_screen.h +++ b/src/gallium/state_trackers/egl/x11/x11_screen.h @@ -48,6 +48,10 @@ struct x11_drawable_buffer { struct x11_screen; +typedef void (*x11_drawable_invalidate_buffers)(struct x11_screen *xscr, + Drawable drawable, + void *user_data); + struct x11_screen * x11_screen_create(Display *dpy, int screen); @@ -71,10 +75,12 @@ const __GLcontextModes * x11_screen_get_glx_visuals(struct x11_screen *xscr); const char * -x11_screen_probe_dri2(struct x11_screen *xscr); +x11_screen_probe_dri2(struct x11_screen *xscr, int *major, int *minor); int -x11_screen_enable_dri2(struct x11_screen *xscr, const char *driver); +x11_screen_enable_dri2(struct x11_screen *xscr, + x11_drawable_invalidate_buffers invalidate_buffers, + void *user_data); __GLcontextModes * x11_context_modes_create(unsigned count); -- cgit v1.2.3 From 29ec53d8439eab85f39de02bd18539c26410d2bf Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 24 Feb 2010 15:34:16 +0800 Subject: st/egl: Refactor dri2_surface_get_buffers. Add dri2_surface_process_drawable_buffers to process the buffers returned by the server. --- src/gallium/state_trackers/egl/x11/native_dri2.c | 118 +++++++++++++---------- 1 file changed, 67 insertions(+), 51 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index feae025dcc..f4072bb0cd 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -98,65 +98,23 @@ dri2_config(const struct native_config *nconf) } /** - * Get the buffers from the server. + * Process the buffers returned by the server. */ static void -dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) +dri2_surface_process_drawable_buffers(struct native_surface *nsurf, + struct x11_drawable_buffer *xbufs, + int num_xbufs) { struct dri2_surface *dri2surf = dri2_surface(nsurf); struct dri2_display *dri2dpy = dri2surf->dri2dpy; - unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; - int num_ins, num_outs, att, i; - struct x11_drawable_buffer *xbufs; struct pipe_texture templ; uint valid_mask; + int i; - /* prepare the attachments */ - num_ins = 0; - for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { - if (native_attachment_mask_test(buffer_mask, att)) { - unsigned int dri2att; - - switch (att) { - case NATIVE_ATTACHMENT_FRONT_LEFT: - dri2att = DRI2BufferFrontLeft; - break; - case NATIVE_ATTACHMENT_BACK_LEFT: - dri2att = DRI2BufferBackLeft; - break; - case NATIVE_ATTACHMENT_FRONT_RIGHT: - dri2att = DRI2BufferFrontRight; - break; - case NATIVE_ATTACHMENT_BACK_RIGHT: - dri2att = DRI2BufferBackRight; - break; - default: - assert(0); - dri2att = 0; - break; - } - - dri2atts[num_ins] = dri2att; - num_ins++; - } - } - - xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, - &dri2surf->width, &dri2surf->height, - dri2atts, FALSE, num_ins, &num_outs); - - /* we should be able to do better... */ - if (xbufs && dri2surf->last_num_xbufs == num_outs && - memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) { - free(xbufs); - return; - } - - /* free the old buffers */ + /* free the old textures */ for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) pipe_texture_reference(&dri2surf->textures[i], NULL); dri2surf->valid_mask = 0x0; - dri2surf->sequence_number++; dri2surf->have_back = FALSE; dri2surf->have_fake = FALSE; @@ -174,7 +132,7 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; valid_mask = 0x0; - for (i = 0; i < num_outs; i++) { + for (i = 0; i < num_xbufs; i++) { struct x11_drawable_buffer *xbuf = &xbufs[i]; const char *desc; enum native_attachment natt; @@ -214,12 +172,70 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) valid_mask |= 1 << natt; } + dri2surf->valid_mask = valid_mask; +} + +/** + * Get the buffers from the server. + */ +static void +dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + struct dri2_display *dri2dpy = dri2surf->dri2dpy; + unsigned int dri2atts[NUM_NATIVE_ATTACHMENTS]; + int num_ins, num_outs, att; + struct x11_drawable_buffer *xbufs; + + /* prepare the attachments */ + num_ins = 0; + for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { + if (native_attachment_mask_test(buffer_mask, att)) { + unsigned int dri2att; + + switch (att) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + dri2att = DRI2BufferFrontLeft; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + dri2att = DRI2BufferBackLeft; + break; + case NATIVE_ATTACHMENT_FRONT_RIGHT: + dri2att = DRI2BufferFrontRight; + break; + case NATIVE_ATTACHMENT_BACK_RIGHT: + dri2att = DRI2BufferBackRight; + break; + default: + assert(0); + dri2att = 0; + break; + } + + dri2atts[num_ins] = dri2att; + num_ins++; + } + } + + xbufs = x11_drawable_get_buffers(dri2dpy->xscr, dri2surf->drawable, + &dri2surf->width, &dri2surf->height, + dri2atts, FALSE, num_ins, &num_outs); + + /* we should be able to do better... */ + if (xbufs && dri2surf->last_num_xbufs == num_outs && + memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) { + free(xbufs); + return; + } + + dri2_surface_process_drawable_buffers(&dri2surf->base, xbufs, num_outs); + + dri2surf->sequence_number++; + if (dri2surf->last_xbufs) free(dri2surf->last_xbufs); dri2surf->last_xbufs = xbufs; dri2surf->last_num_xbufs = num_outs; - - dri2surf->valid_mask = valid_mask; } /** -- cgit v1.2.3 From 33b92471a7b97c4f3ebf722e8551f37e167a445c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 25 Feb 2010 21:16:56 +0800 Subject: st/egl: Reduce validation round-trips in ximage backend. ximage_surface_validate is called several times per frame. This commit adds the client and server stamps to reduce the round-trips to the server. The idea is to bump the server stamp when flush_frontbuffer or swap_buffers is called, and to skip the round-trip when the client stamp is equal to the server stamp. This makes sure the client APIs get the new buffers when a new frame is started while skipping all round-trips during the drawing. To make this work, egl_g3d_validate_context is no longer called after swap_buffers. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 20 +------ src/gallium/state_trackers/egl/x11/native_ximage.c | 62 +++++++++++++--------- 2 files changed, 39 insertions(+), 43 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 13a7487ea8..086e644e21 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -931,25 +931,7 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) if (gctx) gctx->stapi->st_notify_swapbuffers(gctx->draw.st_fb); - /* - * We drew on the back buffer, unless there was no back buffer. - * In that case, we drew on the front buffer. Either case, we call - * swap_buffers. - */ - if (!gsurf->native->swap_buffers(gsurf->native)) - return EGL_FALSE; - - if (gctx) { - struct egl_g3d_config *gconf = egl_g3d_config(gsurf->base.Config); - - /* force validation if the swap method is not copy */ - if (gconf->native->mode.swapMethod != GLX_SWAP_COPY_OML) { - gctx->force_validate = EGL_TRUE; - egl_g3d_validate_context(dpy, &gctx->base); - } - } - - return EGL_TRUE; + return gsurf->native->swap_buffers(gsurf->native); } /** diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 78675a1998..8ba73f289d 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -81,7 +81,8 @@ struct ximage_surface { GC gc; - unsigned int sequence_number; + unsigned int server_stamp; + unsigned int client_stamp; int width, height; struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS]; uint valid_mask; @@ -216,18 +217,11 @@ ximage_surface_update_geometry(struct native_surface *nsurf) ok = XGetGeometry(xsurf->xdpy->dpy, xsurf->drawable, &root, &x, &y, &w, &h, &border, &depth); - if (!ok) { - w = xsurf->width; - h = xsurf->height; - } - - /* all buffers become invalid */ - if (xsurf->width != w || xsurf->height != h) { + if (ok && (xsurf->width != w || xsurf->height != h)) { xsurf->width = w; xsurf->height = h; - xsurf->valid_mask = 0x0; - xsurf->sequence_number++; + xsurf->server_stamp++; updated = TRUE; } @@ -247,10 +241,18 @@ ximage_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask) int att; updated = ximage_surface_update_geometry(&xsurf->base); - buffer_mask &= ~xsurf->valid_mask; - /* all requested buffers are valid */ - if (!buffer_mask) - return TRUE; + if (updated) { + /* all buffers become invalid */ + xsurf->valid_mask = 0x0; + } + else { + buffer_mask &= ~xsurf->valid_mask; + /* all requested buffers are valid */ + if (!buffer_mask) { + xsurf->client_stamp = xsurf->server_stamp; + return TRUE; + } + } new_valid = 0x0; for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { @@ -273,11 +275,8 @@ ximage_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask) } } - if (new_valid) { - xsurf->valid_mask |= new_valid; - if (updated) - xsurf->sequence_number++; - } + xsurf->valid_mask |= new_valid; + xsurf->client_stamp = xsurf->server_stamp; return (new_valid == buffer_mask); } @@ -333,7 +332,15 @@ ximage_surface_draw_buffer(struct native_surface *nsurf, static boolean ximage_surface_flush_frontbuffer(struct native_surface *nsurf) { - return ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_FRONT_LEFT); + struct ximage_surface *xsurf = ximage_surface(nsurf); + boolean ret; + + ret = ximage_surface_draw_buffer(&xsurf->base, + NATIVE_ATTACHMENT_FRONT_LEFT); + /* force buffers to be updated in next validation call */ + xsurf->server_stamp++; + + return ret; } static boolean @@ -345,6 +352,8 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) /* display the back buffer first */ ret = ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); + /* force buffers to be updated in next validation call */ + xsurf->server_stamp++; xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; @@ -356,7 +365,6 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) xtmp = *xfront; *xfront = *xback; *xback = xtmp; - xsurf->sequence_number++; return ret; } @@ -368,11 +376,14 @@ ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask, { struct ximage_surface *xsurf = ximage_surface(nsurf); - if (!ximage_surface_update_buffers(&xsurf->base, attachment_mask)) - return FALSE; + if (xsurf->client_stamp != xsurf->server_stamp || + (xsurf->valid_mask & attachment_mask) != attachment_mask) { + if (!ximage_surface_update_buffers(&xsurf->base, attachment_mask)) + return FALSE; + } if (seq_num) - *seq_num = xsurf->sequence_number; + *seq_num = xsurf->client_stamp; if (textures) { int att; @@ -453,6 +464,9 @@ ximage_display_create_surface(struct native_display *ndpy, return NULL; } + /* initialize the geometry */ + ximage_surface_update_buffers(&xsurf->base, 0x0); + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { struct ximage_buffer *xbuf = &xsurf->buffers[i]; -- cgit v1.2.3 From 6e28a4e0bcd98327838855175a5b214c31a4cde0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 25 Feb 2010 21:18:20 +0800 Subject: st/egl: Reduce validation round-trips in DRI2 backend. This is similar to the changes to reduce the round-trips in ximage backend. When the server supports DRI_InvalidateBuffers, the event is used to update the server stamp (this path is not tested). Otherwise, the server stamp is updated when flush_frontbuffer or swap_buffers is called. This makes sure at least the client APIs get the new buffers when a new frame is started while skipping all round-trips during the drawing. --- src/gallium/state_trackers/egl/x11/native_dri2.c | 102 +++++++++++++++++++---- 1 file changed, 88 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index f4072bb0cd..8df58891a0 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -26,6 +26,7 @@ #include "util/u_math.h" #include "util/u_format.h" #include "util/u_inlines.h" +#include "util/u_hash_table.h" #include "pipe/p_compiler.h" #include "pipe/p_screen.h" #include "pipe/p_context.h" @@ -55,6 +56,8 @@ struct dri2_display { struct dri2_config *configs; int num_configs; + + struct util_hash_table *surfaces; }; struct dri2_surface { @@ -64,7 +67,8 @@ struct dri2_surface { enum pipe_format color_format; struct dri2_display *dri2dpy; - unsigned int sequence_number; + unsigned int server_stamp; + unsigned int client_stamp; int width, height; struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; uint valid_mask; @@ -225,12 +229,14 @@ dri2_surface_get_buffers(struct native_surface *nsurf, uint buffer_mask) if (xbufs && dri2surf->last_num_xbufs == num_outs && memcmp(dri2surf->last_xbufs, xbufs, sizeof(*xbufs) * num_outs) == 0) { free(xbufs); + dri2surf->client_stamp = dri2surf->server_stamp; return; } dri2_surface_process_drawable_buffers(&dri2surf->base, xbufs, num_outs); - dri2surf->sequence_number++; + dri2surf->server_stamp++; + dri2surf->client_stamp = dri2surf->server_stamp; if (dri2surf->last_xbufs) free(dri2surf->last_xbufs); @@ -282,7 +288,7 @@ dri2_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask) } } dri2surf->valid_mask |= new_valid; - /* no need to update sequence number */ + /* no need to update the stamps */ } else { dri2_surface_get_buffers(&dri2surf->base, buffer_mask); @@ -291,6 +297,16 @@ dri2_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask) return ((dri2surf->valid_mask & buffer_mask) == buffer_mask); } +/** + * Return TRUE if the surface receives DRI2_InvalidateBuffers events. + */ +static INLINE boolean +dri2_surface_receive_events(struct native_surface *nsurf) +{ + struct dri2_surface *dri2surf = dri2_surface(nsurf); + return (dri2surf->dri2dpy->dri_minor >= 3); +} + static boolean dri2_surface_flush_frontbuffer(struct native_surface *nsurf) { @@ -307,6 +323,10 @@ dri2_surface_flush_frontbuffer(struct native_surface *nsurf) 0, 0, dri2surf->width, dri2surf->height, DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); + /* force buffers to be updated in next validation call */ + if (!dri2_surface_receive_events(&dri2surf->base)) + dri2surf->server_stamp++; + return TRUE; } @@ -332,6 +352,10 @@ dri2_surface_swap_buffers(struct native_surface *nsurf) 0, 0, dri2surf->width, dri2surf->height, DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); + /* force buffers to be updated in next validation call */ + if (!dri2_surface_receive_events(&dri2surf->base)) + dri2surf->server_stamp++; + return TRUE; } @@ -342,11 +366,14 @@ dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask, { struct dri2_surface *dri2surf = dri2_surface(nsurf); - if (!dri2_surface_update_buffers(&dri2surf->base, attachment_mask)) - return FALSE; + if (dri2surf->server_stamp != dri2surf->client_stamp || + (dri2surf->valid_mask & attachment_mask) != attachment_mask) { + if (!dri2_surface_update_buffers(&dri2surf->base, attachment_mask)) + return FALSE; + } if (seq_num) - *seq_num = dri2surf->sequence_number; + *seq_num = dri2surf->client_stamp; if (textures) { int att; @@ -395,9 +422,13 @@ dri2_surface_destroy(struct native_surface *nsurf) pipe_texture_reference(&ptex, NULL); } - if (dri2surf->drawable) + if (dri2surf->drawable) { x11_drawable_enable_dri2(dri2surf->dri2dpy->xscr, dri2surf->drawable, FALSE); + + util_hash_table_remove(dri2surf->dri2dpy->surfaces, + (void *) dri2surf->drawable); + } free(dri2surf); } @@ -426,8 +457,14 @@ dri2_display_create_surface(struct native_display *ndpy, dri2surf->base.validate = dri2_surface_validate; dri2surf->base.wait = dri2_surface_wait; - if (drawable) + if (drawable) { x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE); + /* initialize the geometry */ + dri2_surface_update_buffers(&dri2surf->base, 0x0); + + util_hash_table_set(dri2surf->dri2dpy->surfaces, + (void *) dri2surf->drawable, (void *) &dri2surf->base); + } return dri2surf; } @@ -673,6 +710,9 @@ dri2_display_destroy(struct native_display *ndpy) if (dri2dpy->base.screen) dri2dpy->base.screen->destroy(dri2dpy->base.screen); + if (dri2dpy->surfaces) + util_hash_table_destroy(dri2dpy->surfaces); + if (dri2dpy->xscr) x11_screen_destroy(dri2dpy->xscr); if (dri2dpy->own_dpy) @@ -682,6 +722,24 @@ dri2_display_destroy(struct native_display *ndpy) free(dri2dpy); } +static void +dri2_display_invalidate_buffers(struct x11_screen *xscr, Drawable drawable, + void *user_data) +{ + struct native_display *ndpy = (struct native_display* ) user_data; + struct dri2_display *dri2dpy = dri2_display(ndpy); + struct native_surface *nsurf; + struct dri2_surface *dri2surf; + + nsurf = (struct native_surface *) + util_hash_table_get(dri2dpy->surfaces, (void *) drawable); + if (!nsurf) + return; + + dri2surf = dri2_surface(nsurf); + dri2surf->server_stamp++; +} + /** * Initialize DRI2 and pipe screen. */ @@ -708,7 +766,8 @@ dri2_display_init_screen(struct native_display *ndpy) return FALSE; } - fd = x11_screen_enable_dri2(dri2dpy->xscr, NULL, NULL); + fd = x11_screen_enable_dri2(dri2dpy->xscr, + dri2_display_invalidate_buffers, &dri2dpy->base); if (fd < 0) return FALSE; @@ -723,6 +782,19 @@ dri2_display_init_screen(struct native_display *ndpy) return TRUE; } +static unsigned +dri2_display_hash_table_hash(void *key) +{ + XID drawable = pointer_to_uintptr(key); + return (unsigned) drawable; +} + +static int +dri2_display_hash_table_compare(void *key1, void *key2) +{ + return (key1 - key2); +} + struct native_display * x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) { @@ -733,11 +805,6 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) return NULL; dri2dpy->api = api; - if (!dri2dpy->api) { - _eglLog(_EGL_WARNING, "failed to create DRM API"); - free(dri2dpy); - return NULL; - } dri2dpy->dpy = dpy; if (!dri2dpy->dpy) { @@ -761,6 +828,13 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) return NULL; } + dri2dpy->surfaces = util_hash_table_create(dri2_display_hash_table_hash, + dri2_display_hash_table_compare); + if (!dri2dpy->surfaces) { + dri2_display_destroy(&dri2dpy->base); + return NULL; + } + dri2dpy->base.destroy = dri2_display_destroy; dri2dpy->base.get_configs = dri2_display_get_configs; dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; -- cgit v1.2.3 From aa799fa2d0701fbaa968036c0c1964d00a530c6d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 15:01:10 +0100 Subject: tgsi: Remove dead code. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 593c3cbfb3..68566d3093 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -960,18 +960,6 @@ micro_pow( #endif } -#if 0 -static void -micro_sqrt( union tgsi_exec_channel *dst, - const union tgsi_exec_channel *src ) -{ - dst->f[0] = sqrtf( src->f[0] ); - dst->f[1] = sqrtf( src->f[1] ); - dst->f[2] = sqrtf( src->f[2] ); - dst->f[3] = sqrtf( src->f[3] ); -} -#endif - static void micro_sub(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src0, -- cgit v1.2.3 From aec4d225b28bfb97aa04845fe038b37e4ffad240 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Thu, 25 Feb 2010 14:21:50 +0100 Subject: python: Fix typo. --- src/gallium/state_trackers/python/p_state.i | 2 +- .../python/tests/regress/fragment-shader/frag-abs.png | Bin 0 -> 8750 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i index 5afe4d4908..eda77b56f8 100644 --- a/src/gallium/state_trackers/python/p_state.i +++ b/src/gallium/state_trackers/python/p_state.i @@ -69,7 +69,7 @@ pipe_blend_state(const char *STRING, unsigned LENGTH) { struct pipe_blend_state *state; - state = CALLOC_STRUCT(pipe_framebuffer_state); + state = CALLOC_STRUCT(pipe_blend_state); if (state) { LENGTH = MIN2(sizeof *state, LENGTH); memcpy(state, STRING, LENGTH); diff --git a/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png new file mode 100644 index 0000000000..c947a7b881 Binary files /dev/null and b/src/gallium/state_trackers/python/tests/regress/fragment-shader/frag-abs.png differ -- cgit v1.2.3 From db2e1518ff4ecb4a394076321ea5cdda3483ccbe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 25 Feb 2010 17:02:52 +0000 Subject: scons: Always build trace driver There are so many state trackers and winsys that rely on it for debug building, and trace can really build anywhere and is thin so there's no point is making it an option. Based on Xavier Chantry 's patch: "I also removed the trace check in xlib SConscript which is now useless, and that script seems to deal with the cell driver, so I added cell in the check for supported drivers." --- SConstruct | 4 ++++ src/gallium/winsys/xlib/SConscript | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/SConstruct b/SConstruct index ea63b90f46..e1c4a1898c 100644 --- a/SConstruct +++ b/SConstruct @@ -110,6 +110,10 @@ Export([ ####################################################################### # Environment setup +# Always build trace driver +if 'trace' not in env['drivers']: + env['drivers'].append('trace') + # Includes env.Append(CPPPATH = [ '#/include', diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index a4dabb7804..8c9d318af2 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -14,11 +14,7 @@ if env['dri']: print 'warning: DRI enabled: skipping build of xlib libGL.so' Return() -if 'trace' not in env['drivers']: - print 'warning: trace pipe driver disabled: skipping build of xlib libGL.so' - Return() - -if not set(('softpipe', 'llvmpipe', 'trace')).intersection(env['drivers']): +if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']): print 'warning: no supported pipe driver: skipping build of xlib libGL.so' Return() -- cgit v1.2.3 From 3e882e943c487945d598cbc6fae8fd570f28081d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 25 Feb 2010 17:52:48 -0800 Subject: util: Remove import of unused sys module. --- src/gallium/auxiliary/util/u_format_parse.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 983c3a90fc..15c887af5e 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -30,9 +30,6 @@ ''' -import sys - - VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5) SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7) -- cgit v1.2.3 From 31ff9b0a135bf913ae6b44868bde31534a87802c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 25 Feb 2010 16:20:01 -0700 Subject: util: remove a trailing semicolon in format table code --- src/gallium/auxiliary/util/u_format_table.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 3d0e3a0349..953b5aed87 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -152,7 +152,7 @@ def write_format_table(formats): print " assert(0);" print " return NULL;" print " }" - print "};" + print "}" print -- cgit v1.2.3 From 900b163a86cc97f029c8bf8cf2779fa173f353de Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 26 Feb 2010 04:02:41 +0200 Subject: minor cleanup of dri/Makefile.template's after miniglx drop also makes the WINDOW_SYSTEM configure var useless ... --- src/gallium/winsys/drm/Makefile.template | 25 ++++--------------------- src/gallium/winsys/drm/radeon/dri/Makefile | 2 -- src/mesa/drivers/dri/Makefile.template | 24 +++--------------------- 3 files changed, 7 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 960353a73d..f4cc0def47 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -19,30 +19,12 @@ COMMON_BM_SOURCES = \ $(TOP)/src/mesa/drivers/dri/common/dri_bufmgr.c \ $(TOP)/src/mesa/drivers/dri/common/dri_drmpool.c - -ifeq ($(WINDOW_SYSTEM),dri) -WINOBJ= -WINLIB= INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) OBJECTS = \ $(C_SOURCES:.c=.o) \ $(ASM_SOURCES:.S=.o) -else -# miniglx -WINOBJ= -WINLIB=-L$(MESA)/src/glx/mini -MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini -INCLUDES = $(MINIGLX_INCLUDES) \ - $(SHARED_INCLUDES) \ - $(PCIACCESS_CFLAGS) - -OBJECTS = $(C_SOURCES:.c=.o) \ - $(MINIGLX_SOURCES:.c=.o) \ - $(ASM_SOURCES:.S=.o) -endif - ### Include directories SHARED_INCLUDES = \ @@ -74,18 +56,19 @@ SHARED_INCLUDES = \ $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ ##### TARGETS ##### default: depend symlinks $(TOP)/$(LIB_DIR)/gallium/$(LIBNAME) -$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(PIPE_DRIVERS) \ -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \ - $(WINOBJ) $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) + $(DRI_LIB_DEPS) $(DRIVER_EXTRAS) $(TOP)/$(LIB_DIR)/gallium: mkdir -p $@ diff --git a/src/gallium/winsys/drm/radeon/dri/Makefile b/src/gallium/winsys/drm/radeon/dri/Makefile index eaa3418032..d75f7dd6da 100644 --- a/src/gallium/winsys/drm/radeon/dri/Makefile +++ b/src/gallium/winsys/drm/radeon/dri/Makefile @@ -4,8 +4,6 @@ include $(TOP)/configs/current LIBNAME = radeong_dri.so -MINIGLX_SOURCES = - PIPE_DRIVERS = \ $(TOP)/src/gallium/state_trackers/dri/libdridrm.a \ $(TOP)/src/gallium/winsys/drm/radeon/core/libradeonwinsys.a \ diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 39d25ce3f4..a0c25d26cd 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -14,28 +14,11 @@ COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \ ../common/drirenderbuffer.c \ ../common/dri_metaops.c -ifeq ($(WINDOW_SYSTEM),dri) -WINOBJ= -WINLIB= INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) OBJECTS = $(C_SOURCES:.c=.o) \ $(ASM_SOURCES:.S=.o) -else -# miniglx -WINOBJ= -WINLIB=-L$(MESA)/src/glx/mini -MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini -INCLUDES = $(MINIGLX_INCLUDES) \ - $(SHARED_INCLUDES) \ - $(PCIACCESS_CFLAGS) - -OBJECTS = $(C_SOURCES:.c=.o) \ - $(MINIGLX_SOURCES:.c=.o) \ - $(ASM_SOURCES:.S=.o) -endif - ### Include directories SHARED_INCLUDES = \ @@ -55,7 +38,7 @@ SHARED_INCLUDES = \ $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ .S.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ + $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ ##### TARGETS ##### @@ -67,11 +50,10 @@ default: subdirs lib lib: symlinks subdirs depend @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) -$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) Makefile \ +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ $(TOP)/src/mesa/drivers/dri/Makefile.template $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) \ - $(DRI_LIB_DEPS) + $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) -- cgit v1.2.3 From e2b02ea9db1a01fd2c4e431edff237d9909863ef Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 10:11:36 +0000 Subject: util: Add is_pot() method to formats. --- src/gallium/auxiliary/util/u_format_parse.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 15c887af5e..f26cb37237 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -37,6 +37,10 @@ SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, PLAIN = 'plain' +def is_pot(x): + return (x & (x - 1)) == 0; + + class Type: '''Describe the type of a color channel.''' @@ -113,6 +117,9 @@ class Format: return True return False + def is_pot(self): + return is_pot(self.block_size()) + def stride(self): return self.block_size()/8 -- cgit v1.2.3 From eee21b3812ce8e1d8c4ebbeb89d86c60867d1116 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 10:11:52 +0000 Subject: llvmpipe: Fix scons dependencies. --- src/gallium/drivers/llvmpipe/SConscript | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 9084c97079..71f9337422 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -18,6 +18,12 @@ env.CodeGenerate( command = 'python $SCRIPT $SOURCE > $TARGET' ) +# XXX: Our dependency scanner only finds depended modules in relative dirs. +env.Depends('lp_tile_soa.c', [ + '#src/gallium/auxiliary/util/u_format_parse.py', + '#src/gallium/auxiliary/util/u_format_access.py', +]) + llvmpipe = env.ConvenienceLibrary( target = 'llvmpipe', source = [ -- cgit v1.2.3 From 8416d342792910bfffcc8806dba0ee35a395b31d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 10:12:32 +0000 Subject: llvmpipe: Fix lp_tile_r5g6b5_unorm_write_4ub. Was using 32bit integer pointers instead of 16bits. --- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index a66a846f8e..4d04905958 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -170,7 +170,7 @@ def emit_unrolled_write_code(format, src_type): '''Emit code for writing a block based on unrolled loops. This is considerably faster than the TILE_PIXEL-based code below. ''' - dst_native_type = intermediate_native_type(format.block_size(), False) + dst_native_type = 'uint%u_t' % format.block_size() print ' const unsigned dstpix_stride = dst_stride / %d;' % format.stride() print ' %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type) print ' unsigned int qx, qy, i;' @@ -249,6 +249,7 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): if format.layout == PLAIN \ and format.colorspace == 'rgb' \ and format.block_size() <= 32 \ + and format.is_pot() \ and not format.is_mixed() \ and format.in_types[0].kind == UNSIGNED: emit_unrolled_write_code(format, src_type) -- cgit v1.2.3 From f2656c3e3cc91edcbf572d175efe9346a30b1da2 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Fri, 26 Feb 2010 14:16:46 +0100 Subject: nv50: adapt to vertex elements cso --- src/gallium/drivers/nv50/nv50_context.h | 10 +++- src/gallium/drivers/nv50/nv50_state.c | 34 ++++++++++--- src/gallium/drivers/nv50/nv50_vbo.c | 84 +++++++++++++++++++-------------- 3 files changed, 85 insertions(+), 43 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index b4de3e2ba5..811b3ef9fe 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -72,6 +72,12 @@ struct nv50_sampler_stateobj { unsigned tsc[8]; }; +struct nv50_vtxelt_stateobj { + struct pipe_vertex_element pipe[16]; + unsigned num_elements; + uint32_t hw[16]; +}; + static INLINE unsigned get_tile_height(uint32_t tile_mode) { @@ -168,8 +174,7 @@ struct nv50_context { struct pipe_buffer *constbuf[PIPE_SHADER_TYPES]; struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned vtxbuf_nr; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; - unsigned vtxelt_nr; + struct nv50_vtxelt_stateobj *vtxelt; struct nv50_sampler_stateobj *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; unsigned sampler_nr[PIPE_SHADER_TYPES]; struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; @@ -217,6 +222,7 @@ extern void nv50_draw_elements_instanced(struct pipe_context *pipe, unsigned count, unsigned startInstance, unsigned instanceCount); +extern void nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso); extern void nv50_vbo_validate(struct nv50_context *nv50); /* nv50_clear.c */ diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 7d304907b6..ffbf3473a1 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -720,15 +720,34 @@ nv50_set_vertex_buffers(struct pipe_context *pipe, unsigned count, nv50->dirty |= NV50_NEW_ARRAYS; } +static void * +nv50_vtxelts_state_create(struct pipe_context *pipe, + unsigned num_elements, + const struct pipe_vertex_element *elements) +{ + struct nv50_vtxelt_stateobj *cso = CALLOC_STRUCT(nv50_vtxelt_stateobj); + + assert(num_elements < 16); /* not doing fallbacks yet */ + cso->num_elements = num_elements; + memcpy(cso->pipe, elements, num_elements * sizeof(*elements)); + + nv50_vtxelt_construct(cso); + + return (void *)cso; +} + static void -nv50_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *ve) +nv50_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso) { - struct nv50_context *nv50 = nv50_context(pipe); + FREE(hwcso); +} - memcpy(nv50->vtxelt, ve, sizeof(*ve) * count); - nv50->vtxelt_nr = count; +static void +nv50_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso) +{ + struct nv50_context *nv50 = nv50_context(pipe); + nv50->vtxelt = hwcso; nv50->dirty |= NV50_NEW_ARRAYS; } @@ -778,7 +797,10 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.set_scissor_state = nv50_set_scissor_state; nv50->pipe.set_viewport_state = nv50_set_viewport_state; + nv50->pipe.create_vertex_elements_state = nv50_vtxelts_state_create; + nv50->pipe.delete_vertex_elements_state = nv50_vtxelts_state_delete; + nv50->pipe.bind_vertex_elements_state = nv50_vtxelts_state_bind; + nv50->pipe.set_vertex_buffers = nv50_set_vertex_buffers; - nv50->pipe.set_vertex_elements = nv50_set_vertex_elements; } diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 909d323e05..c1dcb93b48 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -223,11 +223,10 @@ nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_channel *chan = tesla->channel; float v[4]; - unsigned nr_components = util_format_get_nr_components(nv50->vtxelt[i].src_format); - + enum pipe_format pf = nv50->vtxelt->pipe[i].src_format; + unsigned nr_components = util_format_get_nr_components(pf); - util_format_read_4f(nv50->vtxelt[i].src_format, - v, 0, data, 0, 0, 0, 1, 1); + util_format_read_4f(pf, v, 0, data, 0, 0, 0, 1, 1); switch (nr_components) { case 4: @@ -266,16 +265,17 @@ init_per_instance_arrays_immd(struct nv50_context *nv50, struct nouveau_bo *bo; unsigned i, b, count = 0; - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) + for (i = 0; i < nv50->vtxelt->num_elements; ++i) { + if (!nv50->vtxelt->pipe[i].instance_divisor) continue; ++count; - b = nv50->vtxelt[i].vertex_buffer_index; + b = nv50->vtxelt->pipe[i].vertex_buffer_index; - pos[i] = nv50->vtxelt[i].src_offset + + pos[i] = nv50->vtxelt->pipe[i].src_offset + nv50->vtxbuf[b].buffer_offset + startInstance * nv50->vtxbuf[b].stride; - step[i] = startInstance % nv50->vtxelt[i].instance_divisor; + step[i] = startInstance % + nv50->vtxelt->pipe[i].instance_divisor; bo = nouveau_bo(nv50->vtxbuf[b].buffer); if (!bo->map) @@ -296,22 +296,22 @@ init_per_instance_arrays(struct nv50_context *nv50, struct nouveau_channel *chan = tesla->channel; struct nouveau_bo *bo; struct nouveau_stateobj *so; - unsigned i, b, count = 0; + unsigned i, b, count = 0, num_elements = nv50->vtxelt->num_elements; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; if (nv50->vbo_fifo) return init_per_instance_arrays_immd(nv50, startInstance, pos, step); - so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + so = so_new(num_elements, num_elements * 2, num_elements * 2); - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) + for (i = 0; i < nv50->vtxelt->num_elements; ++i) { + if (!nv50->vtxelt->pipe[i].instance_divisor) continue; ++count; - b = nv50->vtxelt[i].vertex_buffer_index; + b = nv50->vtxelt->pipe[i].vertex_buffer_index; - pos[i] = nv50->vtxelt[i].src_offset + + pos[i] = nv50->vtxelt->pipe[i].src_offset + nv50->vtxbuf[b].buffer_offset + startInstance * nv50->vtxbuf[b].stride; @@ -319,7 +319,8 @@ init_per_instance_arrays(struct nv50_context *nv50, step[i] = 0; continue; } - step[i] = startInstance % nv50->vtxelt[i].instance_divisor; + step[i] = startInstance % + nv50->vtxelt->pipe[i].instance_divisor; bo = nouveau_bo(nv50->vtxbuf[b].buffer); @@ -344,12 +345,12 @@ step_per_instance_arrays_immd(struct nv50_context *nv50, struct nouveau_bo *bo; unsigned i, b; - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) + for (i = 0; i < nv50->vtxelt->num_elements; ++i) { + if (!nv50->vtxelt->pipe[i].instance_divisor) continue; - if (++step[i] != nv50->vtxelt[i].instance_divisor) + if (++step[i] != nv50->vtxelt->pipe[i].instance_divisor) continue; - b = nv50->vtxelt[i].vertex_buffer_index; + b = nv50->vtxelt->pipe[i].vertex_buffer_index; bo = nouveau_bo(nv50->vtxbuf[b].buffer); step[i] = 0; @@ -367,7 +368,7 @@ step_per_instance_arrays(struct nv50_context *nv50, struct nouveau_channel *chan = tesla->channel; struct nouveau_bo *bo; struct nouveau_stateobj *so; - unsigned i, b; + unsigned i, b, num_elements = nv50->vtxelt->num_elements; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; if (nv50->vbo_fifo) { @@ -375,14 +376,14 @@ step_per_instance_arrays(struct nv50_context *nv50, return; } - so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + so = so_new(num_elements, num_elements * 2, num_elements * 2); - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) + for (i = 0; i < nv50->vtxelt->num_elements; ++i) { + if (!nv50->vtxelt->pipe[i].instance_divisor) continue; - b = nv50->vtxelt[i].vertex_buffer_index; + b = nv50->vtxelt->pipe[i].vertex_buffer_index; - if (++step[i] == nv50->vtxelt[i].instance_divisor) { + if (++step[i] == nv50->vtxelt->pipe[i].instance_divisor) { step[i] = 0; pos[i] += nv50->vtxbuf[b].stride; } @@ -740,7 +741,8 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, 0, 0, 1, 1); so = *pso; if (!so) - *pso = so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 4, 0); + *pso = so = so_new(nv50->vtxelt->num_elements, + nv50->vtxelt->num_elements * 4, 0); switch (nr_components) { case 4: @@ -778,6 +780,18 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib, return TRUE; } +void +nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso) +{ + unsigned i; + + for (i = 0; i < cso->num_elements; ++i) { + struct pipe_vertex_element *ve = &cso->pipe[i]; + + cso->hw[i] = nv50_vbo_vtxelt_to_hw(ve); + } +} + void nv50_vbo_validate(struct nv50_context *nv50) { @@ -798,19 +812,19 @@ nv50_vbo_validate(struct nv50_context *nv50) if (NV50_USING_LOATHED_EDGEFLAG(nv50)) nv50->vbo_fifo = 0xffff; /* vertprog can't set edgeflag */ - n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); + n_ve = MAX2(nv50->vtxelt->num_elements, nv50->state.vtxelt_nr); vtxattr = NULL; - vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt_nr * 4); + vtxbuf = so_new(n_ve * 2, n_ve * 5, nv50->vtxelt->num_elements * 4); vtxfmt = so_new(1, n_ve, 0); so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), n_ve); - for (i = 0; i < nv50->vtxelt_nr; i++) { - struct pipe_vertex_element *ve = &nv50->vtxelt[i]; + for (i = 0; i < nv50->vtxelt->num_elements; i++) { + struct pipe_vertex_element *ve = &nv50->vtxelt->pipe[i]; struct pipe_vertex_buffer *vb = &nv50->vtxbuf[ve->vertex_buffer_index]; struct nouveau_bo *bo = nouveau_bo(vb->buffer); - uint32_t hw = nv50_vbo_vtxelt_to_hw(ve); + uint32_t hw = nv50->vtxelt->hw[i]; if (!vb->stride && nv50_vbo_static_attrib(nv50, i, &vtxattr, ve, vb)) { @@ -859,7 +873,7 @@ nv50_vbo_validate(struct nv50_context *nv50) so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); so_data (vtxbuf, 0); } - nv50->state.vtxelt_nr = nv50->vtxelt_nr; + nv50->state.vtxelt_nr = nv50->vtxelt->num_elements; so_ref (vtxfmt, &nv50->state.vtxfmt); so_ref (vtxbuf, &nv50->state.vtxbuf); @@ -1020,13 +1034,13 @@ emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, emit->nr_ve = 0; emit->vtx_dwords = 0; - for (i = 0; i < nv50->vtxelt_nr; ++i) { + for (i = 0; i < nv50->vtxelt->num_elements; ++i) { struct pipe_vertex_element *ve; struct pipe_vertex_buffer *vb; unsigned n, size, nr_components; const struct util_format_description *desc; - ve = &nv50->vtxelt[i]; + ve = &nv50->vtxelt->pipe[i]; vb = &nv50->vtxbuf[ve->vertex_buffer_index]; if (!(nv50->vbo_fifo & (1 << i)) || ve->instance_divisor) continue; -- cgit v1.2.3 From 092010db3798f9a49ff9184bf238099af849e885 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 11:03:06 +0000 Subject: util: Use python names consistent with u_format.h --- src/gallium/auxiliary/util/u_format_access.py | 158 +++++++++++++------------- src/gallium/auxiliary/util/u_format_parse.py | 74 +++++++----- src/gallium/auxiliary/util/u_format_table.py | 8 +- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 70 ++++++------ 4 files changed, 161 insertions(+), 149 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index f7a92f62a8..267fb3fbbd 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -56,12 +56,12 @@ def is_format_supported(format): return False for i in range(4): - type = format.in_types[i] - if type.kind not in (VOID, UNSIGNED, FLOAT): + channel = format.channels[i] + if channel.type not in (VOID, UNSIGNED, FLOAT): return False # We can only read a color from a depth/stencil format if the depth channel is present - if format.colorspace == 'zs' and format.out_swizzle[0] == SWIZZLE_NONE: + if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: return False return True @@ -76,15 +76,15 @@ def native_type(format): return 'uint%u_t' % format.block_size() else: # For array pixel formats return the integer type that matches the color channel - type = format.in_types[0] - if type.kind == UNSIGNED: - return 'uint%u_t' % type.size - elif type.kind == SIGNED: - return 'int%u_t' % type.size - elif type.kind == FLOAT: - if type.size == 32: + channel = format.channels[0] + if channel.type == UNSIGNED: + return 'uint%u_t' % channel.size + elif channel.type == SIGNED: + return 'int%u_t' % channel.size + elif channel.type == FLOAT: + if channel.size == 32: return 'float' - elif type.size == 64: + elif channel.size == 64: return 'double' else: assert False @@ -108,27 +108,27 @@ def intermediate_native_type(bits, sign): return 'uint%u_t' % bits -def get_one_shift(type): - '''Get the number of the bit that matches unity for this type.''' - if type.kind == 'FLOAT': +def get_one_shift(channel): + '''Get the number of the bit that matches unity for this channel.''' + if channel.type == 'FLOAT': assert False - if not type.norm: + if not channel.norm: return 0 - if type.kind == UNSIGNED: - return type.size - if type.kind == SIGNED: - return type.size - 1 - if type.kind == FIXED: - return type.size / 2 + if channel.type == UNSIGNED: + return channel.size + if channel.type == SIGNED: + return channel.size - 1 + if channel.type == FIXED: + return channel.size / 2 assert False -def get_one(type): - '''Get the value of unity for this type.''' - if type.kind == 'FLOAT' or not type.norm: +def get_one(channel): + '''Get the value of unity for this channel.''' + if channel.type == 'FLOAT' or not channel.norm: return 1 else: - return (1 << get_one_shift(type)) - 1 + return (1 << get_one_shift(channel)) - 1 def generate_clamp(): @@ -156,32 +156,32 @@ def generate_clamp(): print -def clamp_expr(src_type, dst_type, dst_native_type, value): +def clamp_expr(src_channel, dst_channel, dst_native_type, value): '''Generate the expression to clamp the value in the source type to the destination type range.''' - if src_type == dst_type: + if src_channel == dst_channel: return value # Pick the approriate clamp function - if src_type.kind == FLOAT: - if src_type.size == 32: + if src_channel.type == FLOAT: + if src_channel.size == 32: func = 'clampf' - elif src_type.size == 64: + elif src_channel.size == 64: func = 'clamp' else: assert False - elif src_type.kind == UNSIGNED: + elif src_channel.type == UNSIGNED: func = 'clampui' - elif src_type.kind == SIGNED: + elif src_channel.type == SIGNED: func = 'clampsi' else: assert False # Clamp floats to [-1, 1] or [0, 1] range - if src_type.kind == FLOAT and dst_type.norm: + if src_channel.type == FLOAT and dst_channel.norm: max = 1 - if src_type.sign and dst_type.sign: + if src_channel.sign and dst_channel.sign: min = -1 else: min = 0 @@ -192,24 +192,24 @@ def clamp_expr(src_type, dst_type, dst_native_type, value): return value -def conversion_expr(src_type, dst_type, dst_native_type, value): +def conversion_expr(src_channel, dst_channel, dst_native_type, value): '''Generate the expression to convert a value between two types.''' - if src_type == dst_type: + if src_channel == dst_channel: return value - if src_type.kind == FLOAT and dst_type.kind == FLOAT: + if src_channel.type == FLOAT and dst_channel.type == FLOAT: return '(%s)%s' % (dst_native_type, value) - if not src_type.norm and not dst_type.norm: + if not src_channel.norm and not dst_channel.norm: return '(%s)%s' % (dst_native_type, value) - value = clamp_expr(src_type, dst_type, dst_native_type, value) + value = clamp_expr(src_channel, dst_channel, dst_native_type, value) - if dst_type.kind == FLOAT: - if src_type.norm: - one = get_one(src_type) - if src_type.size <= 23: + if dst_channel.type == FLOAT: + if src_channel.norm: + one = get_one(src_channel) + if src_channel.size <= 23: scale = '(1.0f/0x%x)' % one else: # bigger than single precision mantissa, use double @@ -217,10 +217,10 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): value = '(%s * %s)' % (value, scale) return '(%s)%s' % (dst_native_type, value) - if src_type.kind == FLOAT: - if dst_type.norm: - dst_one = get_one(dst_type) - if dst_type.size <= 23: + if src_channel.type == FLOAT: + if dst_channel.norm: + dst_one = get_one(dst_channel) + if dst_channel.size <= 23: scale = '0x%x' % dst_one else: # bigger than single precision mantissa, use double @@ -228,18 +228,18 @@ def conversion_expr(src_type, dst_type, dst_native_type, value): value = '(%s * %s)' % (value, scale) return '(%s)%s' % (dst_native_type, value) - if src_type.kind == dst_type.kind: - src_one = get_one(src_type) - dst_one = get_one(dst_type) + if src_channel.type == dst_channel.type: + src_one = get_one(src_channel) + dst_one = get_one(dst_channel) - if src_one > dst_one and src_type.norm and dst_type.norm: + if src_one > dst_one and src_channel.norm and dst_channel.norm: # We can just bitshift - src_shift = get_one_shift(src_type) - dst_shift = get_one_shift(dst_type) + src_shift = get_one_shift(src_channel) + dst_shift = get_one_shift(dst_channel) value = '(%s >> %s)' % (value, src_shift - dst_shift) else: # We need to rescale using an intermediate type big enough to hold the multiplication of both - tmp_native_type = intermediate_native_type(src_type.size + dst_type.size, src_type.sign and dst_type.sign) + tmp_native_type = intermediate_native_type(src_channel.size + dst_channel.size, src_channel.sign and dst_channel.sign) value = '(%s)%s' % (tmp_native_type, value) value = '%s * 0x%x / 0x%x' % (value, dst_one, src_one) value = '(%s)%s' % (dst_native_type, value) @@ -253,11 +253,11 @@ def compute_inverse_swizzle(format): inv_swizzle = [None]*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: inv_swizzle[swizzle] = i elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: inv_swizzle[swizzle] = 0 else: @@ -266,7 +266,7 @@ def compute_inverse_swizzle(format): return inv_swizzle -def generate_format_read(format, dst_type, dst_native_type, dst_suffix): +def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' name = format.short_name() @@ -287,11 +287,11 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): names = ['']*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: names[swizzle] += 'rgba'[i] elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: names[swizzle] = 'z' else: @@ -304,8 +304,8 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; for i in range(4): - src_type = format.in_types[i] - width = src_type.size + src_channel = format.channels[i] + width = src_channel.size if names[i]: value = 'pixel' mask = (1 << width) - 1 @@ -313,35 +313,35 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): value = '(%s >> %u)' % (value, shift) if shift + width < format.block_size(): value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) shift += width else: for i in range(4): - src_type = format.in_types[i] + src_channel = format.channels[i] if names[i]: value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False for i in range(4): if format.colorspace == 'rgb': - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: value = names[swizzle] elif swizzle == SWIZZLE_0: value = '0' elif swizzle == SWIZZLE_1: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False elif format.colorspace == 'zs': if i < 3: value = 'z' else: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False print ' *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i]) @@ -354,7 +354,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print -def generate_format_write(format, src_type, src_native_type, src_suffix): +def generate_format_write(format, src_channel, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' name = format.short_name() @@ -379,11 +379,11 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' %s pixel = 0;' % dst_native_type shift = 0; for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size + dst_channel = format.channels[i] + width = dst_channel.size if inv_swizzle[i] is not None: value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if shift: value = '(%s << %u)' % (value, shift) print ' pixel |= %s;' % value @@ -391,10 +391,10 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print ' *dst_pixel++ = pixel;' else: for i in range(4): - dst_type = format.in_types[i] + dst_channel = format.channels[i] if inv_swizzle[i] is not None: value = 'src_pixel[%u]' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' *dst_pixel++ = %s;' % value else: assert False @@ -408,12 +408,12 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): print -def generate_read(formats, dst_type, dst_native_type, dst_suffix): +def generate_read(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to read pixels from any format''' for format in formats: if is_format_supported(format): - generate_format_read(format, dst_type, dst_native_type, dst_suffix) + generate_format_read(format, dst_channel, dst_native_type, dst_suffix) print 'void' print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) @@ -434,12 +434,12 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): print -def generate_write(formats, src_type, src_native_type, src_suffix): +def generate_write(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to write pixels to any format''' for format in formats: if is_format_supported(format): - generate_format_write(format, src_type, src_native_type, src_suffix) + generate_format_write(format, src_channel, src_native_type, src_suffix) print 'void' print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) @@ -478,14 +478,14 @@ def main(): generate_clamp() - type = Type(FLOAT, False, 32) + type = Channel(FLOAT, False, 32) native_type = 'float' suffix = '4f' generate_read(formats, type, native_type, suffix) generate_write(formats, type, native_type, suffix) - type = Type(UNSIGNED, True, 8) + type = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '4ub' diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index f26cb37237..edc6bba795 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -41,36 +41,36 @@ def is_pot(x): return (x & (x - 1)) == 0; -class Type: - '''Describe the type of a color channel.''' +class Channel: + '''Describe the channel of a color channel.''' - def __init__(self, kind, norm, size): - self.kind = kind + def __init__(self, type, norm, size): + self.type = type self.norm = norm self.size = size - self.sign = kind in (SIGNED, FIXED, FLOAT) + self.sign = type in (SIGNED, FIXED, FLOAT) def __str__(self): - s = str(self.kind) + s = str(self.type) if self.norm: s += 'n' s += str(self.size) return s def __eq__(self, other): - return self.kind == other.kind and self.norm == other.norm and self.size == other.size + return self.type == other.type and self.norm == other.norm and self.size == other.size class Format: '''Describe a pixel format.''' - def __init__(self, name, layout, block_width, block_height, in_types, out_swizzle, colorspace): + def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace): self.name = name self.layout = layout self.block_width = block_width self.block_height = block_height - self.in_types = in_types - self.out_swizzle = out_swizzle + self.channels = channels + self.swizzles = swizzles self.name = name self.colorspace = colorspace @@ -89,42 +89,54 @@ class Format: def block_size(self): size = 0 - for type in self.in_types: - size += type.size + for channel in self.channels: + size += channel.size return size def nr_channels(self): nr_channels = 0 - for type in self.in_types: - if type.size: + for channel in self.channels: + if channel.size: nr_channels += 1 return nr_channels def is_array(self): - ref_type = self.in_types[0] - for type in self.in_types[1:]: - if type.size and (type.size != ref_type.size or type.size % 8): + ref_channel = self.channels[0] + for channel in self.channels[1:]: + if channel.size and (channel.size != ref_channel.size or channel.size % 8): return False return True def is_mixed(self): - ref_type = self.in_types[0] - for type in self.in_types[1:]: - if type.kind != VOID: - if type.kind != ref_type.kind: + ref_channel = self.channels[0] + for channel in self.channels[1:]: + if channel.type != VOID: + if channel.type != ref_channel.type: return True - if type.norm != ref_type.norm: + if channel.norm != ref_channel.norm: return True return False def is_pot(self): return is_pot(self.block_size()) + def is_int(self): + for channel in self.channels: + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + return True + + def is_float(self): + for channel in self.channels: + if channel.type not in (VOID, FLOAT): + return False + return True + def stride(self): return self.block_size()/8 -_kind_parse_map = { +_type_parse_map = { '': VOID, 'x': VOID, 'u': UNSIGNED, @@ -145,7 +157,7 @@ _swizzle_parse_map = { def parse(filename): '''Parse the format descrition in CSV format in terms of the - Type and Format classes above.''' + Channel and Format classes above.''' stream = open(filename) formats = [] @@ -163,10 +175,10 @@ def parse(filename): name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) - in_types = [] + channels = [] for field in fields[4:8]: if field: - kind = _kind_parse_map[field[0]] + type = _type_parse_map[field[0]] if field[1] == 'n': norm = True size = int(field[2:]) @@ -174,13 +186,13 @@ def parse(filename): norm = False size = int(field[1:]) else: - kind = VOID + type = VOID norm = False size = 0 - in_type = Type(kind, norm, size) - in_types.append(in_type) - out_swizzle = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + channel = Channel(type, norm, size) + channels.append(channel) + swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] colorspace = fields[9] - formats.append(Format(name, layout, block_width, block_height, in_types, out_swizzle, colorspace)) + formats.append(Format(name, layout, block_width, block_height, channels, swizzles, colorspace)) return formats diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 953b5aed87..a7a4fd18a8 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -51,7 +51,7 @@ colorspace_channels_map = { } -kind_map = { +type_map = { VOID: "UTIL_FORMAT_TYPE_VOID", UNSIGNED: "UTIL_FORMAT_TYPE_UNSIGNED", SIGNED: "UTIL_FORMAT_TYPE_SIGNED", @@ -112,16 +112,16 @@ def write_format_table(formats): print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): - type = format.in_types[i] + channel = format.channels[i] if i < 3: sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (kind_map[type.kind], bool_map(type.norm), type.size, sep, "xyzw"[i]) + print " {%s, %s, %u}%s\t/* %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i]) print " }," print " {" for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if i < 3: sep = "," else: diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 4d04905958..52d7d3186a 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -45,7 +45,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(sys.argv[0]), '../../auxiliary/u from u_format_access import * -def generate_format_read(format, dst_type, dst_native_type, dst_suffix): +def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' name = format.short_name() @@ -64,11 +64,11 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): names = ['']*4 if format.colorspace == 'rgb': for i in range(4): - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: names[swizzle] += 'rgba'[i] elif format.colorspace == 'zs': - swizzle = format.out_swizzle[0] + swizzle = format.swizzles[0] if swizzle < 4: names[swizzle] = 'z' else: @@ -81,8 +81,8 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print ' %s pixel = *src_pixel++;' % src_native_type shift = 0; for i in range(4): - src_type = format.in_types[i] - width = src_type.size + src_channel = format.channels[i] + width = src_channel.size if names[i]: value = 'pixel' mask = (1 << width) - 1 @@ -90,35 +90,35 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): value = '(%s >> %u)' % (value, shift) if shift + width < format.block_size(): value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) shift += width else: for i in range(4): - src_type = format.in_types[i] + src_channel = format.channels[i] if names[i]: value = '(*src_pixel++)' - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False for i in range(4): if format.colorspace == 'rgb': - swizzle = format.out_swizzle[i] + swizzle = format.swizzles[i] if swizzle < 4: value = names[swizzle] elif swizzle == SWIZZLE_0: value = '0' elif swizzle == SWIZZLE_1: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False elif format.colorspace == 'zs': if i < 3: value = 'z' else: - value = get_one(dst_type) + value = get_one(dst_channel) else: assert False print ' TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i]) @@ -130,7 +130,7 @@ def generate_format_read(format, dst_type, dst_native_type, dst_suffix): print -def pack_rgba(format, src_type, r, g, b, a): +def pack_rgba(format, src_channel, r, g, b, a): """Return an expression for packing r, g, b, a into a pixel of the given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)' """ @@ -152,21 +152,21 @@ def pack_rgba(format, src_type, r, g, b, a): value = None if value: - dst_type = format.in_types[i] + dst_channel = format.channels[i] dst_native_type = native_type(format) - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) term = "((%s) << %d)" % (value, shift) if expr: expr = expr + " | " + term else: expr = term - width = format.in_types[i].size + width = format.channels[i].size shift = shift + width return expr -def emit_unrolled_write_code(format, src_type): +def emit_unrolled_write_code(format, src_channel): '''Emit code for writing a block based on unrolled loops. This is considerably faster than the TILE_PIXEL-based code below. ''' @@ -185,8 +185,8 @@ def emit_unrolled_write_code(format, src_type): print ' const uint8_t *a = src + 3 * TILE_C_STRIDE;' print ' (void) r; (void) g; (void) b; (void) a; /* silence warnings */' print ' for (i = 0; i < TILE_C_STRIDE; i += 2) {' - print ' const uint32_t pixel0 = %s;' % pack_rgba(format, src_type, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]") - print ' const uint32_t pixel1 = %s;' % pack_rgba(format, src_type, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]") + print ' const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]") + print ' const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]") print ' const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);' print ' dstpix[offset + 0] = pixel0;' print ' dstpix[offset + 1] = pixel1;' @@ -196,7 +196,7 @@ def emit_unrolled_write_code(format, src_type): print ' }' -def emit_tile_pixel_write_code(format, src_type): +def emit_tile_pixel_write_code(format, src_channel): '''Emit code for writing a block based on the TILE_PIXEL macro.''' dst_native_type = native_type(format) @@ -213,11 +213,11 @@ def emit_tile_pixel_write_code(format, src_type): print ' %s pixel = 0;' % dst_native_type shift = 0; for i in range(4): - dst_type = format.in_types[i] - width = dst_type.size + dst_channel = format.channels[i] + width = dst_channel.size if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) if shift: value = '(%s << %u)' % (value, shift) print ' pixel |= %s;' % value @@ -225,10 +225,10 @@ def emit_tile_pixel_write_code(format, src_type): print ' *dst_pixel++ = pixel;' else: for i in range(4): - dst_type = format.in_types[i] + dst_channel = format.channels[i] if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_type, dst_type, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' *dst_pixel++ = %s;' % value else: assert False @@ -238,7 +238,7 @@ def emit_tile_pixel_write_code(format, src_type): print ' }' -def generate_format_write(format, src_type, src_native_type, src_suffix): +def generate_format_write(format, src_channel, src_native_type, src_suffix): '''Generate the function to write pixels to a particular format''' name = format.short_name() @@ -251,20 +251,20 @@ def generate_format_write(format, src_type, src_native_type, src_suffix): and format.block_size() <= 32 \ and format.is_pot() \ and not format.is_mixed() \ - and format.in_types[0].kind == UNSIGNED: - emit_unrolled_write_code(format, src_type) + and format.channels[0].type == UNSIGNED: + emit_unrolled_write_code(format, src_channel) else: - emit_tile_pixel_write_code(format, src_type) + emit_tile_pixel_write_code(format, src_channel) print '}' print -def generate_read(formats, dst_type, dst_native_type, dst_suffix): +def generate_read(formats, dst_channel, dst_native_type, dst_suffix): '''Generate the dispatch function to read pixels from any format''' for format in formats: if is_format_supported(format): - generate_format_read(format, dst_type, dst_native_type, dst_suffix) + generate_format_read(format, dst_channel, dst_native_type, dst_suffix) print 'void' print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type) @@ -285,12 +285,12 @@ def generate_read(formats, dst_type, dst_native_type, dst_suffix): print -def generate_write(formats, src_type, src_native_type, src_suffix): +def generate_write(formats, src_channel, src_native_type, src_suffix): '''Generate the dispatch function to write pixels to any format''' for format in formats: if is_format_supported(format): - generate_format_write(format, src_type, src_native_type, src_suffix) + generate_format_write(format, src_channel, src_native_type, src_suffix) print 'void' print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type) @@ -351,12 +351,12 @@ def main(): generate_clamp() - type = Type(UNSIGNED, True, 8) + channel = Channel(UNSIGNED, True, 8) native_type = 'uint8_t' suffix = '4ub' - generate_read(formats, type, native_type, suffix) - generate_write(formats, type, native_type, suffix) + generate_read(formats, channel, native_type, suffix) + generate_write(formats, channel, native_type, suffix) if __name__ == '__main__': -- cgit v1.2.3 From fda9a19b3465e3eb6ef74611a85021055eb78a64 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 15:37:18 +0000 Subject: util: Add util_bswap16. --- src/gallium/auxiliary/util/u_math.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index b2969a210a..d1ec13def3 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -531,6 +531,17 @@ util_bswap32(uint32_t n) } +/** + * Reverse byte order of a 16 bit word. + */ +static INLINE uint16_t +util_bswap16(uint16_t n) +{ + return (n >> 8) | + (n << 8); +} + + /** * Clamp X to [MIN, MAX]. * This is a macro to allow float, int, uint, etc. types. -- cgit v1.2.3 From 4757325951e35460975e77d70dacf8b6eb10ab11 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 15:45:48 +0000 Subject: util: Factor some code into u_format_parse.py --- src/gallium/auxiliary/util/u_format_access.py | 20 +----- src/gallium/auxiliary/util/u_format_parse.py | 95 +++++++++++++++++++++++++-- src/gallium/auxiliary/util/u_format_table.py | 5 +- src/gallium/drivers/llvmpipe/lp_tile_soa.py | 4 +- 4 files changed, 96 insertions(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 267fb3fbbd..a7a91ea652 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -248,24 +248,6 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value): assert False -def compute_inverse_swizzle(format): - '''Return an array[4] of inverse swizzle terms''' - inv_swizzle = [None]*4 - if format.colorspace == 'rgb': - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - inv_swizzle[swizzle] = i - elif format.colorspace == 'zs': - swizzle = format.swizzles[0] - if swizzle < 4: - inv_swizzle[swizzle] = 0 - else: - assert False - - return inv_swizzle - - def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -372,7 +354,7 @@ def generate_format_write(format, src_channel, src_native_type, src_suffix): print ' const %s *src_pixel = src_row;' %src_native_type print ' for (x = 0; x < w; ++x) {' - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() if format.layout == PLAIN: if not format.is_array(): diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index edc6bba795..250926418e 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -36,19 +36,28 @@ SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, PLAIN = 'plain' +RGB = 'rgb' +SRGB = 'srgb' +YUV = 'yuv' +ZS = 'zs' + def is_pot(x): return (x & (x - 1)) == 0; +VERY_LARGE = 99999999999999999999999 + + class Channel: '''Describe the channel of a color channel.''' - def __init__(self, type, norm, size): + def __init__(self, type, norm, size, name = ''): self.type = type self.norm = norm self.size = size self.sign = type in (SIGNED, FIXED, FLOAT) + self.name = name def __str__(self): s = str(self.type) @@ -60,6 +69,30 @@ class Channel: def __eq__(self, other): return self.type == other.type and self.norm == other.norm and self.size == other.size + def max(self): + '''Maximum representable number.''' + if self.type == FLOAT: + return VERY_LARGE + if self.norm: + return 1 + if self.type == UNSIGNED: + return (1 << self.size) - 1 + if self.type == SIGNED: + return self.size - 1 + assert False + + def min(self): + '''Minimum representable number.''' + if self.type == FLOAT: + return -VERY_LARGE + if self.type == UNSIGNED: + return 0 + if self.norm: + return -1 + if self.type == SIGNED: + return -(1 << (self.size - 1)) + assert False + class Format: '''Describe a pixel format.''' @@ -132,6 +165,29 @@ class Format: return False return True + def is_bitmask(self): + if self.block_size() > 32: + return False + if not self.is_pot(): + return False + for channel in self.channels: + if not is_pot(channel.size): + return True + if channel.type not in (VOID, UNSIGNED, SIGNED): + return False + if channel.size >= 32: + return False + return True + + def inv_swizzles(self): + '''Return an array[4] of inverse swizzle terms''' + inv_swizzle = [None]*4 + for i in range(4): + swizzle = self.swizzles[i] + if swizzle < 4: + inv_swizzle[swizzle] = i + return inv_swizzle + def stride(self): return self.block_size()/8 @@ -171,12 +227,39 @@ def parse(filename): line = line.strip() if not line: continue + fields = [field.strip() for field in line.split(',')] + name = fields[0] layout = fields[1] block_width, block_height = map(int, fields[2:4]) + + swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] + colorspace = fields[9] + + if layout == PLAIN: + names = ['']*4 + if colorspace in (RGB, SRGB): + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'rgba'[i] + elif colorspace == ZS: + for i in range(4): + swizzle = swizzles[i] + if swizzle < 4: + names[swizzle] += 'zs'[i] + else: + assert False + for i in range(4): + if names[i] == '': + names[i] = 'x' + else: + names = ['x', 'y', 'z', 'w'] + channels = [] - for field in fields[4:8]: + for i in range(0, 4): + field = fields[4 + i] if field: type = _type_parse_map[field[0]] if field[1] == 'n': @@ -189,10 +272,10 @@ def parse(filename): type = VOID norm = False size = 0 - channel = Channel(type, norm, size) + channel = Channel(type, norm, size, names[i]) channels.append(channel) - swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]] - colorspace = fields[9] - formats.append(Format(name, layout, block_width, block_height, channels, swizzles, colorspace)) + + format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace) + formats.append(format) return formats diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index a7a4fd18a8..4e29d15f3b 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -117,7 +117,10 @@ def write_format_table(formats): sep = "," else: sep = "" - print " {%s, %s, %u}%s\t/* %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i]) + if channel.size: + print " {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name) + else: + print " {0, 0, 0}%s" % (sep,) print " }," print " {" for i in range(4): diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index 52d7d3186a..dc44d67d63 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -135,7 +135,7 @@ def pack_rgba(format, src_channel, r, g, b, a): given format. Ex: '(b << 24) | (g << 16) | (r << 8) | (a << 0)' """ assert format.colorspace == 'rgb' - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() shift = 0 expr = None for i in range(4): @@ -200,7 +200,7 @@ def emit_tile_pixel_write_code(format, src_channel): '''Emit code for writing a block based on the TILE_PIXEL macro.''' dst_native_type = native_type(format) - inv_swizzle = compute_inverse_swizzle(format) + inv_swizzle = format.inv_swizzles() print ' unsigned x, y;' print ' uint8_t *dst_row = dst + y0*dst_stride;' -- cgit v1.2.3 From 9beb302212a2afac408016cbd7b93c8b859e4910 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 16:45:22 +0000 Subject: util: Code generate functions to pack and unpack a single pixel. Should work correctly for all pixel formats except SRGB formats. Generated code made much simpler by defining the pixel format as a C structure. For example this is the generated structure for PIPE_FORMAT_B6UG5SR5S_NORM: union util_format_b6ug5sr5s_norm { uint16_t value; struct { int r:5; int g:5; unsigned b:6; } chan; }; Not used everywhere yet because it seems compiled code is slower than bitshift arithmetic by some misterious reason. So we should generate bitshift arithmetic at least for the simple UNORM pixel formats. --- src/gallium/auxiliary/Makefile | 5 + src/gallium/auxiliary/SConscript | 7 + src/gallium/auxiliary/util/.gitignore | 1 + src/gallium/auxiliary/util/u_format_access.py | 163 +-------- src/gallium/auxiliary/util/u_format_pack.py | 484 ++++++++++++++++++++++++++ src/gallium/drivers/llvmpipe/SConscript | 1 + src/gallium/drivers/llvmpipe/lp_tile_soa.py | 10 +- 7 files changed, 507 insertions(+), 164 deletions(-) create mode 100644 src/gallium/auxiliary/util/u_format_pack.py (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 2d41fb3dca..39e328f514 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -184,5 +184,10 @@ indices/u_unfilled_gen.c: indices/u_unfilled_gen.py util/u_format_table.c: util/u_format_table.py util/u_format_parse.py util/u_format.csv python util/u_format_table.py util/u_format.csv > $@ +util/u_format_pack.h: util/u_format_pack.py util/u_format_parse.py util/u_format.csv + python util/u_format_pack.py util/u_format.csv > $@ + util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv python util/u_format_access.py util/u_format.csv > $@ + +default: util/u_format_pack.h diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 8d2859fa71..47de50bf3e 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -28,6 +28,13 @@ env.CodeGenerate( command = 'python $SCRIPT $SOURCE > $TARGET' ) +env.CodeGenerate( + target = File('util/u_format_pack.h').srcnode(), + script = 'util/u_format_pack.py', + source = ['util/u_format.csv'], + command = 'python $SCRIPT $SOURCE > $TARGET' +) + env.CodeGenerate( target = 'util/u_format_access.c', script = 'util/u_format_access.py', diff --git a/src/gallium/auxiliary/util/.gitignore b/src/gallium/auxiliary/util/.gitignore index 29c586c9b5..448d2f304f 100644 --- a/src/gallium/auxiliary/util/.gitignore +++ b/src/gallium/auxiliary/util/.gitignore @@ -1,2 +1,3 @@ u_format_access.c u_format_table.c +u_format_pack.h diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index a7a91ea652..1c9be1b538 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -39,7 +39,7 @@ import sys -from u_format_parse import * +from u_format_pack import * def is_format_supported(format): @@ -94,160 +94,6 @@ def native_type(format): assert False -def intermediate_native_type(bits, sign): - '''Find a native type adequate to hold intermediate results of the request bit size.''' - - bytes = 4 # don't use anything smaller than 32bits - while bytes * 8 < bits: - bytes *= 2 - bits = bytes*8 - - if sign: - return 'int%u_t' % bits - else: - return 'uint%u_t' % bits - - -def get_one_shift(channel): - '''Get the number of the bit that matches unity for this channel.''' - if channel.type == 'FLOAT': - assert False - if not channel.norm: - return 0 - if channel.type == UNSIGNED: - return channel.size - if channel.type == SIGNED: - return channel.size - 1 - if channel.type == FIXED: - return channel.size / 2 - assert False - - -def get_one(channel): - '''Get the value of unity for this channel.''' - if channel.type == 'FLOAT' or not channel.norm: - return 1 - else: - return (1 << get_one_shift(channel)) - 1 - - -def generate_clamp(): - '''Code generate the clamping functions for each type. - - We don't use a macro so that arguments with side effects, - like *src_pixel++ are correctly handled. - ''' - - for suffix, native_type in [ - ('', 'double'), - ('f', 'float'), - ('ui', 'unsigned int'), - ('si', 'int'), - ]: - print 'static INLINE %s' % native_type - print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type) - print '{' - print ' if(value < lbound)' - print ' return lbound;' - print ' if(value > ubound)' - print ' return ubound;' - print ' return value;' - print '}' - print - - -def clamp_expr(src_channel, dst_channel, dst_native_type, value): - '''Generate the expression to clamp the value in the source type to the - destination type range.''' - - if src_channel == dst_channel: - return value - - # Pick the approriate clamp function - if src_channel.type == FLOAT: - if src_channel.size == 32: - func = 'clampf' - elif src_channel.size == 64: - func = 'clamp' - else: - assert False - elif src_channel.type == UNSIGNED: - func = 'clampui' - elif src_channel.type == SIGNED: - func = 'clampsi' - else: - assert False - - # Clamp floats to [-1, 1] or [0, 1] range - if src_channel.type == FLOAT and dst_channel.norm: - max = 1 - if src_channel.sign and dst_channel.sign: - min = -1 - else: - min = 0 - return '%s(%s, %s, %s)' % (func, value, min, max) - - # FIXME: Also clamp scaled values - - return value - - -def conversion_expr(src_channel, dst_channel, dst_native_type, value): - '''Generate the expression to convert a value between two types.''' - - if src_channel == dst_channel: - return value - - if src_channel.type == FLOAT and dst_channel.type == FLOAT: - return '(%s)%s' % (dst_native_type, value) - - if not src_channel.norm and not dst_channel.norm: - return '(%s)%s' % (dst_native_type, value) - - value = clamp_expr(src_channel, dst_channel, dst_native_type, value) - - if dst_channel.type == FLOAT: - if src_channel.norm: - one = get_one(src_channel) - if src_channel.size <= 23: - scale = '(1.0f/0x%x)' % one - else: - # bigger than single precision mantissa, use double - scale = '(1.0/0x%x)' % one - value = '(%s * %s)' % (value, scale) - return '(%s)%s' % (dst_native_type, value) - - if src_channel.type == FLOAT: - if dst_channel.norm: - dst_one = get_one(dst_channel) - if dst_channel.size <= 23: - scale = '0x%x' % dst_one - else: - # bigger than single precision mantissa, use double - scale = '(double)0x%x' % dst_one - value = '(%s * %s)' % (value, scale) - return '(%s)%s' % (dst_native_type, value) - - if src_channel.type == dst_channel.type: - src_one = get_one(src_channel) - dst_one = get_one(dst_channel) - - if src_one > dst_one and src_channel.norm and dst_channel.norm: - # We can just bitshift - src_shift = get_one_shift(src_channel) - dst_shift = get_one_shift(dst_channel) - value = '(%s >> %s)' % (value, src_shift - dst_shift) - else: - # We need to rescale using an intermediate type big enough to hold the multiplication of both - tmp_native_type = intermediate_native_type(src_channel.size + dst_channel.size, src_channel.sign and dst_channel.sign) - value = '(%s)%s' % (tmp_native_type, value) - value = '%s * 0x%x / 0x%x' % (value, dst_one, src_one) - value = '(%s)%s' % (dst_native_type, value) - return value - - assert False - - def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -302,9 +148,10 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): for i in range(4): src_channel = format.channels[i] if names[i]: - value = '(*src_pixel++)' + value = 'src_pixel[%u]' % i value = conversion_expr(src_channel, dst_channel, dst_native_type, value) print ' %s %s = %s;' % (dst_native_type, names[i], value) + print ' src_pixel += %u;' % (format.nr_channels()) else: assert False @@ -454,12 +301,10 @@ def main(): print __doc__.strip() print print '#include "pipe/p_compiler.h"' - print '#include "u_format.h"' print '#include "u_math.h"' + print '#include "u_format_pack.h"' print - generate_clamp() - type = Channel(FLOAT, False, 32) native_type = 'float' suffix = '4f' diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py new file mode 100644 index 0000000000..3f33f7cc02 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -0,0 +1,484 @@ +#!/usr/bin/env python + +''' +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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 + * Pixel format packing and unpacking functions. + * + * @author Jose Fonseca + */ +''' + + +import sys + +from u_format_parse import * + + +def generate_format_type(format): + '''Generate a structure that describes the format.''' + + print 'union util_format_%s {' % format.short_name() + if format.is_bitmask(): + print ' uint%u_t value;' % (format.block_size(),) + print ' struct {' + for channel in format.channels: + if format.is_bitmask() and not format.is_array(): + if channel.type == VOID: + if channel.size: + print ' unsigned %s:%u;' % (channel.name, channel.size) + elif channel.type == UNSIGNED: + print ' unsigned %s:%u;' % (channel.name, channel.size) + elif channel.type == SIGNED: + print ' int %s:%u;' % (channel.name, channel.size) + else: + assert 0 + else: + assert channel.size % 8 == 0 and is_pot(channel.size) + if channel.type == VOID: + if channel.size: + print ' uint%u_t %s;' % (channel.size, channel.name) + elif channel.type == UNSIGNED: + print ' uint%u_t %s;' % (channel.size, channel.name) + elif channel.type in (SIGNED, FIXED): + print ' int%u_t %s;' % (channel.size, channel.name) + elif channel.type == FLOAT: + if channel.size == 64: + print ' double %s;' % (channel.name) + elif channel.size == 32: + print ' float %s;' % (channel.name) + elif channel.size == 16: + print ' uint16_t %s;' % (channel.name) + else: + assert 0 + else: + assert 0 + print ' } chan;' + print '};' + print + + +def bswap_format(format): + '''Generate a structure that describes the format.''' + + if format.is_bitmask() and not format.is_array(): + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' pixel.value = util_bswap%u(pixel.value);' % format.block_size() + print '#endif' + + +def is_format_supported(format): + '''Determines whether we actually have the plumbing necessary to generate the + to read/write to/from this format.''' + + # FIXME: Ideally we would support any format combination here. + + if format.layout != PLAIN: + return False + + for i in range(4): + channel = format.channels[i] + if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT): + return False + + # We can only read a color from a depth/stencil format if the depth channel is present + if format.colorspace == 'zs' and format.swizzles[0] == SWIZZLE_NONE: + return False + + return True + + +def native_type(format): + '''Get the native appropriate for a format.''' + + if format.layout == PLAIN: + if not format.is_array(): + # For arithmetic pixel formats return the integer type that matches the whole pixel + return 'uint%u_t' % format.block_size() + else: + # For array pixel formats return the integer type that matches the color channel + type = format.channels[0] + if type.type == UNSIGNED: + return 'uint%u_t' % type.size + elif type.type == SIGNED: + return 'int%u_t' % type.size + elif type.type == FLOAT: + if type.size == 32: + return 'float' + elif type.size == 64: + return 'double' + else: + assert False + else: + assert False + else: + assert False + + +def intermediate_native_type(bits, sign): + '''Find a native type adequate to hold intermediate results of the request bit size.''' + + bytes = 4 # don't use anything smaller than 32bits + while bytes * 8 < bits: + bytes *= 2 + bits = bytes*8 + + if sign: + return 'int%u_t' % bits + else: + return 'uint%u_t' % bits + + +def get_one_shift(type): + '''Get the number of the bit that matches unity for this type.''' + if type.type == 'FLOAT': + assert False + if not type.norm: + return 0 + if type.type == UNSIGNED: + return type.size + if type.type == SIGNED: + return type.size - 1 + if type.type == FIXED: + return type.size / 2 + assert False + + +def get_one(type): + '''Get the value of unity for this type.''' + if type.type == 'FLOAT' or not type.norm: + return 1 + else: + return (1 << get_one_shift(type)) - 1 + + +def generate_clamp(): + '''Code generate the clamping functions for each type. + + We don't use a macro so that arguments with side effects, + like *src_pixel++ are correctly handled. + ''' + + for suffix, native_type in [ + ('', 'double'), + ('f', 'float'), + ('ui', 'unsigned int'), + ('si', 'int'), + ]: + print 'static INLINE %s' % native_type + print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type) + print '{' + print ' if(value < lbound)' + print ' return lbound;' + print ' if(value > ubound)' + print ' return ubound;' + print ' return value;' + print '}' + print + + +def clamp_expr(src_channel, dst_channel, dst_native_type, value): + '''Generate the expression to clamp the value in the source type to the + destination type range.''' + + if src_channel == dst_channel: + return value + + # Pick the approriate clamp function + if src_channel.type == FLOAT: + if src_channel.size == 32: + func = 'clampf' + elif src_channel.size == 64: + func = 'clamp' + else: + assert False + elif src_channel.type == UNSIGNED: + func = 'clampui' + elif src_channel.type == SIGNED: + func = 'clampsi' + else: + assert False + + src_min = src_channel.min() + src_max = src_channel.max() + dst_min = dst_channel.min() + dst_max = dst_channel.max() + + if src_min < dst_min and src_max > dst_max: + return 'CLAMP(%s, %s, %s)' % (value, dst_min, dst_max) + + if src_max > dst_max: + return 'MIN2(%s, %s)' % (value, dst_max) + + if src_min < dst_min: + return 'MAX2(%s, %s)' % (value, dst_min) + + return value + + +def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True): + '''Generate the expression to convert a value between two types.''' + + if src_channel == dst_channel: + return value + + if src_channel.type == FLOAT and dst_channel.type == FLOAT: + return '(%s)%s' % (dst_native_type, value) + + if not src_channel.norm and not dst_channel.norm: + return '(%s)%s' % (dst_native_type, value) + + if clamp: + value = clamp_expr(src_channel, dst_channel, dst_native_type, value) + + if dst_channel.type == FLOAT: + if src_channel.norm: + one = get_one(src_channel) + if src_channel.size <= 23: + scale = '(1.0f/0x%x)' % one + else: + # bigger than single precision mantissa, use double + scale = '(1.0/0x%x)' % one + value = '(%s * %s)' % (value, scale) + return '(%s)%s' % (dst_native_type, value) + + if src_channel.type == FLOAT: + if dst_channel.norm: + dst_one = get_one(dst_channel) + if dst_channel.size <= 23: + scale = '0x%x' % dst_one + else: + # bigger than single precision mantissa, use double + scale = '(double)0x%x' % dst_one + value = '(%s * %s)' % (value, scale) + return '(%s)%s' % (dst_native_type, value) + + if not src_channel.norm and not dst_channel.norm: + # neither is normalized -- just cast + return '(%s)%s' % (dst_native_type, value) + + if src_channel.type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED): + src_one = get_one(src_channel) + dst_one = get_one(dst_channel) + + if src_one > dst_one and src_channel.norm: + # We can just bitshift + src_shift = get_one_shift(src_channel) + dst_shift = get_one_shift(dst_channel) + value = '(%s >> %s)' % (value, src_shift - dst_shift) + else: + # We need to rescale using an intermediate type big enough to hold the multiplication of both + tmp_native_type = intermediate_native_type(src_channel.size + dst_channel.size, src_channel.sign and dst_channel.sign) + value = '(%s)%s' % (tmp_native_type, value) + value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one) + value = '(%s)%s' % (dst_native_type, value) + return value + + assert False + + +def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): + '''Generate the function to unpack pixels from a particular format''' + + name = format.short_name() + + src_native_type = native_type(format) + + print 'static INLINE void' + print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type) + print '{' + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + bswap_format(format) + + assert format.layout == PLAIN + + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + print '}' + print + + +def generate_format_pack(format, src_channel, src_native_type, src_suffix): + '''Generate the function to pack pixels to a particular format''' + + name = format.short_name() + + dst_native_type = native_type(format) + + print 'static INLINE void' + print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type) + print '{' + print ' union util_format_%s pixel;' % format.short_name() + + assert format.layout == PLAIN + + inv_swizzle = format.inv_swizzles() + + for i in range(4): + dst_channel = format.channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue + value = 'rgba'[inv_swizzle[i]] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = '0' + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + + bswap_format(format) + print ' memcpy(dst, &pixel, sizeof pixel);' + print '}' + print + + +def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix): + '''Generate the dispatch function to unpack pixels from any format''' + + for format in formats: + if is_format_supported(format): + generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix) + + print 'static INLINE void' + print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type) + print '{' + print ' void (*func)(%s *dst, const void *src);' % dst_native_type + print ' switch(format) {' + for format in formats: + if is_format_supported(format): + print ' case %s:' % format.name + print ' func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix) + print ' break;' + print ' default:' + print ' debug_printf("unsupported format\\n");' + print ' return;' + print ' }' + print ' func(dst, src);' + print '}' + print + + +def generate_pack(formats, src_channel, src_native_type, src_suffix): + '''Generate the dispatch function to pack pixels to any format''' + + for format in formats: + if is_format_supported(format): + generate_format_pack(format, src_channel, src_native_type, src_suffix) + + print 'static INLINE void' + print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type) + print '{' + print ' void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type) + print ' switch(format) {' + for format in formats: + if is_format_supported(format): + print ' case %s:' % format.name + print ' func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix) + print ' break;' + print ' default:' + print ' debug_printf("%s: unsupported format\\n", __FUNCTION__);' + print ' return;' + print ' }' + print ' func(dst, r, g, b, a);' + print '}' + print + + +def main(): + formats = [] + for arg in sys.argv[1:]: + formats.extend(parse(arg)) + + print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */' + print + # This will print the copyright message on the top of this file + print __doc__.strip() + + print + print '#ifndef U_FORMAT_PACK_H' + print '#define U_FORMAT_PACK_H' + print + print '#include "pipe/p_compiler.h"' + print '#include "u_math.h"' + print '#include "u_format.h"' + print + + generate_clamp() + + for format in formats: + if format.layout == PLAIN: + generate_format_type(format) + + channel = Channel(FLOAT, False, 32) + native_type = 'float' + suffix = '4f' + + generate_unpack(formats, channel, native_type, suffix) + generate_pack(formats, channel, native_type, suffix) + + channel = Channel(UNSIGNED, True, 8) + native_type = 'uint8_t' + suffix = '4ub' + + generate_unpack(formats, channel, native_type, suffix) + generate_pack(formats, channel, native_type, suffix) + + print + print '#ifdef __cplusplus' + print '}' + print '#endif' + print + print '#endif /* ! U_FORMAT_PACK_H */' + + +if __name__ == '__main__': + main() diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 71f9337422..13c1a13e87 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -21,6 +21,7 @@ env.CodeGenerate( # XXX: Our dependency scanner only finds depended modules in relative dirs. env.Depends('lp_tile_soa.c', [ '#src/gallium/auxiliary/util/u_format_parse.py', + '#src/gallium/auxiliary/util/u_format_pack.py', '#src/gallium/auxiliary/util/u_format_access.py', ]) diff --git a/src/gallium/drivers/llvmpipe/lp_tile_soa.py b/src/gallium/drivers/llvmpipe/lp_tile_soa.py index dc44d67d63..00b8d4fc38 100644 --- a/src/gallium/drivers/llvmpipe/lp_tile_soa.py +++ b/src/gallium/drivers/llvmpipe/lp_tile_soa.py @@ -90,7 +90,7 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): value = '(%s >> %u)' % (value, shift) if shift + width < format.block_size(): value = '(%s & 0x%x)' % (value, mask) - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) print ' %s %s = %s;' % (dst_native_type, names[i], value) shift += width else: @@ -98,7 +98,7 @@ def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): src_channel = format.channels[i] if names[i]: value = '(*src_pixel++)' - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) print ' %s %s = %s;' % (dst_native_type, names[i], value) else: assert False @@ -154,7 +154,7 @@ def pack_rgba(format, src_channel, r, g, b, a): if value: dst_channel = format.channels[i] dst_native_type = native_type(format) - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) term = "((%s) << %d)" % (value, shift) if expr: expr = expr + " | " + term @@ -217,7 +217,7 @@ def emit_tile_pixel_write_code(format, src_channel): width = dst_channel.size if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) if shift: value = '(%s << %u)' % (value, shift) print ' pixel |= %s;' % value @@ -228,7 +228,7 @@ def emit_tile_pixel_write_code(format, src_channel): dst_channel = format.channels[i] if inv_swizzle[i] is not None: value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False) print ' *dst_pixel++ = %s;' % value else: assert False -- cgit v1.2.3 From c78f84eebb3943e7a2a1eed262d85d2f67f79beb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 26 Feb 2010 16:46:09 +0000 Subject: util: Define SRGB's channels as normalized. A better approximation than uscaled... --- src/gallium/auxiliary/util/u_format.csv | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 50341e9752..b2ee247a6c 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -16,15 +16,15 @@ PIPE_FORMAT_A8L8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, r PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb # SRGB formats -PIPE_FORMAT_L8_SRGB , plain, 1, 1, u8 , , , , xxx1, srgb -PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, u8 , u8 , , , xxxy, srgb -PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , , zyx1, srgb -PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , wzyx, srgb -PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , wzy1, srgb -PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , zyxw, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , zyx1, srgb -PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , yzwx, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, u8 , u8 , u8 , u8 , yzw1, srgb +PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb +PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb +PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , zyx1, srgb +PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb +PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb # Signed formats (typically used for bump map textures) PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb -- cgit v1.2.3 From 549ce307849f9d2d3d73a8e6c6a24a95416b06c1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:43:04 -0700 Subject: gallium/identity: remove unneeded path prefixes on #includes --- src/gallium/drivers/identity/id_drm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_drm.c b/src/gallium/drivers/identity/id_drm.c index b89724e4f3..f258c38cd7 100644 --- a/src/gallium/drivers/identity/id_drm.c +++ b/src/gallium/drivers/identity/id_drm.c @@ -28,11 +28,11 @@ #include "state_tracker/drm_api.h" #include "util/u_memory.h" -#include "identity/id_drm.h" -#include "identity/id_screen.h" -#include "identity/id_public.h" -#include "identity/id_screen.h" -#include "identity/id_objects.h" +#include "id_drm.h" +#include "id_screen.h" +#include "id_public.h" +#include "id_screen.h" +#include "id_objects.h" struct identity_drm_api { -- cgit v1.2.3 From 3f9ec9aa96406356b1224c6926e263cb626b5c67 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:43:19 -0700 Subject: gallium/trace: remove unneeded path prefixes on #includes --- src/gallium/drivers/trace/tr_drm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index b8adde77f1..2b4915003e 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -28,11 +28,11 @@ #include "state_tracker/drm_api.h" #include "util/u_memory.h" -#include "trace/tr_drm.h" -#include "trace/tr_screen.h" -#include "trace/tr_context.h" -#include "trace/tr_buffer.h" -#include "trace/tr_texture.h" +#include "tr_drm.h" +#include "tr_screen.h" +#include "tr_context.h" +#include "tr_buffer.h" +#include "tr_texture.h" struct trace_drm_api { -- cgit v1.2.3 From 298a0352862e748078c7c56acd2cfc96c67373d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:43:56 -0700 Subject: softpipe: fix up #includes --- src/gallium/drivers/softpipe/sp_video_context.c | 8 +++++--- src/gallium/drivers/softpipe/sp_winsys.c | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c index 7a3a636167..272ad40a90 100644 --- a/src/gallium/drivers/softpipe/sp_video_context.c +++ b/src/gallium/drivers/softpipe/sp_video_context.c @@ -25,10 +25,12 @@ * **************************************************************************/ +#include "util/u_inlines.h" +#include "util/u_memory.h" + #include "sp_video_context.h" -#include -#include -#include "softpipe/sp_texture.h" +#include "sp_texture.h" + static void sp_mpeg12_destroy(struct pipe_video_context *vpipe) diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c index f6598927d3..0a6245ed2c 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.c +++ b/src/gallium/drivers/softpipe/sp_winsys.c @@ -37,13 +37,13 @@ #include "util/u_simple_screen.h"/* port to just p_screen */ -#include "pipe/p_format.h" -#include "pipe/p_context.h" #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_inlines.h" -#include "softpipe/sp_winsys.h" +#include "pipe/p_format.h" +#include "pipe/p_context.h" +#include "sp_winsys.h" struct st_softpipe_buffer -- cgit v1.2.3 From d9c65ddd52199469c49fc0d3ad90fedb9a69274d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:44:41 -0700 Subject: gallium: remove unneeded -I path from Makefile.templast --- src/gallium/Makefile.template | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 713e192a4e..6b7c7c80a7 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -20,7 +20,6 @@ INCLUDES = \ -I. \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ - -I$(TOP)/src/gallium/drivers \ $(LIBRARY_INCLUDES) -- cgit v1.2.3 From 5ed444a7a4e8f74100a3678c007ac120e8569229 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:54:05 -0700 Subject: gallium/nouveau: clean-up #includes --- src/gallium/drivers/nouveau/nouveau_context.c | 4 ++-- src/gallium/drivers/nouveau/nouveau_screen.c | 10 +++++----- src/gallium/drivers/nv30/nv30_transfer.c | 14 +++++++------- src/gallium/drivers/nv40/nv40_screen.h | 2 +- src/gallium/drivers/nv40/nv40_transfer.c | 14 +++++++------- 5 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c index 23443869e6..15174983e7 100644 --- a/src/gallium/drivers/nouveau/nouveau_context.c +++ b/src/gallium/drivers/nouveau/nouveau_context.c @@ -1,5 +1,5 @@ -#include -#include +#include "pipe/p_defines.h" +#include "pipe/p_context.h" #include "nouveau/nouveau_screen.h" #include "nouveau/nouveau_context.h" diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 81bc296ab4..3c2f771b51 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -1,9 +1,9 @@ -#include -#include -#include +#include "pipe/p_defines.h" +#include "pipe/p_screen.h" +#include "pipe/p_state.h" -#include -#include +#include "util/u_memory.h" +#include "util/u_inlines.h" #include #include diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c index 554bcbbdd0..3aeda51ea1 100644 --- a/src/gallium/drivers/nv30/nv30_transfer.c +++ b/src/gallium/drivers/nv30/nv30_transfer.c @@ -1,10 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_memory.h" +#include "util/u_math.h" +#include "nouveau/nouveau_winsys.h" #include "nv30_context.h" #include "nv30_screen.h" #include "nv30_state.h" diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h index 9437aa050d..10a952c1fd 100644 --- a/src/gallium/drivers/nv40/nv40_screen.h +++ b/src/gallium/drivers/nv40/nv40_screen.h @@ -2,7 +2,7 @@ #define __NV40_SCREEN_H__ #include "nouveau/nouveau_screen.h" -#include "nouveau/nv04_surface_2d.h" +#include "nouveau/nv40_surface_2d.h" struct nv40_screen { struct nouveau_screen base; diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c index ee266c6cfb..0462a042c3 100644 --- a/src/gallium/drivers/nv40/nv40_transfer.c +++ b/src/gallium/drivers/nv40/nv40_transfer.c @@ -1,10 +1,10 @@ -#include -#include -#include -#include -#include -#include -#include +#include "pipe/p_state.h" +#include "pipe/p_defines.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_memory.h" +#include "util/u_math.h" +#include "nouveau/nouveau_winsys.h" #include "nv40_context.h" #include "nv40_screen.h" #include "nv40_state.h" -- cgit v1.2.3 From ac56a44d5ee08ebfe2310113c6a04d2bc0f90e26 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 10:54:20 -0700 Subject: Revert "gallium: remove unneeded -I path from Makefile.templast" This reverts commit d9c65ddd52199469c49fc0d3ad90fedb9a69274d. Looks like the nouveau drivers need this. Perhaps the drivers could be fixed to add the extra -I path where needed. I'll leave that up to others. --- src/gallium/Makefile.template | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 6b7c7c80a7..713e192a4e 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -20,6 +20,7 @@ INCLUDES = \ -I. \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ + -I$(TOP)/src/gallium/drivers \ $(LIBRARY_INCLUDES) -- cgit v1.2.3 From f89c237c2c35eb3ea554e8f9de036e9ead08173f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 11:58:05 -0700 Subject: gallium: added GENERATED_SOURCES var to Makefile.template For use in dependency checking and make clean. --- src/gallium/Makefile.template | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/Makefile.template b/src/gallium/Makefile.template index 713e192a4e..91a9b54b36 100644 --- a/src/gallium/Makefile.template +++ b/src/gallium/Makefile.template @@ -31,10 +31,10 @@ default: depend lib$(LIBNAME).a lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template $(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS) -depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) +depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES) rm -f depend touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) 2> /dev/null + $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(GENERATED_SOURCES) 2> /dev/null # Emacs tags tags: @@ -42,7 +42,7 @@ tags: # Remove .o and backup files clean: - rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak + rm -f $(OBJECTS) $(GENERATED_SOURCES) lib$(LIBNAME).a depend depend.bak # Dummy target install: -- cgit v1.2.3 From f519d3d6b649780cc557159f783c330c2a70f93b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 11:58:54 -0700 Subject: gallium: define GENERATED auxiliary files Don't need special default dependency on u_format_pack.h anymore. --- src/gallium/auxiliary/Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 39e328f514..60f9c2ae3c 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -160,6 +160,13 @@ GALLIVM_SOURCES = \ GALLIVM_CPP_SOURCES = \ gallivm/lp_bld_misc.cpp +GENERATED_SOURCES = \ + indices/u_indices_gen.c \ + indices/u_unfilled_gen.c \ + util/u_format_access.c \ + util/u_format_pack.h \ + util/u_format_table.c + ifeq ($(MESA_LLVM),1) C_SOURCES += \ @@ -190,4 +197,3 @@ util/u_format_pack.h: util/u_format_pack.py util/u_format_parse.py util/u_format util/u_format_access.c: util/u_format_access.py util/u_format_parse.py util/u_format.csv python util/u_format_access.py util/u_format.csv > $@ -default: util/u_format_pack.h -- cgit v1.2.3 From d1fe9bcc3f07a73b3122851731d5081580d8bb8f Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Fri, 26 Feb 2010 21:11:07 +0100 Subject: nv40: fix include of nv04_surface_2d.h --- src/gallium/drivers/nv40/nv40_screen.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h index 10a952c1fd..9437aa050d 100644 --- a/src/gallium/drivers/nv40/nv40_screen.h +++ b/src/gallium/drivers/nv40/nv40_screen.h @@ -2,7 +2,7 @@ #define __NV40_SCREEN_H__ #include "nouveau/nouveau_screen.h" -#include "nouveau/nv40_surface_2d.h" +#include "nouveau/nv04_surface_2d.h" struct nv40_screen { struct nouveau_screen base; -- cgit v1.2.3 From 4fd43b09224c0e3b37de54e24508dcea5cd50dd8 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Tue, 9 Feb 2010 22:54:15 +0100 Subject: vmware: Update vmwgfx_drm.h to kernel version. Signed-off-by: Thomas Hellstrom --- src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h index 1457966db8..47914bdb71 100644 --- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h +++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h @@ -260,15 +260,23 @@ union drm_vmw_surface_reference_arg { * to the nearest kernel tick. * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an * uint64_t. + * @version: Allows expanding the execbuf ioctl parameters without breaking + * backwards compatibility, since user-space will always tell the kernel + * which version it uses. + * @flags: Execbuf flags. None currently. * * Argument to the DRM_VMW_EXECBUF Ioctl. */ +#define DRM_VMW_EXECBUF_VERSION 0 + struct drm_vmw_execbuf_arg { uint64_t commands; uint32_t command_size; uint32_t throttle_us; uint64_t fence_rep; + uint32_t version; + uint32_t flags; }; /** -- cgit v1.2.3 From 0a1b760cd274aff96d68757dabf9caa077119f37 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Mon, 15 Feb 2010 14:24:51 +0100 Subject: st/xorg, vmware/xorg: Fix xnfcalloc arguments. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- src/gallium/winsys/drm/vmware/xorg/vmw_screen.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index f53a879a14..90b8b8b465 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -155,7 +155,7 @@ drv_get_rec(ScrnInfoPtr pScrn) if (pScrn->driverPrivate) return TRUE; - pScrn->driverPrivate = xnfcalloc(sizeof(modesettingRec), 1); + pScrn->driverPrivate = xnfcalloc(1, sizeof(modesettingRec)); return TRUE; } diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c index 7c9757cce9..0d255d2726 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c @@ -87,7 +87,7 @@ vmw_screen_init(ScrnInfoPtr pScrn) modesettingPtr ms = modesettingPTR(pScrn); struct vmw_driver *vmw; - vmw = xnfcalloc(sizeof(*vmw), 1); + vmw = xnfcalloc(1, sizeof(*vmw)); if (!vmw) return FALSE; -- cgit v1.2.3 From d11f9a7bd83b7f0ea9ee959a764b77a4c3c55969 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 11 Feb 2010 14:41:40 +0100 Subject: drm/vmware: Latest interface changes are backwards incopatible Since the execbuffer change actually changed size off the ioctl struct and not just a reuse of padded bits, we can't support old kernels as easily as the scanout change was. --- src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index 1dcbc419db..a7c6e88b9e 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -49,7 +49,7 @@ static struct dri1_api_version ddx_required = { 0, 1, 0 }; static struct dri1_api_version ddx_compat = { 0, 0, 0 }; static struct dri1_api_version dri_required = { 4, 0, 0 }; static struct dri1_api_version dri_compat = { 4, 0, 0 }; -static struct dri1_api_version drm_required = { 0, 1, 0 }; +static struct dri1_api_version drm_required = { 1, 0, 0 }; static struct dri1_api_version drm_compat = { 1, 0, 0 }; static struct dri1_api_version drm_scanout = { 0, 9, 0 }; -- cgit v1.2.3 From 1eb5b42097fe2cf6e9d87db72dc004379e424101 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Feb 2010 15:51:59 +0100 Subject: st/xorg: Make default of debugging fallbacks smart Set it to the same as 2d acceleration --- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 90b8b8b465..ad4f38f450 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -673,7 +673,7 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); ms->accelerate_2d = xf86ReturnOptValBool(ms->Options, OPTION_2D_ACCEL, FALSE); - ms->debug_fallback = xf86ReturnOptValBool(ms->Options, OPTION_DEBUG_FALLBACK, TRUE); + ms->debug_fallback = xf86ReturnOptValBool(ms->Options, OPTION_DEBUG_FALLBACK, ms->accelerate_2d); if (ms->screen) { ms->exa = xorg_exa_init(pScrn, ms->accelerate_2d); -- cgit v1.2.3 From dfe0cc4b021572bd4646630cf9faec2492cbf416 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Feb 2010 15:53:42 +0100 Subject: st/xorg: A bit more debugging info --- src/gallium/state_trackers/xorg/xorg_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index ad4f38f450..b92f643bff 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -684,6 +684,11 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #endif } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "##################################\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "# Usefull debugging info follows #\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "##################################\n"); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %s backend\n", + ms->screen ? "Gallium3D" : "libkms"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "2D Acceleration is %s\n", ms->screen && ms->accelerate_2d ? "enabled" : "disabled"); xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fallback debugging is %s\n", @@ -694,6 +699,7 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) #else xf86DrvMsg(pScrn->scrnIndex, X_INFO, "3D Acceleration is disabled\n"); #endif + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "##################################\n"); miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); -- cgit v1.2.3 From ab8a232b2cad965501e3778219e957509a078757 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 18 Feb 2010 16:02:03 +0100 Subject: vmware/xorg: Export modinfo just as the other vmware X drivers does --- src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c | 45 +++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c index cd273d091f..bc5d39f749 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c @@ -33,12 +33,50 @@ #include "vmw_hook.h" + +/* + * Defines and modinfo + */ + +#define VMWGFX_DRIVER_NAME "vmwgfx" + +#define VMW_STRING_INNER(s) #s +#define VMW_STRING(str) VMW_STRING_INNER(str) + +#define VMWGFX_VERSION_MAJOR 10 +#define VMWGFX_VERSION_MINOR 16 +#define VMWGFX_VERSION_PATCH 9 +#define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR) +#define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR) +#define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH) + +#define VMWGFX_DRIVER_VERSION \ + (VMWGFX_VERSION_MAJOR * 65536 + VMWGFX_VERSION_MINOR * 256 + VMWGFX_VERSION_PATCH) +#define VMWGFX_DRIVER_VERSION_STRING \ + VMWGFX_VERSION_STRING_MAJOR "." VMWGFX_VERSION_STRING_MINOR \ + "." VMWGFX_VERSION_STRING_PATCH + +/* + * Standard four digit version string expected by VMware Tools installer. + * As the driver's version is only {major, minor, patchlevel}, simply append an + * extra zero for the fourth digit. + */ +#ifdef __GNUC__ +_X_EXPORT const char vmwgfx_drv_modinfo[] __attribute__((section(".modinfo"),unused)) = + "version=" VMWGFX_DRIVER_VERSION_STRING ".0"; +#endif + static void vmw_xorg_identify(int flags); _X_EXPORT Bool vmw_xorg_pci_probe(DriverPtr driver, int entity_num, struct pci_device *device, intptr_t match_data); + +/* + * Tables + */ + static const struct pci_id_match vmw_xorg_device_match[] = { {0x15ad, PCI_MATCH_ANY, PCI_MATCH_ANY, PCI_MATCH_ANY, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0}, @@ -55,12 +93,12 @@ static PciChipsets vmw_xorg_pci_devices[] = { }; static XF86ModuleVersionInfo vmw_xorg_version = { - "vmwgfx", + VMWGFX_DRIVER_NAME, MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, XORG_VERSION_CURRENT, - 0, 1, 0, /* major, minor, patch */ + VMWGFX_VERSION_MAJOR, VMWGFX_VERSION_MINOR, VMWGFX_VERSION_PATCH, ABI_CLASS_VIDEODRV, ABI_VIDEODRV_VERSION, MOD_CLASS_VIDEODRV, @@ -73,7 +111,7 @@ static XF86ModuleVersionInfo vmw_xorg_version = { _X_EXPORT DriverRec vmwgfx = { 1, - "vmwgfx", + VMWGFX_DRIVER_NAME, vmw_xorg_identify, NULL, xorg_tracker_available_options, @@ -92,6 +130,7 @@ _X_EXPORT XF86ModuleData vmwgfxModuleData = { NULL }; + /* * Xorg driver functions */ -- cgit v1.2.3 From 55e5737bae6b88c2d1bc4c0d94e11548518659b8 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Mon, 15 Feb 2010 14:10:19 +0100 Subject: st/xorg: Encapsulate all customizable stuff in a separate class. This avoids exposing the ms driver structure to the winsys, and nicely encapsulates driver customizable stuff. In the future more things might be customizable by the winsys, like throttling, 3D readback etc. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/xorg/xorg_driver.c | 35 +++++++++--- src/gallium/state_trackers/xorg/xorg_tracker.h | 18 ++++--- src/gallium/winsys/drm/vmware/xorg/vmw_driver.h | 36 +++++++------ src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c | 20 +++---- src/gallium/winsys/drm/vmware/xorg/vmw_screen.c | 72 ++++++++++++------------- src/gallium/winsys/drm/vmware/xorg/vmw_video.c | 31 ++++++----- 6 files changed, 121 insertions(+), 91 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index b92f643bff..5397ee777a 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -333,6 +333,7 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) EntityInfoPtr pEnt; EntPtr msEnt = NULL; int max_width, max_height; + CustomizerPtr cust; if (pScrn->numEntities != 1) return FALSE; @@ -344,6 +345,9 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) return TRUE; } + cust = (CustomizerPtr) pScrn->driverPrivate; + pScrn->driverPrivate = NULL; + /* Allocate driverPrivate */ if (!drv_get_rec(pScrn)) return FALSE; @@ -351,6 +355,7 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) ms = modesettingPTR(pScrn); ms->SaveGeneration = -1; ms->pEnt = pEnt; + ms->cust = cust; pScrn->displayWidth = 640; /* default it */ @@ -608,6 +613,7 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; + CustomizerPtr cust = ms->cust; if (!drv_init_drm(pScrn)) { FatalError("Could not init DRM"); @@ -731,8 +737,8 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (serverGeneration == 1) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); - if (ms->winsys_screen_init) - ms->winsys_screen_init(pScrn); + if (cust && cust->winsys_screen_init) + cust->winsys_screen_init(cust, ms->fd); return drv_enter_vt(scrnIndex, 1); } @@ -765,10 +771,11 @@ drv_leave_vt(int scrnIndex, int flags) ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + CustomizerPtr cust = ms->cust; int o; - if (ms->winsys_leave_vt) - ms->winsys_leave_vt(pScrn); + if (cust && cust->winsys_leave_vt) + cust->winsys_leave_vt(cust); for (o = 0; o < config->num_crtc; o++) { xf86CrtcPtr crtc = config->crtc[o]; @@ -802,6 +809,7 @@ drv_enter_vt(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); + CustomizerPtr cust = ms->cust; if (drmSetMaster(ms->fd)) { if (errno == EINVAL) { @@ -832,8 +840,8 @@ drv_enter_vt(int scrnIndex, int flags) if (!xf86SetDesiredModes(pScrn)) return FALSE; - if (ms->winsys_enter_vt) - ms->winsys_enter_vt(pScrn); + if (cust && cust->winsys_enter_vt) + cust->winsys_enter_vt(cust); return TRUE; } @@ -851,13 +859,14 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; modesettingPtr ms = modesettingPTR(pScrn); + CustomizerPtr cust = ms->cust; if (pScrn->vtSema) { drv_leave_vt(scrnIndex, 0); } - if (ms->winsys_screen_close) - ms->winsys_screen_close(pScrn); + if (cust && cust->winsys_screen_close) + cust->winsys_screen_close(cust); #ifdef DRI2 if (ms->screen) @@ -1119,4 +1128,14 @@ static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn) return TRUE; } +CustomizerPtr xorg_customizer(ScrnInfoPtr pScrn) +{ + return modesettingPTR(pScrn)->cust; +} + +Bool xorg_has_gallium(ScrnInfoPtr pScrn) +{ + return modesettingPTR(pScrn)->screen != NULL; +} + /* vim: set sw=4 ts=8 sts=4: */ diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index 58bb60a721..2f5cc64d9c 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -67,6 +67,14 @@ typedef struct #define XORG_NR_FENCES 3 +typedef struct _CustomizerRec +{ + Bool (*winsys_screen_init)(struct _CustomizerRec *cust, int fd); + Bool (*winsys_screen_close)(struct _CustomizerRec *cust); + Bool (*winsys_enter_vt)(struct _CustomizerRec *cust); + Bool (*winsys_leave_vt)(struct _CustomizerRec *cust); +} CustomizerRec, *CustomizerPtr; + typedef struct _modesettingRec { /* drm */ @@ -117,12 +125,7 @@ typedef struct _modesettingRec Bool accelerate_2d; Bool debug_fallback; - /* winsys hocks */ - Bool (*winsys_screen_init)(ScrnInfoPtr pScr); - Bool (*winsys_screen_close)(ScrnInfoPtr pScr); - Bool (*winsys_enter_vt)(ScrnInfoPtr pScr); - Bool (*winsys_leave_vt)(ScrnInfoPtr pScr); - void *winsys_priv; + CustomizerPtr cust; #ifdef DRM_MODE_FEATURE_DIRTYFB DamagePtr damage; @@ -131,6 +134,9 @@ typedef struct _modesettingRec #define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) +CustomizerPtr xorg_customizer(ScrnInfoPtr pScrn); + +Bool xorg_has_gallium(ScrnInfoPtr pScrn); /*********************************************************************** * xorg_exa.c diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h index 3efe851a4b..ba754b51e4 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_driver.h @@ -40,8 +40,11 @@ struct vmw_dma_buffer; -struct vmw_driver +struct vmw_customizer { + CustomizerRec base; + ScrnInfoPtr pScrn; + int fd; void *cursor_priv; @@ -50,11 +53,10 @@ struct vmw_driver void *video_priv; }; -static INLINE struct vmw_driver * -vmw_driver(ScrnInfoPtr pScrn) +static INLINE struct vmw_customizer * +vmw_customizer(CustomizerPtr cust) { - modesettingPtr ms = modesettingPTR(pScrn); - return ms ? (struct vmw_driver *)ms->winsys_priv : NULL; + return cust ? (struct vmw_customizer *) cust : NULL; } @@ -62,40 +64,40 @@ vmw_driver(ScrnInfoPtr pScrn) * vmw_video.c */ -Bool vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +Bool vmw_video_init(struct vmw_customizer *vmw); -Bool vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +Bool vmw_video_close(struct vmw_customizer *vmw); -void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +void vmw_video_stop_all(struct vmw_customizer *vmw); /*********************************************************************** * vmw_ioctl.c */ -int vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot); +int vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot); -struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_driver *vmw, +struct vmw_dma_buffer * vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle); -void * vmw_ioctl_buffer_map(struct vmw_driver *vmw, +void * vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -void vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, +void vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -void vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, +void vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf); -int vmw_ioctl_supports_streams(struct vmw_driver *vmw); +int vmw_ioctl_supports_streams(struct vmw_customizer *vmw); -int vmw_ioctl_num_streams(struct vmw_driver *vmw, +int vmw_ioctl_num_streams(struct vmw_customizer *vmw, uint32_t *ntot, uint32_t *nfree); -int vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id); +int vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id); -int vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out); +int vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out); #endif diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c index ab2b5fadc4..521578ab35 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_ioctl.c @@ -57,7 +57,7 @@ struct vmw_dma_buffer }; static int -vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out) +vmw_ioctl_get_param(struct vmw_customizer *vmw, uint32_t param, uint64_t *out) { struct drm_vmw_getparam_arg gp_arg; int ret; @@ -75,7 +75,7 @@ vmw_ioctl_get_param(struct vmw_driver *vmw, uint32_t param, uint64_t *out) } int -vmw_ioctl_supports_streams(struct vmw_driver *vmw) +vmw_ioctl_supports_streams(struct vmw_customizer *vmw) { uint64_t value; int ret; @@ -88,7 +88,7 @@ vmw_ioctl_supports_streams(struct vmw_driver *vmw) } int -vmw_ioctl_num_streams(struct vmw_driver *vmw, +vmw_ioctl_num_streams(struct vmw_customizer *vmw, uint32_t *ntot, uint32_t *nfree) { uint64_t v1, v2; @@ -109,7 +109,7 @@ vmw_ioctl_num_streams(struct vmw_driver *vmw, } int -vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out) +vmw_ioctl_claim_stream(struct vmw_customizer *vmw, uint32_t *out) { struct drm_vmw_stream_arg s_arg; int ret; @@ -125,7 +125,7 @@ vmw_ioctl_claim_stream(struct vmw_driver *vmw, uint32_t *out) } int -vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id) +vmw_ioctl_unref_stream(struct vmw_customizer *vmw, uint32_t stream_id) { struct drm_vmw_stream_arg s_arg; int ret; @@ -140,7 +140,7 @@ vmw_ioctl_unref_stream(struct vmw_driver *vmw, uint32_t stream_id) } int -vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot) +vmw_ioctl_cursor_bypass(struct vmw_customizer *vmw, int xhot, int yhot) { struct drm_vmw_cursor_bypass_arg arg; int ret; @@ -157,7 +157,7 @@ vmw_ioctl_cursor_bypass(struct vmw_driver *vmw, int xhot, int yhot) } struct vmw_dma_buffer * -vmw_ioctl_buffer_create(struct vmw_driver *vmw, uint32_t size, unsigned *handle) +vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *handle) { struct vmw_dma_buffer *buf; union drm_vmw_alloc_dmabuf_arg arg; @@ -198,7 +198,7 @@ err: } void -vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { struct drm_vmw_unref_dmabuf_arg arg; @@ -215,7 +215,7 @@ vmw_ioctl_buffer_destroy(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) } void * -vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_map(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { void *map; @@ -236,7 +236,7 @@ vmw_ioctl_buffer_map(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) } void -vmw_ioctl_buffer_unmap(struct vmw_driver *vmw, struct vmw_dma_buffer *buf) +vmw_ioctl_buffer_unmap(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf) { --buf->map_count; } diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c index 0d255d2726..f43f91e5c0 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_screen.c @@ -41,7 +41,8 @@ xf86CrtcFuncsRec vmw_screen_crtc_funcs; static void vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) { - struct vmw_driver *vmw = modesettingPTR(crtc->scrn)->winsys_priv; + struct vmw_customizer *vmw = + vmw_customizer(xorg_customizer(crtc->scrn)); xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); xf86CrtcFuncsPtr funcs = vmw->cursor_priv; CursorPtr c = config->cursor; @@ -53,8 +54,9 @@ vmw_screen_cursor_load_argb(xf86CrtcPtr crtc, CARD32 *image) } static void -vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_screen_cursor_init(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); int i; @@ -70,9 +72,9 @@ vmw_screen_cursor_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) } static void -vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_screen_cursor_close(struct vmw_customizer *vmw) { - xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(vmw->pScrn); int i; vmw_ioctl_cursor_bypass(vmw, 0, 0); @@ -82,50 +84,39 @@ vmw_screen_cursor_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) } static Bool -vmw_screen_init(ScrnInfoPtr pScrn) +vmw_screen_init(CustomizerPtr cust, int fd) { - modesettingPtr ms = modesettingPTR(pScrn); - struct vmw_driver *vmw; - - vmw = xnfcalloc(1, sizeof(*vmw)); - if (!vmw) - return FALSE; - - vmw->fd = ms->fd; - ms->winsys_priv = vmw; + struct vmw_customizer *vmw = vmw_customizer(cust); - vmw_screen_cursor_init(pScrn, vmw); + vmw->fd = fd; + vmw_screen_cursor_init(vmw); /* if gallium is used then we don't need to do anything more. */ - if (ms->screen) + if (xorg_has_gallium(vmw->pScrn)) return TRUE; - vmw_video_init(pScrn, vmw); + vmw_video_init(vmw); return TRUE; } static Bool -vmw_screen_close(ScrnInfoPtr pScrn) +vmw_screen_close(CustomizerPtr cust) { - modesettingPtr ms = modesettingPTR(pScrn); - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(cust); if (!vmw) return TRUE; - vmw_screen_cursor_close(pScrn, vmw); + vmw_screen_cursor_close(vmw); - vmw_video_close(pScrn, vmw); - - ms->winsys_priv = NULL; - xfree(vmw); + vmw_video_close(vmw); return TRUE; } static Bool -vmw_screen_enter_vt(ScrnInfoPtr pScrn) +vmw_screen_enter_vt(CustomizerPtr cust) { debug_printf("%s: enter\n", __func__); @@ -133,13 +124,13 @@ vmw_screen_enter_vt(ScrnInfoPtr pScrn) } static Bool -vmw_screen_leave_vt(ScrnInfoPtr pScrn) +vmw_screen_leave_vt(CustomizerPtr cust) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(cust); debug_printf("%s: enter\n", __func__); - vmw_video_stop_all(pScrn, vmw); + vmw_video_stop_all(vmw); return TRUE; } @@ -153,18 +144,27 @@ static Bool (*vmw_screen_pre_init_saved)(ScrnInfoPtr pScrn, int flags) = NULL; static Bool vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags) { - modesettingPtr ms; + struct vmw_customizer *vmw; + CustomizerPtr cust; + + vmw = xnfcalloc(1, sizeof(*vmw)); + if (!vmw) + return FALSE; + + cust = &vmw->base; + + cust->winsys_screen_init = vmw_screen_init; + cust->winsys_screen_close = vmw_screen_close; + cust->winsys_enter_vt = vmw_screen_enter_vt; + cust->winsys_leave_vt = vmw_screen_leave_vt; + vmw->pScrn = pScrn; + + pScrn->driverPrivate = cust; pScrn->PreInit = vmw_screen_pre_init_saved; if (!pScrn->PreInit(pScrn, flags)) return FALSE; - ms = modesettingPTR(pScrn); - ms->winsys_screen_init = vmw_screen_init; - ms->winsys_screen_close = vmw_screen_close; - ms->winsys_enter_vt = vmw_screen_enter_vt; - ms->winsys_leave_vt = vmw_screen_leave_vt; - return TRUE; } diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c index ff3b992d07..de28f06a47 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_video.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_video.c @@ -226,7 +226,7 @@ static void vmw_xv_query_best_size(ScrnInfoPtr pScrn, Bool motion, /* * Local functions. */ -static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw); +static XF86VideoAdaptorPtr vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw); static int vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port, @@ -243,9 +243,9 @@ static int vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, short height, RegionPtr clipBoxes); static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port); -static int vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, +static int vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size, struct vmw_video_buffer *out); -static int vmw_video_buffer_free(struct vmw_driver *vmw, +static int vmw_video_buffer_free(struct vmw_customizer *vmw, struct vmw_video_buffer *out); @@ -267,8 +267,9 @@ static int vmw_video_buffer_free(struct vmw_driver *vmw, */ Bool -vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_init(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; ScreenPtr pScreen = pScrn->pScreen; XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL; XF86VideoAdaptorPtr newAdaptor = NULL; @@ -345,8 +346,9 @@ vmw_video_init(ScrnInfoPtr pScrn, struct vmw_driver *vmw) */ Bool -vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_close(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; struct vmw_video_private *video; int i; @@ -387,8 +389,9 @@ vmw_video_close(ScrnInfoPtr pScrn, struct vmw_driver *vmw) *----------------------------------------------------------------------------- */ -void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +void vmw_video_stop_all(struct vmw_customizer *vmw) { + ScrnInfoPtr pScrn = vmw->pScrn; struct vmw_video_private *video = vmw->video_priv; int i; @@ -421,7 +424,7 @@ void vmw_video_stop_all(ScrnInfoPtr pScrn, struct vmw_driver *vmw) */ static XF86VideoAdaptorPtr -vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_driver *vmw) +vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw) { XF86VideoAdaptorPtr adaptor; struct vmw_video_private *video; @@ -515,7 +518,7 @@ vmw_video_port_init(ScrnInfoPtr pScrn, struct vmw_video_port *port, unsigned char *buf, short width, short height, RegionPtr clipBoxes) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); unsigned short w, h; int i, ret; @@ -583,7 +586,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, unsigned char *buf, short width, short height, RegionPtr clipBoxes) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct drm_vmw_control_stream_arg arg; unsigned short w, h; int size; @@ -675,7 +678,7 @@ vmw_video_port_play(ScrnInfoPtr pScrn, struct vmw_video_port *port, static void vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); uint32 id, colorKey, flags; Bool isAutoPaintColorkey; int i; @@ -721,7 +724,7 @@ vmw_video_port_cleanup(ScrnInfoPtr pScrn, struct vmw_video_port *port) */ static int -vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, +vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size, struct vmw_video_buffer *out) { out->buf = vmw_ioctl_buffer_create(vmw, size, &out->handle); @@ -764,7 +767,7 @@ vmw_video_buffer_alloc(struct vmw_driver *vmw, int size, */ static int -vmw_video_buffer_free(struct vmw_driver *vmw, +vmw_video_buffer_free(struct vmw_customizer *vmw, struct vmw_video_buffer *out) { if (out->size == 0) @@ -814,7 +817,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y, Bool sync, RegionPtr clipBoxes, pointer data, DrawablePtr dst) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct vmw_video_port *port = data; debug_printf("%s: enter (%u, %u) (%ux%u) (%u, %u) (%ux%u) (%ux%u)\n", __func__, @@ -852,7 +855,7 @@ vmw_xv_put_image(ScrnInfoPtr pScrn, short src_x, short src_y, static void vmw_xv_stop_video(ScrnInfoPtr pScrn, pointer data, Bool cleanup) { - struct vmw_driver *vmw = vmw_driver(pScrn); + struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn)); struct vmw_video_port *port = data; struct drm_vmw_control_stream_arg arg; int ret; -- cgit v1.2.3 From bad4b29d77817b54ab9b19ff9c8a0e5bf2de00fa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 22 Feb 2010 14:46:10 +0100 Subject: st/xorg: Obey max {width|height} from kernel and Gallium --- src/gallium/state_trackers/xorg/xorg_driver.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 5397ee777a..62cf2e0006 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -428,8 +428,8 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags) xf86CrtcConfigInit(pScrn, &crtc_config_funcs); xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); - max_width = 8192; - max_height = 8192; + max_width = 2048; /* A very low default */ + max_height = 2048; /* see screen_init */ xf86CrtcSetSizeRange(pScrn, 320, 200, max_width, max_height); if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { @@ -612,6 +612,7 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); + unsigned max_width, max_height; VisualPtr visual; CustomizerPtr cust = ms->cust; @@ -630,6 +631,26 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } + /* get max width and height */ + { + drmModeResPtr res; + res = drmModeGetResources(ms->fd); + max_width = res->max_width; + max_height = res->max_height; + drmModeFreeResources(res); + } + + if (ms->screen) { + float maxf; + int max; + maxf = ms->screen->get_paramf(ms->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); + max = (1 << (int)(maxf - 1.0f)); + max_width = max < max_width ? max : max_width; + max_height = max < max_height ? max : max_height; + } + + xf86CrtcSetSizeRange(pScrn, 1, 1, max_width, max_height); + pScrn->pScreen = pScreen; /* HW dependent - FIXME */ -- cgit v1.2.3 From 956cd73c23269e4f76cbfee9076ec6eeb1f3262a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 22 Feb 2010 14:47:15 +0100 Subject: st/xorg: Make resize fail gracefully --- src/gallium/state_trackers/xorg/xorg_driver.c | 69 +++++++++++++++++++++------ 1 file changed, 55 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 62cf2e0006..4f99e0001b 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -184,30 +184,47 @@ static Bool drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height) { modesettingPtr ms = modesettingPTR(pScrn); - PixmapPtr rootPixmap; ScreenPtr pScreen = pScrn->pScreen; + int old_width, old_height; + PixmapPtr rootPixmap; if (width == pScrn->virtualX && height == pScrn->virtualY) return TRUE; + old_width = pScrn->virtualX; + old_height = pScrn->virtualY; pScrn->virtualX = width; pScrn->virtualY = height; - /* - * Remove the old framebuffer & texture. - */ - drmModeRmFB(ms->fd, ms->fb_id); - if (!ms->destroy_front_buffer(pScrn)) - FatalError("failed to destroy front buffer\n"); + /* ms->create_front_buffer will remove the old front buffer */ rootPixmap = pScreen->GetScreenPixmap(pScreen); if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, -1, -1, -1, NULL)) - return FALSE; + goto error_modify; pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8); - /* now create new frontbuffer */ - return ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn); + if (ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn)) + return TRUE; + + /* + * This is the error recovery path. + */ + + if (!pScreen->ModifyPixmapHeader(rootPixmap, old_width, old_height, -1, -1, -1, NULL)) + FatalError("failed to resize rootPixmap error path\n"); + + pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8); + +error_modify: + pScrn->virtualX = old_width; + pScrn->virtualY = old_height; + + if (ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn)) + return FALSE; + + FatalError("failed to setup old framebuffer\n"); + return FALSE; } static const xf86CrtcConfigFuncsRec crtc_config_funcs = { @@ -812,6 +829,7 @@ drv_leave_vt(int scrnIndex, int flags) } drmModeRmFB(ms->fd, ms->fb_id); + ms->fb_id = -1; drv_restore_hw_state(pScrn); @@ -936,6 +954,15 @@ static Bool drv_destroy_front_buffer_ga3d(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); + + if (!ms->root_bo) + return TRUE; + + if (ms->fb_id != -1) { + drmModeRmFB(ms->fd, ms->fb_id); + ms->fb_id = -1; + } + pipe_texture_reference(&ms->root_texture, NULL); return TRUE; } @@ -944,7 +971,7 @@ static Bool drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); - unsigned handle, stride; + unsigned handle, stride, fb_id; struct pipe_texture *tex; int ret; @@ -969,19 +996,23 @@ drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) pScrn->bitsPerPixel, stride, handle, - &ms->fb_id); + &fb_id); if (ret) { - debug_printf("%s: failed to create framebuffer (%i, %s)", + debug_printf("%s: failed to create framebuffer (%i, %s)\n", __func__, ret, strerror(-ret)); goto err_destroy; } + if (!drv_destroy_front_buffer_ga3d(pScrn)) + FatalError("%s: failed to take down old framebuffer\n", __func__); + pScrn->frameX0 = 0; pScrn->frameY0 = 0; drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); pipe_texture_reference(&ms->root_texture, tex); pipe_texture_reference(&tex, NULL); + ms->fb_id = fb_id; return TRUE; @@ -1029,6 +1060,11 @@ drv_destroy_front_buffer_kms(ScrnInfoPtr pScrn) if (!ms->root_bo) return TRUE; + if (ms->fb_id != -1) { + drmModeRmFB(ms->fd, ms->fb_id); + ms->fb_id = -1; + } + kms_bo_unmap(ms->root_bo); kms_bo_destroy(&ms->root_bo); return TRUE; @@ -1041,6 +1077,7 @@ drv_create_front_buffer_kms(ScrnInfoPtr pScrn) unsigned handle, stride; struct kms_bo *bo; unsigned attr[8]; + unsigned fb_id; int ret; attr[0] = KMS_BO_TYPE; @@ -1071,17 +1108,21 @@ drv_create_front_buffer_kms(ScrnInfoPtr pScrn) pScrn->bitsPerPixel, stride, handle, - &ms->fb_id); + &fb_id); if (ret) { debug_printf("%s: failed to create framebuffer (%i, %s)", __func__, ret, strerror(-ret)); goto err_destroy; } + if (!drv_destroy_front_buffer_kms(pScrn)) + FatalError("%s: could not takedown old bo", __func__); + pScrn->frameX0 = 0; pScrn->frameY0 = 0; drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); ms->root_bo = bo; + ms->fb_id = fb_id; return TRUE; -- cgit v1.2.3 From cfbf75670dbb7e2a1fcb760d1792e4c9de634c7f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 22 Feb 2010 20:06:23 +0100 Subject: vmware/xorg: Bump to match vmware driver --- src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c index bc5d39f749..87aad25b24 100644 --- a/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c +++ b/src/gallium/winsys/drm/vmware/xorg/vmw_xorg.c @@ -43,9 +43,9 @@ #define VMW_STRING_INNER(s) #s #define VMW_STRING(str) VMW_STRING_INNER(str) -#define VMWGFX_VERSION_MAJOR 10 -#define VMWGFX_VERSION_MINOR 16 -#define VMWGFX_VERSION_PATCH 9 +#define VMWGFX_VERSION_MAJOR 11 +#define VMWGFX_VERSION_MINOR 0 +#define VMWGFX_VERSION_PATCH 0 #define VMWGFX_VERSION_STRING_MAJOR VMW_STRING(VMWGFX_VERSION_MAJOR) #define VMWGFX_VERSION_STRING_MINOR VMW_STRING(VMWGFX_VERSION_MINOR) #define VMWGFX_VERSION_STRING_PATCH VMW_STRING(VMWGFX_VERSION_PATCH) -- cgit v1.2.3 From 122b472814d7694d997a55aac3d32340bf09218d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Feb 2010 16:51:15 +0100 Subject: st/xorg: Fix copy-topy --- src/gallium/state_trackers/xorg/xorg_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 4f99e0001b..aa8ab7901f 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -955,7 +955,7 @@ drv_destroy_front_buffer_ga3d(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); - if (!ms->root_bo) + if (!ms->root_texture) return TRUE; if (ms->fb_id != -1) { -- cgit v1.2.3 From bbefd86125f89451d75a96f31e1f4c871a1582c0 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 25 Feb 2010 16:51:30 +0100 Subject: st/xorg: Re-enable crtc on resize --- src/gallium/state_trackers/xorg/xorg_driver.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index aa8ab7901f..8fb6e5a96d 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -183,10 +183,12 @@ drv_probe_ddc(ScrnInfoPtr pScrn, int index) static Bool drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height) { + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); modesettingPtr ms = modesettingPTR(pScrn); ScreenPtr pScreen = pScrn->pScreen; int old_width, old_height; PixmapPtr rootPixmap; + int i; if (width == pScrn->virtualX && height == pScrn->virtualY) return TRUE; @@ -204,13 +206,29 @@ drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height) pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8); - if (ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn)) - return TRUE; + if (!ms->create_front_buffer(pScrn) || !ms->bind_front_buffer(pScrn)) + goto error_create; /* - * This is the error recovery path. + * create && bind will turn off all crtc(s) in the kernel so we need to + * re-enable all the crtcs again. For real HW we might want to do this + * before destroying the old framebuffer. */ + for (i = 0; i < xf86_config->num_crtc; i++) { + xf86CrtcPtr crtc = xf86_config->crtc[i]; + + if (!crtc->enabled) + continue; + + crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc->rotation, crtc->x, crtc->y); + } + + return TRUE; + /* + * This is the error recovery path. + */ +error_create: if (!pScreen->ModifyPixmapHeader(rootPixmap, old_width, old_height, -1, -1, -1, NULL)) FatalError("failed to resize rootPixmap error path\n"); -- cgit v1.2.3 From 307071fe1e2bfacba9780e2397785495ae0b0ea1 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 27 Feb 2010 02:01:56 -0800 Subject: st/dri: Assert pointer is not null before dereferencing. --- src/gallium/state_trackers/dri/dri_drawable.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 8843e087a8..4809b9090d 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -134,12 +134,13 @@ dri_get_buffers(__DRIdrawable * dPriv) if ((dri_screen->dri2.loader && (dri_screen->dri2.loader->base.version > 2) - && (dri_screen->dri2.loader->getBuffersWithFormat != NULL))) + && (dri_screen->dri2.loader->getBuffersWithFormat != NULL))) { buffers = (*dri_screen->dri2.loader->getBuffersWithFormat) (dri_drawable, &dri_drawable->w, &dri_drawable->h, drawable->attachments, drawable->num_attachments, &count, dri_drawable->loaderPrivate); - else + } else { + assert(dri_screen->dri2.loader); buffers = (*dri_screen->dri2.loader->getBuffers) (dri_drawable, &dri_drawable->w, &dri_drawable->h, @@ -148,6 +149,7 @@ dri_get_buffers(__DRIdrawable * dPriv) num_attachments, &count, dri_drawable-> loaderPrivate); + } if (buffers == NULL) { return; -- cgit v1.2.3 From dba7ad895333b9b0988239266a217edeebe6a3b3 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 26 Feb 2010 22:34:09 +0100 Subject: r300g: remove pointless "while" --- src/gallium/drivers/r300/r300_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index ec72d6c3b5..d604bfb7d7 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -123,7 +123,7 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300, static boolean r300_reserve_cs_space(struct r300_context *r300, unsigned dwords) { - while (!r300->winsys->check_cs(r300->winsys, dwords)) { + if (!r300->winsys->check_cs(r300->winsys, dwords)) { r300->context.flush(&r300->context, 0, NULL); return TRUE; } -- cgit v1.2.3 From 93da1522098145f0e7ff9d4188050728b075b4a1 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 00:37:01 +0100 Subject: r300g: always emit the correct max vertex index to avoid DRM errors Fixing bizarre reports that a vertex buffer is not large enough. --- src/gallium/drivers/r300/r300_context.h | 1 + src/gallium/drivers/r300/r300_render.c | 7 +++++-- src/gallium/drivers/r300/r300_state.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 3d4f6524e5..8704f18529 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -326,6 +326,7 @@ struct r300_context { /* Vertex buffers for Gallium. */ struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; + int vertex_buffer_max_index; /* Vertex elements for Gallium. */ struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; int vertex_element_count; diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index d604bfb7d7..e4f7615368 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -452,8 +452,11 @@ void r300_draw_elements(struct pipe_context* pipe, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { - pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0, - mode, start, count); + struct r300_context *r300 = r300_context(pipe); + + pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, + r300->vertex_buffer_max_index, + mode, start, count); } void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 0f14ccc53e..ee4409c889 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1026,10 +1026,17 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, const struct pipe_vertex_buffer* buffers) { struct r300_context* r300 = r300_context(pipe); + unsigned i, max_index = ~0; memcpy(r300->vertex_buffer, buffers, sizeof(struct pipe_vertex_buffer) * count); + + for (i = 0; i < count; i++) { + max_index = MIN2(buffers[i].max_index, max_index); + } + r300->vertex_buffer_count = count; + r300->vertex_buffer_max_index = max_index; if (r300->draw) { draw_flush(r300->draw); -- cgit v1.2.3 From c05f998f02b0799e46e6c306c03a09c35bd37cc0 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 02:46:20 +0100 Subject: radeong: clean up includes --- src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 6 ++++-- src/gallium/winsys/drm/radeon/core/radeon_buffer.h | 10 ---------- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 10 ++++++++++ src/gallium/winsys/drm/radeon/core/radeon_drm.h | 15 --------------- src/gallium/winsys/drm/radeon/core/radeon_r300.c | 3 +++ src/gallium/winsys/drm/radeon/core/radeon_r300.h | 11 +---------- 6 files changed, 18 insertions(+), 37 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index 5cbf0dd2c5..e5c6919933 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -31,11 +31,13 @@ */ #include "radeon_buffer.h" +#include "radeon_drm.h" -#include "radeon_bo_gem.h" -#include "r300_context.h" #include "util/u_format.h" #include "util/u_math.h" +#include "util/u_memory.h" + +#include "radeon_bo_gem.h" #include struct radeon_vl_context diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h index f1c8fc2a3b..f776e2d900 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h @@ -30,21 +30,11 @@ #ifndef RADEON_BUFFER_H #define RADEON_BUFFER_H -#include - -#include "util/u_simple_screen.h" -#include "pipe/p_defines.h" -#include "util/u_inlines.h" - #include "pipebuffer/pb_buffer.h" -#include "util/u_memory.h" - #include "radeon_bo.h" #include "radeon_cs.h" -#include "radeon_drm.h" - #include "radeon_winsys.h" struct radeon_pipe_buffer { diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index 0c0e118ba3..e817a26da6 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -30,6 +30,16 @@ */ #include "radeon_drm.h" +#include "radeon_r300.h" +#include "radeon_buffer.h" + +#include "r300_winsys.h" +#include "trace/tr_drm.h" + +#include "util/u_memory.h" + +#include "xf86drm.h" +#include /* Helper function to do the ioctls needed for setup and init. */ static void do_ioctls(int fd, struct radeon_winsys* winsys) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 8d74cbafc2..f62a9b8048 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -30,23 +30,8 @@ #ifndef RADEON_DRM_H #define RADEON_DRM_H -#include - -#include "xf86drm.h" - -#include "pipe/p_screen.h" - -#include "trace/tr_drm.h" -#include "util/u_debug.h" -#include "util/u_memory.h" - #include "state_tracker/drm_api.h" -#include "radeon_buffer.h" -#include "radeon_r300.h" - -/* XXX */ -#include "r300_screen.h" struct pipe_screen* radeon_create_screen(struct drm_api* api, int drmFB, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index d759beaba1..122bd21354 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -21,6 +21,9 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "radeon_r300.h" +#include "radeon_buffer.h" + +#include "radeon_cs_gem.h" static void radeon_set_flush_cb(struct radeon_winsys *winsys, void (*flush_cb)(void *), diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h index cfbdb30266..e655dc32c8 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h @@ -23,16 +23,7 @@ #ifndef RADEON_R300_H #define RADEON_R300_H -/* XXX WTF is this! I shouldn't have to include those first three! FUCK! */ -#include -#include -#include "drm.h" -#include "radeon_drm.h" -#include "radeon_cs_gem.h" - -#include "r300_winsys.h" - -#include "radeon_buffer.h" +#include "radeon_winsys.h" void radeon_setup_winsys(int fd, struct radeon_winsys* winsys); -- cgit v1.2.3 From f129a7dd686cb3d824253bffab8c8b32b8ef8b69 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 20:00:38 +0100 Subject: r300g: mark rasterizer_state as dirty only when it's not NULL --- src/gallium/drivers/r300/r300_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index ee4409c889..0fbb9e7716 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -824,13 +824,13 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->tcl_bypass = rs->rs.bypass_vs_clip_and_viewport; r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; + r300->rs_state.dirty = TRUE; } else { r300->tcl_bypass = FALSE; r300->polygon_offset_enabled = FALSE; } r300->rs_state.state = rs; - r300->rs_state.dirty = TRUE; /* XXX Why is this still needed, dammit!? */ r300->scissor_state.dirty = TRUE; r300->viewport_state.dirty = TRUE; -- cgit v1.2.3 From a3d4d0dec2882e352dc9ddcc1572e36620a4d13e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 20:03:34 +0100 Subject: r300g: put the emission of R300_US_OUT_FMT_UNUSED back It wasn't such a good idea to remove it. :/ --- src/gallium/drivers/r300/r300_emit.c | 6 +++++- src/gallium/drivers/r300/r300_state.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 3037a38989..1ea622f850 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -387,7 +387,8 @@ void r300_emit_fb_state(struct r300_context* r300, void* state) int i; CS_LOCALS(r300); - BEGIN_CS((10 * fb->nr_cbufs) + (fb->zsbuf ? 10 : 0) + 6); + BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) + + (fb->zsbuf ? 10 : 0) + 6); /* Flush and free renderbuffer caches. */ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, @@ -426,6 +427,9 @@ void r300_emit_fb_state(struct r300_context* r300, void* state) OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), tex->fb_state.us_out_fmt); } + for (; i < 4; i++) { + OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), R300_US_OUT_FMT_UNUSED); + } /* Set up a zbuffer. */ if (fb->zsbuf) { diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 0fbb9e7716..2c4beee5ad 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -598,7 +598,8 @@ static void memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); - r300->fb_state.size = (10 * state->nr_cbufs) + (state->zsbuf ? 10 : 0) + 6; + r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) + + (state->zsbuf ? 10 : 0) + 6; r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); -- cgit v1.2.3 From 74f94e8fdfe035fa68acdc19e6b0afc2957a4264 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 20:05:00 +0100 Subject: r300g: move the emission of GA_POINT_MINMAX into emit_fb_state The only practical limits are the ones derived from the currently-set framebuffer state. --- src/gallium/drivers/r300/r300_context.h | 1 - src/gallium/drivers/r300/r300_emit.c | 10 +++++----- src/gallium/drivers/r300/r300_state.c | 19 ++----------------- 3 files changed, 7 insertions(+), 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 8704f18529..ac14e3f0df 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -86,7 +86,6 @@ struct r300_rs_state { uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */ uint32_t antialiasing_config; /* R300_GB_AA_CONFIG: 0x4020 */ uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */ - uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */ uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */ float depth_scale; /* R300_SU_POLY_OFFSET_FRONT_SCALE: 0x42a4 */ /* R300_SU_POLY_OFFSET_BACK_SCALE: 0x42ac */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 1ea622f850..7fc66dd265 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -388,7 +388,7 @@ void r300_emit_fb_state(struct r300_context* r300, void* state) CS_LOCALS(r300); BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) + - (fb->zsbuf ? 10 : 0) + 6); + (fb->zsbuf ? 10 : 0) + 8); /* Flush and free renderbuffer caches. */ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, @@ -447,6 +447,8 @@ void r300_emit_fb_state(struct r300_context* r300, void* state) 0, RADEON_GEM_DOMAIN_VRAM, 0); } + OUT_CS_REG(R300_GA_POINT_MINMAX, + (MAX2(fb->width, fb->height) * 6) << R300_GA_POINT_MINMAX_MAX_SHIFT); END_CS; } @@ -582,15 +584,13 @@ void r300_emit_rs_state(struct r300_context* r300, void* state) float scale, offset; CS_LOCALS(r300); - BEGIN_CS(18 + (rs->polygon_offset_enable ? 5 : 0)); + BEGIN_CS(17 + (rs->polygon_offset_enable ? 5 : 0)); OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status); OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config); OUT_CS_REG(R300_GA_POINT_SIZE, rs->point_size); - OUT_CS_REG_SEQ(R300_GA_POINT_MINMAX, 2); - OUT_CS(rs->point_minmax); - OUT_CS(rs->line_control); + OUT_CS_REG(R300_GA_LINE_CNTL, rs->line_control); if (rs->polygon_offset_enable) { scale = rs->depth_scale * 12; diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 2c4beee5ad..f1f0de1a46 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -599,7 +599,7 @@ static void memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) + - (state->zsbuf ? 10 : 0) + 6; + (state->zsbuf ? 10 : 0) + 8; r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); @@ -718,22 +718,6 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->point_size = pack_float_16_6x(state->point_size) | (pack_float_16_6x(state->point_size) << R300_POINTSIZE_X_SHIFT); - /* Point minimum and maximum sizes. This register has to be emitted, - * and it'd be a step backwards to put it in invariant state. */ - if (r300screen->caps->is_r500) { - rs->point_minmax = - ((int)(0.0 * 6.0) << R300_GA_POINT_MINMAX_MIN_SHIFT) | - ((int)(4096.0 * 6.0) << R300_GA_POINT_MINMAX_MAX_SHIFT); - } else if (r300screen->caps->is_r400) { - rs->point_minmax = - ((int)(0.0 * 6.0) << R300_GA_POINT_MINMAX_MIN_SHIFT) | - ((int)(4021.0 * 6.0) << R300_GA_POINT_MINMAX_MAX_SHIFT); - } else { - rs->point_minmax = - ((int)(0.0 * 6.0) << R300_GA_POINT_MINMAX_MIN_SHIFT) | - ((int)(2560.0 * 6.0) << R300_GA_POINT_MINMAX_MAX_SHIFT); - } - rs->line_control = pack_float_16_6x(state->line_width) | R300_GA_LINE_CNTL_END_TYPE_COMP; @@ -832,6 +816,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) } r300->rs_state.state = rs; + r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0); /* XXX Why is this still needed, dammit!? */ r300->scissor_state.dirty = TRUE; r300->viewport_state.dirty = TRUE; -- cgit v1.2.3 From 1eba490202b09ee87f1c8af5a3bb77b5c3f23599 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 27 Feb 2010 20:28:53 +0000 Subject: util: Fix X8/A8B8G8R8_SNORM's swizzle. --- src/gallium/auxiliary/util/u_format.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index b2ee247a6c..7595576953 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -27,8 +27,8 @@ PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, s PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb # Signed formats (typically used for bump map textures) -PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzyx, rgb -PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb +PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb +PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb PIPE_FORMAT_X8UB8UG8SR8S_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb PIPE_FORMAT_B6UG5SR5S_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb -- cgit v1.2.3 From 841122d0e8025290ff2691e13ade1099d2c3351c Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 21:54:16 +0100 Subject: r300g: add size parameter to the atom emit functions Maintaining a closer relationship between the atom size and what's passed in BEGIN_CS. --- src/gallium/drivers/r300/r300_context.h | 2 +- src/gallium/drivers/r300/r300_emit.c | 34 +++++++++++++++---------- src/gallium/drivers/r300/r300_emit.h | 33 +++++++++++++++--------- src/gallium/drivers/r300/r300_state_invariant.c | 3 ++- src/gallium/drivers/r300/r300_state_invariant.h | 3 ++- 5 files changed, 47 insertions(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index ac14e3f0df..e3ad586921 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -45,7 +45,7 @@ struct r300_atom { /* Opaque state. */ void* state; /* Emit the state to the context. */ - void (*emit)(struct r300_context*, void*); + void (*emit)(struct r300_context*, unsigned, void*); /* Upper bound on number of dwords to emit. */ unsigned size; /* Whether this atom should be emitted. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 7fc66dd265..a17ebb3ea8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -34,7 +34,8 @@ #include "r300_screen.h" #include "r300_vs.h" -void r300_emit_blend_state(struct r300_context* r300, void* state) +void r300_emit_blend_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_blend_state* blend = (struct r300_blend_state*)state; struct pipe_framebuffer_state* fb = @@ -58,7 +59,8 @@ void r300_emit_blend_state(struct r300_context* r300, void* state) END_CS; } -void r300_emit_blend_color_state(struct r300_context* r300, void* state) +void r300_emit_blend_color_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_blend_color_state* bc = (struct r300_blend_color_state*)state; struct r300_screen* r300screen = r300_screen(r300->context.screen); @@ -77,7 +79,8 @@ void r300_emit_blend_color_state(struct r300_context* r300, void* state) } } -void r300_emit_clip_state(struct r300_context* r300, void* state) +void r300_emit_clip_state(struct r300_context* r300, + unsigned size, void* state) { struct pipe_clip_state* clip = (struct pipe_clip_state*)state; int i; @@ -107,7 +110,7 @@ void r300_emit_clip_state(struct r300_context* r300, void* state) } -void r300_emit_dsa_state(struct r300_context* r300, void* state) +void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state) { struct r300_dsa_state* dsa = (struct r300_dsa_state*)state; struct r300_screen* r300screen = r300_screen(r300->context.screen); @@ -378,7 +381,7 @@ void r500_emit_fs_constant_buffer(struct r300_context* r300, END_CS; } -void r300_emit_fb_state(struct r300_context* r300, void* state) +void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) { struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)state; struct r300_screen* r300screen = r300_screen(r300->context.screen); @@ -578,7 +581,7 @@ void r300_emit_query_end(struct r300_context* r300) r300_emit_query_finish(r300, query); } -void r300_emit_rs_state(struct r300_context* r300, void* state) +void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) { struct r300_rs_state* rs = (struct r300_rs_state*)state; float scale, offset; @@ -621,7 +624,8 @@ void r300_emit_rs_state(struct r300_context* r300, void* state) END_CS; } -void r300_emit_rs_block_state(struct r300_context* r300, void* state) +void r300_emit_rs_block_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_rs_block* rs = (struct r300_rs_block*)state; unsigned i; @@ -663,7 +667,8 @@ void r300_emit_rs_block_state(struct r300_context* r300, void* state) END_CS; } -void r300_emit_scissor_state(struct r300_context* r300, void* state) +void r300_emit_scissor_state(struct r300_context* r300, + unsigned size, void* state) { unsigned minx, miny, maxx, maxy; uint32_t top_left, bottom_right; @@ -810,7 +815,8 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) END_CS; } -void r300_emit_vertex_format_state(struct r300_context* r300, void* state) +void r300_emit_vertex_format_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_vertex_info* vertex_info = (struct r300_vertex_info*)state; unsigned i; @@ -856,7 +862,7 @@ static void r300_flush_pvs(struct r300_context* r300) END_CS; } -void r300_emit_vs_state(struct r300_context* r300, void* state) +void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) { struct r300_vertex_shader* vs = (struct r300_vertex_shader*)state; struct r300_vertex_program_code* code = &vs->code; @@ -942,7 +948,8 @@ void r300_emit_vs_constant_buffer(struct r300_context* r300, END_CS; } -void r300_emit_viewport_state(struct r300_context* r300, void* state) +void r300_emit_viewport_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_viewport_state* viewport = (struct r300_viewport_state*)state; CS_LOCALS(r300); @@ -986,7 +993,8 @@ void r300_emit_texture_count(struct r300_context* r300) } -void r300_emit_ztop_state(struct r300_context* r300, void* state) +void r300_emit_ztop_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_ztop_state* ztop = (struct r300_ztop_state*)state; CS_LOCALS(r300); @@ -1110,7 +1118,7 @@ void r300_emit_dirty_state(struct r300_context* r300) foreach(atom, &r300->atom_list) { if (atom->dirty || atom->always_dirty) { - atom->emit(r300, atom->state); + atom->emit(r300, atom->size, atom->state); atom->dirty = FALSE; } } diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index f27cf5f32d..a9b75d5b37 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -31,13 +31,17 @@ struct r300_vertex_program_code; void r300_emit_aos(struct r300_context* r300, unsigned offset); -void r300_emit_blend_state(struct r300_context* r300, void* state); +void r300_emit_blend_state(struct r300_context* r300, + unsigned size, void* state); -void r300_emit_blend_color_state(struct r300_context* r300, void* state); +void r300_emit_blend_color_state(struct r300_context* r300, + unsigned size, void* state); -void r300_emit_clip_state(struct r300_context* r300, void* state); +void r300_emit_clip_state(struct r300_context* r300, + unsigned size, void* state); -void r300_emit_dsa_state(struct r300_context* r300, void* state); +void r300_emit_dsa_state(struct r300_context* r300, + unsigned size, void* state); void r300_emit_fragment_program_code(struct r300_context* r300, struct rX00_fragment_program_code* generic_code); @@ -51,18 +55,20 @@ void r500_emit_fragment_program_code(struct r300_context* r300, void r500_emit_fs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants); -void r300_emit_fb_state(struct r300_context* r300, void* state); +void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state); void r300_emit_query_begin(struct r300_context* r300, struct r300_query* query); void r300_emit_query_end(struct r300_context* r300); -void r300_emit_rs_state(struct r300_context* r300, void* state); +void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_rs_block_state(struct r300_context* r300, void* state); +void r300_emit_rs_block_state(struct r300_context* r300, + unsigned size, void* state); -void r300_emit_scissor_state(struct r300_context* r300, void* state); +void r300_emit_scissor_state(struct r300_context* r300, + unsigned size, void* state); void r300_emit_texture(struct r300_context* r300, struct r300_sampler_state* sampler, @@ -71,7 +77,8 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_vertex_buffer(struct r300_context* r300); -void r300_emit_vertex_format_state(struct r300_context* r300, void* state); +void r300_emit_vertex_format_state(struct r300_context* r300, + unsigned size, void* state); void r300_emit_vertex_program_code(struct r300_context* r300, struct r300_vertex_program_code* code); @@ -79,13 +86,15 @@ void r300_emit_vertex_program_code(struct r300_context* r300, void r300_emit_vs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants); -void r300_emit_vs_state(struct r300_context* r300, void* state); +void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_viewport_state(struct r300_context* r300, void* state); +void r300_emit_viewport_state(struct r300_context* r300, + unsigned size, void* state); void r300_emit_texture_count(struct r300_context* r300); -void r300_emit_ztop_state(struct r300_context* r300, void* state); +void r300_emit_ztop_state(struct r300_context* r300, + unsigned size, void* state); void r300_flush_textures(struct r300_context* r300); diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 97927acf1b..4a2c68269b 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -38,7 +38,8 @@ struct pipe_viewport_state r300_viewport_identity = { * * Note that eventually this should be empty, but it's useful for development * and general unduplication of code. */ -void r300_emit_invariant_state(struct r300_context* r300, void* state) +void r300_emit_invariant_state(struct r300_context* r300, + unsigned size, void* state) { struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h index 5d1a963654..83d031c7fe 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.h +++ b/src/gallium/drivers/r300/r300_state_invariant.h @@ -25,6 +25,7 @@ struct r300_context; -void r300_emit_invariant_state(struct r300_context* r300, void* state); +void r300_emit_invariant_state(struct r300_context* r300, + unsigned size, void* state); #endif /* R300_STATE_INVARIANT_H */ -- cgit v1.2.3 From fe6d3b9222ce184daab61ebb390a6af0b9889abf Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 23:26:19 +0100 Subject: r300g: atomize PVS flush The first non-state atom. It's better and cleaner to have it. --- src/gallium/drivers/r300/r300_context.c | 39 +++++++++++++++++---------------- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 8 +------ src/gallium/drivers/r300/r300_emit.h | 2 ++ src/gallium/drivers/r300/r300_state.c | 5 ++++- 5 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 47883589a7..5fc3a30804 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -96,12 +96,12 @@ static void r300_flush_cb(void *data) } #define R300_INIT_ATOM(atomname, atomsize) \ - r300->atomname##_state.name = #atomname; \ - r300->atomname##_state.state = NULL; \ - r300->atomname##_state.size = atomsize; \ - r300->atomname##_state.emit = r300_emit_##atomname##_state; \ - r300->atomname##_state.dirty = FALSE; \ - insert_at_tail(&r300->atom_list, &r300->atomname##_state); + r300->atomname.name = #atomname; \ + r300->atomname.state = NULL; \ + r300->atomname.size = atomsize; \ + r300->atomname.emit = r300_emit_##atomname; \ + r300->atomname.dirty = FALSE; \ + insert_at_tail(&r300->atom_list, &r300->atomname); static void r300_setup_atoms(struct r300_context* r300) { @@ -114,19 +114,20 @@ static void r300_setup_atoms(struct r300_context* r300) * an upper bound on each atom, to keep the emission machinery from * underallocating space. */ make_empty_list(&r300->atom_list); - R300_INIT_ATOM(invariant, 71); - R300_INIT_ATOM(ztop, 2); - R300_INIT_ATOM(blend, 8); - R300_INIT_ATOM(blend_color, 3); - R300_INIT_ATOM(clip, 29); - R300_INIT_ATOM(dsa, 8); - R300_INIT_ATOM(fb, 56); - R300_INIT_ATOM(rs, 25); - R300_INIT_ATOM(scissor, 3); - R300_INIT_ATOM(viewport, 9); - R300_INIT_ATOM(rs_block, 21); - R300_INIT_ATOM(vertex_format, 26); - R300_INIT_ATOM(vs, 1031); + R300_INIT_ATOM(invariant_state, 71); + R300_INIT_ATOM(ztop_state, 2); + R300_INIT_ATOM(blend_state, 8); + R300_INIT_ATOM(blend_color_state, 3); + R300_INIT_ATOM(clip_state, 29); + R300_INIT_ATOM(dsa_state, 8); + R300_INIT_ATOM(fb_state, 56); + R300_INIT_ATOM(rs_state, 25); + R300_INIT_ATOM(scissor_state, 3); + R300_INIT_ATOM(viewport_state, 9); + R300_INIT_ATOM(rs_block_state, 21); + R300_INIT_ATOM(vertex_format_state, 26); + R300_INIT_ATOM(pvs_flush, 2); + R300_INIT_ATOM(vs_state, 1031); /* Some non-CSO atoms need explicit space to store the state locally. */ r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index e3ad586921..32b64b6b28 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -318,6 +318,8 @@ struct r300_context { struct r300_atom viewport_state; /* ZTOP state. */ struct r300_atom ztop_state; + /* PVS flush. */ + struct r300_atom pvs_flush; /* Invariant state. This must be emitted to get the engine started. */ struct r300_atom invariant_state; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a17ebb3ea8..6a0ede359b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -853,7 +853,7 @@ void r300_emit_vertex_format_state(struct r300_context* r300, END_CS; } -static void r300_flush_pvs(struct r300_context* r300) +void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state) { CS_LOCALS(r300); @@ -887,8 +887,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) return; } - r300_flush_pvs(r300); - BEGIN_CS(9 + code->length); /* R300_VAP_PVS_CODE_CNTL_0 * R300_VAP_PVS_CONST_CNTL @@ -1170,10 +1168,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_flush_textures(r300); } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS || r300->vs_state.dirty) { - r300_flush_pvs(r300); - } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { struct r300_vertex_shader* vs = r300->vs_state.state; r300_emit_vs_constant_buffer(r300, &vs->code.constants); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index a9b75d5b37..5809bf4340 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -96,6 +96,8 @@ void r300_emit_texture_count(struct r300_context* r300); void r300_emit_ztop_state(struct r300_context* r300, unsigned size, void* state); +void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state); + void r300_flush_textures(struct r300_context* r300); unsigned r300_get_num_dirty_dwords(struct r300_context *r300); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index f1f0de1a46..79cd715af1 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1109,6 +1109,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300->vs_state.dirty = TRUE; r300->vertex_format_state.dirty = TRUE; + r300->pvs_flush.dirty = TRUE; if (r300->fs) { r300_vertex_shader_setup_wpos(r300); @@ -1186,8 +1187,10 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, r300->shader_constants[shader].count = buf->size / (4 * sizeof(float)); pipe_buffer_unmap(pipe->screen, buf); - if (shader == PIPE_SHADER_VERTEX) + if (shader == PIPE_SHADER_VERTEX) { r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; + r300->pvs_flush.dirty = TRUE; + } else if (shader == PIPE_SHADER_FRAGMENT) r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; } -- cgit v1.2.3 From 279715e76e5385afaad2834191e8578cf3a5d233 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 23:37:01 +0100 Subject: r300g: atomize invalidation of texture caches --- src/gallium/drivers/r300/r300_context.c | 1 + src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 8 +------- src/gallium/drivers/r300/r300_emit.h | 2 +- src/gallium/drivers/r300/r300_state.c | 6 ++++++ 5 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 5fc3a30804..5f50b60eab 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -128,6 +128,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(vertex_format_state, 26); R300_INIT_ATOM(pvs_flush, 2); R300_INIT_ATOM(vs_state, 1031); + R300_INIT_ATOM(texture_cache_inval, 2); /* Some non-CSO atoms need explicit space to store the state locally. */ r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 32b64b6b28..47f2aa5154 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -320,6 +320,8 @@ struct r300_context { struct r300_atom ztop_state; /* PVS flush. */ struct r300_atom pvs_flush; + /* Texture cache invalidate. */ + struct r300_atom texture_cache_inval; /* Invariant state. This must be emitted to get the engine started. */ struct r300_atom invariant_state; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 6a0ede359b..ad19725e60 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1002,7 +1002,7 @@ void r300_emit_ztop_state(struct r300_context* r300, END_CS; } -void r300_flush_textures(struct r300_context* r300) +void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, void* state) { CS_LOCALS(r300); @@ -1107,7 +1107,6 @@ void r300_emit_dirty_state(struct r300_context* r300) struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_atom* atom; unsigned i; - int dirty_tex = 0; if (r300->dirty_state & R300_NEW_QUERY) { r300_emit_query_start(r300); @@ -1155,7 +1154,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300->sampler_states[i], r300->textures[i], i); - dirty_tex |= r300->dirty_state & (R300_NEW_TEXTURE << i); } r300->dirty_state &= ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i)); @@ -1164,10 +1162,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES); } - if (dirty_tex) { - r300_flush_textures(r300); - } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { struct r300_vertex_shader* vs = r300->vs_state.state; r300_emit_vs_constant_buffer(r300, &vs->code.constants); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 5809bf4340..c73b016b76 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -98,7 +98,7 @@ void r300_emit_ztop_state(struct r300_context* r300, void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state); -void r300_flush_textures(struct r300_context* r300); +void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, void* state); unsigned r300_get_num_dirty_dwords(struct r300_context *r300); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 79cd715af1..15e0a0ad35 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -922,6 +922,7 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; + boolean dirty_tex = FALSE; int i; /* XXX magic num */ @@ -934,6 +935,7 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, pipe_texture_reference((struct pipe_texture**)&r300->textures[i], texture[i]); r300->dirty_state |= (R300_NEW_TEXTURE << i); + dirty_tex = TRUE; /* R300-specific - set the texrect factor in a fragment shader */ if (!is_r500 && r300->textures[i]->is_npot) { @@ -953,6 +955,10 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } r300->texture_count = count; + + if (dirty_tex) { + r300->texture_cache_inval.dirty = TRUE; + } } static void r300_set_scissor_state(struct pipe_context* pipe, -- cgit v1.2.3 From 4ed97f0a73db37f6105b6282d92646c3f66c2645 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 23:12:46 +0100 Subject: r300g: use the atom size directly during emission --- src/gallium/drivers/r300/r300_context.c | 22 +++++++++-------- src/gallium/drivers/r300/r300_emit.c | 35 +++++++++++++-------------- src/gallium/drivers/r300/r300_state.c | 2 +- src/gallium/drivers/r300/r300_state_derived.c | 2 +- 4 files changed, 31 insertions(+), 30 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 5f50b60eab..3a84fc564d 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -105,29 +105,31 @@ static void r300_flush_cb(void *data) static void r300_setup_atoms(struct r300_context* r300) { + boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; + boolean has_tcl = r300_screen(r300->context.screen)->caps->has_tcl; + /* Create the actual atom list. * * Each atom is examined and emitted in the order it appears here, which * can affect performance and conformance if not handled with care. * - * Some atoms never change size, others change every emit. This is just - * an upper bound on each atom, to keep the emission machinery from - * underallocating space. */ + * Some atoms never change size, others change every emit - those have + * the size of 0 here. */ make_empty_list(&r300->atom_list); R300_INIT_ATOM(invariant_state, 71); R300_INIT_ATOM(ztop_state, 2); R300_INIT_ATOM(blend_state, 8); - R300_INIT_ATOM(blend_color_state, 3); - R300_INIT_ATOM(clip_state, 29); - R300_INIT_ATOM(dsa_state, 8); - R300_INIT_ATOM(fb_state, 56); - R300_INIT_ATOM(rs_state, 25); + R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2); + R300_INIT_ATOM(clip_state, has_tcl ? 5 + (6 * 4) : 2); + R300_INIT_ATOM(dsa_state, is_r500 ? 8 : 6); + R300_INIT_ATOM(fb_state, 0); + R300_INIT_ATOM(rs_state, 0); R300_INIT_ATOM(scissor_state, 3); R300_INIT_ATOM(viewport_state, 9); - R300_INIT_ATOM(rs_block_state, 21); + R300_INIT_ATOM(rs_block_state, 0); R300_INIT_ATOM(vertex_format_state, 26); R300_INIT_ATOM(pvs_flush, 2); - R300_INIT_ATOM(vs_state, 1031); + R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(texture_cache_inval, 2); /* Some non-CSO atoms need explicit space to store the state locally. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index ad19725e60..013611018b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -42,7 +42,7 @@ void r300_emit_blend_state(struct r300_context* r300, (struct pipe_framebuffer_state*)r300->fb_state.state; CS_LOCALS(r300); - BEGIN_CS(8); + BEGIN_CS(size); OUT_CS_REG(R300_RB3D_ROPCNTL, blend->rop); OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 3); if (fb->nr_cbufs) { @@ -67,13 +67,13 @@ void r300_emit_blend_color_state(struct r300_context* r300, CS_LOCALS(r300); if (r300screen->caps->is_r500) { - BEGIN_CS(3); + BEGIN_CS(size); OUT_CS_REG_SEQ(R500_RB3D_CONSTANT_COLOR_AR, 2); OUT_CS(bc->blend_color_red_alpha); OUT_CS(bc->blend_color_green_blue); END_CS; } else { - BEGIN_CS(2); + BEGIN_CS(size); OUT_CS_REG(R300_RB3D_BLEND_COLOR, bc->blend_color); END_CS; } @@ -88,7 +88,7 @@ void r300_emit_clip_state(struct r300_context* r300, CS_LOCALS(r300); if (r300screen->caps->has_tcl) { - BEGIN_CS(5 + (6 * 4)); + BEGIN_CS(size); OUT_CS_REG(R300_VAP_PVS_VECTOR_INDX_REG, (r300screen->caps->is_r500 ? R500_PVS_UCP_START : R300_PVS_UCP_START)); @@ -103,7 +103,7 @@ void r300_emit_clip_state(struct r300_context* r300, R300_PS_UCP_MODE_CLIP_AS_TRIFAN); END_CS; } else { - BEGIN_CS(2); + BEGIN_CS(size); OUT_CS_REG(R300_VAP_CLIP_CNTL, R300_CLIP_DISABLE); END_CS; } @@ -119,7 +119,7 @@ void r300_emit_dsa_state(struct r300_context* r300, unsigned size, void* state) struct pipe_stencil_ref stencil_ref = r300->stencil_ref; CS_LOCALS(r300); - BEGIN_CS(r300screen->caps->is_r500 ? 8 : 6); + BEGIN_CS(size); OUT_CS_REG(R300_FG_ALPHA_FUNC, dsa->alpha_function); OUT_CS_REG_SEQ(R300_ZB_CNTL, 3); @@ -390,8 +390,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state) int i; CS_LOCALS(r300); - BEGIN_CS((10 * fb->nr_cbufs) + (2 * (4 - fb->nr_cbufs)) + - (fb->zsbuf ? 10 : 0) + 8); + BEGIN_CS(size); /* Flush and free renderbuffer caches. */ OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, @@ -587,7 +586,7 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state) float scale, offset; CS_LOCALS(r300); - BEGIN_CS(17 + (rs->polygon_offset_enable ? 5 : 0)); + BEGIN_CS(size); OUT_CS_REG(R300_VAP_CNTL_STATUS, rs->vap_control_status); OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config); @@ -636,7 +635,7 @@ void r300_emit_rs_block_state(struct r300_context* r300, DBG(r300, DBG_DRAW, "r300: RS emit:\n"); - BEGIN_CS(5 + count*2); + BEGIN_CS(size); if (r300screen->caps->is_r500) { OUT_CS_REG_SEQ(R500_RS_IP_0, count); } else { @@ -722,7 +721,7 @@ void r300_emit_scissor_state(struct r300_context* r300, (((maxy - 1) + 1440) << R300_SCISSORS_Y_SHIFT); } - BEGIN_CS(3); + BEGIN_CS(size); OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2); OUT_CS(top_left); OUT_CS(bottom_right); @@ -824,7 +823,7 @@ void r300_emit_vertex_format_state(struct r300_context* r300, DBG(r300, DBG_DRAW, "r300: VAP/PSC emit:\n"); - BEGIN_CS(26); + BEGIN_CS(size); OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_info->vinfo.size); OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); @@ -857,7 +856,7 @@ void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state) { CS_LOCALS(r300); - BEGIN_CS(2); + BEGIN_CS(size); OUT_CS_REG(R300_VAP_PVS_STATE_FLUSH_REG, 0x0); END_CS; } @@ -887,7 +886,7 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) return; } - BEGIN_CS(9 + code->length); + BEGIN_CS(size); /* R300_VAP_PVS_CODE_CNTL_0 * R300_VAP_PVS_CONST_CNTL * R300_VAP_PVS_CODE_CNTL_1 @@ -953,11 +952,11 @@ void r300_emit_viewport_state(struct r300_context* r300, CS_LOCALS(r300); if (r300->tcl_bypass) { - BEGIN_CS(2); + BEGIN_CS(2); /* XXX tcl_bypass will be removed in gallium anyway */ OUT_CS_REG(R300_VAP_VTE_CNTL, 0); END_CS; } else { - BEGIN_CS(9); + BEGIN_CS(size); OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); OUT_CS_32F(viewport->xscale); OUT_CS_32F(viewport->xoffset); @@ -997,7 +996,7 @@ void r300_emit_ztop_state(struct r300_context* r300, struct r300_ztop_state* ztop = (struct r300_ztop_state*)state; CS_LOCALS(r300); - BEGIN_CS(2); + BEGIN_CS(size); OUT_CS_REG(R300_ZB_ZTOP, ztop->z_buffer_top); END_CS; } @@ -1006,7 +1005,7 @@ void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, voi { CS_LOCALS(r300); - BEGIN_CS(2); + BEGIN_CS(size); OUT_CS_REG(R300_TX_INVALTAGS, 0); END_CS; } diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 15e0a0ad35..97a0897a5e 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1111,7 +1111,7 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) } r300->vs_state.state = vs; - r300->vs_state.size = vs->code.length + 11; + r300->vs_state.size = vs->code.length + 9; r300->vs_state.dirty = TRUE; r300->vertex_format_state.dirty = TRUE; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index b33d44990a..86301e23d7 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -420,7 +420,7 @@ static void r300_update_rs_block(struct r300_context* r300, /* Now, after all that, see if we actually need to update the state. */ if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) { memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block)); - r300->rs_block_state.size = 5 + count; + r300->rs_block_state.size = 5 + count*2; r300->rs_block_state.dirty = TRUE; } } -- cgit v1.2.3 From d36e3952c21240cde19dac7f16cc37aac7174673 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 27 Feb 2010 17:00:03 +0100 Subject: r300g: put validating buffers after flushing Also cleaning up the nasty validation process. --- src/gallium/drivers/r300/r300_emit.c | 32 +++++++++++++++++--- src/gallium/drivers/r300/r300_emit.h | 4 ++- src/gallium/drivers/r300/r300_render.c | 54 ++++------------------------------ 3 files changed, 37 insertions(+), 53 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 013611018b..d66fa0dbdb 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1010,11 +1010,16 @@ void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, voi END_CS; } -void r300_emit_buffer_validate(struct r300_context *r300) +void r300_emit_buffer_validate(struct r300_context *r300, + boolean do_validate_vertex_buffers, + struct pipe_buffer *index_buffer) { struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)r300->fb_state.state; struct r300_texture* tex; + struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; + struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_buffer *pbuf; unsigned i; boolean invalid = FALSE; @@ -1061,16 +1066,35 @@ validate: goto validate; } } - /* ...and vertex buffer. */ + /* ...vertex buffer for SWTCL path... */ if (r300->vbo) { if (!r300->winsys->add_buffer(r300->winsys, r300->vbo, RADEON_GEM_DOMAIN_GTT, 0)) { r300->context.flush(&r300->context, 0, NULL); goto validate; } - } else { - /* debug_printf("No VBO while emitting dirty state!\n"); */ } + /* ...vertex buffers for HWTCL path... */ + if (do_validate_vertex_buffers) { + for (i = 0; i < r300->vertex_element_count; i++) { + pbuf = vbuf[velem[i].vertex_buffer_index].buffer; + + if (!r300->winsys->add_buffer(r300->winsys, pbuf, + RADEON_GEM_DOMAIN_GTT, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } + } + } + /* ...and index buffer for HWTCL path. */ + if (index_buffer) { + if (!r300->winsys->add_buffer(r300->winsys, index_buffer, + RADEON_GEM_DOMAIN_GTT, 0)) { + r300->context.flush(&r300->context, 0, NULL); + goto validate; + } + } + if (!r300->winsys->validate(r300->winsys)) { r300->context.flush(&r300->context, 0, NULL); if (invalid) { diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index c73b016b76..4a3f94087b 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -105,6 +105,8 @@ unsigned r300_get_num_dirty_dwords(struct r300_context *r300); /* Emit all dirty state. */ void r300_emit_dirty_state(struct r300_context* r300); -void r300_emit_buffer_validate(struct r300_context *r300); +void r300_emit_buffer_validate(struct r300_context *r300, + boolean do_validate_vertex_buffers, + struct pipe_buffer *index_buffer); #endif /* R300_EMIT_H */ diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index e4f7615368..c5baf5508e 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -186,6 +186,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, dwords = 10 + count * vertex_size; r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); + r300_emit_buffer_validate(r300, FALSE, 0); r300_emit_dirty_state(r300); BEGIN_CS(dwords); @@ -313,31 +314,6 @@ static void r300_emit_draw_elements(struct r300_context *r300, END_CS; } -static boolean r300_setup_vertex_buffers(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; - struct pipe_buffer *pbuf; - -validate: - for (int i = 0; i < r300->vertex_element_count; i++) { - pbuf = vbuf[velem[i].vertex_buffer_index].buffer; - - if (!r300->winsys->add_buffer(r300->winsys, pbuf, - RADEON_GEM_DOMAIN_GTT, 0)) { - r300->context.flush(&r300->context, 0, NULL); - goto validate; - } - } - - if (!r300->winsys->validate(r300->winsys)) { - r300->context.flush(&r300->context, 0, NULL); - return r300->winsys->validate(r300->winsys); - } - - return TRUE; -} - static void r300_shorten_ubyte_elts(struct r300_context* r300, struct pipe_buffer** elts, unsigned count) @@ -393,30 +369,16 @@ void r300_draw_range_elements(struct pipe_context* pipe, return; } - r300_update_derived_state(r300); - - r300_emit_buffer_validate(r300); - - if (!r300_setup_vertex_buffers(r300)) { - return; - } - if (indexSize == 1) { r300_shorten_ubyte_elts(r300, &indexBuffer, count); indexSize = 2; } - if (!r300->winsys->add_buffer(r300->winsys, indexBuffer, - RADEON_GEM_DOMAIN_GTT, 0)) { - goto cleanup; - } - - if (!r300->winsys->validate(r300->winsys)) { - goto cleanup; - } + r300_update_derived_state(r300); /* 128 dwords for emit_aos and emit_draw_elements */ r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); + r300_emit_buffer_validate(r300, TRUE, indexBuffer); r300_emit_dirty_state(r300); r300_emit_aos(r300, 0); @@ -434,13 +396,13 @@ void r300_draw_range_elements(struct pipe_context* pipe, /* 16 spare dwords are enough for emit_draw_elements. */ if (count && r300_reserve_cs_space(r300, 16)) { + r300_emit_buffer_validate(r300, TRUE, indexBuffer); r300_emit_dirty_state(r300); r300_emit_aos(r300, 0); } } while (count); } -cleanup: if (indexBuffer != orgIndexBuffer) { pipe->screen->buffer_destroy(indexBuffer); } @@ -477,18 +439,13 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, r300_update_derived_state(r300); - r300_emit_buffer_validate(r300); - if (immd_is_good_idea(r300, count)) { r300_emit_draw_arrays_immediate(r300, mode, start, count); } else { - if (!r300_setup_vertex_buffers(r300)) { - return; - } - /* Make sure there are at least 128 spare dwords in the command buffer. * (most of it being consumed by emit_aos) */ r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); + r300_emit_buffer_validate(r300, TRUE, 0); r300_emit_dirty_state(r300); if (alt_num_verts || count <= 65535) { @@ -506,6 +463,7 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, /* Again, we emit both AOS and draw_arrays so there should be * at least 128 spare dwords. */ if (count && r300_reserve_cs_space(r300, 128)) { + r300_emit_buffer_validate(r300, TRUE, 0); r300_emit_dirty_state(r300); } } while (count); -- cgit v1.2.3 From 79a86d312d8b3bc2e4fa28734467400e0b050301 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 28 Feb 2010 16:28:44 +0000 Subject: i965g: Fix texture creation --- src/gallium/drivers/i965/brw_screen_texture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index 8bdd43cf14..38e9961398 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -250,7 +250,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen, tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW; tex->ss.ss0.surface_type = translate_tex_target(tex->base.target); - format = translate_tex_target(tex->base.format); + format = translate_tex_format(tex->base.format); assert(format != BRW_SURFACEFORMAT_INVALID); tex->ss.ss0.surface_format = format; -- cgit v1.2.3 From 942762cd973af0df75040de21d3321cd19829e70 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 28 Feb 2010 07:45:56 +0100 Subject: r300g: decouple vertex stream setup (PSC) and VS output mapping (VAP_OUT) Formerly known as vertex_format_state. These two are completely unrelated when using HWTCL and decoupling them makes the design less SWTCL-centric. When bypass_vs_clip_and_viewport gets removed, the PSC setup will no longer be a derived state. This change shouldn't make unbreaking SWTCL harder. --- src/gallium/drivers/r300/r300_context.c | 9 +++-- src/gallium/drivers/r300/r300_context.h | 35 ++++++++++------- src/gallium/drivers/r300/r300_emit.c | 55 +++++++++++++++------------ src/gallium/drivers/r300/r300_emit.h | 5 ++- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state.c | 14 +++++-- src/gallium/drivers/r300/r300_state_derived.c | 47 +++++++++++++---------- 7 files changed, 101 insertions(+), 66 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 3a84fc564d..1d7d598b24 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -59,7 +59,8 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->fb_state.state); FREE(r300->rs_block_state.state); FREE(r300->scissor_state.state); - FREE(r300->vertex_format_state.state); + FREE(r300->vertex_stream_state.state); + FREE(r300->vap_output_state.state); FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); FREE(r300); @@ -127,7 +128,8 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(scissor_state, 3); R300_INIT_ATOM(viewport_state, 9); R300_INIT_ATOM(rs_block_state, 0); - R300_INIT_ATOM(vertex_format_state, 26); + R300_INIT_ATOM(vertex_stream_state, 0); + R300_INIT_ATOM(vap_output_state, 6); R300_INIT_ATOM(pvs_flush, 2); R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(texture_cache_inval, 2); @@ -138,7 +140,8 @@ static void r300_setup_atoms(struct r300_context* r300) r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state); r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); - r300->vertex_format_state.state = CALLOC_STRUCT(r300_vertex_info); + r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state); + r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 47f2aa5154..3eb884a0cf 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -134,6 +134,21 @@ struct r300_texture_fb_state { uint32_t zb_format; /* R300_ZB_FORMAT */ }; +struct r300_vertex_stream_state { + /* R300_VAP_PROG_STREAK_CNTL_[0-7] */ + uint32_t vap_prog_stream_cntl[8]; + /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */ + uint32_t vap_prog_stream_cntl_ext[8]; + + unsigned count; +}; + +struct r300_vap_output_state { + uint32_t vap_vtx_state_cntl; /* R300_VAP_VTX_STATE_CNTL: 0x2180 */ + uint32_t vap_vsm_vtx_assm; /* R300_VAP_VSM_VTX_ASSM: 0x2184 */ + uint32_t vap_out_vtx_fmt[2]; /* R300_VAP_OUTPUT_VTX_FMT_[0-1]: 0x2090 */ +}; + struct r300_viewport_state { float xscale; /* R300_VAP_VPORT_XSCALE: 0x2098 */ float xoffset; /* R300_VAP_VPORT_XOFFSET: 0x209c */ @@ -246,16 +261,6 @@ struct r300_texture { enum r300_buffer_tiling microtile, macrotile; }; -struct r300_vertex_info { - /* Parent class */ - struct vertex_info vinfo; - - /* R300_VAP_PROG_STREAK_CNTL_[0-7] */ - uint32_t vap_prog_stream_cntl[8]; - /* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */ - uint32_t vap_prog_stream_cntl_ext[8]; -}; - extern struct pipe_viewport_state r300_viewport_identity; struct r300_context { @@ -280,9 +285,6 @@ struct r300_context { struct r300_query *query_current; struct r300_query query_list; - /* Vertex formatting information. */ - struct r300_atom vertex_format_state; - /* Various CSO state objects. */ /* Beginning of atom list. */ struct r300_atom atom_list; @@ -312,6 +314,10 @@ struct r300_context { /* Texture states. */ struct r300_texture* textures[8]; int texture_count; + /* Vertex stream formatting state. */ + struct r300_atom vertex_stream_state; + /* VAP (vertex shader) output mapping state. */ + struct r300_atom vap_output_state; /* Vertex shader. */ struct r300_atom vs_state; /* Viewport state. */ @@ -334,6 +340,9 @@ struct r300_context { struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; int vertex_element_count; + /* Vertex info for Draw. */ + struct vertex_info vertex_info; + struct pipe_stencil_ref stencil_ref; /* Bitmask of dirty state objects. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index d66fa0dbdb..6a6771399a 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -814,44 +814,51 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) END_CS; } -void r300_emit_vertex_format_state(struct r300_context* r300, +void r300_emit_vertex_stream_state(struct r300_context* r300, unsigned size, void* state) { - struct r300_vertex_info* vertex_info = (struct r300_vertex_info*)state; + struct r300_vertex_stream_state *streams = + (struct r300_vertex_stream_state*)state; unsigned i; CS_LOCALS(r300); - DBG(r300, DBG_DRAW, "r300: VAP/PSC emit:\n"); + DBG(r300, DBG_DRAW, "r300: PSC emit:\n"); BEGIN_CS(size); - OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_info->vinfo.size); - - OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); - OUT_CS(vertex_info->vinfo.hwfmt[0]); - OUT_CS(vertex_info->vinfo.hwfmt[1]); - OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); - OUT_CS(vertex_info->vinfo.hwfmt[2]); - OUT_CS(vertex_info->vinfo.hwfmt[3]); - for (i = 0; i < 4; i++) { - DBG(r300, DBG_DRAW, " : hwfmt%d: 0x%08x\n", i, - vertex_info->vinfo.hwfmt[i]); - } - - OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8); - for (i = 0; i < 8; i++) { - OUT_CS(vertex_info->vap_prog_stream_cntl[i]); + OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, streams->count); + for (i = 0; i < streams->count; i++) { + OUT_CS(streams->vap_prog_stream_cntl[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl%d: 0x%08x\n", i, - vertex_info->vap_prog_stream_cntl[i]); + streams->vap_prog_stream_cntl[i]); } - OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, 8); - for (i = 0; i < 8; i++) { - OUT_CS(vertex_info->vap_prog_stream_cntl_ext[i]); + OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_EXT_0, streams->count); + for (i = 0; i < streams->count; i++) { + OUT_CS(streams->vap_prog_stream_cntl_ext[i]); DBG(r300, DBG_DRAW, " : prog_stream_cntl_ext%d: 0x%08x\n", i, - vertex_info->vap_prog_stream_cntl_ext[i]); + streams->vap_prog_stream_cntl_ext[i]); } END_CS; } +void r300_emit_vap_output_state(struct r300_context* r300, + unsigned size, void* state) +{ + struct r300_vap_output_state *vap_out_state = + (struct r300_vap_output_state*)state; + CS_LOCALS(r300); + + DBG(r300, DBG_DRAW, "r300: VAP emit:\n"); + + BEGIN_CS(size); + OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); + OUT_CS(vap_out_state->vap_vtx_state_cntl); + OUT_CS(vap_out_state->vap_vsm_vtx_assm); + OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); + OUT_CS(vap_out_state->vap_out_vtx_fmt[0]); + OUT_CS(vap_out_state->vap_out_vtx_fmt[1]); + END_CS; +} + void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state) { CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 4a3f94087b..a2c2a91b88 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -77,9 +77,12 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_vertex_buffer(struct r300_context* r300); -void r300_emit_vertex_format_state(struct r300_context* r300, +void r300_emit_vertex_stream_state(struct r300_context* r300, unsigned size, void* state); +void r300_emit_vap_output_state(struct r300_context* r300, + unsigned size, void* state); + void r300_emit_vertex_program_code(struct r300_context* r300, struct r300_vertex_program_code* code); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index c5baf5508e..770a92be74 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -597,7 +597,7 @@ r300_render_get_vertex_info(struct vbuf_render* render) r300_update_derived_state(r300); - return (struct vertex_info*)r300->vertex_format_state.state; + return &r300->vertex_info; } static boolean r300_render_allocate_vertices(struct vbuf_render* render, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 97a0897a5e..5a47158400 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -659,7 +659,11 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) r300->fs = fs; r300_pick_fragment_shader(r300); - r300->vertex_format_state.dirty = TRUE; + r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ + + if (r300->vs_state.state && r300_vertex_shader_setup_wpos(r300)) { + r300->vap_output_state.dirty = TRUE; + } r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS; } @@ -1033,9 +1037,9 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, if (r300->draw) { draw_flush(r300->draw); draw_set_vertex_buffers(r300->draw, count, buffers); + } else { + r300->vertex_stream_state.dirty = TRUE; } - - r300->vertex_format_state.dirty = TRUE; } static boolean r300_validate_aos(struct r300_context *r300) @@ -1114,7 +1118,9 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300->vs_state.size = vs->code.length + 9; r300->vs_state.dirty = TRUE; - r300->vertex_format_state.dirty = TRUE; + r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ + r300->vap_output_state.dirty = TRUE; + r300->vertex_stream_state.dirty = TRUE; /* XXX needed for TCL bypass */ r300->pvs_flush.dirty = TRUE; if (r300->fs) { diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 86301e23d7..0574d98e07 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -49,9 +49,7 @@ static void r300_draw_emit_attrib(struct r300_context* r300, output = draw_find_shader_output(r300->draw, info->output_semantic_name[index], info->output_semantic_index[index]); - draw_emit_vertex_attr( - (struct vertex_info*)r300->vertex_format_state.state, - emit, interp, output); + draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output); } static void r300_draw_emit_all_attribs(struct r300_context* r300) @@ -106,17 +104,21 @@ static void r300_draw_emit_all_attribs(struct r300_context* r300) } /* Update the PSC tables. */ +/* XXX move this function into r300_state.c after TCL-bypass gets removed + * XXX because this one is dependent only on vertex elements. */ static void r300_vertex_psc(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_vertex_info *vformat = - (struct r300_vertex_info*)r300->vertex_format_state.state; + struct r300_vertex_stream_state *vformat = + (struct r300_vertex_stream_state*)r300->vertex_stream_state.state; uint16_t type, swizzle; enum pipe_format format; unsigned i; int identity[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; int* stream_tab; + memset(vformat, 0, sizeof(struct r300_vertex_stream_state)); + /* If TCL is bypassed, map vertex streams to equivalent VS output * locations. */ if (r300->tcl_bypass) { @@ -157,20 +159,25 @@ static void r300_vertex_psc(struct r300_context* r300) } vformat->vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC << (i & 1 ? 16 : 0)); + + vformat->count = (i >> 1) + 1; + r300->vertex_stream_state.size = (1 + vformat->count) * 2; } /* Update the PSC tables for SW TCL, using Draw. */ static void r300_swtcl_vertex_psc(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_vertex_info *vformat = - (struct r300_vertex_info*)r300->vertex_format_state.state; - struct vertex_info* vinfo = &vformat->vinfo; + struct r300_vertex_stream_state *vformat = + (struct r300_vertex_stream_state*)r300->vertex_stream_state.state; + struct vertex_info* vinfo = &r300->vertex_info; uint16_t type, swizzle; enum pipe_format format; unsigned i, attrib_count; int* vs_output_tab = vs->stream_loc_notcl; + memset(vformat, 0, sizeof(struct r300_vertex_stream_state)); + /* For each Draw attribute, route it to the fragment shader according * to the vs_output_tab. */ attrib_count = vinfo->num_attribs; @@ -212,6 +219,9 @@ static void r300_swtcl_vertex_psc(struct r300_context* r300) } vformat->vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC << (i & 1 ? 16 : 0)); + + vformat->count = (i >> 1) + 1; + r300->vertex_stream_state.size = (1 + vformat->count) * 2; } static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr, @@ -430,13 +440,12 @@ static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; struct r300_screen* r300screen = r300_screen(r300->context.screen); - struct r300_vertex_info *vformat = - (struct r300_vertex_info*)r300->vertex_format_state.state; - struct vertex_info* vinfo = &vformat->vinfo; + struct r300_vap_output_state *vap_out = + (struct r300_vap_output_state*)r300->vap_output_state.state; - /* Mmm, delicious hax */ - memset(r300->vertex_format_state.state, 0, sizeof(struct r300_vertex_info)); - memcpy(vinfo->hwfmt, vs->hwfmt, sizeof(uint)*4); + /* XXX Mmm, delicious hax */ + memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); + memcpy(vap_out, vs->hwfmt, sizeof(uint)*4); r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs); @@ -444,8 +453,7 @@ static void r300_update_derived_shader_state(struct r300_context* r300) r300_vertex_psc(r300); } else { r300_draw_emit_all_attribs(r300); - draw_compute_vertex_size( - (struct vertex_info*)r300->vertex_format_state.state); + draw_compute_vertex_size(&r300->vertex_info); r300_swtcl_vertex_psc(r300); } } @@ -523,10 +531,9 @@ static void r300_update_ztop(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { - /* XXX */ - if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER || - r300->vs_state.dirty || r300->vertex_format_state.dirty || - r300->rs_state.dirty) { + if (r300->rs_block_state.dirty || + r300->vertex_stream_state.dirty || /* XXX put updating this state out of this file */ + r300->rs_state.dirty) { /* XXX and remove this one (tcl_bypass dependency) */ r300_update_derived_shader_state(r300); } -- cgit v1.2.3 From d2ac3d5e79bdf5a32a2dca135403d963ac6c83e4 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 28 Feb 2010 19:28:31 +0100 Subject: r300g: atomize texture and sampler states --- src/gallium/drivers/r300/r300_blit.c | 8 +- src/gallium/drivers/r300/r300_context.c | 3 + src/gallium/drivers/r300/r300_context.h | 35 +++++--- src/gallium/drivers/r300/r300_emit.c | 117 +++++++------------------- src/gallium/drivers/r300/r300_emit.h | 11 +-- src/gallium/drivers/r300/r300_fs.c | 7 +- src/gallium/drivers/r300/r300_state.c | 43 +++++----- src/gallium/drivers/r300/r300_state_derived.c | 62 +++++++++++++- src/gallium/drivers/r300/r300_texture.c | 2 +- 9 files changed, 153 insertions(+), 135 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 187b4bf384..32d05749bd 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -98,6 +98,8 @@ static void r300_hw_copy(struct pipe_context* pipe, unsigned width, unsigned height) { struct r300_context* r300 = r300_context(pipe); + struct r300_textures_state* state = + (struct r300_textures_state*)r300->textures_state.state; /* Yeah we have to save all those states to ensure this blitter operation * is really transparent. The states will be restored by the blitter once @@ -106,11 +108,11 @@ static void r300_hw_copy(struct pipe_context* pipe, util_blitter_save_framebuffer(r300->blitter, r300->fb_state.state); util_blitter_save_fragment_sampler_states( - r300->blitter, r300->sampler_count, (void**)r300->sampler_states); + r300->blitter, state->sampler_count, (void**)state->sampler_states); util_blitter_save_fragment_sampler_textures( - r300->blitter, r300->texture_count, - (struct pipe_texture**)r300->textures); + r300->blitter, state->texture_count, + (struct pipe_texture**)state->textures); /* Do a copy */ util_blitter_copy(r300->blitter, diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 1d7d598b24..86b98a4ba5 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -59,6 +59,7 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->fb_state.state); FREE(r300->rs_block_state.state); FREE(r300->scissor_state.state); + FREE(r300->textures_state.state); FREE(r300->vertex_stream_state.state); FREE(r300->vap_output_state.state); FREE(r300->viewport_state.state); @@ -133,6 +134,7 @@ static void r300_setup_atoms(struct r300_context* r300) R300_INIT_ATOM(pvs_flush, 2); R300_INIT_ATOM(vs_state, 0); R300_INIT_ATOM(texture_cache_inval, 2); + R300_INIT_ATOM(textures_state, 0); /* Some non-CSO atoms need explicit space to store the state locally. */ r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state); @@ -140,6 +142,7 @@ static void r300_setup_atoms(struct r300_context* r300) r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state); r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); + r300->textures_state.state = CALLOC_STRUCT(r300_textures_state); r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state); r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 3eb884a0cf..b98fe347b8 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -118,7 +118,7 @@ struct r300_sampler_state { unsigned min_lod, max_lod; }; -struct r300_texture_state { +struct r300_texture_format_state { uint32_t format0; /* R300_TX_FORMAT0: 0x4480 */ uint32_t format1; /* R300_TX_FORMAT1: 0x44c0 */ uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */ @@ -134,6 +134,25 @@ struct r300_texture_fb_state { uint32_t zb_format; /* R300_ZB_FORMAT */ }; +struct r300_textures_state { + /* Textures. */ + struct r300_texture *textures[8]; + int texture_count; + /* Sampler states. */ + struct r300_sampler_state *sampler_states[8]; + int sampler_count; + + /* These is the merge of the texture and sampler states. */ + unsigned count; + uint32_t tx_enable; /* R300_TX_ENABLE: 0x4101 */ + struct r300_texture_sampler_state { + uint32_t format[3]; /* R300_TX_FORMAT[0-2] */ + uint32_t filter[2]; /* R300_TX_FILTER[0-1] */ + uint32_t border_color; /* R300_TX_BORDER_COLOR: 0x45c0 */ + uint32_t tile_config; /* R300_TX_OFFSET (subset thereof) */ + } regs[8]; +}; + struct r300_vertex_stream_state { /* R300_VAP_PROG_STREAK_CNTL_[0-7] */ uint32_t vap_prog_stream_cntl[8]; @@ -165,10 +184,6 @@ struct r300_ztop_state { #define R300_NEW_FRAGMENT_SHADER 0x00000020 #define R300_NEW_FRAGMENT_SHADER_CONSTANTS 0x00000040 -#define R300_NEW_SAMPLER 0x00000200 -#define R300_ANY_NEW_SAMPLERS 0x0001fe00 -#define R300_NEW_TEXTURE 0x00040000 -#define R300_ANY_NEW_TEXTURES 0x03fc0000 #define R300_NEW_VERTEX_SHADER_CONSTANTS 0x10000000 #define R300_NEW_QUERY 0x40000000 #define R300_NEW_KITCHEN_SINK 0x7fffffff @@ -254,7 +269,7 @@ struct r300_texture { struct pipe_buffer* buffer; /* Registers carrying texture format data. */ - struct r300_texture_state state; + struct r300_texture_format_state state; struct r300_texture_fb_state fb_state; /* Buffer tiling */ @@ -306,14 +321,10 @@ struct r300_context { struct r300_atom rs_state; /* RS block state. */ struct r300_atom rs_block_state; - /* Sampler states. */ - struct r300_sampler_state* sampler_states[8]; - int sampler_count; /* Scissor state. */ struct r300_atom scissor_state; - /* Texture states. */ - struct r300_texture* textures[8]; - int texture_count; + /* Textures state. */ + struct r300_atom textures_state; /* Vertex stream formatting state. */ struct r300_atom vertex_stream_state; /* VAP (vertex shader) output mapping state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 6a6771399a..17d55ba3b4 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -146,6 +146,8 @@ static const float * get_shader_constant( { struct r300_viewport_state* viewport = (struct r300_viewport_state*)r300->viewport_state.state; + struct r300_textures_state* texstate = + (struct r300_textures_state*)r300->textures_state.state; static float vec[4] = { 0.0, 0.0, 0.0, 1.0 }; struct pipe_texture *tex; @@ -161,7 +163,7 @@ static const float * get_shader_constant( /* Factor for converting rectangle coords to * normalized coords. Should only show up on non-r500. */ case RC_STATE_R300_TEXRECT_FACTOR: - tex = &r300->textures[constant->u.State[1]]->tex; + tex = &texstate->textures[constant->u.State[1]]->tex; vec[0] = 1.0 / tex->width0; vec[1] = 1.0 / tex->height0; break; @@ -728,49 +730,35 @@ void r300_emit_scissor_state(struct r300_context* r300, END_CS; } -void r300_emit_texture(struct r300_context* r300, - struct r300_sampler_state* sampler, - struct r300_texture* tex, - unsigned offset) +void r300_emit_textures_state(struct r300_context *r300, + unsigned size, void *state) { - uint32_t filter0 = sampler->filter0; - uint32_t format0 = tex->state.format0; - unsigned min_level, max_level; + struct r300_textures_state *allstate = (struct r300_textures_state*)state; + struct r300_texture_sampler_state *texstate; + unsigned i; CS_LOCALS(r300); - /* to emulate 1D textures through 2D ones correctly */ - if (tex->tex.target == PIPE_TEXTURE_1D) { - filter0 &= ~R300_TX_WRAP_T_MASK; - filter0 |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE); - } + BEGIN_CS(size); + OUT_CS_REG(R300_TX_ENABLE, allstate->tx_enable); - if (tex->is_npot) { - /* NPOT textures don't support mip filter, unfortunately. - * This prevents incorrect rendering. */ - filter0 &= ~R300_TX_MIN_FILTER_MIP_MASK; - } else { - /* determine min/max levels */ - /* the MAX_MIP level is the largest (finest) one */ - max_level = MIN2(sampler->max_lod, tex->tex.last_level); - min_level = MIN2(sampler->min_lod, max_level); - format0 |= R300_TX_NUM_LEVELS(max_level); - filter0 |= R300_TX_MAX_MIP_LEVEL(min_level); - } + for (i = 0; i < allstate->count; i++) { + if ((1 << i) & allstate->tx_enable) { + texstate = &allstate->regs[i]; + + OUT_CS_REG(R300_TX_FILTER0_0 + (i * 4), texstate->filter[0]); + OUT_CS_REG(R300_TX_FILTER1_0 + (i * 4), texstate->filter[1]); + OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (i * 4), + texstate->border_color); + + OUT_CS_REG(R300_TX_FORMAT0_0 + (i * 4), texstate->format[0]); + OUT_CS_REG(R300_TX_FORMAT1_0 + (i * 4), texstate->format[1]); + OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]); - BEGIN_CS(16); - OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), filter0 | - (offset << 28)); - OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1); - OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color); - - OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), format0); - OUT_CS_REG(R300_TX_FORMAT1_0 + (offset * 4), tex->state.format1); - OUT_CS_REG(R300_TX_FORMAT2_0 + (offset * 4), tex->state.format2); - OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (offset * 4), 1); - OUT_CS_RELOC(tex->buffer, - R300_TXO_MACRO_TILE(tex->macrotile) | - R300_TXO_MICRO_TILE(tex->microtile), - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0); + OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1); + OUT_CS_RELOC(allstate->textures[i]->buffer, texstate->tile_config, + RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0); + } + } END_CS; } @@ -976,27 +964,6 @@ void r300_emit_viewport_state(struct r300_context* r300, } } -void r300_emit_texture_count(struct r300_context* r300) -{ - uint32_t tx_enable = 0; - int i; - CS_LOCALS(r300); - - /* Notice that texture_count and sampler_count are just sizes - * of the respective arrays. We still have to check for the individual - * elements. */ - for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) { - if (r300->textures[i]) { - tx_enable |= 1 << i; - } - } - - BEGIN_CS(2); - OUT_CS_REG(R300_TX_ENABLE, tx_enable); - END_CS; - -} - void r300_emit_ztop_state(struct r300_context* r300, unsigned size, void* state) { @@ -1023,6 +990,8 @@ void r300_emit_buffer_validate(struct r300_context *r300, { struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)r300->fb_state.state; + struct r300_textures_state *texstate = + (struct r300_textures_state*)r300->textures_state.state; struct r300_texture* tex; struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; struct pipe_vertex_element *velem = r300->vertex_element; @@ -1055,9 +1024,9 @@ validate: } } /* ...textures... */ - for (i = 0; i < r300->texture_count; i++) { - tex = r300->textures[i]; - if (!tex) + for (i = 0; i < texstate->count; i++) { + tex = texstate->textures[i]; + if (!tex || !texstate->sampler_states[i]) continue; if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { @@ -1136,7 +1105,6 @@ void r300_emit_dirty_state(struct r300_context* r300) { struct r300_screen* r300screen = r300_screen(r300->context.screen); struct r300_atom* atom; - unsigned i; if (r300->dirty_state & R300_NEW_QUERY) { r300_emit_query_start(r300); @@ -1171,27 +1139,6 @@ void r300_emit_dirty_state(struct r300_context* r300) r300->dirty_state &= ~R300_NEW_FRAGMENT_SHADER_CONSTANTS; } - /* Samplers and textures are tracked separately but emitted together. */ - if (r300->dirty_state & - (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { - r300_emit_texture_count(r300); - - for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) { - if (r300->dirty_state & - ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) { - if (r300->textures[i]) { - r300_emit_texture(r300, - r300->sampler_states[i], - r300->textures[i], - i); - } - r300->dirty_state &= - ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i)); - } - } - r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES); - } - if (r300->dirty_state & R300_NEW_VERTEX_SHADER_CONSTANTS) { struct r300_vertex_shader* vs = r300->vs_state.state; r300_emit_vs_constant_buffer(r300, &vs->code.constants); diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index a2c2a91b88..449e640a88 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -70,10 +70,8 @@ void r300_emit_rs_block_state(struct r300_context* r300, void r300_emit_scissor_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_texture(struct r300_context* r300, - struct r300_sampler_state* sampler, - struct r300_texture* tex, - unsigned offset); +void r300_emit_textures_state(struct r300_context *r300, + unsigned size, void *state); void r300_emit_vertex_buffer(struct r300_context* r300); @@ -83,9 +81,6 @@ void r300_emit_vertex_stream_state(struct r300_context* r300, void r300_emit_vap_output_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_vertex_program_code(struct r300_context* r300, - struct r300_vertex_program_code* code); - void r300_emit_vs_constant_buffer(struct r300_context* r300, struct rc_constant_list* constants); @@ -94,8 +89,6 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state); void r300_emit_viewport_state(struct r300_context* r300, unsigned size, void* state); -void r300_emit_texture_count(struct r300_context* r300); - void r300_emit_ztop_state(struct r300_context* r300, unsigned size, void* state); diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index ae4c62b2f1..3c2625269b 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -133,10 +133,13 @@ static void get_compare_state( struct r300_fragment_program_external_state* state, unsigned shadow_samplers) { + struct r300_textures_state *texstate = + (struct r300_textures_state*)r300->textures_state.state; + memset(state, 0, sizeof(*state)); - for (int i = 0; i < r300->sampler_count; i++) { - struct r300_sampler_state* s = r300->sampler_states[i]; + for (int i = 0; i < texstate->sampler_count; i++) { + struct r300_sampler_state* s = texstate->sampler_states[i]; if (s && s->state.compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { /* XXX Gallium doesn't provide us with any information regarding diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 5a47158400..12bf083871 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -859,7 +859,7 @@ static void* state->max_anisotropy > 0); /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */ - /* We must pass these to the emit function to clamp them properly. */ + /* We must pass these to the merge function to clamp them properly. */ sampler->min_lod = MAX2((unsigned)state->min_lod, 0); sampler->max_lod = MAX2((unsigned)ceilf(state->max_lod), 0); @@ -885,23 +885,20 @@ static void r300_bind_sampler_states(struct pipe_context* pipe, void** states) { struct r300_context* r300 = r300_context(pipe); - int i; + struct r300_textures_state* state = + (struct r300_textures_state*)r300->textures_state.state; if (count > 8) { return; } - for (i = 0; i < count; i++) { - if (r300->sampler_states[i] != states[i]) { - r300->sampler_states[i] = (struct r300_sampler_state*)states[i]; - r300->dirty_state |= (R300_NEW_SAMPLER << i); - } - } + memcpy(state->sampler_states, states, sizeof(void*) * count); + state->sampler_count = count; - r300->sampler_count = count; + r300->textures_state.dirty = TRUE; /* Pick a fragment shader based on the texture compare state. */ - if (r300->fs && (r300->dirty_state & R300_ANY_NEW_SAMPLERS)) { + if (r300->fs && count) { if (r300_pick_fragment_shader(r300)) { r300->dirty_state |= R300_NEW_FRAGMENT_SHADER | R300_NEW_FRAGMENT_SHADER_CONSTANTS; @@ -925,24 +922,25 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, struct pipe_texture** texture) { struct r300_context* r300 = r300_context(pipe); + struct r300_textures_state* state = + (struct r300_textures_state*)r300->textures_state.state; + unsigned i; boolean is_r500 = r300_screen(r300->context.screen)->caps->is_r500; boolean dirty_tex = FALSE; - int i; /* XXX magic num */ if (count > 8) { return; } - + for (i = 0; i < count; i++) { - if (r300->textures[i] != (struct r300_texture*)texture[i]) { - pipe_texture_reference((struct pipe_texture**)&r300->textures[i], - texture[i]); - r300->dirty_state |= (R300_NEW_TEXTURE << i); + if (state->textures[i] != (struct r300_texture*)texture[i]) { + pipe_texture_reference((struct pipe_texture**)&state->textures[i], + texture[i]); dirty_tex = TRUE; - /* R300-specific - set the texrect factor in a fragment shader */ - if (!is_r500 && r300->textures[i]->is_npot) { + /* R300-specific - set the texrect factor in the fragment shader */ + if (!is_r500 && state->textures[i]->is_npot) { /* XXX It would be nice to re-emit just 1 constant, * XXX not all of them */ r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; @@ -951,14 +949,15 @@ static void r300_set_sampler_textures(struct pipe_context* pipe, } for (i = count; i < 8; i++) { - if (r300->textures[i]) { - pipe_texture_reference((struct pipe_texture**)&r300->textures[i], + if (state->textures[i]) { + pipe_texture_reference((struct pipe_texture**)&state->textures[i], NULL); - r300->dirty_state |= (R300_NEW_TEXTURE << i); } } - r300->texture_count = count; + state->texture_count = count; + + r300->textures_state.dirty = TRUE; if (dirty_tex) { r300->texture_cache_inval.dirty = TRUE; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 0574d98e07..6eb7f2bfd1 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -431,7 +431,6 @@ static void r300_update_rs_block(struct r300_context* r300, if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) { memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block)); r300->rs_block_state.size = 5 + count*2; - r300->rs_block_state.dirty = TRUE; } } @@ -529,6 +528,63 @@ static void r300_update_ztop(struct r300_context* r300) r300->ztop_state.dirty = TRUE; } +static void r300_merge_textures_and_samplers(struct r300_context* r300) +{ + struct r300_textures_state *state = + (struct r300_textures_state*)r300->textures_state.state; + struct r300_texture_sampler_state *texstate; + struct r300_sampler_state *sampler; + struct r300_texture *tex; + unsigned min_level, max_level, i, size; + unsigned count = MIN2(state->texture_count, state->sampler_count); + + state->tx_enable = 0; + size = 2; + + for (i = 0; i < count; i++) { + if (state->textures[i] && state->sampler_states[i]) { + state->tx_enable |= 1 << i; + + tex = state->textures[i]; + sampler = state->sampler_states[i]; + + texstate = &state->regs[i]; + memcpy(texstate->format, &tex->state, sizeof(uint32_t)*3); + texstate->filter[0] = sampler->filter0; + texstate->filter[1] = sampler->filter1; + texstate->border_color = sampler->border_color; + texstate->tile_config = R300_TXO_MACRO_TILE(tex->macrotile) | + R300_TXO_MICRO_TILE(tex->microtile); + + /* to emulate 1D textures through 2D ones correctly */ + if (tex->tex.target == PIPE_TEXTURE_1D) { + texstate->filter[0] &= ~R300_TX_WRAP_T_MASK; + texstate->filter[0] |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE); + } + + if (tex->is_npot) { + /* NPOT textures don't support mip filter, unfortunately. + * This prevents incorrect rendering. */ + texstate->filter[0] &= ~R300_TX_MIN_FILTER_MIP_MASK; + } else { + /* determine min/max levels */ + /* the MAX_MIP level is the largest (finest) one */ + max_level = MIN2(sampler->max_lod, tex->tex.last_level); + min_level = MIN2(sampler->min_lod, max_level); + texstate->format[0] |= R300_TX_NUM_LEVELS(max_level); + texstate->filter[0] |= R300_TX_MAX_MIP_LEVEL(min_level); + } + + texstate->filter[0] |= i << 28; + + size += 16; + state->count = i+1; + } + } + + r300->textures_state.size = size; +} + void r300_update_derived_state(struct r300_context* r300) { if (r300->rs_block_state.dirty || @@ -537,5 +593,9 @@ void r300_update_derived_state(struct r300_context* r300) r300_update_derived_shader_state(r300); } + if (r300->textures_state.dirty) { + r300_merge_textures_and_samplers(r300); + } + r300_update_ztop(r300); } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7c3b781c0b..2246c75056 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -505,7 +505,7 @@ boolean r300_is_sampler_format_supported(enum pipe_format format) static void r300_setup_texture_state(struct r300_screen* screen, struct r300_texture* tex) { - struct r300_texture_state* state = &tex->state; + struct r300_texture_format_state* state = &tex->state; struct pipe_texture *pt = &tex->tex; unsigned i; boolean is_r500 = screen->caps->is_r500; -- cgit v1.2.3 From e243e87b522487f3c5e2c705884a97bafe091d32 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 27 Feb 2010 23:49:58 +0000 Subject: llvmpipe: Don't mention deprecated drivers=trace option. Now trace always built. --- src/gallium/drivers/llvmpipe/README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README index 72d9f39658..ae2c1ba943 100644 --- a/src/gallium/drivers/llvmpipe/README +++ b/src/gallium/drivers/llvmpipe/README @@ -86,7 +86,7 @@ Building To build everything on Linux invoke scons as: - scons debug=yes statetrackers=mesa drivers=trace,llvmpipe winsys=xlib dri=false + scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=xlib dri=false Alternatively, you can build it with GNU make, if you prefer, by invoking it as @@ -96,7 +96,7 @@ but the rest of these instructions assume that scons is used. For windows is everything the except except the winsys: - scons debug=yes statetrackers=mesa drivers=trace,llvmpipe winsys=gdi dri=false + scons debug=yes statetrackers=mesa drivers=llvmpipe winsys=gdi dri=false Using ===== -- cgit v1.2.3 From f54aecc4f2e83babd1883c2bbd0bba6906cdab07 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 27 Feb 2010 23:50:09 +0000 Subject: python: Don't mention deprecated drivers=trace option. Now trace always built. --- src/gallium/state_trackers/python/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/README b/src/gallium/state_trackers/python/README index 4a06073024..e24a262aba 100644 --- a/src/gallium/state_trackers/python/README +++ b/src/gallium/state_trackers/python/README @@ -18,7 +18,7 @@ On a Windows machine ensure the swig command is in your PATH. Invoke scons on the top dir as - scons debug=yes statetrackers=python drivers=softpipe,trace winsys=none + scons debug=yes statetrackers=python drivers=softpipe winsys=none To use it set PYTHONPATH appropriately, e.g, in Linux do: -- cgit v1.2.3 From bd3c063da8ad8044a4d0361b279805bc4a73d011 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 14:22:30 +0000 Subject: python: Don't mention deprecated drivers=trace option. Now trace always built. --- src/gallium/auxiliary/util/u_format.csv | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 7595576953..b73bae2809 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -43,7 +43,11 @@ PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un24, un8 , , , x___, z PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un8 , un24, , , y___, zs # YUV formats +# http://www.fourcc.org/yuv.php#UYVY PIPE_FORMAT_YCBCR , subsampled, 2, 1, x32 , , , , xyz1, yuv +# http://www.fourcc.org/yuv.php#YUYV (a.k.a http://www.fourcc.org/yuv.php#YUY2) +# XXX: u_tile.c's ycbcr_get_tile_rgba actually interprets it as VYUY but the +# intent should be to match D3DFMT_YUY2 PIPE_FORMAT_YCBCR_REV , subsampled, 2, 1, x32 , , , , xyz1, yuv # Compressed formats -- cgit v1.2.3 From ffe90af2e8c834ab790462fce532cfca0a423ebd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 14:24:41 +0000 Subject: util: Tweak comments regarding R8G8B8A8/X8_UNORM. --- src/gallium/auxiliary/util/u_format.csv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index b73bae2809..bb117f1066 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -3,6 +3,8 @@ PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, r PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +# XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -135,5 +137,3 @@ PIPE_FORMAT_B6G5R5_SNORM , plain, 1, 1, sn5 , sn5 , sn6 , , xyz1, r PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb PIPE_FORMAT_R8G8B8X8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , wzy1, rgb PIPE_FORMAT_R8G8B8X8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , wzy1, rgb -# XXX: This one is mentioned in mesa and r300, but not anywhere else. Not sure it is actually needed -PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -- cgit v1.2.3 From 4a991b5783e213e31cacf530c02318f911bec2f6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 14:49:18 +0000 Subject: util: More documentation for u_format.csv --- src/gallium/auxiliary/util/u_format.csv | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index bb117f1066..25b94e4e52 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -1,3 +1,60 @@ +########################################################################### +# +# Copyright 2009-2010 VMware, Inc. +# 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 THE AUTHORS 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. +# +########################################################################### + +# This CSV file has the input data for u_format.h's struct +# util_format_description. +# +# Each format entry contains: +# - name, per enum pipe_format +# - layout, per enum util_format_layout, in shortened lower caps +# - pixel block's width +# - pixel block's height +# - channel encoding (only meaningful for plain layout), containing for each +# channel the following information: +# - type, one of +# - 'x': void +# - 'u': unsigned +# - 's': signed +# - 'h': fixed +# - 'f': FLOAT +# - optionally followed by 'n' if it is normalized +# - number of bits +# - channel swizzle +# - color space: rgb, yub, sz +# +# See also: +# - http://msdn.microsoft.com/en-us/library/ee416489.aspx +# - http://msdn.microsoft.com/en-us/library/ee415668.aspx +# +# Note that GL doesn't really specify the layout of internal formats. See +# OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized +# internal formats to base in- ternal formats, and desired component +# resolutions for each sized internal format." + # Typical rendertarget formats PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb -- cgit v1.2.3 From b66b4cf64655b7994c1cefda622cca6951077795 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 14:56:05 +0000 Subject: util: A few more todo marks. --- src/gallium/auxiliary/util/u_format.csv | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 25b94e4e52..a7bd6abf81 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -62,6 +62,7 @@ PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb # XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later +# XXX: insert PIPE_FORMAT_R8G8B8_UNORM here later PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -170,6 +171,8 @@ PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, r PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb +# XXX: insert PIPE_FORMAT_R8G8B8_UNORM here later +# XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb -- cgit v1.2.3 From 3a26193fd58e3cde277f63dcb9ea049a82860398 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 15:14:00 +0000 Subject: r300: Don't implement PIPE_FORMAT_R8G8B8X8_SNORM. This format is not actually used by any state tracker. Probably the reverse notation was mean, which would make it identical to PIPE_FORMAT_X8B8G8R8_SNORM. --- src/gallium/drivers/r300/r300_texture.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 2246c75056..181711b3d2 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -329,7 +329,6 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_R8G8B8A8_SRGB: case PIPE_FORMAT_R8G8B8X8_UNORM: case PIPE_FORMAT_R8G8B8X8_SRGB: - case PIPE_FORMAT_R8G8B8X8_SNORM: case PIPE_FORMAT_A8B8G8R8_SNORM: case PIPE_FORMAT_X8B8G8R8_SNORM: case PIPE_FORMAT_X8UB8UG8SR8S_NORM: @@ -463,7 +462,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) case PIPE_FORMAT_R8G8B8A8_SRGB: case PIPE_FORMAT_R8G8B8X8_UNORM: case PIPE_FORMAT_R8G8B8X8_SRGB: - case PIPE_FORMAT_R8G8B8X8_SNORM: return modifier | R300_C0_SEL_A | R300_C1_SEL_B | R300_C2_SEL_G | R300_C3_SEL_R; -- cgit v1.2.3 From 28f28885652cbf80118a0c27d4ca3a83ec999370 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 15:14:30 +0000 Subject: util: A few more links for D3D formats. --- src/gallium/auxiliary/util/u_format.csv | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index a7bd6abf81..aff59ff554 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -47,8 +47,9 @@ # - color space: rgb, yub, sz # # See also: -# - http://msdn.microsoft.com/en-us/library/ee416489.aspx -# - http://msdn.microsoft.com/en-us/library/ee415668.aspx +# - http://msdn.microsoft.com/en-us/library/ee416489.aspx (D3D9) +# - http://msdn.microsoft.com/en-us/library/ee415668.aspx (D3D9 -> D3D10) +# - http://msdn.microsoft.com/en-us/library/ee418116.aspx (D3D10) # # Note that GL doesn't really specify the layout of internal formats. See # OpenGL 2.1 specification, Table 3.16, on the "Correspondence of sized -- cgit v1.2.3 From cfdc14624747ac9f43b26915ddf14af3d50c6fe7 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 15:16:54 +0000 Subject: util: Remove inexisting formats. Can't find these formats used in any state tracker or any API. For some of these probably the reverse notation was meant, for which formats already exist. --- src/gallium/auxiliary/util/u_format.csv | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index aff59ff554..3c5f75c365 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -191,10 +191,3 @@ PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, r # FIXME: They are used with different meanings in different places!!! PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , zyx1, rgb PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb - -# Unused formats -# XXX: Couldn't find any state tracker using them!! -PIPE_FORMAT_B6G5R5_SNORM , plain, 1, 1, sn5 , sn5 , sn6 , , xyz1, rgb -PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , wzy1, rgb -PIPE_FORMAT_R8G8B8X8_USCALED , plain, 1, 1, u8 , u8 , u8 , u8 , wzy1, rgb -PIPE_FORMAT_R8G8B8X8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , wzy1, rgb -- cgit v1.2.3 From 4c3bfc9778d9a0a75bf93b15303a4839f971f695 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 15:17:41 +0000 Subject: gallium: Remove inexisting formats. Can't find these formats used in any state tracker or any API. For some of these probably the reverse notation was meant, for which formats already exist. --- src/gallium/include/pipe/p_format.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index f33b0639ef..998d1a639f 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -117,20 +117,16 @@ enum pipe_format { PIPE_FORMAT_R8G8_USCALED = 70, PIPE_FORMAT_R8G8B8_USCALED = 71, PIPE_FORMAT_R8G8B8A8_USCALED = 72, - PIPE_FORMAT_R8G8B8X8_USCALED = 73, PIPE_FORMAT_R8_SNORM = 74, PIPE_FORMAT_R8G8_SNORM = 75, PIPE_FORMAT_R8G8B8_SNORM = 76, PIPE_FORMAT_R8G8B8A8_SNORM = 77, - PIPE_FORMAT_R8G8B8X8_SNORM = 78, - PIPE_FORMAT_B6G5R5_SNORM = 79, PIPE_FORMAT_A8B8G8R8_SNORM = 80, PIPE_FORMAT_X8B8G8R8_SNORM = 81, PIPE_FORMAT_R8_SSCALED = 82, PIPE_FORMAT_R8G8_SSCALED = 83, PIPE_FORMAT_R8G8B8_SSCALED = 84, PIPE_FORMAT_R8G8B8A8_SSCALED = 85, - PIPE_FORMAT_R8G8B8X8_SSCALED = 86, PIPE_FORMAT_R32_FIXED = 87, PIPE_FORMAT_R32G32_FIXED = 88, PIPE_FORMAT_R32G32B32_FIXED = 89, -- cgit v1.2.3 From b2e94d05c9602e2814a513a51eed67d014b338f3 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 15 Feb 2010 17:17:30 +0000 Subject: gallium: Expose a opaque winsys handle and functions on pipe_screen Instead of having these functions on a side interface like on drm_api create a opaque winsys_handle that is to be passed down into the winsys. Currently the only thing ported to this new interface is drm_api, and of that only the components that builds by default is ported. All the drivers and any extra state trackers needs to be ported before this can go into master. --- src/gallium/drivers/identity/id_drm.c | 59 --------------------- src/gallium/drivers/identity/id_screen.c | 35 +++++++++++++ src/gallium/drivers/trace/tr_drm.c | 66 +----------------------- src/gallium/drivers/trace/tr_screen.c | 34 ++++++++++++ src/gallium/include/pipe/p_screen.h | 20 +++++++ src/gallium/include/state_tracker/drm_api.h | 56 ++++++++++---------- src/gallium/state_trackers/dri/dri_drawable.c | 8 ++- src/gallium/state_trackers/egl/x11/native_dri2.c | 9 ++-- src/gallium/state_trackers/xorg/xorg_crtc.c | 13 ++--- src/gallium/state_trackers/xorg/xorg_dri2.c | 12 +++-- src/gallium/state_trackers/xorg/xorg_driver.c | 15 +++--- 11 files changed, 153 insertions(+), 174 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_drm.c b/src/gallium/drivers/identity/id_drm.c index f258c38cd7..936ccc444a 100644 --- a/src/gallium/drivers/identity/id_drm.c +++ b/src/gallium/drivers/identity/id_drm.c @@ -63,62 +63,6 @@ identity_drm_create_screen(struct drm_api *_api, int fd, return identity_screen_create(screen); } - -static struct pipe_texture * -identity_drm_texture_from_shared_handle(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_drm_api *id_api = identity_drm_api(_api); - struct pipe_screen *screen = id_screen->screen; - struct drm_api *api = id_api->api; - struct pipe_texture *result; - - result = api->texture_from_shared_handle(api, screen, templ, name, stride, handle); - - result = identity_texture_create(identity_screen(_screen), result); - - return result; -} - -static boolean -identity_drm_shared_handle_from_texture(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned *stride, - unsigned *handle) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_texture *id_texture = identity_texture(_texture); - struct identity_drm_api *id_api = identity_drm_api(_api); - struct pipe_screen *screen = id_screen->screen; - struct pipe_texture *texture = id_texture->texture; - struct drm_api *api = id_api->api; - - return api->shared_handle_from_texture(api, screen, texture, stride, handle); -} - -static boolean -identity_drm_local_handle_from_texture(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned *stride, - unsigned *handle) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_texture *id_texture = identity_texture(_texture); - struct identity_drm_api *id_api = identity_drm_api(_api); - struct pipe_screen *screen = id_screen->screen; - struct pipe_texture *texture = id_texture->texture; - struct drm_api *api = id_api->api; - - return api->local_handle_from_texture(api, screen, texture, stride, handle); -} - static void identity_drm_destroy(struct drm_api *_api) { @@ -145,9 +89,6 @@ identity_drm_create(struct drm_api *api) id_api->base.name = api->name; id_api->base.driver_name = api->driver_name; id_api->base.create_screen = identity_drm_create_screen; - id_api->base.texture_from_shared_handle = identity_drm_texture_from_shared_handle; - id_api->base.shared_handle_from_texture = identity_drm_shared_handle_from_texture; - id_api->base.local_handle_from_texture = identity_drm_local_handle_from_texture; id_api->base.destroy = identity_drm_destroy; id_api->api = api; diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index b85492114a..77e15b92f7 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -134,6 +134,39 @@ identity_screen_texture_create(struct pipe_screen *_screen, return NULL; } +static struct pipe_texture * +identity_screen_texture_from_handle(struct pipe_screen *_screen, + const struct pipe_texture *templ, + struct winsys_handle *handle) +{ + struct identity_screen *id_screen = identity_screen(_screen); + struct pipe_screen *screen = id_screen->screen; + struct pipe_texture *result; + + /* TODO trace call */ + + result = screen->texture_from_handle(screen, templ, handle); + + result = identity_texture_create(identity_screen(_screen), result); + + return result; +} + +static boolean +identity_screen_texture_get_handle(struct pipe_screen *_screen, + struct pipe_texture *_texture, + struct winsys_handle *handle) +{ + struct identity_screen *id_screen = identity_screen(_screen); + struct identity_texture *id_texture = identity_texture(_texture); + struct pipe_screen *screen = id_screen->screen; + struct pipe_texture *texture = id_texture->texture; + + /* TODO trace call */ + + return screen->texture_get_handle(screen, texture, handle); +} + static struct pipe_texture * identity_screen_texture_blanket(struct pipe_screen *_screen, const struct pipe_texture *templat, @@ -495,6 +528,8 @@ identity_screen_create(struct pipe_screen *screen) id_screen->base.is_format_supported = identity_screen_is_format_supported; id_screen->base.context_create = identity_screen_context_create; id_screen->base.texture_create = identity_screen_texture_create; + id_screen->base.texture_from_handle = identity_screen_texture_from_handle; + id_screen->base.texture_get_handle = identity_screen_texture_get_handle; id_screen->base.texture_blanket = identity_screen_texture_blanket; id_screen->base.texture_destroy = identity_screen_texture_destroy; id_screen->base.get_tex_surface = identity_screen_get_tex_surface; diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index 2b4915003e..c16989fa52 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -62,69 +62,8 @@ trace_drm_create_screen(struct drm_api *_api, int fd, screen = api->create_screen(api, fd, arg); - return trace_screen_create(screen); -} - - -static struct pipe_texture * -trace_drm_texture_from_shared_handle(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle) -{ - struct trace_screen *tr_screen = trace_screen(_screen); - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct pipe_screen *screen = tr_screen->screen; - struct drm_api *api = tr_api->api; - struct pipe_texture *result; - - /* TODO trace call */ - - result = api->texture_from_shared_handle(api, screen, templ, name, stride, handle); - - result = trace_texture_create(trace_screen(_screen), result); - - return result; -} - -static boolean -trace_drm_shared_handle_from_texture(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned *stride, - unsigned *handle) -{ - struct trace_screen *tr_screen = trace_screen(_screen); - struct trace_texture *tr_texture = trace_texture(_texture); - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct pipe_screen *screen = tr_screen->screen; - struct pipe_texture *texture = tr_texture->texture; - struct drm_api *api = tr_api->api; - - /* TODO trace call */ - - return api->shared_handle_from_texture(api, screen, texture, stride, handle); -} -static boolean -trace_drm_local_handle_from_texture(struct drm_api *_api, - struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned *stride, - unsigned *handle) -{ - struct trace_screen *tr_screen = trace_screen(_screen); - struct trace_texture *tr_texture = trace_texture(_texture); - struct trace_drm_api *tr_api = trace_drm_api(_api); - struct pipe_screen *screen = tr_screen->screen; - struct pipe_texture *texture = tr_texture->texture; - struct drm_api *api = tr_api->api; - - /* TODO trace call */ - - return api->local_handle_from_texture(api, screen, texture, stride, handle); + return trace_screen_create(screen); } static void @@ -158,9 +97,6 @@ trace_drm_create(struct drm_api *api) tr_api->base.name = api->name; tr_api->base.driver_name = api->driver_name; tr_api->base.create_screen = trace_drm_create_screen; - tr_api->base.texture_from_shared_handle = trace_drm_texture_from_shared_handle; - tr_api->base.shared_handle_from_texture = trace_drm_shared_handle_from_texture; - tr_api->base.local_handle_from_texture = trace_drm_local_handle_from_texture; tr_api->base.destroy = trace_drm_destroy; tr_api->api = api; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 388d83eb5c..ac0876c3a8 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -236,6 +236,38 @@ trace_screen_texture_create(struct pipe_screen *_screen, return result; } +static struct pipe_texture * +trace_screen_texture_from_handle(struct pipe_screen *_screen, + const struct pipe_texture *templ, + struct winsys_handle *handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_texture *result; + + /* TODO trace call */ + + result = screen->texture_from_handle(screen, templ, handle); + + result = trace_texture_create(trace_screen(_screen), result); + + return result; +} + +static boolean +trace_screen_texture_get_handle(struct pipe_screen *_screen, + struct pipe_texture *_texture, + struct winsys_handle *handle) +{ + struct trace_screen *tr_screen = trace_screen(_screen); + struct trace_texture *tr_texture = trace_texture(_texture); + struct pipe_screen *screen = tr_screen->screen; + struct pipe_texture *texture = tr_texture->texture; + + /* TODO trace call */ + + return screen->texture_get_handle(screen, texture, handle); +} static struct pipe_texture * trace_screen_texture_blanket(struct pipe_screen *_screen, @@ -931,6 +963,8 @@ trace_screen_create(struct pipe_screen *screen) assert(screen->context_create); tr_scr->base.context_create = trace_screen_context_create; tr_scr->base.texture_create = trace_screen_texture_create; + tr_scr->base.texture_from_handle = trace_screen_texture_from_handle; + tr_scr->base.texture_get_handle = trace_screen_texture_get_handle; tr_scr->base.texture_blanket = trace_screen_texture_blanket; tr_scr->base.texture_destroy = trace_screen_texture_destroy; tr_scr->base.get_tex_surface = trace_screen_get_tex_surface; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index e4a9222809..617c47e4dc 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -49,6 +49,8 @@ extern "C" { #endif +/** Opaque type */ +struct winsys_handle; /** Opaque type */ struct pipe_fence_handle; struct pipe_winsys; @@ -107,6 +109,24 @@ struct pipe_screen { struct pipe_texture * (*texture_create)(struct pipe_screen *, const struct pipe_texture *templat); + /** + * Create a texture from a winsys_handle. The handle is often created in + * another process by first creating a pipe texture and then calling + * texture_get_handle. + */ + struct pipe_texture * (*texture_from_handle)(struct pipe_screen *, + const struct pipe_texture *templat, + struct winsys_handle *handle); + + /** + * Get a winsys_handle from a texture. Some platforms/winsys requires + * that the texture is created with a special usage flag like + * DISPLAYTARGET or PRIMARY. + */ + boolean (*texture_get_handle)(struct pipe_screen *, + struct pipe_texture *tex, + struct winsys_handle *handle); + /** * Create a new texture object, using the given template info, but on top of * existing memory. diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index e9fa9b4d2a..d3edddd5d4 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -17,6 +17,31 @@ enum drm_create_screen_mode { DRM_CREATE_MAX }; +#define DRM_API_HANDLE_TYPE_SHARED 0 +#define DRM_API_HANDLE_TYPE_KMS 1 + +/** + * For use with pipe_screen::{texture_from_handle|texture_get_handle}. + */ +struct winsys_handle +{ + /** + * Unused for texture_from_handle, always DRM_API_HANDLE_TYPE_SHARED. + * Input to texture_get_handle, use TEXTURE_USAGE to select handle for kms or ipc. + */ + unsigned type; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned handle; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned stride; +}; + /** * Modes other than DRM_CREATE_NORMAL derive from this struct. */ @@ -28,6 +53,8 @@ struct drm_create_screen_arg { struct drm_api { + void (*destroy)(struct drm_api *api); + const char *name; /** @@ -36,37 +63,10 @@ struct drm_api const char *driver_name; /** - * Special buffer functions + * Create a pipe srcreen. */ - /*@{*/ struct pipe_screen* (*create_screen)(struct drm_api *api, int drm_fd, struct drm_create_screen_arg *arg); - /*@}*/ - - /** - * Special buffer functions - */ - /*@{*/ - struct pipe_texture* - (*texture_from_shared_handle)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle); - boolean (*shared_handle_from_texture)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle); - boolean (*local_handle_from_texture)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle); - /*@}*/ - - void (*destroy)(struct drm_api *api); }; extern struct drm_api * drm_api_create(void); diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 4809b9090d..fe91cf59b4 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -58,6 +58,7 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_surface *surface = NULL; struct pipe_texture *texture = NULL; struct pipe_texture templat; + struct winsys_handle whandle; memset(&templat, 0, sizeof(templat)); templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; @@ -68,8 +69,11 @@ dri_surface_from_handle(struct drm_api *api, templat.width0 = width; templat.height0 = height; - texture = api->texture_from_shared_handle(api, screen, &templat, - "dri2 buffer", pitch, handle); + memset(&whandle, 0, sizeof(whandle)); + whandle.handle = handle; + whandle.stride = pitch; + + texture = screen->texture_from_handle(screen, &templat, &whandle); if (!texture) { debug_printf("%s: Failed to blanket the buffer with a texture\n", __func__); diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 8df58891a0..b80b376e12 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -112,6 +112,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf, struct dri2_surface *dri2surf = dri2_surface(nsurf); struct dri2_display *dri2dpy = dri2surf->dri2dpy; struct pipe_texture templ; + struct winsys_handle whandle; uint valid_mask; int i; @@ -169,9 +170,11 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf, continue; } - dri2surf->textures[natt] = - dri2dpy->api->texture_from_shared_handle(dri2dpy->api, - dri2dpy->base.screen, &templ, desc, xbuf->pitch, xbuf->name); + memset(&whandle, 0, sizeof(whandle)); + whandle.stride = xbuf->pitch; + whandle.handle = xbuf->name; + dri2surf->textures[natt] = dri2dpy->base.screen->texture_from_handle( + dri2dpy->base.screen, &templ, &whandle); if (dri2surf->textures[natt]) valid_mask |= 1 << natt; } diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 221ce772af..4a77f54080 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -197,7 +197,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) if (!crtcp->cursor_tex) { struct pipe_texture templat; - unsigned pitch; + struct winsys_handle whandle; memset(&templat, 0, sizeof(templat)); templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; @@ -209,13 +209,14 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) templat.width0 = 64; templat.height0 = 64; + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_KMS; + crtcp->cursor_tex = ms->screen->texture_create(ms->screen, &templat); - ms->api->local_handle_from_texture(ms->api, - ms->screen, - crtcp->cursor_tex, - &pitch, - &crtcp->cursor_handle); + ms->screen->texture_get_handle(ms->screen, crtcp->cursor_tex, &whandle); + + crtcp->cursor_handle = whandle.handle; } transfer = ms->screen->get_tex_transfer(ms->screen, crtcp->cursor_tex, diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 5b67392435..5472285ec1 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -67,7 +67,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form struct exa_pixmap_priv *exa_priv; BufferPrivatePtr private = buffer->driverPrivate; PixmapPtr pPixmap; - unsigned stride, handle; + struct winsys_handle whandle; if (pDraw->type == DRAWABLE_PIXMAP) pPixmap = (PixmapPtr) pDraw; @@ -75,6 +75,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw); exa_priv = exaGetPixmapDriverPrivate(pPixmap); + switch (buffer->attachment) { default: if (buffer->attachment != DRI2BufferFakeFrontLeft || @@ -153,10 +154,13 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form if (!tex) FatalError("NO TEXTURE IN DRI2\n"); - ms->api->shared_handle_from_texture(ms->api, ms->screen, tex, &stride, &handle); + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_SHARED; + + ms->screen->texture_get_handle(ms->screen, tex, &whandle); - buffer->name = handle; - buffer->pitch = stride; + buffer->name = whandle.handle; + buffer->pitch = whandle.stride; buffer->cpp = 4; buffer->driverPrivate = private; buffer->flags = 0; /* not tiled */ diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 8fb6e5a96d..004a28f00e 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -989,8 +989,9 @@ static Bool drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); - unsigned handle, stride, fb_id; struct pipe_texture *tex; + struct winsys_handle whandle; + unsigned fb_id; int ret; ms->noEvict = TRUE; @@ -1001,10 +1002,10 @@ drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) if (!tex) return FALSE; - if (!ms->api->local_handle_from_texture(ms->api, ms->screen, - tex, - &stride, - &handle)) + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_KMS; + + if (!ms->screen->texture_get_handle(ms->screen, tex, &whandle)) goto err_destroy; ret = drmModeAddFB(ms->fd, @@ -1012,8 +1013,8 @@ drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) pScrn->virtualY, pScrn->depth, pScrn->bitsPerPixel, - stride, - handle, + whandle.stride, + whandle.handle, &fb_id); if (ret) { debug_printf("%s: failed to create framebuffer (%i, %s)\n", -- cgit v1.2.3 From 3f37f23d17734e8a49809859df58354ed9c00a2d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 17 Feb 2010 21:08:49 +0000 Subject: gallium: Reorg texture usage flags Introduce a new shared usage and rename primary to scanout. The display target usage is more of a windows concept and doesn't mean the same thing as shared. Display target means that the surface should be presentable, for softpipe this means that it should be backed by a hardware buffer. --- src/gallium/drivers/i915/i915_texture.c | 14 +++++++------- src/gallium/drivers/i965/brw_screen_texture.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_texture.c | 3 ++- src/gallium/drivers/r300/r300_screen.c | 6 ++++-- src/gallium/drivers/softpipe/sp_texture.c | 3 ++- src/gallium/drivers/svga/svga_screen_texture.c | 6 +++++- src/gallium/include/pipe/p_defines.h | 5 +++-- src/gallium/state_trackers/egl/kms/native_kms.c | 2 +- src/gallium/state_trackers/xorg/xorg_crtc.c | 2 +- src/gallium/state_trackers/xorg/xorg_dri2.c | 2 +- src/gallium/state_trackers/xorg/xorg_exa.c | 10 +++++----- src/gallium/state_trackers/xorg/xvmc/surface.c | 2 +- src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 2 +- 13 files changed, 35 insertions(+), 26 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 7ba222c78b..5ad65a2e9c 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -219,12 +219,12 @@ i915_miptree_layout_2d(struct i915_texture *tex) unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0); /* used for scanouts that need special layouts */ - if (pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) + if (pt->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) if (i915_scanout_layout(tex)) return; - /* for shared buffers we use something very like scanout */ - if (pt->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) + /* shared buffers needs to be compatible with X servers */ + if (pt->tex_usage & PIPE_TEXTURE_USAGE_SHARED) if (i915_display_target_layout(tex)) return; @@ -369,12 +369,12 @@ i945_miptree_layout_2d(struct i915_texture *tex) unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0); /* used for scanouts that need special layouts */ - if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) + if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) if (i915_scanout_layout(tex)) return; - /* for shared buffers we use some very like scanout */ - if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) + /* shared buffers needs to be compatible with X servers */ + if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SHARED) if (i915_display_target_layout(tex)) return; @@ -642,7 +642,7 @@ i915_texture_create(struct pipe_screen *screen, /* for scanouts and cursors, cursors arn't scanouts */ - if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width0 != 64) + if (templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT && templat->width0 != 64) buf_usage = INTEL_NEW_SCANOUT; else buf_usage = INTEL_NEW_TEXTURE; diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index 38e9961398..2d7b6ec222 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -231,8 +231,8 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen, goto fail; - if (templ->tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY)) { + if (templ->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { buffer_type = BRW_BUFFER_TYPE_SCANOUT; } else { diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 7f45635542..7d15e85600 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -125,7 +125,8 @@ llvmpipe_texture_create(struct pipe_screen *_screen, lpt->base.screen = &screen->base; if (lpt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY)) { + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { if (!llvmpipe_displaytarget_layout(screen, lpt)) goto fail; } diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 6a55570571..2d8b313e5d 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -231,14 +231,16 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, /* Check colorbuffer format support. */ if ((usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY)) && + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) && /* 2101010 cannot be rendered to on non-r5xx. */ (is_r500 || !is_color2101010) && r300_is_colorbuffer_format_supported(format)) { retval |= usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY); + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED); } /* Check depth-stencil format support. */ diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 371c4e2025..d3997854b2 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -123,7 +123,8 @@ softpipe_texture_create(struct pipe_screen *screen, util_is_power_of_two(template->depth0)); if (spt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY)) { + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { if (!softpipe_displaytarget_layout(screen, spt)) goto fail; } diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 12f3531a1d..b34f906ceb 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -315,7 +315,11 @@ svga_texture_create(struct pipe_screen *screen, tex->key.cachable = 0; } - if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) { + if(templat->tex_usage & PIPE_TEXTURE_USAGE_SHARED) { + tex->key.cachable = 0; + } + + if(templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) { tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT; tex->key.cachable = 0; } diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 5cebd43ace..5c97dc87e8 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -176,11 +176,12 @@ enum pipe_texture_target { #define PIPE_TEX_COMPARE_R_TO_TEXTURE 1 #define PIPE_TEXTURE_USAGE_RENDER_TARGET 0x1 -#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET 0x2 /* ie a backbuffer */ -#define PIPE_TEXTURE_USAGE_PRIMARY 0x4 /* ie a frontbuffer */ +#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET 0x2 /* windows presentable buffer, ie a backbuffer */ +#define PIPE_TEXTURE_USAGE_SCANOUT 0x4 /* ie a frontbuffer */ #define PIPE_TEXTURE_USAGE_DEPTH_STENCIL 0x8 #define PIPE_TEXTURE_USAGE_SAMPLER 0x10 #define PIPE_TEXTURE_USAGE_DYNAMIC 0x20 +#define PIPE_TEXTURE_USAGE_SHARED 0x40 /** Pipe driver custom usage flags should be greater or equal to this value */ #define PIPE_TEXTURE_USAGE_CUSTOM (1 << 16) diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index ee6ab2e60b..dbdb1e635a 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -55,7 +55,7 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, templ.format = ksurf->color_format; templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) - templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + templ.tex_usage |= PIPE_TEXTURE_SCANOUT; } /* create textures */ diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 4a77f54080..8f6426bcc8 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -201,7 +201,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) memset(&templat, 0, sizeof(templat)); templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; - templat.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + templat.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT; templat.target = PIPE_TEXTURE_2D; templat.last_level = 0; templat.depth0 = 1; diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 5472285ec1..e7f1b2d411 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -129,7 +129,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form template.depth0 = 1; template.last_level = 0; template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL | - PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + PIPE_TEXTURE_USAGE_SHARED; tex = ms->screen->texture_create(ms->screen, &template); pipe_texture_reference(&exa_priv->depth_stencil_tex, tex); } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 665efdc0f0..5c3e92efdf 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -789,7 +789,7 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap) return 0; } - priv->flags |= PIPE_TEXTURE_USAGE_PRIMARY; + priv->flags |= PIPE_TEXTURE_USAGE_SCANOUT; return 0; } @@ -805,7 +805,7 @@ xorg_exa_set_shared_usage(PixmapPtr pPixmap) return 0; } - priv->flags |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + priv->flags |= PIPE_TEXTURE_USAGE_SHARED; return 0; } @@ -943,7 +943,7 @@ xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex) { struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); - int mask = PIPE_TEXTURE_USAGE_PRIMARY | PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + int mask = PIPE_TEXTURE_USAGE_SHARED | PIPE_TEXTURE_USAGE_SCANOUT; if (!priv) return FALSE; @@ -976,8 +976,8 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn, template.depth0 = 1; template.last_level = 0; template.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET; - template.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; - template.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + template.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT; + template.tex_usage |= PIPE_TEXTURE_USAGE_SHARED; return exa->scrn->texture_create(exa->scrn, &template); } diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index 0e39a390c6..c113f49e55 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -106,7 +106,7 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u template.width0 = width; template.height0 = height; template.depth0 = 1; - template.tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + template.tex_usage = PIPE_TEXTURE_USAGE_SHARED; tex = vpipe->screen->texture_create(vpipe->screen, &template); if (!tex) diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index c814d986b1..80b5a4c091 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -23,7 +23,7 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen, struct pipe_texture tmpl; memset(&tmpl, 0, sizeof(tmpl)); - tmpl.tex_usage = PIPE_TEXTURE_USAGE_PRIMARY; + tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT; tmpl.target = PIPE_TEXTURE_2D; tmpl.last_level = 0; tmpl.depth0 = 1; -- cgit v1.2.3 From 0e1eb1b8765149873f9fd27d455d8b7ed3387709 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 17 Feb 2010 21:28:01 +0000 Subject: i915g: Conversion to winsys handle --- src/gallium/drivers/i915/i915_texture.c | 104 +++++++++++---------- src/gallium/drivers/i915/intel_winsys.h | 39 ++++---- src/gallium/winsys/drm/intel/gem/intel_drm_api.c | 96 ------------------- .../winsys/drm/intel/gem/intel_drm_buffer.c | 63 +++++++++++++ 4 files changed, 137 insertions(+), 165 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 5ad65a2e9c..334959c46d 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -672,6 +672,58 @@ fail: return NULL; } +static struct pipe_texture * +i915_texture_from_handle(struct pipe_screen * screen, + const struct pipe_texture *templat, + struct winsys_handle *whandle) +{ + struct i915_screen *is = i915_screen(screen); + struct i915_texture *tex; + struct intel_winsys *iws = is->iws; + struct intel_buffer *buffer; + unsigned stride; + + assert(screen); + + buffer = iws->buffer_from_handle(iws, whandle, &stride); + + /* Only supports one type */ + if (templat->target != PIPE_TEXTURE_2D || + templat->last_level != 0 || + templat->depth0 != 1) { + return NULL; + } + + tex = CALLOC_STRUCT(i915_texture); + if (!tex) + return NULL; + + tex->base = *templat; + pipe_reference_init(&tex->base.reference, 1); + tex->base.screen = screen; + + tex->stride = stride; + + i915_miptree_set_level_info(tex, 0, 1, templat->width0, templat->height0, 1); + i915_miptree_set_image_offset(tex, 0, 0, 0, 0); + + tex->buffer = buffer; + + return &tex->base; +} + +static boolean +i915_texture_get_handle(struct pipe_screen * screen, + struct pipe_texture *texture, + struct winsys_handle *whandle) +{ + struct i915_screen *is = i915_screen(screen); + struct i915_texture *tex = (struct i915_texture *)texture; + struct intel_winsys *iws = is->iws; + + return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride); +} + static struct pipe_texture * i915_texture_blanket(struct pipe_screen * screen, const struct pipe_texture *base, @@ -869,6 +921,8 @@ void i915_init_screen_texture_functions(struct i915_screen *is) { is->base.texture_create = i915_texture_create; + is->base.texture_from_handle = i915_texture_from_handle; + is->base.texture_get_handle = i915_texture_get_handle; is->base.texture_blanket = i915_texture_blanket; is->base.texture_destroy = i915_texture_destroy; is->base.get_tex_surface = i915_get_tex_surface; @@ -878,53 +932,3 @@ i915_init_screen_texture_functions(struct i915_screen *is) is->base.transfer_unmap = i915_transfer_unmap; is->base.tex_transfer_destroy = i915_tex_transfer_destroy; } - -struct pipe_texture * -i915_texture_blanket_intel(struct pipe_screen *screen, - struct pipe_texture *base, - unsigned stride, - struct intel_buffer *buffer) -{ - struct i915_texture *tex; - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - tex = CALLOC_STRUCT(i915_texture); - if (!tex) - return NULL; - - tex->base = *base; - pipe_reference_init(&tex->base.reference, 1); - tex->base.screen = screen; - - tex->stride = stride; - - i915_miptree_set_level_info(tex, 0, 1, base->width0, base->height0, 1); - i915_miptree_set_image_offset(tex, 0, 0, 0, 0); - - tex->buffer = buffer; - - return &tex->base; -} - -boolean -i915_get_texture_buffer_intel(struct pipe_texture *texture, - struct intel_buffer **buffer, - unsigned *stride) -{ - struct i915_texture *tex = (struct i915_texture *)texture; - - if (!texture) - return FALSE; - - *stride = tex->stride; - *buffer = tex->buffer; - - return TRUE; -} diff --git a/src/gallium/drivers/i915/intel_winsys.h b/src/gallium/drivers/i915/intel_winsys.h index b3a802b0e2..00fd0c1efe 100644 --- a/src/gallium/drivers/i915/intel_winsys.h +++ b/src/gallium/drivers/i915/intel_winsys.h @@ -33,6 +33,7 @@ struct intel_buffer; struct intel_batchbuffer; struct pipe_texture; struct pipe_fence_handle; +struct winsys_handle; enum intel_buffer_usage { @@ -128,6 +129,25 @@ struct intel_winsys { unsigned size, unsigned alignment, enum intel_buffer_type type); + /** + * Creates a buffer from a handle. + * Used to implement pipe_screen::texture_from_handle. + * Also provides the stride information needed for the + * texture via the stride argument. + */ + struct intel_buffer *(*buffer_from_handle)(struct intel_winsys *iws, + struct winsys_handle *whandle, + unsigned *stride); + + /** + * Used to implement pipe_screen::texture_get_handle. + * The winsys might need the stride information. + */ + boolean (*buffer_get_handle)(struct intel_winsys *iws, + struct intel_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride); + /** * Fence a buffer with a fence reg. * Not to be confused with pipe_fence_handle. @@ -204,23 +224,4 @@ struct intel_winsys { struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id); -/** - * Get the intel_winsys buffer backing the texture. - * - * TODO UGLY - */ -boolean i915_get_texture_buffer_intel(struct pipe_texture *texture, - struct intel_buffer **buffer, - unsigned *stride); - -/** - * Wrap a intel_winsys buffer with a texture blanket. - * - * TODO UGLY - */ -struct pipe_texture * i915_texture_blanket_intel(struct pipe_screen *screen, - struct pipe_texture *tmplt, - unsigned pitch, - struct intel_buffer *buffer); - #endif diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c index 377ed25513..e3b980a832 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_drm_api.c +++ b/src/gallium/winsys/drm/intel/gem/intel_drm_api.c @@ -38,99 +38,6 @@ intel_drm_get_device_id(unsigned int *device_id) fclose(file); } -static struct intel_buffer * -intel_drm_buffer_from_handle(struct intel_drm_winsys *idws, - const char* name, unsigned handle) -{ - struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); - uint32_t tile = 0, swizzle = 0; - - if (!buf) - return NULL; - - buf->magic = 0xDEAD1337; - buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, name, handle); - buf->flinked = TRUE; - buf->flink = handle; - - if (!buf->bo) - goto err; - - drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); - if (tile != INTEL_TILE_NONE) - buf->map_gtt = TRUE; - - return (struct intel_buffer *)buf; - -err: - FREE(buf); - return NULL; -} - - -/* - * Exported functions - */ - - -static struct pipe_texture * -intel_drm_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char* name, - unsigned pitch, - unsigned handle) -{ - struct intel_drm_winsys *idws = intel_drm_winsys(i915_screen(screen)->iws); - struct intel_buffer *buffer; - - buffer = intel_drm_buffer_from_handle(idws, name, handle); - if (!buffer) - return NULL; - - return i915_texture_blanket_intel(screen, templ, pitch, buffer); -} - -static boolean -intel_drm_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct intel_drm_buffer *buf = NULL; - struct intel_buffer *buffer = NULL; - if (!i915_get_texture_buffer_intel(texture, &buffer, pitch)) - return FALSE; - - buf = intel_drm_buffer(buffer); - if (!buf->flinked) { - if (drm_intel_bo_flink(buf->bo, &buf->flink)) - return FALSE; - buf->flinked = TRUE; - } - - *handle = buf->flink; - - return TRUE; -} - -static boolean -intel_drm_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct intel_buffer *buffer = NULL; - if (!i915_get_texture_buffer_intel(texture, &buffer, pitch)) - return FALSE; - - *handle = intel_drm_buffer(buffer)->bo->handle; - - return TRUE; -} - static void intel_drm_winsys_destroy(struct intel_winsys *iws) { @@ -192,9 +99,6 @@ struct drm_api intel_drm_api = .name = "i915", .driver_name = "i915", .create_screen = intel_drm_create_screen, - .texture_from_shared_handle = intel_drm_texture_from_shared_handle, - .shared_handle_from_texture = intel_drm_shared_handle_from_texture, - .local_handle_from_texture = intel_drm_local_handle_from_texture, .destroy = destroy, }; diff --git a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c index ac4dd6e00e..cb4f92a3b1 100644 --- a/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c +++ b/src/gallium/winsys/drm/intel/gem/intel_drm_buffer.c @@ -1,4 +1,5 @@ +#include "state_tracker/drm_api.h" #include "intel_drm_winsys.h" #include "util/u_memory.h" @@ -52,6 +53,66 @@ err: return NULL; } +static struct intel_buffer * +intel_drm_buffer_from_handle(struct intel_winsys *iws, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct intel_drm_winsys *idws = intel_drm_winsys(iws); + struct intel_drm_buffer *buf = CALLOC_STRUCT(intel_drm_buffer); + uint32_t tile = 0, swizzle = 0; + + if (!buf) + return NULL; + + buf->magic = 0xDEAD1337; + buf->bo = drm_intel_bo_gem_create_from_name(idws->pools.gem, "gallium3d_from_handle", whandle->handle); + buf->flinked = TRUE; + buf->flink = whandle->handle; + + if (!buf->bo) + goto err; + + drm_intel_bo_get_tiling(buf->bo, &tile, &swizzle); + if (tile != INTEL_TILE_NONE) + buf->map_gtt = TRUE; + + *stride = whandle->stride; + + return (struct intel_buffer *)buf; + +err: + FREE(buf); + return NULL; +} + +static boolean +intel_drm_buffer_get_handle(struct intel_winsys *iws, + struct intel_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride) +{ + struct intel_drm_buffer *buf = intel_drm_buffer(buffer); + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + if (drm_intel_bo_flink(buf->bo, &buf->flink)) + return FALSE; + buf->flinked = TRUE; + } + + whandle->handle = buf->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; + } else { + assert(!"unknown usage"); + return FALSE; + } + + whandle->stride = stride; + return TRUE; +} + static int intel_drm_buffer_set_fence_reg(struct intel_winsys *iws, struct intel_buffer *buffer, @@ -146,6 +207,8 @@ void intel_drm_winsys_init_buffer_functions(struct intel_drm_winsys *idws) { idws->base.buffer_create = intel_drm_buffer_create; + idws->base.buffer_from_handle = intel_drm_buffer_from_handle; + idws->base.buffer_get_handle = intel_drm_buffer_get_handle; idws->base.buffer_set_fence_reg = intel_drm_buffer_set_fence_reg; idws->base.buffer_map = intel_drm_buffer_map; idws->base.buffer_unmap = intel_drm_buffer_unmap; -- cgit v1.2.3 From 45089784e3d5f8c9b87c2c6b943391f2e5125096 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 17 Feb 2010 21:45:41 +0000 Subject: i965g: Conversion to winsys handle --- src/gallium/drivers/i965/brw_screen_texture.c | 230 +++++++++++----------- src/gallium/drivers/i965/brw_winsys.h | 10 + src/gallium/winsys/drm/i965/gem/i965_drm_api.c | 126 ------------ src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c | 75 +++++++ 4 files changed, 200 insertions(+), 241 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index 2d7b6ec222..995a6f1d7f 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -303,6 +303,119 @@ fail: return NULL; } +static struct pipe_texture * +brw_texture_from_handle(struct pipe_screen *screen, + const struct pipe_texture *templ, + struct winsys_handle *whandle) +{ + struct brw_screen *bscreen = brw_screen(screen); + struct brw_texture *tex; + struct brw_winsys_buffer *buffer; + unsigned tiling; + unsigned pitch; + + if (templ->target != PIPE_TEXTURE_2D || + templ->last_level != 0 || + templ->depth0 != 1) + return NULL; + + if (util_format_is_compressed(templ->format)) + return NULL; + + tex = CALLOC_STRUCT(brw_texture); + if (!tex) + return NULL; + + if (bscreen->sws->bo_from_handle(bscreen->sws, whandle, &pitch, &tiling, &buffer) != PIPE_OK) + goto fail; + + memcpy(&tex->base, templ, sizeof *templ); + pipe_reference_init(&tex->base.reference, 1); + tex->base.screen = screen; + + /* XXX: cpp vs. blocksize + */ + tex->cpp = util_format_get_blocksize(tex->base.format); + tex->tiling = tiling; + + make_empty_list(&tex->views[0]); + make_empty_list(&tex->views[1]); + + if (!brw_texture_layout(bscreen, tex)) + goto fail; + + /* XXX Maybe some more checks? */ + if ((pitch / tex->cpp) < tex->pitch) + goto fail; + + tex->pitch = pitch / tex->cpp; + + tex->bo = buffer; + + /* fix this warning */ +#if 0 + if (tex->size > buffer->size) + goto fail; +#endif + + tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW; + tex->ss.ss0.surface_type = translate_tex_target(tex->base.target); + tex->ss.ss0.surface_format = translate_tex_format(tex->base.format); + assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID); + + /* This is ok for all textures with channel width 8bit or less: + */ +/* tex->ss.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */ + + + /* XXX: what happens when tex->bo->offset changes??? + */ + tex->ss.ss1.base_addr = 0; /* reloc */ + tex->ss.ss2.mip_count = tex->base.last_level; + tex->ss.ss2.width = tex->base.width0 - 1; + tex->ss.ss2.height = tex->base.height0 - 1; + + switch (tex->tiling) { + case BRW_TILING_NONE: + tex->ss.ss3.tiled_surface = 0; + tex->ss.ss3.tile_walk = 0; + break; + case BRW_TILING_X: + tex->ss.ss3.tiled_surface = 1; + tex->ss.ss3.tile_walk = BRW_TILEWALK_XMAJOR; + break; + case BRW_TILING_Y: + tex->ss.ss3.tiled_surface = 1; + tex->ss.ss3.tile_walk = BRW_TILEWALK_YMAJOR; + break; + } + + tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1; + tex->ss.ss3.depth = tex->base.depth0 - 1; + + tex->ss.ss4.min_lod = 0; + + return &tex->base; + +fail: + FREE(tex); + return NULL; +} + +static boolean +brw_texture_get_handle(struct pipe_screen *screen, + struct pipe_texture *texture, + struct winsys_handle *whandle) +{ + struct brw_screen *bscreen = brw_screen(screen); + struct brw_texture *tex = brw_texture(texture); + unsigned stride; + + stride = tex->pitch * tex->cpp; + + return bscreen->sws->bo_get_handle(tex->bo, whandle, stride); +} + static struct pipe_texture *brw_texture_blanket(struct pipe_screen *screen, const struct pipe_texture *templ, const unsigned *stride, @@ -451,125 +564,12 @@ brw_tex_transfer_destroy(struct pipe_transfer *trans) } -/* - * Functions exported to the winsys - */ - -boolean brw_texture_get_winsys_buffer(struct pipe_texture *texture, - struct brw_winsys_buffer **buffer, - unsigned *stride) -{ - struct brw_texture *tex = brw_texture(texture); - - *buffer = tex->bo; - if (stride) - *stride = tex->pitch * tex->cpp; - - return TRUE; -} - -struct pipe_texture * -brw_texture_blanket_winsys_buffer(struct pipe_screen *screen, - const struct pipe_texture *templ, - unsigned pitch, - unsigned tiling, - struct brw_winsys_buffer *buffer) -{ - struct brw_screen *bscreen = brw_screen(screen); - struct brw_texture *tex; - GLuint format; - - if (templ->target != PIPE_TEXTURE_2D || - templ->last_level != 0 || - templ->depth0 != 1) - return NULL; - - if (util_format_is_compressed(templ->format)) - return NULL; - - tex = CALLOC_STRUCT(brw_texture); - if (!tex) - return NULL; - - memcpy(&tex->base, templ, sizeof *templ); - pipe_reference_init(&tex->base.reference, 1); - tex->base.screen = screen; - - /* XXX: cpp vs. blocksize - */ - tex->cpp = util_format_get_blocksize(tex->base.format); - tex->tiling = tiling; - - make_empty_list(&tex->views[0]); - make_empty_list(&tex->views[1]); - - if (!brw_texture_layout(bscreen, tex)) - goto fail; - - /* XXX Maybe some more checks? */ - if ((pitch / tex->cpp) < tex->pitch) - goto fail; - - tex->pitch = pitch / tex->cpp; - - tex->bo = buffer; - - /* fix this warning */ -#if 0 - if (tex->size > buffer->size) - goto fail; -#endif - - tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW; - tex->ss.ss0.surface_type = translate_tex_target(tex->base.target); - - format = translate_tex_format(tex->base.format); - assert(format != BRW_SURFACEFORMAT_INVALID); - tex->ss.ss0.surface_format = format; - - /* This is ok for all textures with channel width 8bit or less: - */ -/* tex->ss.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */ - - - /* XXX: what happens when tex->bo->offset changes??? - */ - tex->ss.ss1.base_addr = 0; /* reloc */ - tex->ss.ss2.mip_count = tex->base.last_level; - tex->ss.ss2.width = tex->base.width0 - 1; - tex->ss.ss2.height = tex->base.height0 - 1; - - switch (tex->tiling) { - case BRW_TILING_NONE: - tex->ss.ss3.tiled_surface = 0; - tex->ss.ss3.tile_walk = 0; - break; - case BRW_TILING_X: - tex->ss.ss3.tiled_surface = 1; - tex->ss.ss3.tile_walk = BRW_TILEWALK_XMAJOR; - break; - case BRW_TILING_Y: - tex->ss.ss3.tiled_surface = 1; - tex->ss.ss3.tile_walk = BRW_TILEWALK_YMAJOR; - break; - } - - tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1; - tex->ss.ss3.depth = tex->base.depth0 - 1; - - tex->ss.ss4.min_lod = 0; - - return &tex->base; - -fail: - FREE(tex); - return NULL; -} - void brw_screen_tex_init( struct brw_screen *brw_screen ) { brw_screen->base.is_format_supported = brw_is_format_supported; brw_screen->base.texture_create = brw_texture_create; + brw_screen->base.texture_from_handle = brw_texture_from_handle; + brw_screen->base.texture_get_handle = brw_texture_get_handle; brw_screen->base.texture_destroy = brw_texture_destroy; brw_screen->base.texture_blanket = brw_texture_blanket; brw_screen->base.get_tex_transfer = brw_get_tex_transfer; diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h index c82d00f4a4..139e26e31f 100644 --- a/src/gallium/drivers/i965/brw_winsys.h +++ b/src/gallium/drivers/i965/brw_winsys.h @@ -162,6 +162,16 @@ struct brw_winsys_screen { unsigned alignment, struct brw_winsys_buffer **bo_out); + enum pipe_error (*bo_from_handle)(struct brw_winsys_screen *sws, + struct winsys_handle *whandle, + unsigned *stride, + unsigned *tiling, + struct brw_winsys_buffer **bo_out); + + enum pipe_error (*bo_get_handle)(struct brw_winsys_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride); + /* Destroy a buffer when our refcount goes to zero: */ void (*bo_destroy)(struct brw_winsys_buffer *buffer); diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c index a061eef0be..21e82303f7 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_api.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_api.c @@ -37,129 +37,6 @@ i965_libdrm_get_device_id(unsigned int *device_id) fclose(file); } -static struct i965_libdrm_buffer * -i965_libdrm_buffer_from_handle(struct i965_libdrm_winsys *idws, - const char* name, unsigned handle) -{ - struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer); - uint32_t swizzle = 0; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!buf) - return NULL; - pipe_reference_init(&buf->base.reference, 1); - buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, name, handle); - buf->base.size = buf->bo->size; - buf->base.sws = &idws->base; - buf->flinked = TRUE; - buf->flink = handle; - - - if (!buf->bo) - goto err; - - drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle); - if (buf->tiling != 0) - buf->map_gtt = TRUE; - - return buf; - -err: - FREE(buf); - return NULL; -} - - -/* - * Exported functions - */ - - -static struct pipe_texture * -i965_libdrm_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *template, - const char* name, - unsigned pitch, - unsigned handle) -{ - /* XXX: this is silly -- there should be a way to get directly from - * the "drm_api" struct to ourselves, without peering into - * unrelated code: - */ - struct i965_libdrm_winsys *idws = i965_libdrm_winsys(brw_screen(screen)->sws); - struct i965_libdrm_buffer *buffer; - - if (BRW_DUMP) - debug_printf("%s %s pitch %d handle 0x%x\n", __FUNCTION__, - name, pitch, handle); - - buffer = i965_libdrm_buffer_from_handle(idws, name, handle); - if (!buffer) - return NULL; - - return brw_texture_blanket_winsys_buffer(screen, template, pitch, - buffer->tiling, - &buffer->base); -} - - -static boolean -i965_libdrm_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct i965_libdrm_buffer *buf = NULL; - struct brw_winsys_buffer *buffer = NULL; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch)) - return FALSE; - - buf = i965_libdrm_buffer(buffer); - if (!buf->flinked) { - if (drm_intel_bo_flink(buf->bo, &buf->flink)) - return FALSE; - buf->flinked = TRUE; - } - - *handle = buf->flink; - - if (BRW_DUMP) - debug_printf(" -> pitch %d handle 0x%x\n", *pitch, *handle); - - return TRUE; -} - -static boolean -i965_libdrm_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *pitch, - unsigned *handle) -{ - struct brw_winsys_buffer *buffer = NULL; - - if (BRW_DUMP) - debug_printf("%s\n", __FUNCTION__); - - if (!brw_texture_get_winsys_buffer(texture, &buffer, pitch)) - return FALSE; - - *handle = i965_libdrm_buffer(buffer)->bo->handle; - - if (BRW_DUMP) - debug_printf(" -> pitch %d handle 0x%x\n", *pitch, *handle); - - return TRUE; -} - static void i965_libdrm_winsys_destroy(struct brw_winsys_screen *iws) { @@ -225,9 +102,6 @@ struct drm_api i965_libdrm_api = { .name = "i965", .create_screen = i965_libdrm_create_screen, - .texture_from_shared_handle = i965_libdrm_texture_from_shared_handle, - .shared_handle_from_texture = i965_libdrm_shared_handle_from_texture, - .local_handle_from_texture = i965_libdrm_local_handle_from_texture, .destroy = destroy, }; diff --git a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c index 07be1df87f..33a17496b2 100644 --- a/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c +++ b/src/gallium/winsys/drm/i965/gem/i965_drm_buffer.c @@ -1,4 +1,5 @@ +#include "state_tracker/drm_api.h" #include "i965_drm_winsys.h" #include "util/u_memory.h" #include "util/u_inlines.h" @@ -122,6 +123,78 @@ err: return PIPE_ERROR_OUT_OF_MEMORY; } +static enum pipe_error +i965_libdrm_bo_from_handle(struct brw_winsys_screen *sws, + struct winsys_handle *whandle, + unsigned *stride, + unsigned *tile, + struct brw_winsys_buffer **bo_out) +{ + struct i965_libdrm_winsys *idws = i965_libdrm_winsys(sws); + struct i965_libdrm_buffer *buf = CALLOC_STRUCT(i965_libdrm_buffer); + uint32_t swizzle = 0; + + if (BRW_DUMP) + debug_printf("%s\n", __FUNCTION__); + + if (!buf) + return PIPE_ERROR_OUT_OF_MEMORY; + + pipe_reference_init(&buf->base.reference, 1); + buf->bo = drm_intel_bo_gem_create_from_name(idws->gem, "FROM_HANDLE", whandle->handle); + buf->base.size = buf->bo->size; + buf->base.sws = &idws->base; + buf->flinked = TRUE; + buf->flink = whandle->handle; + + + if (!buf->bo) + goto err; + + drm_intel_bo_get_tiling(buf->bo, &buf->tiling, &swizzle); + if (buf->tiling != 0) + buf->map_gtt = TRUE; + + *tile = buf->tiling; + *stride = whandle->stride; + + *bo_out = &buf->base; + return PIPE_OK; + +err: + FREE(buf); + return PIPE_ERROR_OUT_OF_MEMORY; +} + +static enum pipe_error +i965_libdrm_bo_get_handle(struct brw_winsys_buffer *buffer, + struct winsys_handle *whandle, + unsigned stride) +{ + struct i965_libdrm_buffer *buf = i965_libdrm_buffer(buffer); + + if (BRW_DUMP) + debug_printf("%s\n", __FUNCTION__); + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + if (drm_intel_bo_flink(buf->bo, &buf->flink)) + return PIPE_ERROR_BAD_INPUT; + buf->flinked = TRUE; + } + + whandle->handle = buf->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; + } else { + assert(!"unknown usage"); + return PIPE_ERROR_BAD_INPUT; + } + + whandle->stride = stride; + return PIPE_OK; +} + static void i965_libdrm_bo_destroy(struct brw_winsys_buffer *buffer) { @@ -415,6 +488,8 @@ void i965_libdrm_winsys_init_buffer_functions(struct i965_libdrm_winsys *idws) { idws->base.bo_alloc = i965_libdrm_bo_alloc; + idws->base.bo_from_handle = i965_libdrm_bo_from_handle; + idws->base.bo_get_handle = i965_libdrm_bo_get_handle; idws->base.bo_destroy = i965_libdrm_bo_destroy; idws->base.bo_emit_reloc = i965_libdrm_bo_emit_reloc; idws->base.bo_exec = i965_libdrm_bo_exec; -- cgit v1.2.3 From 3a2358b6c64e028e170fef3254d54170fb2d14f1 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 26 Feb 2010 04:27:48 +0000 Subject: svga: Conversion to winsys handle --- src/gallium/drivers/svga/svga_screen_texture.c | 62 ++++++++---------- src/gallium/drivers/svga/svga_winsys.h | 33 ++++++---- .../winsys/drm/vmware/core/vmw_screen_dri.c | 76 +++++++++++++--------- 3 files changed, 91 insertions(+), 80 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index b34f906ceb..994a6e0fd1 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -426,13 +426,15 @@ svga_texture_blanket(struct pipe_screen * screen, } -struct pipe_texture * -svga_screen_texture_wrap_surface(struct pipe_screen *screen, - struct pipe_texture *base, - enum SVGA3dSurfaceFormat format, - struct svga_winsys_surface *srf) +static struct pipe_texture * +svga_screen_texture_from_handle(struct pipe_screen *screen, + const struct pipe_texture *base, + struct winsys_handle *whandle) { + struct svga_winsys_screen *sws = svga_winsys_screen(screen); + struct svga_winsys_surface *srf; struct svga_texture *tex; + enum SVGA3dSurfaceFormat format = 0; assert(screen); /* Only supports one type */ @@ -442,6 +444,8 @@ svga_screen_texture_wrap_surface(struct pipe_screen *screen, return NULL; } + srf = sws->surface_from_handle(sws, whandle, &format); + if (!srf) return NULL; @@ -482,6 +486,22 @@ svga_screen_texture_wrap_surface(struct pipe_screen *screen, } +static boolean +svga_screen_texture_get_handle(struct pipe_screen *screen, + struct pipe_texture *texture, + struct winsys_handle *whandle) +{ + struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen); + unsigned stride; + + assert(svga_texture(texture)->key.cachable == 0); + svga_texture(texture)->key.cachable = 0; + stride = util_format_get_nblocksx(texture->format, texture->width0) * + util_format_get_blocksize(texture->format); + return sws->surface_get_handle(sws, svga_texture(texture)->handle, stride, whandle); +} + + static void svga_texture_destroy(struct pipe_texture *pt) { @@ -959,6 +979,8 @@ void svga_screen_init_texture_functions(struct pipe_screen *screen) { screen->texture_create = svga_texture_create; + screen->texture_from_handle = svga_screen_texture_from_handle; + screen->texture_get_handle = svga_screen_texture_get_handle; screen->texture_destroy = svga_texture_destroy; screen->get_tex_surface = svga_get_tex_surface; screen->tex_surface_destroy = svga_tex_surface_destroy; @@ -1124,33 +1146,3 @@ svga_destroy_sampler_view_priv(struct svga_sampler_view *v) pipe_texture_reference(&v->texture, NULL); FREE(v); } - -boolean -svga_screen_buffer_from_texture(struct pipe_texture *texture, - struct pipe_buffer **buffer, - unsigned *stride) -{ - struct svga_texture *stex = svga_texture(texture); - - *buffer = svga_screen_buffer_wrap_surface - (texture->screen, - svga_translate_format(texture->format), - stex->handle); - - *stride = util_format_get_stride(texture->format, texture->width0); - - return *buffer != NULL; -} - - -struct svga_winsys_surface * -svga_screen_texture_get_winsys_surface(struct pipe_texture *texture) -{ - struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen); - struct svga_winsys_surface *vsurf = NULL; - - assert(svga_texture(texture)->key.cachable == 0); - svga_texture(texture)->key.cachable = 0; - sws->surface_reference(sws, &vsurf, svga_texture(texture)->handle); - return vsurf; -} diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h index b4e3af0eaf..d4bb176f9a 100644 --- a/src/gallium/drivers/svga/svga_winsys.h +++ b/src/gallium/drivers/svga/svga_winsys.h @@ -51,6 +51,7 @@ struct pipe_context; struct pipe_fence_handle; struct pipe_texture; struct svga_region; +struct winsys_handle; #define SVGA_BUFFER_USAGE_PINNED (PIPE_BUFFER_USAGE_CUSTOM << 0) @@ -186,6 +187,25 @@ struct svga_winsys_screen uint32 numFaces, uint32 numMipLevels); + /** + * Creates a surface from a winsys handle. + * Used to implement pipe_screen::texture_from_handle. + */ + struct svga_winsys_surface * + (*surface_from_handle)(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format); + + /** + * Get a winsys_handle from a surface. + * Used to implement pipe_screen::texture_get_handle. + */ + boolean + (*surface_get_handle)(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle); + /** * Whether this surface is sitting in a validate list */ @@ -283,20 +303,7 @@ svga_screen_buffer_wrap_surface(struct pipe_screen *screen, enum SVGA3dSurfaceFormat format, struct svga_winsys_surface *srf); -struct svga_winsys_surface * -svga_screen_texture_get_winsys_surface(struct pipe_texture *texture); struct svga_winsys_surface * svga_screen_buffer_get_winsys_surface(struct pipe_buffer *buffer); -boolean -svga_screen_buffer_from_texture(struct pipe_texture *texture, - struct pipe_buffer **buffer, - unsigned *stride); - -struct pipe_texture * -svga_screen_texture_wrap_surface(struct pipe_screen *screen, - struct pipe_texture *base, - enum SVGA3dSurfaceFormat format, - struct svga_winsys_surface *srf); - #endif /* SVGA_WINSYS_H_ */ diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index a7c6e88b9e..0e3dad84a5 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -44,6 +44,16 @@ #include +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format); +static boolean +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle); + static struct dri1_api dri1_api_hooks; static struct dri1_api_version ddx_required = { 0, 1, 0 }; static struct dri1_api_version ddx_compat = { 0, 0, 0 }; @@ -129,7 +139,12 @@ vmw_drm_create_screen(struct drm_api *drm_api, &drm_compat, "use old scanout field (not a error)")) use_old_scanout_flag = TRUE; dri1->api = &dri1_api_hooks; +#if 0 break; +#else + assert(!"No dri 1 support for now\n"); + return NULL; +#endif default: return NULL; } @@ -139,6 +154,10 @@ vmw_drm_create_screen(struct drm_api *drm_api, if (!vws) goto out_no_vws; + /* XXX do this properly */ + vws->base.surface_from_handle = vmw_drm_surface_from_handle; + vws->base.surface_get_handle = vmw_drm_surface_get_handle; + screen = svga_screen_create( &vws->base ); if (!screen) goto out_no_screen; @@ -200,6 +219,7 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe, const struct drm_clip_rect *bbox, struct pipe_fence_handle **p_fence) { +#if 0 struct svga_winsys_surface *srf = svga_screen_texture_get_winsys_surface(surf->texture); struct vmw_svga_winsys_surface *vsrf = vmw_svga_winsys_surface(srf); @@ -246,21 +266,19 @@ vmw_dri1_present_locked(struct pipe_context *locked_pipe, *p_fence = (visible) ? vmw_pipe_fence(fence_seq) : NULL; vmw_svga_winsys_surface_reference(&vsrf, NULL); +#else + assert(!"No dri 1 support for now\n"); +#endif } -static struct pipe_texture * -vmw_drm_texture_from_handle(struct drm_api *drm_api, - struct pipe_screen *screen, - struct pipe_texture *templat, - const char *name, - unsigned stride, - unsigned handle) +static struct svga_winsys_surface * +vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + struct winsys_handle *whandle, + SVGA3dSurfaceFormat *format) { struct vmw_svga_winsys_surface *vsrf; struct svga_winsys_surface *ssrf; - struct vmw_winsys_screen *vws = - vmw_winsys_screen(svga_winsys_screen(screen)); - struct pipe_texture *tex; + struct vmw_winsys_screen *vws = vmw_winsys_screen(sws); union drm_vmw_surface_reference_arg arg; struct drm_vmw_surface_arg *req = &arg.req; struct drm_vmw_surface_create_req *rep = &arg.rep; @@ -273,7 +291,7 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, */ memset(&arg, 0, sizeof(arg)); - req->sid = handle; + req->sid = whandle->handle; ret = drmCommandWriteRead(vws->ioctl.drm_fd, DRM_VMW_REF_SURFACE, &arg, sizeof(arg)); @@ -281,14 +299,14 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, if (ret) { fprintf(stderr, "Failed referencing shared surface. SID %d.\n" "Error %d (%s).\n", - handle, ret, strerror(-ret)); + whandle->handle, ret, strerror(-ret)); return NULL; } if (rep->mip_levels[0] != 1) { fprintf(stderr, "Incorrect number of mipmap levels on shared surface." " SID %d, levels %d\n", - handle, rep->mip_levels[0]); + whandle->handle, rep->mip_levels[0]); goto out_mip; } @@ -296,7 +314,7 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, if (rep->mip_levels[i] != 0) { fprintf(stderr, "Incorrect number of faces levels on shared surface." " SID %d, face %d present.\n", - handle, i); + whandle->handle, i); goto out_mip; } } @@ -308,38 +326,32 @@ vmw_drm_texture_from_handle(struct drm_api *drm_api, pipe_reference_init(&vsrf->refcnt, 1); p_atomic_set(&vsrf->validated, 0); vsrf->screen = vws; - vsrf->sid = handle; + vsrf->sid = whandle->handle; ssrf = svga_winsys_surface(vsrf); - tex = svga_screen_texture_wrap_surface(screen, templat, rep->format, ssrf); - if (!tex) - vmw_svga_winsys_surface_reference(&vsrf, NULL); + *format = rep->format; + + return ssrf; - return tex; - out_mip: - vmw_ioctl_surface_destroy(vws, handle); +out_mip: + vmw_ioctl_surface_destroy(vws, whandle->handle); return NULL; } static boolean -vmw_drm_handle_from_texture(struct drm_api *drm_api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) +vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + struct svga_winsys_surface *surface, + unsigned stride, + struct winsys_handle *whandle) { - struct svga_winsys_surface *surface = - svga_screen_texture_get_winsys_surface(texture); struct vmw_svga_winsys_surface *vsrf; if (!surface) return FALSE; vsrf = vmw_svga_winsys_surface(surface); - *handle = vsrf->sid; - *stride = util_format_get_nblocksx(texture->format, texture->width0) * - util_format_get_blocksize(texture->format); + whandle->handle = vsrf->sid; + whandle->stride = stride; - vmw_svga_winsys_surface_reference(&vsrf, NULL); return TRUE; } -- cgit v1.2.3 From d160eed005e75d8933562f4880dfc84033011ac5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 1 Mar 2010 15:11:39 +0000 Subject: r300g: Conversion to to winsys handle --- src/gallium/drivers/r300/r300_texture.c | 66 +++++++++++ src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 71 ++++++++++++ src/gallium/winsys/drm/radeon/core/radeon_drm.c | 121 --------------------- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 22 ---- src/gallium/winsys/drm/radeon/core/radeon_winsys.h | 12 ++ 5 files changed, 149 insertions(+), 143 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 2246c75056..3b39207a45 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -848,6 +848,70 @@ static struct pipe_texture* return (struct pipe_texture*)tex; } +static struct pipe_texture* + r300_texture_from_handle(struct pipe_screen* screen, + const struct pipe_texture* base, + struct winsys_handle *whandle) +{ + struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys; + struct r300_screen* rscreen = r300_screen(screen); + struct pipe_buffer *buffer; + struct r300_texture* tex; + unsigned stride; + + /* Support only 2D textures without mipmaps */ + if (base->target != PIPE_TEXTURE_2D || + base->depth0 != 1 || + base->last_level != 0) { + return NULL; + } + + buffer = winsys->buffer_from_handle(winsys, screen, whandle, &stride); + if (!buffer) { + return NULL; + } + + tex = CALLOC_STRUCT(r300_texture); + if (!tex) { + return NULL; + } + + tex->tex = *base; + pipe_reference_init(&tex->tex.reference, 1); + tex->tex.screen = screen; + + tex->stride_override = stride; + tex->pitch[0] = stride / util_format_get_blocksize(base->format); + + r300_setup_flags(tex); + r300_setup_texture_state(rscreen, tex); + + /* one ref already taken */ + tex->buffer = buffer; + + return (struct pipe_texture*)tex; +} + +static boolean + r300_texture_get_handle(struct pipe_screen* screen, + struct pipe_texture *texture, + struct winsys_handle *whandle) +{ + struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys; + struct r300_texture* tex = (struct r300_texture*)texture; + unsigned stride; + + if (!tex) { + return FALSE; + } + + stride = r300_texture_get_stride(r300_screen(screen), tex, 0); + + winsys->buffer_get_handle(winsys, tex->buffer, stride, whandle); + + return TRUE; +} + static struct pipe_video_surface * r300_video_surface_create(struct pipe_screen *screen, enum pipe_video_chroma_format chroma_format, @@ -899,6 +963,8 @@ static void r300_video_surface_destroy(struct pipe_video_surface *vsfc) void r300_init_screen_texture_functions(struct pipe_screen* screen) { screen->texture_create = r300_texture_create; + screen->texture_from_handle = r300_texture_from_handle; + screen->texture_get_handle = r300_texture_get_handle; screen->texture_destroy = r300_texture_destroy; screen->get_tex_surface = r300_get_tex_surface; screen->tex_surface_destroy = r300_tex_surface_destroy; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c index e5c6919933..daa032af6f 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c @@ -264,6 +264,75 @@ static int radeon_fence_finish(struct pipe_winsys *ws, return 0; } +/* Create a buffer from a handle. */ +static struct pipe_buffer* radeon_buffer_from_handle(struct radeon_winsys *radeon_ws, + struct pipe_screen *screen, + struct winsys_handle *whandle, + unsigned *stride) +{ + struct radeon_bo_manager* bom = radeon_ws->priv->bom; + struct radeon_pipe_buffer* radeon_buffer; + struct radeon_bo* bo = NULL; + + bo = radeon_bo_open(bom, whandle->handle, 0, 0, 0, 0); + if (bo == NULL) { + return NULL; + } + + radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); + if (radeon_buffer == NULL) { + radeon_bo_unref(bo); + return NULL; + } + + pipe_reference_init(&radeon_buffer->base.reference, 1); + radeon_buffer->base.screen = screen; + radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; + radeon_buffer->bo = bo; + + *stride = whandle->stride; + + return &radeon_buffer->base; +} + +static boolean radeon_buffer_get_handle(struct radeon_winsys *radeon_ws, + struct pipe_buffer *buffer, + unsigned stride, + struct winsys_handle *whandle) +{ + int retval, fd; + struct drm_gem_flink flink; + struct radeon_pipe_buffer* radeon_buffer; + + radeon_buffer = (struct radeon_pipe_buffer*)buffer; + + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + if (!radeon_buffer->flinked) { + fd = radeon_ws->priv->fd; + + flink.handle = radeon_buffer->bo->handle; + + retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); + if (retval) { + debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", + retval); + return FALSE; + } + + radeon_buffer->flink = flink.name; + radeon_buffer->flinked = TRUE; + } + + whandle->handle = radeon_buffer->flink; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle; + } + whandle->stride = stride; + + return TRUE; +} + struct radeon_winsys* radeon_pipe_winsys(int fd) { struct radeon_winsys* radeon_ws; @@ -298,6 +367,8 @@ struct radeon_winsys* radeon_pipe_winsys(int fd) radeon_ws->base.get_name = radeon_get_name; radeon_ws->buffer_set_tiling = radeon_buffer_set_tiling; + radeon_ws->buffer_from_handle = radeon_buffer_from_handle; + radeon_ws->buffer_get_handle = radeon_buffer_get_handle; return radeon_ws; } diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index e817a26da6..97edb6a47e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -148,124 +148,6 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api, } } - -boolean radeon_buffer_from_texture(struct drm_api* api, - struct pipe_screen* screen, - struct pipe_texture* texture, - struct pipe_buffer** buffer, - unsigned* stride) -{ - /* XXX fix this */ - return r300_get_texture_buffer(screen, texture, buffer, stride); -} - -/* Create a buffer from a handle. */ -/* XXX what's up with name? */ -struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, - struct pipe_screen* screen, - const char* name, - unsigned handle) -{ - struct radeon_bo_manager* bom = - ((struct radeon_winsys*)screen->winsys)->priv->bom; - struct radeon_pipe_buffer* radeon_buffer; - struct radeon_bo* bo = NULL; - - bo = radeon_bo_open(bom, handle, 0, 0, 0, 0); - if (bo == NULL) { - return NULL; - } - - radeon_buffer = CALLOC_STRUCT(radeon_pipe_buffer); - if (radeon_buffer == NULL) { - radeon_bo_unref(bo); - return NULL; - } - - pipe_reference_init(&radeon_buffer->base.reference, 1); - radeon_buffer->base.screen = screen; - radeon_buffer->base.usage = PIPE_BUFFER_USAGE_PIXEL; - radeon_buffer->bo = bo; - return &radeon_buffer->base; -} - -static struct pipe_texture* -radeon_texture_from_shared_handle(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle) -{ - struct pipe_buffer *buffer; - struct pipe_texture *blanket; - - buffer = radeon_buffer_from_handle(api, screen, name, handle); - if (!buffer) { - return NULL; - } - - blanket = screen->texture_blanket(screen, templ, &stride, buffer); - - pipe_buffer_reference(&buffer, NULL); - - return blanket; -} - -static boolean radeon_shared_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) -{ - int retval, fd; - struct drm_gem_flink flink; - struct radeon_pipe_buffer* radeon_buffer; - struct pipe_buffer *buffer = NULL; - - if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { - return FALSE; - } - - radeon_buffer = (struct radeon_pipe_buffer*)buffer; - if (!radeon_buffer->flinked) { - fd = ((struct radeon_winsys*)screen->winsys)->priv->fd; - - flink.handle = radeon_buffer->bo->handle; - - retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink); - if (retval) { - debug_printf("radeon: DRM_IOCTL_GEM_FLINK failed, error %d\n", - retval); - return FALSE; - } - - radeon_buffer->flink = flink.name; - radeon_buffer->flinked = TRUE; - } - - *handle = radeon_buffer->flink; - return TRUE; -} - -static boolean radeon_local_handle_from_texture(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle) -{ - struct pipe_buffer *buffer = NULL; - if (!radeon_buffer_from_texture(api, screen, texture, &buffer, stride)) { - return FALSE; - } - - *handle = ((struct radeon_pipe_buffer*)buffer)->bo->handle; - - pipe_buffer_reference(&buffer, NULL); - - return TRUE; -} - static void radeon_drm_api_destroy(struct drm_api *api) { return; @@ -275,9 +157,6 @@ struct drm_api drm_api_hooks = { .name = "radeon", .driver_name = "radeon", .create_screen = radeon_create_screen, - .texture_from_shared_handle = radeon_texture_from_shared_handle, - .shared_handle_from_texture = radeon_shared_handle_from_texture, - .local_handle_from_texture = radeon_local_handle_from_texture, .destroy = radeon_drm_api_destroy, }; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index f62a9b8048..78451b6f01 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -37,28 +37,6 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api, int drmFB, struct drm_create_screen_arg *arg); - -boolean radeon_buffer_from_texture(struct drm_api* api, - struct pipe_screen* screen, - struct pipe_texture* texture, - struct pipe_buffer** buffer, - unsigned* stride); - -struct pipe_buffer* radeon_buffer_from_handle(struct drm_api* api, - struct pipe_screen* screen, - const char* name, - unsigned handle); - -boolean radeon_handle_from_buffer(struct drm_api* api, - struct pipe_screen* screen, - struct pipe_buffer* buffer, - unsigned* handle); - -boolean radeon_global_handle_from_buffer(struct drm_api* api, - struct pipe_screen* screen, - struct pipe_buffer* buffer, - unsigned* handle); - void radeon_destroy_drm_api(struct drm_api* api); /* Guess at whether this chipset should use r300g. diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h index 4901080ca7..37eeb45979 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h @@ -56,6 +56,18 @@ struct radeon_winsys { /* VRAM size. */ uint32_t vram_size; + /* Create a buffer from a winsys handle. */ + struct pipe_buffer *(*buffer_from_handle)(struct radeon_winsys *winsys, + struct pipe_screen *screen, + struct winsys_handle *whandle, + unsigned *stride); + + /* Get the handle from a buffer. */ + boolean (*buffer_get_handle)(struct radeon_winsys *winsys, + struct pipe_buffer *buffer, + unsigned stride, + struct winsys_handle *whandle); + /* Add a pipe_buffer to the list of buffer objects to validate. */ boolean (*add_buffer)(struct radeon_winsys* winsys, struct pipe_buffer* pbuffer, -- cgit v1.2.3 From 932e6f8d527d2147ecc4e75ce9ae2f71e23e61af Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 1 Mar 2010 17:06:20 +0100 Subject: util: Fix u_blitter setup code after bypass_vs_clip_and_viewport removal. Not tested. --- src/gallium/auxiliary/util/u_blitter.c | 46 ++++++++++++++++++++++++++-------- src/gallium/auxiliary/util/u_blitter.h | 16 ++++++++++++ 2 files changed, 51 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 50877f6b01..f93c69d193 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -93,6 +93,12 @@ struct blitter_context_priv /* Rasterizer state. */ void *rs_state; + + /* Viewport state. */ + struct pipe_viewport_state viewport; + + /* Clip state. */ + struct pipe_clip_state clip; }; struct blitter_context *util_blitter_create(struct pipe_context *pipe) @@ -262,6 +268,9 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) pipe->set_stencil_ref(pipe, &ctx->blitter.saved_stencil_ref); + pipe->set_viewport_state(pipe, &ctx->blitter.saved_viewport); + pipe->set_clip_state(pipe, &ctx->blitter.saved_clip); + /* restore the state objects which are required to be saved before copy/fill */ if (ctx->blitter.saved_fb_state.nr_cbufs != ~0) { @@ -287,25 +296,40 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) static void blitter_set_rectangle(struct blitter_context_priv *ctx, unsigned x1, unsigned y1, unsigned x2, unsigned y2, + unsigned width, unsigned height, float depth) { int i; /* set vertex positions */ - ctx->vertices[0][0][0] = x1; /*v0.x*/ - ctx->vertices[0][0][1] = y1; /*v0.y*/ + ctx->vertices[0][0][0] = (float)x1 / width * 2.0f - 1.0f; /*v0.x*/ + ctx->vertices[0][0][1] = (float)y1 / height * 2.0f - 1.0f; /*v0.y*/ - ctx->vertices[1][0][0] = x2; /*v1.x*/ - ctx->vertices[1][0][1] = y1; /*v1.y*/ + ctx->vertices[1][0][0] = (float)x2 / width * 2.0f - 1.0f; /*v1.x*/ + ctx->vertices[1][0][1] = (float)y1 / height * 2.0f - 1.0f; /*v1.y*/ - ctx->vertices[2][0][0] = x2; /*v2.x*/ - ctx->vertices[2][0][1] = y2; /*v2.y*/ + ctx->vertices[2][0][0] = (float)x2 / width * 2.0f - 1.0f; /*v2.x*/ + ctx->vertices[2][0][1] = (float)y2 / height * 2.0f - 1.0f; /*v2.y*/ - ctx->vertices[3][0][0] = x1; /*v3.x*/ - ctx->vertices[3][0][1] = y2; /*v3.y*/ + ctx->vertices[3][0][0] = (float)x1 / width * 2.0f - 1.0f; /*v3.x*/ + ctx->vertices[3][0][1] = (float)y2 / height * 2.0f - 1.0f; /*v3.y*/ for (i = 0; i < 4; i++) ctx->vertices[i][0][2] = depth; /*z*/ + + /* viewport */ + ctx->viewport.scale[0] = 0.5f * width; + ctx->viewport.scale[1] = 0.5f * height; + ctx->viewport.scale[2] = 0.5f; + ctx->viewport.scale[3] = 1.0f; + ctx->viewport.translate[0] = 0.5f * width; + ctx->viewport.translate[1] = 0.5f * height; + ctx->viewport.translate[2] = 0.5f; + ctx->viewport.translate[3] = 0.0f; + ctx->pipe->set_viewport_state(ctx->pipe, &ctx->viewport); + + /* clip */ + ctx->pipe->set_clip_state(ctx->pipe, &ctx->clip); } static void blitter_set_clear_color(struct blitter_context_priv *ctx, @@ -549,7 +573,7 @@ void util_blitter_clear(struct blitter_context *blitter, pipe->bind_vs_state(pipe, ctx->vs_col); blitter_set_clear_color(ctx, rgba); - blitter_set_rectangle(ctx, 0, 0, width, height, depth); + blitter_set_rectangle(ctx, 0, 0, width, height, width, height, depth); blitter_draw_quad(ctx); blitter_restore_CSOs(ctx); } @@ -632,7 +656,7 @@ static void util_blitter_do_copy(struct blitter_context *blitter, assert(0); } - blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0); + blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, dst->width, dst->height, 0); blitter_draw_quad(ctx); } @@ -793,7 +817,7 @@ void util_blitter_fill(struct blitter_context *blitter, pipe->set_framebuffer_state(pipe, &fb_state); blitter_set_clear_color(ctx, rgba); - blitter_set_rectangle(ctx, 0, 0, width, height, 0); + blitter_set_rectangle(ctx, 0, 0, width, height, dst->width, dst->height, 0); blitter_draw_quad(ctx); blitter_restore_CSOs(ctx); } diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index a2f17073ac..92008fce99 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -48,6 +48,8 @@ struct blitter_context struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */ struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */ + struct pipe_viewport_state saved_viewport; + struct pipe_clip_state saved_clip; int saved_num_sampler_states; void *saved_sampler_states[32]; @@ -205,6 +207,20 @@ void util_blitter_save_framebuffer(struct blitter_context *blitter, blitter->saved_fb_state = *state; } +static INLINE +void util_blitter_save_viewport(struct blitter_context *blitter, + struct pipe_viewport_state *state) +{ + blitter->saved_viewport = *state; +} + +static INLINE +void util_blitter_save_clip(struct blitter_context *blitter, + struct pipe_clip_state *state) +{ + blitter->saved_clip = *state; +} + static INLINE void util_blitter_save_fragment_sampler_states( struct blitter_context *blitter, -- cgit v1.2.3 From b42455c4f48076eec34e383d5b9cc4670f2d048f Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 1 Mar 2010 17:07:03 +0100 Subject: r300: Save viewport and clip states before invoking blitter. --- src/gallium/drivers/r300/r300_blit.c | 2 ++ src/gallium/drivers/r300/r300_context.h | 4 ++++ src/gallium/drivers/r300/r300_state.c | 4 ++++ 3 files changed, 10 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index eb9b0beeb5..ec7414dc36 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -34,6 +34,8 @@ static void r300_blitter_save_states(struct r300_context* r300) util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state); util_blitter_save_fragment_shader(r300->blitter, r300->fs); util_blitter_save_vertex_shader(r300->blitter, r300->vs); + util_blitter_save_viewport(r300->blitter, &r300->viewport); + util_blitter_save_clip(r300->blitter, &r300->clip); } /* Clear currently bound buffers. */ diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2f056aafcb..97100c08cc 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -333,6 +333,10 @@ struct r300_context { struct pipe_stencil_ref stencil_ref; + struct pipe_clip_state clip; + + struct pipe_viewport_state viewport; + /* Bitmask of dirty state objects. */ uint32_t dirty_state; /* Flag indicating whether or not the HW is dirty. */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 3550c69c46..ebb859138f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -376,6 +376,8 @@ static void r300_set_clip_state(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); + r300->clip = *state; + if (r300_screen(pipe->screen)->caps->has_tcl) { memcpy(r300->clip_state.state, state, sizeof(struct pipe_clip_state)); r300->clip_state.size = 29; @@ -986,6 +988,8 @@ static void r300_set_viewport_state(struct pipe_context* pipe, struct r300_viewport_state* viewport = (struct r300_viewport_state*)r300->viewport_state.state; + r300->viewport = *state; + /* Do the transform in HW. */ viewport->vte_control = R300_VTX_W0_FMT; -- cgit v1.2.3 From 018f4aca794d41cbf215992f8f0dec584aa6bc91 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:07:53 +0000 Subject: util: Fix PIPE_FORMAT_R8G8B8_UNORM description and notes. There is actually no ambiguity in use -- it is always used as R8 G8 B8 --- src/gallium/auxiliary/util/u_format.csv | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 3c5f75c365..1d54fd518a 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -63,7 +63,6 @@ PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, r PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb # XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later -# XXX: insert PIPE_FORMAT_R8G8B8_UNORM here later PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -172,7 +171,7 @@ PIPE_FORMAT_R16G16B16_SSCALED , plain, 1, 1, s16 , s16 , s16 , , xyz1, r PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb -# XXX: insert PIPE_FORMAT_R8G8B8_UNORM here later +PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb # XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb @@ -189,5 +188,4 @@ PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, r # Ambiguous formats # FIXME: They are used with different meanings in different places!!! -PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , zyx1, rgb PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -- cgit v1.2.3 From cd8b6523039d68459756db487566a97fac1d4d75 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:24:09 +0000 Subject: gallium: Introduce a new format to disambiguate PIPE_FORMAT_R8G8B8A8_UNORM. PIPE_FORMAT_R8G8B8A8_UNORM now means just R8 G8 B8 A8 PIPE_FORMAT_R8G8B8A8_UNORM_REV means A8 B8 G8 R8 And the thumb rule is vertex buffers refer to PIPE_FORMAT_R8G8B8A8_UNORM, while textures refer to PIPE_FORMAT_R8G8B8A8_UNORM_REV. PIPE_FORMAT_R8G8B8A8_UNORM_REV is just a temporary name. --- src/gallium/include/pipe/p_format.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 998d1a639f..79e4df7b4d 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -158,6 +158,8 @@ enum pipe_format { PIPE_FORMAT_DXT3_SRGBA = 108, PIPE_FORMAT_DXT5_SRGBA = 109, + PIPE_FORMAT_R8G8B8A8_UNORM_REV = 110, + PIPE_FORMAT_COUNT }; -- cgit v1.2.3 From daf7caf4cfb1c3732a31be56157e9c7d0399ef58 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:24:48 +0000 Subject: util: Use PIPE_FORMAT_R8G8B8A8_UNORM_REV where appropriate. --- src/gallium/auxiliary/util/u_format.csv | 8 ++------ src/gallium/auxiliary/util/u_pack_color.h | 6 +++--- src/gallium/auxiliary/util/u_surface.c | 2 +- src/gallium/auxiliary/util/u_tile.c | 6 +++--- 4 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 1d54fd518a..9cb67a261e 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -61,8 +61,8 @@ PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, r PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_R8G8B8A8_UNORM_REV , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -# XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb @@ -172,7 +172,7 @@ PIPE_FORMAT_R16G16B16A16_SSCALED , plain, 1, 1, s16 , s16 , s16 , s16 , xyzw, r PIPE_FORMAT_R8_UNORM , plain, 1, 1, un8 , , , , x001, rgb PIPE_FORMAT_R8G8_UNORM , plain, 1, 1, un8 , un8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , , xyz1, rgb -# XXX: insert PIPE_FORMAT_R8G8B8A8_UNORM here later +PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb PIPE_FORMAT_R8_USCALED , plain, 1, 1, u8 , , , , x001, rgb PIPE_FORMAT_R8G8_USCALED , plain, 1, 1, u8 , u8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_USCALED , plain, 1, 1, u8 , u8 , u8 , , xyz1, rgb @@ -185,7 +185,3 @@ PIPE_FORMAT_R8_SSCALED , plain, 1, 1, s8 , , , , x001, r PIPE_FORMAT_R8G8_SSCALED , plain, 1, 1, s8 , s8 , , , xy01, rgb PIPE_FORMAT_R8G8B8_SSCALED , plain, 1, 1, s8 , s8 , s8 , , xyz1, rgb PIPE_FORMAT_R8G8B8A8_SSCALED , plain, 1, 1, s8 , s8 , s8 , s8 , xyzw, rgb - -# Ambiguous formats -# FIXME: They are used with different meanings in different places!!! -PIPE_FORMAT_R8G8B8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 0ab53c75dd..4e4ac7f3da 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -57,7 +57,7 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, enum pipe_format format, union util_color *uc) { switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } @@ -153,7 +153,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, ubyte *r, ubyte *g, ubyte *b, ubyte *a) { switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: { uint p = uc->ui; *r = (ubyte) ((p >> 24) & 0xff); @@ -326,7 +326,7 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * } switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index c9f1c9c210..948c1e76d0 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -56,7 +56,7 @@ util_create_rgba_surface(struct pipe_screen *screen, static const enum pipe_format rgbaFormats[] = { PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_R8G8B8A8_UNORM_REV, PIPE_FORMAT_NONE }; const uint target = PIPE_TEXTURE_2D; diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 0051258e22..6000e93a0b 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -248,7 +248,7 @@ b8g8r8a8_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_R8G8B8A8_UNORM ***/ +/*** PIPE_FORMAT_R8G8B8A8_UNORM_REV ***/ static void r8g8b8a8_get_tile_rgba(const unsigned *src, @@ -1171,7 +1171,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_B8G8R8A8_UNORM: b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_A1R5G5B5_UNORM: @@ -1300,7 +1300,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, case PIPE_FORMAT_B8G8R8A8_UNORM: b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_A1R5G5B5_UNORM: -- cgit v1.2.3 From 2c1249e2265cbe96bb00e94f2d9a19c5d8a9d5c4 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:25:25 +0000 Subject: i915g: Use PIPE_FORMAT_R8G8B8A8_UNORM_REV where appropriate. --- src/gallium/drivers/i915/i915_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index b1d754dc4e..eec2b2895f 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -165,7 +165,7 @@ i915_is_format_supported(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format tex_supported[] = { - PIPE_FORMAT_R8G8B8A8_UNORM, + PIPE_FORMAT_R8G8B8A8_UNORM_REV, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_L8_UNORM, -- cgit v1.2.3 From a2bcdb7e509fde231846f3af09bef38ed1df4068 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:26:36 +0000 Subject: r300: Use PIPE_FORMAT_R8G8B8A8_UNORM_REV where appropriate. --- src/gallium/drivers/r300/r300_texture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 181711b3d2..5b674f6e57 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -324,7 +324,7 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_SRGB: case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_B8G8R8X8_SRGB: - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_R8G8B8A8_SRGB: case PIPE_FORMAT_R8G8B8X8_UNORM: @@ -457,7 +457,7 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) R300_C2_SEL_G | R300_C3_SEL_B; /* RGBA 32-bit outputs. */ - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_R8G8B8A8_UNORM_REV: case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_R8G8B8A8_SRGB: case PIPE_FORMAT_R8G8B8X8_UNORM: -- cgit v1.2.3 From 88e640fc14c3146966b6ba886d7f79874e745b35 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:28:38 +0000 Subject: xlib: Use PIPE_FORMAT_R8G8B8A8_UNORM(_REV) as appropriate. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 188b885f68..228e6d0a50 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -274,10 +274,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */; + return PIPE_FORMAT_R8G8B8A8_UNORM; } else { - return PIPE_FORMAT_R8G8B8A8_UNORM; + return PIPE_FORMAT_R8G8B8A8_UNORM_REV; } } else if ( GET_REDMASK(v) == 0xff0000 -- cgit v1.2.3 From ac8e1c18f2b75ff8a49efbc1aad3a5864f3cfcf0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 16:42:54 +0000 Subject: util: Fix PIPE_FORMAT_R8G8B8_SRGB swizzles. The only user of PIPE_FORMAT_R8G8B8_SRGB is mesa, which per src/mesa/main/texstore.c interprets it as R8 G8 B8 and not the other way around. --- src/gallium/auxiliary/util/u_format.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 9cb67a261e..e9ec377fb1 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -78,7 +78,7 @@ PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, r # SRGB formats PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb -PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , zyx1, srgb +PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb -- cgit v1.2.3 From 9a2c4f907b87e81173f50222c4bc325064609392 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 1 Mar 2010 17:57:18 +0100 Subject: tgsi: Cleanup exec code for CLAMP, CMP and CND. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 67 ++++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 68566d3093..f853ea2820 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -109,6 +109,42 @@ micro_ceil(union tgsi_exec_channel *dst, dst->f[3] = ceilf(src->f[3]); } +static void +micro_clamp(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) +{ + dst->f[0] = src0->f[0] < src1->f[0] ? src1->f[0] : src0->f[0] > src2->f[0] ? src2->f[0] : src0->f[0]; + dst->f[1] = src0->f[1] < src1->f[1] ? src1->f[1] : src0->f[1] > src2->f[1] ? src2->f[1] : src0->f[1]; + dst->f[2] = src0->f[2] < src1->f[2] ? src1->f[2] : src0->f[2] > src2->f[2] ? src2->f[2] : src0->f[2]; + dst->f[3] = src0->f[3] < src1->f[3] ? src1->f[3] : src0->f[3] > src2->f[3] ? src2->f[3] : src0->f[3]; +} + +static void +micro_cmp(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) +{ + dst->f[0] = src0->f[0] < 0.0f ? src1->f[0] : src2->f[0]; + dst->f[1] = src0->f[1] < 0.0f ? src1->f[1] : src2->f[1]; + dst->f[2] = src0->f[2] < 0.0f ? src1->f[2] : src2->f[2]; + dst->f[3] = src0->f[3] < 0.0f ? src1->f[3] : src2->f[3]; +} + +static void +micro_cnd(union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src0, + const union tgsi_exec_channel *src1, + const union tgsi_exec_channel *src2) +{ + dst->f[0] = src2->f[0] > 0.5f ? src0->f[0] : src1->f[0]; + dst->f[1] = src2->f[1] > 0.5f ? src0->f[1] : src1->f[1]; + dst->f[2] = src2->f[2] > 0.5f ? src0->f[2] : src1->f[2]; + dst->f[3] = src2->f[3] > 0.5f ? src0->f[3] : src1->f[3]; +} + static void micro_cos(union tgsi_exec_channel *dst, const union tgsi_exec_channel *src) @@ -2653,15 +2689,7 @@ exec_instruction( break; case TGSI_OPCODE_CND: - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - FETCH(&r[2], 2, chan_index); - micro_lt(&d[chan_index], &mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C], &r[2], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_trinary(mach, inst, micro_cnd, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_DP2A: @@ -2673,16 +2701,7 @@ exec_instruction( break; case TGSI_OPCODE_CLAMP: - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - micro_max(&r[0], &r[0], &r[1]); - FETCH(&r[1], 2, chan_index); - micro_min(&d[chan_index], &r[0], &r[1]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_trinary(mach, inst, micro_clamp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_FLR: @@ -3076,15 +3095,7 @@ exec_instruction( break; case TGSI_OPCODE_CMP: - FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH(&r[0], 0, chan_index); - FETCH(&r[1], 1, chan_index); - FETCH(&r[2], 2, chan_index); - micro_lt(&d[chan_index], &r[0], &mach->Temps[TEMP_0_I].xyzw[TEMP_0_C], &r[1], &r[2]); - } - FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) { - STORE(&d[chan_index], 0, chan_index); - } + exec_vector_trinary(mach, inst, micro_cmp, TGSI_EXEC_DATA_FLOAT, TGSI_EXEC_DATA_FLOAT); break; case TGSI_OPCODE_SCS: -- cgit v1.2.3 From ac4abaecd5f52e416c89bfe19b34ed7f4e014b21 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:40:22 +0100 Subject: util: adapt blitter code to new vertex element cso The interface of util_draw_vertex_buffer looks a bit odd (calling code has to set vertex elements but not vertex buffers) but due to the way cso state handling generally works (can't re-bind original vertex element state easily there) I guess that's ok for now. --- src/gallium/auxiliary/util/u_blit.c | 16 ++++++++++++++++ src/gallium/auxiliary/util/u_blitter.c | 23 ++++++++++++++++++++++- src/gallium/auxiliary/util/u_blitter.h | 8 ++++++++ src/gallium/auxiliary/util/u_draw_quad.c | 11 +---------- src/gallium/auxiliary/util/u_gen_mipmap.c | 13 +++++++++++++ 5 files changed, 60 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index f0bc58a558..0d93e23df8 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -62,6 +62,7 @@ struct blit_state struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; struct pipe_viewport_state viewport; + struct pipe_vertex_element velem[2]; void *vs; void *fs[TGSI_WRITEMASK_XYZW + 1]; @@ -115,6 +116,15 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) ctx->sampler.normalized_coords = 1; + /* vertex elements state */ + memset(&ctx->velem[0], 0, sizeof(ctx->velem[0]) * 2); + for (i = 0; i < 2; i++) { + ctx->velem[i].src_offset = i * 4 * sizeof(float); + ctx->velem[i].instance_divisor = 0; + ctx->velem[i].vertex_buffer_index = 0; + ctx->velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + /* vertex shader - still required to provide the linkage between * fragment shader input semantics and vertex_element/buffers. */ @@ -410,11 +420,13 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_vertex_elements(ctx->cso); /* set misc state we care about */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_vertex_elements(ctx->cso, 2, ctx->velem); /* sampler */ ctx->sampler.min_img_filter = filter; @@ -464,6 +476,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_vertex_elements(ctx->cso); pipe_texture_reference(&tex, NULL); } @@ -547,11 +560,13 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_vertex_elements(ctx->cso); /* set misc state we care about */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_vertex_elements(ctx->cso, 2, ctx->velem); /* sampler */ ctx->sampler.min_img_filter = filter; @@ -596,4 +611,5 @@ util_blit_pixels_tex(struct blit_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_vertex_elements(ctx->cso); } diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 18f8606818..3542a2e444 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -88,6 +88,8 @@ struct blitter_context_priv void *dsa_write_depth_keep_stencil; void *dsa_keep_depth_stencil; + void *velem_state; + /* Sampler state for clamping to a miplevel. */ void *sampler_state[PIPE_MAX_TEXTURE_LEVELS]; @@ -102,6 +104,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) struct pipe_depth_stencil_alpha_state dsa = { { 0 } }; struct pipe_rasterizer_state rs_state = { 0 }; struct pipe_sampler_state *sampler_state; + struct pipe_vertex_element velem[2]; unsigned i; ctx = CALLOC_STRUCT(blitter_context_priv); @@ -116,6 +119,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->blitter.saved_rs_state = INVALID_PTR; ctx->blitter.saved_fs = INVALID_PTR; ctx->blitter.saved_vs = INVALID_PTR; + ctx->blitter.saved_velem_state = INVALID_PTR; ctx->blitter.saved_fb_state.nr_cbufs = ~0; ctx->blitter.saved_num_textures = ~0; ctx->blitter.saved_num_sampler_states = ~0; @@ -165,6 +169,16 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) rs_state.flatshade = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); + /* vertex elements state */ + memset(&velem[0], 0, sizeof(velem[0]) * 2); + for (i = 0; i < 2; i++) { + velem[i].src_offset = i * 4 * sizeof(float); + velem[i].instance_divisor = 0; + velem[i].vertex_buffer_index = 0; + velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + ctx->velem_state = pipe->create_vertex_elements_state(pipe, 2, &velem[0]); + /* fragment shaders are created on-demand */ /* vertex shaders */ @@ -214,6 +228,7 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_rasterizer_state(pipe, ctx->rs_state); pipe->delete_vs_state(pipe, ctx->vs_col); pipe->delete_vs_state(pipe, ctx->vs_tex); + pipe->delete_vertex_elements_state(pipe, ctx->velem_state); for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { if (ctx->fs_texfetch_col[i]) @@ -241,7 +256,8 @@ static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx) ctx->blitter.saved_dsa_state != INVALID_PTR && ctx->blitter.saved_rs_state != INVALID_PTR && ctx->blitter.saved_fs != INVALID_PTR && - ctx->blitter.saved_vs != INVALID_PTR); + ctx->blitter.saved_vs != INVALID_PTR && + ctx->blitter.saved_velem_state != INVALID_PTR); } static void blitter_restore_CSOs(struct blitter_context_priv *ctx) @@ -254,12 +270,14 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx) pipe->bind_rasterizer_state(pipe, ctx->blitter.saved_rs_state); pipe->bind_fs_state(pipe, ctx->blitter.saved_fs); pipe->bind_vs_state(pipe, ctx->blitter.saved_vs); + pipe->bind_vertex_elements_state(pipe, ctx->blitter.saved_velem_state); ctx->blitter.saved_blend_state = INVALID_PTR; ctx->blitter.saved_dsa_state = INVALID_PTR; ctx->blitter.saved_rs_state = INVALID_PTR; ctx->blitter.saved_fs = INVALID_PTR; ctx->blitter.saved_vs = INVALID_PTR; + ctx->blitter.saved_velem_state = INVALID_PTR; pipe->set_stencil_ref(pipe, &ctx->blitter.saved_stencil_ref); @@ -546,6 +564,7 @@ void util_blitter_clear(struct blitter_context *blitter, pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->bind_rasterizer_state(pipe, ctx->rs_state); + pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, num_cbufs)); pipe->bind_vs_state(pipe, ctx->vs_col); @@ -611,6 +630,7 @@ static void util_blitter_do_copy(struct blitter_context *blitter, pipe->bind_vs_state(pipe, ctx->vs_tex); pipe->bind_fragment_sampler_states(pipe, 1, blitter_get_sampler_state(ctx, src->level)); + pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->set_fragment_sampler_textures(pipe, 1, &src->texture); pipe->set_framebuffer_state(pipe, &fb_state); @@ -784,6 +804,7 @@ void util_blitter_fill(struct blitter_context *blitter, pipe->bind_rasterizer_state(pipe, ctx->rs_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1)); pipe->bind_vs_state(pipe, ctx->vs_col); + pipe->bind_vertex_elements_state(pipe, ctx->velem_state); /* set a framebuffer state */ fb_state.width = dst->width; diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h index a2f17073ac..7d8a09edb5 100644 --- a/src/gallium/auxiliary/util/u_blitter.h +++ b/src/gallium/auxiliary/util/u_blitter.h @@ -43,6 +43,7 @@ struct blitter_context /* Private members, really. */ void *saved_blend_state; /**< blend state */ void *saved_dsa_state; /**< depth stencil alpha state */ + void *saved_velem_state; /**< vertex elements state */ void *saved_rs_state; /**< rasterizer state */ void *saved_fs, *saved_vs; /**< fragment shader, vertex shader */ @@ -170,6 +171,13 @@ void util_blitter_save_depth_stencil_alpha(struct blitter_context *blitter, blitter->saved_dsa_state = state; } +static INLINE +void util_blitter_save_vertex_elements(struct blitter_context *blitter, + void *state) +{ + blitter->saved_velem_state = state; +} + static INLINE void util_blitter_save_stencil_ref(struct blitter_context *blitter, const struct pipe_stencil_ref *state) diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c index 36e9a4941f..8c194102bf 100644 --- a/src/gallium/auxiliary/util/u_draw_quad.c +++ b/src/gallium/auxiliary/util/u_draw_quad.c @@ -45,8 +45,6 @@ util_draw_vertex_buffer(struct pipe_context *pipe, uint num_attribs) { struct pipe_vertex_buffer vbuffer; - struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS]; - uint i; assert(num_attribs <= PIPE_MAX_ATTRIBS); @@ -58,14 +56,7 @@ util_draw_vertex_buffer(struct pipe_context *pipe, vbuffer.max_index = num_verts - 1; pipe->set_vertex_buffers(pipe, 1, &vbuffer); - /* tell pipe about the vertex attributes */ - for (i = 0; i < num_attribs; i++) { - velements[i].src_offset = i * 4 * sizeof(float); - velements[i].instance_divisor = 0; - velements[i].vertex_buffer_index = 0; - velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - } - pipe->set_vertex_elements(pipe, num_attribs, velements); + /* note: vertex elements already set by caller */ /* draw */ pipe->draw_arrays(pipe, prim_type, 0, num_verts); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 4e358d3938..db726df9c3 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -61,6 +61,7 @@ struct gen_mipmap_state struct pipe_depth_stencil_alpha_state depthstencil; struct pipe_rasterizer_state rasterizer; struct pipe_sampler_state sampler; + struct pipe_vertex_element velem[2]; void *vs; void *fs2d, *fsCube; @@ -1307,6 +1308,15 @@ util_create_gen_mipmap(struct pipe_context *pipe, ctx->sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; ctx->sampler.normalized_coords = 1; + /* vertex elements state */ + memset(&ctx->velem[0], 0, sizeof(ctx->velem[0]) * 2); + for (i = 0; i < 2; i++) { + ctx->velem[i].src_offset = i * 4 * sizeof(float); + ctx->velem[i].instance_divisor = 0; + ctx->velem[i].vertex_buffer_index = 0; + ctx->velem[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + /* vertex shader - still needed to specify mapping from fragment * shader input semantics to vertex elements */ @@ -1499,11 +1509,13 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_save_framebuffer(ctx->cso); cso_save_fragment_shader(ctx->cso); cso_save_vertex_shader(ctx->cso); + cso_save_vertex_elements(ctx->cso); /* bind our state */ cso_set_blend(ctx->cso, &ctx->blend); cso_set_depth_stencil_alpha(ctx->cso, &ctx->depthstencil); cso_set_rasterizer(ctx->cso, &ctx->rasterizer); + cso_set_vertex_elements(ctx->cso, 2, ctx->velem); cso_set_fragment_shader_handle(ctx->cso, fs); cso_set_vertex_shader_handle(ctx->cso, ctx->vs); @@ -1578,4 +1590,5 @@ util_gen_mipmap(struct gen_mipmap_state *ctx, cso_restore_framebuffer(ctx->cso); cso_restore_fragment_shader(ctx->cso); cso_restore_vertex_shader(ctx->cso); + cso_restore_vertex_elements(ctx->cso); } -- cgit v1.2.3 From 49d3f662b60be08328e7c1dc381d07f50c384601 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:41:03 +0100 Subject: vl: adapt to new vertex element cso interface --- src/gallium/auxiliary/vl/vl_compositor.c | 29 +++--- src/gallium/auxiliary/vl/vl_compositor.h | 2 +- src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 118 ++++++++++++----------- src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h | 4 +- 4 files changed, 82 insertions(+), 71 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c index 5d61423f9d..6d461cb880 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.c +++ b/src/gallium/auxiliary/vl/vl_compositor.c @@ -230,6 +230,7 @@ static bool init_pipe_state(struct vl_compositor *c) { struct pipe_sampler_state sampler; + struct pipe_vertex_element vertex_elems[2]; assert(c); @@ -251,15 +252,27 @@ init_pipe_state(struct vl_compositor *c) /*sampler.border_color[i] = ;*/ /*sampler.max_anisotropy = ;*/ c->sampler = c->pipe->create_sampler_state(c->pipe, &sampler); - + + vertex_elems[0].src_offset = 0; + vertex_elems[0].instance_divisor = 0; + vertex_elems[0].vertex_buffer_index = 0; + vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; + vertex_elems[1].src_offset = 0; + vertex_elems[1].instance_divisor = 0; + vertex_elems[1].vertex_buffer_index = 1; + vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; + c->vertex_elems = c->pipe->create_vertex_elements_state(c->pipe, 2, vertex_elems); + + return true; } static void cleanup_pipe_state(struct vl_compositor *c) { assert(c); - + c->pipe->delete_sampler_state(c->pipe, c->sampler); + c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems); } static bool @@ -314,11 +327,6 @@ init_buffers(struct vl_compositor *c) pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[0].buffer); - c->vertex_elems[0].src_offset = 0; - c->vertex_elems[0].instance_divisor = 0; - c->vertex_elems[0].vertex_buffer_index = 0; - c->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; - /* * Create our texcoord buffer and texcoord buffer element * Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices @@ -343,11 +351,6 @@ init_buffers(struct vl_compositor *c) pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[1].buffer); - c->vertex_elems[1].src_offset = 0; - c->vertex_elems[1].instance_divisor = 0; - c->vertex_elems[1].vertex_buffer_index = 1; - c->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; - /* * Create our vertex shader's constant buffer * Const buffer contains scaling and translation vectors @@ -481,7 +484,7 @@ void vl_compositor_render(struct vl_compositor *compositor, compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader); compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader); compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs); - compositor->pipe->set_vertex_elements(compositor->pipe, 2, compositor->vertex_elems); + compositor->pipe->bind_vertex_elements_state(compositor->pipe, compositor->vertex_elems); compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, compositor->vs_const_buf); compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf); diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h index 6a9a3fd7af..51755554da 100644 --- a/src/gallium/auxiliary/vl/vl_compositor.h +++ b/src/gallium/auxiliary/vl/vl_compositor.h @@ -43,10 +43,10 @@ struct vl_compositor void *sampler; void *vertex_shader; void *fragment_shader; + void *vertex_elems; struct pipe_viewport_state viewport; struct pipe_scissor_state scissor; struct pipe_vertex_buffer vertex_bufs[2]; - struct pipe_vertex_element vertex_elems[2]; struct pipe_buffer *vs_const_buf, *fs_const_buf; }; diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 6b9ecd4268..0763b5bb0e 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -708,6 +708,7 @@ static bool init_pipe_state(struct vl_mpeg12_mc_renderer *r) { struct pipe_sampler_state sampler; + struct pipe_vertex_element vertex_elems[8]; unsigned filters[5]; unsigned i; @@ -771,6 +772,59 @@ init_pipe_state(struct vl_mpeg12_mc_renderer *r) r->samplers.all[i] = r->pipe->create_sampler_state(r->pipe, &sampler); } + /* Position element */ + vertex_elems[0].src_offset = 0; + vertex_elems[0].instance_divisor = 0; + vertex_elems[0].vertex_buffer_index = 0; + vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* Luma, texcoord element */ + vertex_elems[1].src_offset = sizeof(struct vertex2f); + vertex_elems[1].instance_divisor = 0; + vertex_elems[1].vertex_buffer_index = 0; + vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* Chroma Cr texcoord element */ + vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2; + vertex_elems[2].instance_divisor = 0; + vertex_elems[2].vertex_buffer_index = 0; + vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* Chroma Cb texcoord element */ + vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3; + vertex_elems[3].instance_divisor = 0; + vertex_elems[3].vertex_buffer_index = 0; + vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* First ref surface top field texcoord element */ + vertex_elems[4].src_offset = 0; + vertex_elems[4].instance_divisor = 0; + vertex_elems[4].vertex_buffer_index = 1; + vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* First ref surface bottom field texcoord element */ + vertex_elems[5].src_offset = sizeof(struct vertex2f); + vertex_elems[5].instance_divisor = 0; + vertex_elems[5].vertex_buffer_index = 1; + vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* Second ref surface top field texcoord element */ + vertex_elems[6].src_offset = 0; + vertex_elems[6].instance_divisor = 0; + vertex_elems[6].vertex_buffer_index = 2; + vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* Second ref surface bottom field texcoord element */ + vertex_elems[7].src_offset = sizeof(struct vertex2f); + vertex_elems[7].instance_divisor = 0; + vertex_elems[7].vertex_buffer_index = 2; + vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT; + + /* need versions with 4,6 and 8 vertex elems */ + r->vertex_elems[0] = r->pipe->create_vertex_elements_state(r->pipe, 4, vertex_elems); + r->vertex_elems[1] = r->pipe->create_vertex_elements_state(r->pipe, 6, vertex_elems); + r->vertex_elems[2] = r->pipe->create_vertex_elements_state(r->pipe, 8, vertex_elems); + return true; } @@ -783,6 +837,8 @@ cleanup_pipe_state(struct vl_mpeg12_mc_renderer *r) for (i = 0; i < 5; ++i) r->pipe->delete_sampler_state(r->pipe, r->samplers.all[i]); + for (i = 0; i < 3; i++) + r->pipe->delete_vertex_elements_state(r->pipe, r->vertex_elems[i]); } static bool @@ -888,54 +944,6 @@ init_buffers(struct vl_mpeg12_mc_renderer *r) ); } - /* Position element */ - r->vertex_elems[0].src_offset = 0; - r->vertex_elems[0].instance_divisor = 0; - r->vertex_elems[0].vertex_buffer_index = 0; - r->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* Luma, texcoord element */ - r->vertex_elems[1].src_offset = sizeof(struct vertex2f); - r->vertex_elems[1].instance_divisor = 0; - r->vertex_elems[1].vertex_buffer_index = 0; - r->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* Chroma Cr texcoord element */ - r->vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2; - r->vertex_elems[2].instance_divisor = 0; - r->vertex_elems[2].vertex_buffer_index = 0; - r->vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* Chroma Cb texcoord element */ - r->vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3; - r->vertex_elems[3].instance_divisor = 0; - r->vertex_elems[3].vertex_buffer_index = 0; - r->vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* First ref surface top field texcoord element */ - r->vertex_elems[4].src_offset = 0; - r->vertex_elems[4].instance_divisor = 0; - r->vertex_elems[4].vertex_buffer_index = 1; - r->vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* First ref surface bottom field texcoord element */ - r->vertex_elems[5].src_offset = sizeof(struct vertex2f); - r->vertex_elems[5].instance_divisor = 0; - r->vertex_elems[5].vertex_buffer_index = 1; - r->vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* Second ref surface top field texcoord element */ - r->vertex_elems[6].src_offset = 0; - r->vertex_elems[6].instance_divisor = 0; - r->vertex_elems[6].vertex_buffer_index = 2; - r->vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT; - - /* Second ref surface bottom field texcoord element */ - r->vertex_elems[7].src_offset = sizeof(struct vertex2f); - r->vertex_elems[7].instance_divisor = 0; - r->vertex_elems[7].vertex_buffer_index = 2; - r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT; - r->vs_const_buf = pipe_buffer_create ( r->pipe->screen, @@ -1299,7 +1307,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) { r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 4, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[0]); r->pipe->set_fragment_sampler_textures(r->pipe, 3, r->textures.all); r->pipe->bind_fragment_sampler_states(r->pipe, 3, r->samplers.all); r->pipe->bind_vs_state(r->pipe, r->i_vs); @@ -1312,7 +1320,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] > 0) { r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]); r->textures.individual.ref[0] = r->past; r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all); r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all); @@ -1326,7 +1334,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (false /*num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] > 0 */ ) { r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]); r->textures.individual.ref[0] = r->past; r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all); r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all); @@ -1340,7 +1348,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] > 0) { r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]); r->textures.individual.ref[0] = r->future; r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all); r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all); @@ -1354,7 +1362,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (false /*num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] > 0 */ ) { r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 6, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]); r->textures.individual.ref[0] = r->future; r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all); r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all); @@ -1368,7 +1376,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] > 0) { r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]); r->textures.individual.ref[0] = r->past; r->textures.individual.ref[1] = r->future; r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all); @@ -1383,7 +1391,7 @@ flush(struct vl_mpeg12_mc_renderer *r) if (false /*num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] > 0 */ ) { r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all); - r->pipe->set_vertex_elements(r->pipe, 8, r->vertex_elems); + r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]); r->textures.individual.ref[0] = r->past; r->textures.individual.ref[1] = r->future; r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h index f00b8c7b8b..a11a3e7307 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h @@ -66,8 +66,8 @@ struct vl_mpeg12_mc_renderer struct pipe_buffer *vs_const_buf; struct pipe_buffer *fs_const_buf; struct pipe_framebuffer_state fb_state; - struct pipe_vertex_element vertex_elems[8]; - + void *vertex_elems[3]; + union { void *all[5]; -- cgit v1.2.3 From 8397c80646364eb20d7e83304b55e6f3ee353b49 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:42:47 +0100 Subject: gallium/docs: document new vertex element cso interface --- src/gallium/docs/source/context.rst | 2 +- src/gallium/docs/source/cso/velems.rst | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/gallium/docs/source/cso/velems.rst (limited to 'src/gallium') diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 9080addba4..4608e97adb 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -24,6 +24,7 @@ CSO objects handled by the context object: * :ref:`Depth, Stencil, & Alpha`: ``*_depth_stencil_alpha_state`` * :ref:`Shader`: These have two sets of methods. ``*_fs_state`` is for fragment shaders, and ``*_vs_state`` is for vertex shaders. +* :ref:`Vertex Elements`: ``*_vertex_elements_state`` Resource Binding State @@ -60,7 +61,6 @@ objects. They all follow simple, one-method binding calls, e.g. not have the scissor test enabled, then the scissor bounds never need to be set since they will not be used. * ``set_viewport_state`` -* ``set_vertex_elements`` Clearing diff --git a/src/gallium/docs/source/cso/velems.rst b/src/gallium/docs/source/cso/velems.rst new file mode 100644 index 0000000000..8e758fae10 --- /dev/null +++ b/src/gallium/docs/source/cso/velems.rst @@ -0,0 +1,24 @@ +.. _vertex,elements + +Vertex Elements +=============== + +This state controls format etc. of the input attributes contained +in the pipe_vertex_buffer(s). There's one pipe_vertex_element array member +for each input attribute. + +Members +------- + +src_offset + The byte offset of the attribute in the buffer given by + vertex_buffer_index for the first vertex. +instance_divisor + The instance data rate divisor, used for instancing. + 0 means this is per-vertex data, n means per-instance data used for + n consecutive instances (n > 0). +vertex_buffer_index + The vertex buffer this attribute lives in. Several attributes may + live in the same vertex buffer. +src_format + The format of the attribute data. One of the PIPE_FORMAT tokens. -- cgit v1.2.3 From 711476be2904bd16d45b424236d6aefa9a9e6bc9 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:43:58 +0100 Subject: xorg: adapt to new vertex element cso --- src/gallium/state_trackers/xorg/xorg_renderer.c | 13 +++++++++++++ src/gallium/state_trackers/xorg/xorg_renderer.h | 1 + 2 files changed, 14 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 83b0d31e38..1eb926360b 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -68,6 +68,8 @@ renderer_draw(struct xorg_renderer *r) if (buf) { + cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems); + util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, num_verts, /* verts */ @@ -92,6 +94,7 @@ renderer_init_state(struct xorg_renderer *r) { struct pipe_depth_stencil_alpha_state dsa; struct pipe_rasterizer_state raster; + unsigned i; /* set common initial clip state */ memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); @@ -103,6 +106,14 @@ renderer_init_state(struct xorg_renderer *r) raster.gl_rasterization_rules = 1; cso_set_rasterizer(r->cso, &raster); + /* vertex elements state */ + memset(&r->velems[0], 0, sizeof(r->velems[0]) * 3); + for (i = 0; i < 3; i++) { + r->velems[i].src_offset = i * 4 * sizeof(float); + r->velems[i].instance_divisor = 0; + r->velems[i].vertex_buffer_index = 0; + r->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } } @@ -600,6 +611,8 @@ void renderer_draw_yuv(struct xorg_renderer *r, if (buf) { const int num_attribs = 2; /*pos + tex coord*/ + cso_set_vertex_elements(r->cso, num_attribs, r->velems); + util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_QUADS, 4, /* verts */ diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h index af6aa0567d..3d00628719 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.h +++ b/src/gallium/state_trackers/xorg/xorg_renderer.h @@ -28,6 +28,7 @@ struct xorg_renderer { float buffer[BUF_SIZE]; int buffer_size; + struct pipe_vertex_element velems[3]; /* number of attributes per vertex for the current * draw operation */ -- cgit v1.2.3 From 1f57069c68f7bf812d4d2e054c5ced3ed72cfa10 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:45:25 +0100 Subject: vega: adapt to new vertex element cso --- src/gallium/state_trackers/vega/api_masks.c | 2 ++ src/gallium/state_trackers/vega/polygon.c | 3 ++- src/gallium/state_trackers/vega/renderer.c | 5 +++++ src/gallium/state_trackers/vega/vg_context.c | 8 ++++++++ src/gallium/state_trackers/vega/vg_context.h | 1 + 5 files changed, 18 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c index 9c123a4cf9..7eb5ea1f07 100644 --- a/src/gallium/state_trackers/vega/api_masks.c +++ b/src/gallium/state_trackers/vega/api_masks.c @@ -86,6 +86,8 @@ draw_clear_quad(struct vg_context *st, /* draw */ if (buf) { + cso_set_vertex_elements(st->cso_context, 2, st->velems); + util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c index 96fbbfc85a..eef2c1eb87 100644 --- a/src/gallium/state_trackers/vega/polygon.c +++ b/src/gallium/state_trackers/vega/polygon.c @@ -292,11 +292,12 @@ static void draw_polygon(struct vg_context *ctx, pipe->set_vertex_buffers(pipe, 1, &vbuffer); /* tell pipe about the vertex attributes */ + memset(&velement, 0, sizeof(velement)); velement.src_offset = 0; velement.instance_divisor = 0; velement.vertex_buffer_index = 0; velement.src_format = PIPE_FORMAT_R32G32_FLOAT; - pipe->set_vertex_elements(pipe, 1, &velement); + cso_set_vertex_elements(ctx->cso_context, 1, &velement); /* draw */ pipe->draw_arrays(pipe, PIPE_PRIM_TRIANGLE_FAN, diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index 05620efa9c..47e8b470a1 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -210,6 +210,7 @@ void renderer_draw_quad(struct renderer *r, buf = setup_vertex_data(r, x1, y1, x2, y2, depth); if (buf) { + cso_set_vertex_elements(r->cso, 2, r->owner->velems); util_draw_vertex_buffer(r->pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ @@ -248,6 +249,7 @@ void renderer_draw_texture(struct renderer *r, s0, t0, s1, t1, 0.0f); if (buf) { + cso_set_vertex_elements(r->cso, 2, r->owner->velems); util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ @@ -370,6 +372,7 @@ void renderer_copy_texture(struct renderer *ctx, 0.0f); if (buf) { + cso_set_vertex_elements(ctx->cso, 2, ctx->owner->velems); util_draw_vertex_buffer(ctx->pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ @@ -535,6 +538,7 @@ void renderer_copy_surface(struct renderer *ctx, (float) dstX1, (float) dstY1, z); if (buf) { + cso_set_vertex_elements(ctx->cso, 2, ctx->owner->velems); util_draw_vertex_buffer(ctx->pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ @@ -587,6 +591,7 @@ void renderer_texture_quad(struct renderer *r, s0, t0, s1, t1, 0.0f); if (buf) { + cso_set_vertex_elements(r->cso, 2, r->owner->velems); util_draw_vertex_buffer(pipe, buf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, /* verts */ diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c index 426bf9bc62..170391ec03 100644 --- a/src/gallium/state_trackers/vega/vg_context.c +++ b/src/gallium/state_trackers/vega/vg_context.c @@ -72,6 +72,7 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, struct vg_context *share) { struct vg_context *ctx; + unsigned i; ctx = CALLOC_STRUCT(vg_context); @@ -103,6 +104,13 @@ struct vg_context * vg_create_context(struct pipe_context *pipe, ctx->blend_sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST; ctx->blend_sampler.normalized_coords = 0; + for (i = 0; i < 2; i++) { + ctx->velems[i].src_offset = i * 4 * sizeof(float); + ctx->velems[i].instance_divisor = 0; + ctx->velems[i].vertex_buffer_index = 0; + ctx->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + vg_set_error(ctx, VG_NO_ERROR); ctx->owned_objects[VG_OBJECT_PAINT] = cso_hash_create(); diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h index bc88c8d139..804e9e76d7 100644 --- a/src/gallium/state_trackers/vega/vg_context.h +++ b/src/gallium/state_trackers/vega/vg_context.h @@ -146,6 +146,7 @@ struct vg_context struct vg_shader *clear_vs; struct vg_shader *texture_vs; struct pipe_buffer *vs_const_buffer; + struct pipe_vertex_element velems[2]; }; struct vg_object { -- cgit v1.2.3 From 9abef5ebfa6be3f8d39fbc8b92293c2c0c81ce46 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:45:46 +0100 Subject: vega: adapt to new vertex element cso --- src/gallium/state_trackers/python/p_context.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i index 3f36ccb621..5c44462e80 100644 --- a/src/gallium/state_trackers/python/p_context.i +++ b/src/gallium/state_trackers/python/p_context.i @@ -51,7 +51,7 @@ struct st_context { void set_blend( const struct pipe_blend_state *state ) { cso_set_blend($self->cso, state); } - + void set_fragment_sampler( unsigned index, const struct pipe_sampler_state *state ) { cso_single_sampler($self->cso, index, state); cso_single_sampler_done($self->cso); @@ -222,9 +222,9 @@ struct st_context { void set_vertex_elements(unsigned num) { $self->num_vertex_elements = num; - $self->pipe->set_vertex_elements($self->pipe, - $self->num_vertex_elements, - $self->vertex_elements); + cso_set_vertex_elements($self->cso, + $self->num_vertex_elements, + $self->vertex_elements); } /* -- cgit v1.2.3 From 618e7e0c88400dc853b0ff4792a0c70800587073 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:45:57 +0100 Subject: trace: adapt to new vertex element cso --- src/gallium/drivers/trace/tr_context.c | 91 +++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index df40fbade6..133521f45e 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -773,6 +773,70 @@ trace_context_delete_vs_state(struct pipe_context *_pipe, } +static INLINE void * +trace_context_create_vertex_elements_state(struct pipe_context *_pipe, + unsigned num_elements, + const struct pipe_vertex_element *elements) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + void * result; + + trace_dump_call_begin("pipe_context", "create_vertex_elements_state"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(uint, num_elements); + + trace_dump_arg_begin("elements"); + trace_dump_struct_array(vertex_element, elements, num_elements); + trace_dump_arg_end(); + + result = pipe->create_vertex_elements_state(pipe, num_elements, elements); + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + return result; +} + + +static INLINE void +trace_context_bind_vertex_elements_state(struct pipe_context *_pipe, + void *state) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + trace_dump_call_begin("pipe_context", "bind_vertex_elements_state"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, state); + + pipe->bind_vertex_elements_state(pipe, state); + + trace_dump_call_end(); +} + + +static INLINE void +trace_context_delete_vertex_elements_state(struct pipe_context *_pipe, + void *state) +{ + struct trace_context *tr_ctx = trace_context(_pipe); + struct pipe_context *pipe = tr_ctx->pipe; + + trace_dump_call_begin("pipe_context", "delete_verte_elements_state"); + + trace_dump_arg(ptr, pipe); + trace_dump_arg(ptr, state); + + pipe->delete_vertex_elements_state(pipe, state); + + trace_dump_call_end(); +} + + static INLINE void trace_context_set_blend_color(struct pipe_context *_pipe, const struct pipe_blend_color *state) @@ -1047,29 +1111,6 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe, } -static INLINE void -trace_context_set_vertex_elements(struct pipe_context *_pipe, - unsigned num_elements, - const struct pipe_vertex_element *elements) -{ - struct trace_context *tr_ctx = trace_context(_pipe); - struct pipe_context *pipe = tr_ctx->pipe; - - trace_dump_call_begin("pipe_context", "set_vertex_elements"); - - trace_dump_arg(ptr, pipe); - trace_dump_arg(uint, num_elements); - - 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(); -} - - static INLINE void trace_context_surface_copy(struct pipe_context *_pipe, struct pipe_surface *dest, @@ -1303,6 +1344,9 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.create_vs_state = trace_context_create_vs_state; tr_ctx->base.bind_vs_state = trace_context_bind_vs_state; tr_ctx->base.delete_vs_state = trace_context_delete_vs_state; + tr_ctx->base.create_vertex_elements_state = trace_context_create_vertex_elements_state; + tr_ctx->base.bind_vertex_elements_state = trace_context_bind_vertex_elements_state; + tr_ctx->base.delete_vertex_elements_state = trace_context_delete_vertex_elements_state; tr_ctx->base.set_blend_color = trace_context_set_blend_color; tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref; tr_ctx->base.set_clip_state = trace_context_set_clip_state; @@ -1314,7 +1358,6 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.set_fragment_sampler_textures = trace_context_set_fragment_sampler_textures; tr_ctx->base.set_vertex_sampler_textures = trace_context_set_vertex_sampler_textures; tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers; - tr_ctx->base.set_vertex_elements = trace_context_set_vertex_elements; if (pipe->surface_copy) tr_ctx->base.surface_copy = trace_context_surface_copy; if (pipe->surface_fill) -- cgit v1.2.3 From b1676a953eb61838e9ef03532792bc723f4d4ada Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:46:12 +0100 Subject: svga: adapt to new vertex element cso --- src/gallium/drivers/svga/svga_context.h | 8 +++-- src/gallium/drivers/svga/svga_pipe_vertex.c | 38 ++++++++++++++++++------ src/gallium/drivers/svga/svga_state_need_swtnl.c | 4 +-- src/gallium/drivers/svga/svga_state_vdecl.c | 8 ++--- src/gallium/drivers/svga/svga_state_vs.c | 4 +-- src/gallium/drivers/svga/svga_swtnl_state.c | 4 +-- 6 files changed, 45 insertions(+), 21 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 03302e2a6e..4d9f00991a 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -169,6 +169,11 @@ struct svga_sampler_state { unsigned view_max_lod; }; +struct svga_velems_state { + unsigned count; + struct pipe_vertex_element velem[]; +}; + /* Use to calculate differences between state emitted to hardware and * current driver-calculated state. */ @@ -178,13 +183,13 @@ struct svga_state const struct svga_depth_stencil_state *depth; const struct svga_rasterizer_state *rast; const struct svga_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct svga_velems_state *velems; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; /* or texture ID's? */ struct svga_fragment_shader *fs; struct svga_vertex_shader *vs; struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS]; struct pipe_buffer *cb[PIPE_SHADER_TYPES]; struct pipe_framebuffer_state framebuffer; @@ -204,7 +209,6 @@ struct svga_state unsigned num_samplers; unsigned num_textures; - unsigned num_vertex_elements; unsigned num_vertex_buffers; unsigned reduced_prim; diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index ffc0f99565..979deb12af 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -26,6 +26,7 @@ #include "util/u_inlines.h" #include "pipe/p_defines.h" #include "util/u_math.h" +#include "util/u_memory.h" #include "tgsi/tgsi_parse.h" #include "svga_screen.h" @@ -64,20 +65,37 @@ static void svga_set_vertex_buffers(struct pipe_context *pipe, svga->dirty |= SVGA_NEW_VBUFFER; } -static void svga_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *elements) + +static void * +svga_create_vertex_elements_state(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) { - struct svga_context *svga = svga_context(pipe); - unsigned i; + struct svga_velems_state *velems; + assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct svga_velems_state *) MALLOC(sizeof(struct svga_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} - for (i = 0; i < count; i++) - svga->curr.ve[i] = elements[i]; +static void svga_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) +{ + struct svga_context *svga = svga_context(pipe); + struct svga_velems_state *svga_velems = (struct svga_velems_state *) velems; - svga->curr.num_vertex_elements = count; + svga->curr.velems = svga_velems; svga->dirty |= SVGA_NEW_VELEMENT; } +static void svga_delete_vertex_elements_state(struct pipe_context *pipe, + void *velems) +{ + FREE(velems); +} void svga_cleanup_vertex_state( struct svga_context *svga ) { @@ -91,7 +109,9 @@ void svga_cleanup_vertex_state( struct svga_context *svga ) void svga_init_vertex_functions( struct svga_context *svga ) { svga->pipe.set_vertex_buffers = svga_set_vertex_buffers; - svga->pipe.set_vertex_elements = svga_set_vertex_elements; + svga->pipe.create_vertex_elements_state = svga_create_vertex_elements_state; + svga->pipe.bind_vertex_elements_state = svga_bind_vertex_elements_state; + svga->pipe.delete_vertex_elements_state = svga_delete_vertex_elements_state; } diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index dd13a89d24..94fe0bc968 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -76,8 +76,8 @@ static int update_need_swvfetch( struct svga_context *svga, unsigned i; boolean need_swvfetch = FALSE; - for (i = 0; i < svga->curr.num_vertex_elements; i++) { - svga->state.sw.ve_format[i] = svga_translate_vertex_format(svga->curr.ve[i].src_format); + for (i = 0; i < svga->curr.velems->count; i++) { + svga->state.sw.ve_format[i] = svga_translate_vertex_format(svga->curr.velems->velem[i].src_format); if (svga->state.sw.ve_format[i] == SVGA3D_DECLTYPE_MAX) { need_swvfetch = TRUE; break; diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c index d1066ce13b..91854f6530 100644 --- a/src/gallium/drivers/svga/svga_state_vdecl.c +++ b/src/gallium/drivers/svga/svga_state_vdecl.c @@ -98,17 +98,17 @@ upload_user_buffers( struct svga_context *svga ) static int emit_hw_vs_vdecl( struct svga_context *svga, unsigned dirty ) { - const struct pipe_vertex_element *ve = svga->curr.ve; + const struct pipe_vertex_element *ve = svga->curr.velems->velem; SVGA3dVertexDecl decl; unsigned i; - assert(svga->curr.num_vertex_elements >= + assert(svga->curr.velems->count >= svga->curr.vs->base.info.file_count[TGSI_FILE_INPUT]); svga_hwtnl_reset_vdecl( svga->hwtnl, - svga->curr.num_vertex_elements ); + svga->curr.velems->count ); - for (i = 0; i < svga->curr.num_vertex_elements; i++) { + for (i = 0; i < svga->curr.velems->count; i++) { const struct pipe_vertex_buffer *vb = &svga->curr.vb[ve[i].vertex_buffer_index]; unsigned usage, index; diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c index d7999fe53d..781f7bf533 100644 --- a/src/gallium/drivers/svga/svga_state_vs.c +++ b/src/gallium/drivers/svga/svga_state_vs.c @@ -186,8 +186,8 @@ static int update_zero_stride( struct svga_context *svga, svga->curr.zero_stride_vertex_elements = 0; svga->curr.num_zero_stride_vertex_elements = 0; - for (i = 0; i < svga->curr.num_vertex_elements; i++) { - const struct pipe_vertex_element *vel = &svga->curr.ve[i]; + for (i = 0; i < svga->curr.velems->count; i++) { + const struct pipe_vertex_element *vel = &svga->curr.velems->velem[i]; const struct pipe_vertex_buffer *vbuffer = &svga->curr.vb[ vel->vertex_buffer_index]; if (vbuffer->stride == 0) { diff --git a/src/gallium/drivers/svga/svga_swtnl_state.c b/src/gallium/drivers/svga/svga_swtnl_state.c index 35f36a828f..246d34e649 100644 --- a/src/gallium/drivers/svga/svga_swtnl_state.c +++ b/src/gallium/drivers/svga/svga_swtnl_state.c @@ -99,8 +99,8 @@ static int update_swtnl_draw( struct svga_context *svga, if (dirty & SVGA_NEW_VELEMENT) draw_set_vertex_elements(svga->swtnl.draw, - svga->curr.num_vertex_elements, - svga->curr.ve ); + svga->curr.velems->count, + svga->curr.velems->velem ); if (dirty & SVGA_NEW_CLIP) draw_set_clip_state(svga->swtnl.draw, -- cgit v1.2.3 From 057427dd3ea9da6f907b39391f6bd1b093fb128e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:46:29 +0100 Subject: softpipe: adapt to new vertex element cso --- src/gallium/drivers/softpipe/sp_context.c | 5 +++- src/gallium/drivers/softpipe/sp_context.h | 4 +-- src/gallium/drivers/softpipe/sp_state.h | 17 +++++++++---- src/gallium/drivers/softpipe/sp_state_vertex.c | 35 +++++++++++++++++++------- 4 files changed, 44 insertions(+), 17 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index ddc35bcd62..e8f2318e48 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -245,6 +245,10 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.bind_gs_state = softpipe_bind_gs_state; softpipe->pipe.delete_gs_state = softpipe_delete_gs_state; + softpipe->pipe.create_vertex_elements_state = softpipe_create_vertex_elements_state; + softpipe->pipe.bind_vertex_elements_state = softpipe_bind_vertex_elements_state; + softpipe->pipe.delete_vertex_elements_state = softpipe_delete_vertex_elements_state; + softpipe->pipe.set_blend_color = softpipe_set_blend_color; softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref; softpipe->pipe.set_clip_state = softpipe_set_clip_state; @@ -257,7 +261,6 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.set_viewport_state = softpipe_set_viewport_state; softpipe->pipe.set_vertex_buffers = softpipe_set_vertex_buffers; - softpipe->pipe.set_vertex_elements = softpipe_set_vertex_elements; softpipe->pipe.draw_arrays = softpipe_draw_arrays; softpipe->pipe.draw_elements = softpipe_draw_elements; diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 95def72c54..396d46d4ba 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -45,6 +45,7 @@ struct softpipe_tile_cache; struct softpipe_tex_tile_cache; struct sp_fragment_shader; struct sp_vertex_shader; +struct sp_velems_state; struct softpipe_context { @@ -59,6 +60,7 @@ struct softpipe_context { struct sp_fragment_shader *fs; struct sp_vertex_shader *vs; struct sp_geometry_shader *gs; + struct sp_velems_state *velems; /** Other rendering state */ struct pipe_blend_color blend_color; @@ -72,13 +74,11 @@ struct softpipe_context { struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned num_samplers; unsigned num_textures; unsigned num_vertex_samplers; unsigned num_vertex_textures; - unsigned num_vertex_elements; unsigned num_vertex_buffers; unsigned dirty; /**< Mask of SP_NEW_x flags */ diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index 4370bbeaee..a6b9a841fe 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -100,6 +100,11 @@ struct sp_geometry_shader { struct draw_geometry_shader *draw_data; }; +struct sp_velems_state { + unsigned count; + struct pipe_vertex_element velem[]; +}; + void * softpipe_create_blend_state(struct pipe_context *, @@ -160,8 +165,14 @@ void *softpipe_create_gs_state(struct pipe_context *, void softpipe_bind_gs_state(struct pipe_context *, void *); void softpipe_delete_gs_state(struct pipe_context *, void *); +void *softpipe_create_vertex_elements_state(struct pipe_context *, + unsigned count, + const struct pipe_vertex_element *); +void softpipe_bind_vertex_elements_state(struct pipe_context *, void *); +void softpipe_delete_vertex_elements_state(struct pipe_context *, void *); + void softpipe_set_polygon_stipple( struct pipe_context *, - const struct pipe_poly_stipple * ); + const struct pipe_poly_stipple * ); void softpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); @@ -178,10 +189,6 @@ softpipe_set_vertex_sampler_textures(struct pipe_context *, void softpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); -void softpipe_set_vertex_elements(struct pipe_context *, - unsigned count, - const struct pipe_vertex_element *); - void softpipe_set_vertex_buffers(struct pipe_context *, unsigned count, const struct pipe_vertex_buffer *); diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index b491d92ed1..e7dc3d002b 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -32,27 +32,44 @@ #include "sp_context.h" #include "sp_state.h" +#include "util/u_memory.h" #include "draw/draw_context.h" +void * +softpipe_create_vertex_elements_state(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) +{ + struct sp_velems_state *velems; + assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct sp_velems_state *) MALLOC(sizeof(struct sp_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} + void -softpipe_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *attribs) +softpipe_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) { struct softpipe_context *softpipe = softpipe_context(pipe); + struct sp_velems_state *sp_velems = (struct sp_velems_state *) velems; - assert(count <= PIPE_MAX_ATTRIBS); - - memcpy(softpipe->vertex_element, attribs, - count * sizeof(struct pipe_vertex_element)); - softpipe->num_vertex_elements = count; + softpipe->velems = sp_velems; softpipe->dirty |= SP_NEW_VERTEX; - draw_set_vertex_elements(softpipe->draw, count, attribs); + draw_set_vertex_elements(softpipe->draw, sp_velems->count, sp_velems->velem); } +void +softpipe_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); +} void softpipe_set_vertex_buffers(struct pipe_context *pipe, -- cgit v1.2.3 From f89730385532056e89e3b9053c244a67f84e323e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:46:39 +0100 Subject: llvmpipe: adapt to new vertex element cso --- src/gallium/drivers/llvmpipe/lp_context.c | 5 +++- src/gallium/drivers/llvmpipe/lp_context.h | 4 +-- src/gallium/drivers/llvmpipe/lp_state.h | 16 ++++++++---- src/gallium/drivers/llvmpipe/lp_state_vertex.c | 34 +++++++++++++++++++------- 4 files changed, 42 insertions(+), 17 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 9120226de0..ccd1cf8eec 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -145,6 +145,10 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe->pipe.bind_vs_state = llvmpipe_bind_vs_state; llvmpipe->pipe.delete_vs_state = llvmpipe_delete_vs_state; + llvmpipe->pipe.create_vertex_elements_state = llvmpipe_create_vertex_elements_state; + llvmpipe->pipe.bind_vertex_elements_state = llvmpipe_bind_vertex_elements_state; + llvmpipe->pipe.delete_vertex_elements_state = llvmpipe_delete_vertex_elements_state; + llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color; llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref; llvmpipe->pipe.set_clip_state = llvmpipe_set_clip_state; @@ -157,7 +161,6 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe->pipe.set_viewport_state = llvmpipe_set_viewport_state; llvmpipe->pipe.set_vertex_buffers = llvmpipe_set_vertex_buffers; - llvmpipe->pipe.set_vertex_elements = llvmpipe_set_vertex_elements; llvmpipe->pipe.draw_arrays = llvmpipe_draw_arrays; llvmpipe->pipe.draw_elements = llvmpipe_draw_elements; diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h index 955c7eb8e0..217ec59b68 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.h +++ b/src/gallium/drivers/llvmpipe/lp_context.h @@ -46,6 +46,7 @@ struct lp_fragment_shader; struct lp_vertex_shader; struct lp_blend_state; struct setup_context; +struct lp_velems_state; struct llvmpipe_context { struct pipe_context pipe; /**< base class */ @@ -58,6 +59,7 @@ struct llvmpipe_context { const struct pipe_rasterizer_state *rasterizer; struct lp_fragment_shader *fs; const struct lp_vertex_shader *vs; + const struct lp_velems_state *velems; /** Other rendering state */ struct pipe_blend_color blend_color; @@ -71,13 +73,11 @@ struct llvmpipe_context { struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; unsigned num_samplers; unsigned num_textures; unsigned num_vertex_samplers; unsigned num_vertex_textures; - unsigned num_vertex_elements; unsigned num_vertex_buffers; unsigned dirty; /**< Mask of LP_NEW_x flags */ diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 9beba32271..57f5bd0042 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -119,6 +119,10 @@ struct lp_vertex_shader { struct draw_vertex_shader *draw_data; }; +struct lp_velems_state { + unsigned count; + struct pipe_vertex_element velem[]; +}; void * @@ -176,8 +180,14 @@ void *llvmpipe_create_vs_state(struct pipe_context *, void llvmpipe_bind_vs_state(struct pipe_context *, void *); void llvmpipe_delete_vs_state(struct pipe_context *, void *); +void *llvmpipe_create_vertex_elements_state(struct pipe_context *, + unsigned count, + const struct pipe_vertex_element *); +void llvmpipe_bind_vertex_elements_state(struct pipe_context *, void *); +void llvmpipe_delete_vertex_elements_state(struct pipe_context *, void *); + void llvmpipe_set_polygon_stipple( struct pipe_context *, - const struct pipe_poly_stipple * ); + const struct pipe_poly_stipple * ); void llvmpipe_set_scissor_state( struct pipe_context *, const struct pipe_scissor_state * ); @@ -194,10 +204,6 @@ llvmpipe_set_vertex_sampler_textures(struct pipe_context *, void llvmpipe_set_viewport_state( struct pipe_context *, const struct pipe_viewport_state * ); -void llvmpipe_set_vertex_elements(struct pipe_context *, - unsigned count, - const struct pipe_vertex_element *); - void llvmpipe_set_vertex_buffers(struct pipe_context *, unsigned count, const struct pipe_vertex_buffer *); diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c index 57ac25ea0c..5a9b6d5e18 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c @@ -35,24 +35,40 @@ #include "draw/draw_context.h" +void * +llvmpipe_create_vertex_elements_state(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) +{ + struct lp_velems_state *velems; + assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct lp_velems_state *) MALLOC(sizeof(struct lp_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} + void -llvmpipe_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *attribs) +llvmpipe_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + struct lp_velems_state *lp_velems = (struct lp_velems_state *) velems; - assert(count <= PIPE_MAX_ATTRIBS); - - memcpy(llvmpipe->vertex_element, attribs, - count * sizeof(struct pipe_vertex_element)); - llvmpipe->num_vertex_elements = count; + llvmpipe->velems = lp_velems; llvmpipe->dirty |= LP_NEW_VERTEX; - draw_set_vertex_elements(llvmpipe->draw, count, attribs); + draw_set_vertex_elements(llvmpipe->draw, lp_velems->count, lp_velems->velem); } +void +llvmpipe_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); +} void llvmpipe_set_vertex_buffers(struct pipe_context *pipe, -- cgit v1.2.3 From e9441e1f88cc07365f4d7d9149ccefe128809645 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:46:49 +0100 Subject: r300g: adapt to new vertex element cso --- src/gallium/drivers/r300/r300_blit.c | 1 + src/gallium/drivers/r300/r300_context.h | 8 +++-- src/gallium/drivers/r300/r300_emit.c | 4 +-- src/gallium/drivers/r300/r300_render.c | 12 ++++---- src/gallium/drivers/r300/r300_state.c | 44 +++++++++++++++++++-------- src/gallium/drivers/r300/r300_state_derived.c | 6 ++-- 6 files changed, 50 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index eb9b0beeb5..2f9650df1b 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -34,6 +34,7 @@ static void r300_blitter_save_states(struct r300_context* r300) util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state); util_blitter_save_fragment_shader(r300->blitter, r300->fs); util_blitter_save_vertex_shader(r300->blitter, r300->vs); + util_blitter_save_vertex_elements(r300->blitter, r300->vs); } /* Clear currently bound buffers. */ diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 1eba8a8ed1..0ee0ab47a6 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -247,6 +247,11 @@ struct r300_vertex_info { uint32_t vap_prog_stream_cntl_ext[8]; }; +struct r300_velems_state { + unsigned count; + struct pipe_vertex_element velem[]; +}; + extern struct pipe_viewport_state r300_viewport_identity; struct r300_context { @@ -317,8 +322,7 @@ struct r300_context { struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; /* Vertex elements for Gallium. */ - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; - int vertex_element_count; + struct r300_velems_state *velems; struct pipe_stencil_ref stencil_ref; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 88fe166359..fa3df9a23b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -776,9 +776,9 @@ void r300_emit_texture(struct r300_context* r300, void r300_emit_aos(struct r300_context* r300, unsigned offset) { struct pipe_vertex_buffer *vb1, *vb2, *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_vertex_element *velem = r300->velems->velem; int i; - unsigned size1, size2, aos_count = r300->vertex_element_count; + unsigned size1, size2, aos_count = r300->velems->count; unsigned packet_size = (aos_count * 3 + 1) / 2; CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index cd4971ae13..1850a6f247 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -128,7 +128,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, { struct pipe_vertex_element* velem; struct pipe_vertex_buffer* vbuf; - unsigned vertex_element_count = r300->vertex_element_count; + unsigned vertex_element_count = r300->velems->count; unsigned i, v, vbi, dw, elem_offset; /* Size of the vertex, in dwords. */ @@ -151,7 +151,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, /* Calculate the vertex size, offsets, strides etc. and map the buffers. */ for (i = 0; i < vertex_element_count; i++) { - velem = &r300->vertex_element[i]; + velem = &r300->velems->velem[i]; offset[i] = velem->src_offset / 4; size[i] = util_format_get_blocksize(velem->src_format) / 4; vertex_size += size[i]; @@ -183,7 +183,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, /* Emit vertices. */ for (v = 0; v < count; v++) { for (i = 0; i < vertex_element_count; i++) { - velem = &r300->vertex_element[i]; + velem = &r300->velems->velem[i]; vbi = velem->vertex_buffer_index; elem_offset = offset[i] + stride[vbi] * (v + start); @@ -196,7 +196,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, /* Unmap buffers. */ for (i = 0; i < vertex_element_count; i++) { - vbi = r300->vertex_element[i].vertex_buffer_index; + vbi = r300->velems->velem[i].vertex_buffer_index; if (map[vbi]) { vbuf = &r300->vertex_buffer[vbi]; @@ -278,11 +278,11 @@ static void r300_emit_draw_elements(struct r300_context *r300, static boolean r300_setup_vertex_buffers(struct r300_context *r300) { struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_vertex_element *velem = r300->velems->velem; struct pipe_buffer *pbuf; validate: - for (int i = 0; i < r300->vertex_element_count; i++) { + for (int i = 0; i < r300->velems->count; i++) { pbuf = vbuf[velem[i].vertex_buffer_index].buffer; if (!r300->winsys->add_buffer(r300->winsys, pbuf, diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 34bf81c193..ceac690fc4 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1044,11 +1044,11 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, static boolean r300_validate_aos(struct r300_context *r300) { struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_vertex_element *velem = r300->velems->velem; int i; /* Check if formats and strides are aligned to the size of DWORD. */ - for (i = 0; i < r300->vertex_element_count; i++) { + for (i = 0; i < r300->velems->count; i++) { if (vbuf[velem[i].vertex_buffer_index].stride % 4 != 0 || util_format_get_blocksize(velem[i].src_format) % 4 != 0) { return FALSE; @@ -1057,20 +1057,32 @@ static boolean r300_validate_aos(struct r300_context *r300) return TRUE; } -static void r300_set_vertex_elements(struct pipe_context* pipe, - unsigned count, - const struct pipe_vertex_element* elements) +static void* r300_create_vertex_elements_state(struct pipe_context* pipe, + unsigned count, + const struct pipe_vertex_element* attribs) { - struct r300_context* r300 = r300_context(pipe); + /*XXX could precalculate state here instead of later */ + struct r300_velems_state *velems; + assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct r300_velems_state *) MALLOC(sizeof(struct r300_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} + +static void r300_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) +{ + struct r300_context *r300 = r300_context(pipe); + struct r300_velems_state *r300_velems = (struct r300_velems_state *) velems; - memcpy(r300->vertex_element, - elements, - sizeof(struct pipe_vertex_element) * count); - r300->vertex_element_count = count; + r300->velems = r300_velems; if (r300->draw) { draw_flush(r300->draw); - draw_set_vertex_elements(r300->draw, count, elements); + draw_set_vertex_elements(r300->draw, r300_velems->count, r300_velems->velem); } if (!r300_validate_aos(r300)) { @@ -1080,6 +1092,11 @@ static void r300_set_vertex_elements(struct pipe_context* pipe, } } +static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); +} + static void* r300_create_vs_state(struct pipe_context* pipe, const struct pipe_shader_state* shader) { @@ -1241,7 +1258,10 @@ void r300_init_state_functions(struct r300_context* r300) r300->context.set_viewport_state = r300_set_viewport_state; r300->context.set_vertex_buffers = r300_set_vertex_buffers; - r300->context.set_vertex_elements = r300_set_vertex_elements; + + r300->context.create_vertex_elements_state = r300_create_vertex_elements_state; + r300->context.bind_vertex_elements_state = r300_bind_vertex_elements_state; + r300->context.delete_vertex_elements_state = r300_delete_vertex_elements_state; r300->context.create_vs_state = r300_create_vs_state; r300->context.bind_vs_state = r300_bind_vs_state; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 2cbce9210a..c43a93601c 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -128,10 +128,10 @@ static void r300_vertex_psc(struct r300_context* r300) DBG(r300, DBG_DRAW, "r300: vs expects %d attribs, routing %d elements" " in psc\n", r300->vs->info.num_inputs, - r300->vertex_element_count); + r300->velems->count); - for (i = 0; i < r300->vertex_element_count; i++) { - format = r300->vertex_element[i].src_format; + for (i = 0; i < r300->velems->count; i++) { + format = r300->velems->velem[i].src_format; type = r300_translate_vertex_data_type(format) | (stream_tab[i] << R300_DST_VEC_LOC_SHIFT); -- cgit v1.2.3 From 4dfe2df6296745e054db6c83cdd122417a3e3764 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:47:04 +0100 Subject: cell: adapt to new vertex element cso --- src/gallium/drivers/cell/ppu/cell_context.h | 8 +++-- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 41 ++++++++++++++++++------ 2 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index a77cc5b906..84ad0f3422 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -93,6 +93,11 @@ struct cell_buffer_list struct cell_buffer_node *head; }; +struct cell_velems_state +{ + unsigned count; + struct pipe_vertex_element velem[]; +} /** * Per-context state, subclass of pipe_context. @@ -110,6 +115,7 @@ struct cell_context const struct pipe_rasterizer_state *rasterizer; const struct cell_vertex_shader_state *vs; const struct cell_fragment_shader_state *fs; + const struct cell_velems_state *velems; struct spe_function logic_op; @@ -125,8 +131,6 @@ struct cell_context struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; uint num_vertex_buffers; - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; - uint num_vertex_elements; ubyte *cbuf_map[PIPE_MAX_COLOR_BUFS]; ubyte *zsbuf_map; diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index fbe55c8472..35c919fb6b 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -32,24 +32,43 @@ #include "cell_context.h" #include "cell_state.h" +#include "util/u_memory.h" #include "draw/draw_context.h" -static void -cell_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *elements) +void * +cell_create_vertex_elements_state(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) { - struct cell_context *cell = cell_context(pipe); - + struct cell_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} + +void +cell_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) +{ + struct cell_context *cell = cell_context(pipe); + struct cell_velems_state *cell_velems = (struct cell_velems_state *) velems; - memcpy(cell->vertex_element, elements, count * sizeof(elements[0])); - cell->num_vertex_elements = count; + cell->velems = cell_velems; cell->dirty |= CELL_NEW_VERTEX; - draw_set_vertex_elements(cell->draw, count, elements); + draw_set_vertex_elements(cell->draw, cell_velems->count, cell_velems->velem); +} + +void +cell_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); } @@ -75,5 +94,7 @@ 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; + cell->pipe.create_vertex_elements_state = cell_create_vertex_elements_state; + cell->pipe.bind_vertex_elements_state = cell_bind_vertex_elements_state; + cell->pipe.delete_vertex_elements_state = cell_delete_vertex_elements_state; } -- cgit v1.2.3 From 8e2df0dcb92b7b092b35df3d35591c31d5f2ca5f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:47:17 +0100 Subject: i915g: adapt to new vertex element cso --- src/gallium/drivers/i915/i915_context.h | 8 ++++++-- src/gallium/drivers/i915/i915_state.c | 35 +++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index da769e7b29..369c63eece 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -148,7 +148,7 @@ struct i915_state /** Describes the current hardware vertex layout */ struct vertex_info vertex_info; - + unsigned id; /* track lost context events */ }; @@ -187,6 +187,11 @@ struct i915_sampler_state { unsigned maxlod; }; +struct i915_velems_state { + unsigned count; + struct pipe_vertex_element velem[]; +}; + struct i915_texture { struct pipe_texture base; @@ -247,7 +252,6 @@ struct i915_context unsigned num_samplers; unsigned num_textures; - unsigned num_vertex_elements; unsigned num_vertex_buffers; struct intel_batchbuffer *batch; diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 62169918e2..46406065c3 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -742,21 +742,42 @@ static void i915_set_vertex_buffers(struct pipe_context *pipe, draw_set_vertex_buffers(i915->draw, count, buffers); } -static void i915_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *elements) +static void * +i915_create_vertex_elements_state(struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs) +{ + struct i915_velems_state *velems; + assert(count <= PIPE_MAX_ATTRIBS); + velems = (struct i915_velems_state *) MALLOC(sizeof(struct i915_velems_state) + count * sizeof(*attribs)); + if (velems) { + velems->count = count; + memcpy(velems->velem, attribs, sizeof(*attribs) * count); + } + return velems; +} + +static void +i915_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) { struct i915_context *i915 = i915_context(pipe); + struct i915_velems_state *i915_velems = (struct i915_velems_state *) velems; + /* Because we change state before the draw_set_vertex_buffers call * we need a flush here, just to be sure. */ draw_flush(i915->draw); - i915->num_vertex_elements = count; /* pass-through to draw module */ - draw_set_vertex_elements(i915->draw, count, elements); + draw_set_vertex_elements(i915->draw, i915_velems->count, i915_velems->velem); } +static void +i915_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); +} void i915_init_state_functions( struct i915_context *i915 ) @@ -782,6 +803,9 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.create_vs_state = i915_create_vs_state; i915->base.bind_vs_state = i915_bind_vs_state; i915->base.delete_vs_state = i915_delete_vs_state; + i915->base.create_vertex_elements_state = i915_create_vertex_elements_state; + i915->base.bind_vertex_elements_state = i915_bind_vertex_elements_state; + i915->base.delete_vertex_elements_state = i915_delete_vertex_elements_state; i915->base.set_blend_color = i915_set_blend_color; i915->base.set_stencil_ref = i915_set_stencil_ref; @@ -794,5 +818,4 @@ i915_init_state_functions( struct i915_context *i915 ) i915->base.set_fragment_sampler_textures = i915_set_sampler_textures; i915->base.set_viewport_state = i915_set_viewport_state; i915->base.set_vertex_buffers = i915_set_vertex_buffers; - i915->base.set_vertex_elements = i915_set_vertex_elements; } -- cgit v1.2.3 From 470dbb84b8e892bf6d5a9136b40dd68f5b146a05 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:47:28 +0100 Subject: i965g: adapt to new vertex element cso --- src/gallium/drivers/i965/brw_context.h | 5 +- src/gallium/drivers/i965/brw_draw_upload.c | 211 +----------------------- src/gallium/drivers/i965/brw_pipe_vertex.c | 247 ++++++++++++++++++++++++++++- src/gallium/drivers/i965/brw_structs.h | 4 +- 4 files changed, 251 insertions(+), 216 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h index 12cfa7b049..f5b1a06576 100644 --- a/src/gallium/drivers/i965/brw_context.h +++ b/src/gallium/drivers/i965/brw_context.h @@ -351,7 +351,7 @@ struct brw_vs_prog_data { /* Size == 0 if output either not written, or always [0,0,0,1] */ -struct brw_vs_ouput_sizes { +struct brw_vs_output_sizes { GLubyte output_size[PIPE_MAX_SHADER_OUTPUTS]; }; @@ -546,14 +546,13 @@ struct brw_context const struct brw_blend_state *blend; const struct brw_rasterizer_state *rast; const struct brw_depth_stencil_state *zstencil; + const struct brw_vertex_element_packet *velems; const struct brw_sampler *sampler[PIPE_MAX_SAMPLERS]; unsigned num_samplers; struct pipe_texture *texture[PIPE_MAX_SAMPLERS]; struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS]; - unsigned num_vertex_elements; unsigned num_textures; unsigned num_vertex_buffers; diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c index 9eafdd4085..0820ba20a0 100644 --- a/src/gallium/drivers/i965/brw_draw_upload.c +++ b/src/gallium/drivers/i965/brw_draw_upload.c @@ -30,7 +30,6 @@ #include "util/u_upload_mgr.h" #include "util/u_math.h" -#include "util/u_format.h" #include "brw_draw.h" #include "brw_defines.h" @@ -43,141 +42,6 @@ -static unsigned brw_translate_surface_format( unsigned id ) -{ - switch (id) { - case PIPE_FORMAT_R64_FLOAT: - return BRW_SURFACEFORMAT_R64_FLOAT; - case PIPE_FORMAT_R64G64_FLOAT: - return BRW_SURFACEFORMAT_R64G64_FLOAT; - case PIPE_FORMAT_R64G64B64_FLOAT: - return BRW_SURFACEFORMAT_R64G64B64_FLOAT; - case PIPE_FORMAT_R64G64B64A64_FLOAT: - return BRW_SURFACEFORMAT_R64G64B64A64_FLOAT; - - case PIPE_FORMAT_R32_FLOAT: - return BRW_SURFACEFORMAT_R32_FLOAT; - case PIPE_FORMAT_R32G32_FLOAT: - return BRW_SURFACEFORMAT_R32G32_FLOAT; - case PIPE_FORMAT_R32G32B32_FLOAT: - return BRW_SURFACEFORMAT_R32G32B32_FLOAT; - case PIPE_FORMAT_R32G32B32A32_FLOAT: - return BRW_SURFACEFORMAT_R32G32B32A32_FLOAT; - - case PIPE_FORMAT_R32_UNORM: - return BRW_SURFACEFORMAT_R32_UNORM; - case PIPE_FORMAT_R32G32_UNORM: - return BRW_SURFACEFORMAT_R32G32_UNORM; - case PIPE_FORMAT_R32G32B32_UNORM: - return BRW_SURFACEFORMAT_R32G32B32_UNORM; - case PIPE_FORMAT_R32G32B32A32_UNORM: - return BRW_SURFACEFORMAT_R32G32B32A32_UNORM; - - case PIPE_FORMAT_R32_USCALED: - return BRW_SURFACEFORMAT_R32_USCALED; - case PIPE_FORMAT_R32G32_USCALED: - return BRW_SURFACEFORMAT_R32G32_USCALED; - case PIPE_FORMAT_R32G32B32_USCALED: - return BRW_SURFACEFORMAT_R32G32B32_USCALED; - case PIPE_FORMAT_R32G32B32A32_USCALED: - return BRW_SURFACEFORMAT_R32G32B32A32_USCALED; - - case PIPE_FORMAT_R32_SNORM: - return BRW_SURFACEFORMAT_R32_SNORM; - case PIPE_FORMAT_R32G32_SNORM: - return BRW_SURFACEFORMAT_R32G32_SNORM; - case PIPE_FORMAT_R32G32B32_SNORM: - return BRW_SURFACEFORMAT_R32G32B32_SNORM; - case PIPE_FORMAT_R32G32B32A32_SNORM: - return BRW_SURFACEFORMAT_R32G32B32A32_SNORM; - - case PIPE_FORMAT_R32_SSCALED: - return BRW_SURFACEFORMAT_R32_SSCALED; - case PIPE_FORMAT_R32G32_SSCALED: - return BRW_SURFACEFORMAT_R32G32_SSCALED; - case PIPE_FORMAT_R32G32B32_SSCALED: - return BRW_SURFACEFORMAT_R32G32B32_SSCALED; - case PIPE_FORMAT_R32G32B32A32_SSCALED: - return BRW_SURFACEFORMAT_R32G32B32A32_SSCALED; - - case PIPE_FORMAT_R16_UNORM: - return BRW_SURFACEFORMAT_R16_UNORM; - case PIPE_FORMAT_R16G16_UNORM: - return BRW_SURFACEFORMAT_R16G16_UNORM; - case PIPE_FORMAT_R16G16B16_UNORM: - return BRW_SURFACEFORMAT_R16G16B16_UNORM; - case PIPE_FORMAT_R16G16B16A16_UNORM: - return BRW_SURFACEFORMAT_R16G16B16A16_UNORM; - - case PIPE_FORMAT_R16_USCALED: - return BRW_SURFACEFORMAT_R16_USCALED; - case PIPE_FORMAT_R16G16_USCALED: - return BRW_SURFACEFORMAT_R16G16_USCALED; - case PIPE_FORMAT_R16G16B16_USCALED: - return BRW_SURFACEFORMAT_R16G16B16_USCALED; - case PIPE_FORMAT_R16G16B16A16_USCALED: - return BRW_SURFACEFORMAT_R16G16B16A16_USCALED; - - case PIPE_FORMAT_R16_SNORM: - return BRW_SURFACEFORMAT_R16_SNORM; - case PIPE_FORMAT_R16G16_SNORM: - return BRW_SURFACEFORMAT_R16G16_SNORM; - case PIPE_FORMAT_R16G16B16_SNORM: - return BRW_SURFACEFORMAT_R16G16B16_SNORM; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return BRW_SURFACEFORMAT_R16G16B16A16_SNORM; - - case PIPE_FORMAT_R16_SSCALED: - return BRW_SURFACEFORMAT_R16_SSCALED; - case PIPE_FORMAT_R16G16_SSCALED: - return BRW_SURFACEFORMAT_R16G16_SSCALED; - case PIPE_FORMAT_R16G16B16_SSCALED: - return BRW_SURFACEFORMAT_R16G16B16_SSCALED; - case PIPE_FORMAT_R16G16B16A16_SSCALED: - return BRW_SURFACEFORMAT_R16G16B16A16_SSCALED; - - case PIPE_FORMAT_R8_UNORM: - return BRW_SURFACEFORMAT_R8_UNORM; - case PIPE_FORMAT_R8G8_UNORM: - return BRW_SURFACEFORMAT_R8G8_UNORM; - case PIPE_FORMAT_R8G8B8_UNORM: - return BRW_SURFACEFORMAT_R8G8B8_UNORM; - case PIPE_FORMAT_R8G8B8A8_UNORM: - return BRW_SURFACEFORMAT_R8G8B8A8_UNORM; - - case PIPE_FORMAT_R8_USCALED: - return BRW_SURFACEFORMAT_R8_USCALED; - case PIPE_FORMAT_R8G8_USCALED: - return BRW_SURFACEFORMAT_R8G8_USCALED; - case PIPE_FORMAT_R8G8B8_USCALED: - return BRW_SURFACEFORMAT_R8G8B8_USCALED; - case PIPE_FORMAT_R8G8B8A8_USCALED: - return BRW_SURFACEFORMAT_R8G8B8A8_USCALED; - - case PIPE_FORMAT_R8_SNORM: - return BRW_SURFACEFORMAT_R8_SNORM; - case PIPE_FORMAT_R8G8_SNORM: - return BRW_SURFACEFORMAT_R8G8_SNORM; - case PIPE_FORMAT_R8G8B8_SNORM: - return BRW_SURFACEFORMAT_R8G8B8_SNORM; - case PIPE_FORMAT_R8G8B8A8_SNORM: - return BRW_SURFACEFORMAT_R8G8B8A8_SNORM; - - case PIPE_FORMAT_R8_SSCALED: - return BRW_SURFACEFORMAT_R8_SSCALED; - case PIPE_FORMAT_R8G8_SSCALED: - return BRW_SURFACEFORMAT_R8G8_SSCALED; - case PIPE_FORMAT_R8G8B8_SSCALED: - return BRW_SURFACEFORMAT_R8G8B8_SSCALED; - case PIPE_FORMAT_R8G8B8A8_SSCALED: - return BRW_SURFACEFORMAT_R8G8B8A8_SSCALED; - - default: - assert(0); - return 0; - } -} - static unsigned get_index_type(int type) { switch (type) { @@ -316,77 +180,16 @@ static int brw_emit_vertex_buffers( struct brw_context *brw ) - static int brw_emit_vertex_elements(struct brw_context *brw) { - GLuint nr = brw->curr.num_vertex_elements; - GLuint i; + const struct brw_vertex_element_packet *brw_velems = brw->curr.velems; + unsigned size = brw_velems->header.length + 2; + /* why is this here */ brw_emit_query_begin(brw); - /* If the VS doesn't read any inputs (calculating vertex position from - * a state variable for some reason, for example), emit a single pad - * VERTEX_ELEMENT struct and bail. - * - * The stale VB state stays in place, but they don't do anything unless - * a VE loads from them. - */ - if (nr == 0) { - BEGIN_BATCH(3, IGNORE_CLIPRECTS); - OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | 1); - OUT_BATCH((0 << BRW_VE0_INDEX_SHIFT) | - BRW_VE0_VALID | - (BRW_SURFACEFORMAT_R32G32B32A32_FLOAT << BRW_VE0_FORMAT_SHIFT) | - (0 << BRW_VE0_SRC_OFFSET_SHIFT)); - OUT_BATCH((BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_0_SHIFT) | - (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_1_SHIFT) | - (BRW_VE1_COMPONENT_STORE_0 << BRW_VE1_COMPONENT_2_SHIFT) | - (BRW_VE1_COMPONENT_STORE_1_FLT << BRW_VE1_COMPONENT_3_SHIFT)); - ADVANCE_BATCH(); - return 0; - } - - /* Now emit vertex element (VEP) state packets. - * - */ - BEGIN_BATCH(1 + nr * 2, IGNORE_CLIPRECTS); - OUT_BATCH((CMD_VERTEX_ELEMENT << 16) | ((1 + nr * 2) - 2)); - for (i = 0; i < nr; i++) { - const struct pipe_vertex_element *input = &brw->curr.vertex_element[i]; - unsigned nr_components = util_format_get_nr_components(input->src_format); - - uint32_t format = brw_translate_surface_format( input->src_format ); - uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC; - uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC; - uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC; - uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC; - - switch (nr_components) { - case 0: comp0 = BRW_VE1_COMPONENT_STORE_0; - case 1: comp1 = BRW_VE1_COMPONENT_STORE_0; - case 2: comp2 = BRW_VE1_COMPONENT_STORE_0; - case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT; - break; - } - - OUT_BATCH((input->vertex_buffer_index << BRW_VE0_INDEX_SHIFT) | - BRW_VE0_VALID | - (format << BRW_VE0_FORMAT_SHIFT) | - (input->src_offset << BRW_VE0_SRC_OFFSET_SHIFT)); + brw_batchbuffer_data(brw->batch, brw_velems, size * 4, IGNORE_CLIPRECTS); - if (BRW_IS_IGDNG(brw)) - OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) | - (comp1 << BRW_VE1_COMPONENT_1_SHIFT) | - (comp2 << BRW_VE1_COMPONENT_2_SHIFT) | - (comp3 << BRW_VE1_COMPONENT_3_SHIFT)); - else - OUT_BATCH((comp0 << BRW_VE1_COMPONENT_0_SHIFT) | - (comp1 << BRW_VE1_COMPONENT_1_SHIFT) | - (comp2 << BRW_VE1_COMPONENT_2_SHIFT) | - (comp3 << BRW_VE1_COMPONENT_3_SHIFT) | - ((i * 4) << BRW_VE1_DST_OFFSET_SHIFT)); - } - ADVANCE_BATCH(); return 0; } @@ -399,10 +202,11 @@ static int brw_emit_vertices( struct brw_context *brw ) if (ret) return ret; + /* XXX should separate this? */ ret = brw_emit_vertex_elements( brw ); if (ret) return ret; - + return 0; } @@ -410,7 +214,8 @@ static int brw_emit_vertices( struct brw_context *brw ) const struct brw_tracked_state brw_vertices = { .dirty = { .mesa = (PIPE_NEW_INDEX_RANGE | - PIPE_NEW_VERTEX_BUFFER), + PIPE_NEW_VERTEX_BUFFER | + PIPE_NEW_VERTEX_ELEMENT), .brw = BRW_NEW_BATCH, .cache = 0, }, diff --git a/src/gallium/drivers/i965/brw_pipe_vertex.c b/src/gallium/drivers/i965/brw_pipe_vertex.c index e3c48e3149..3d84fb86fb 100644 --- a/src/gallium/drivers/i965/brw_pipe_vertex.c +++ b/src/gallium/drivers/i965/brw_pipe_vertex.c @@ -1,22 +1,251 @@ #include "brw_context.h" +#include "brw_defines.h" +#include "brw_structs.h" +#include "util/u_memory.h" +#include "util/u_format.h" -static void brw_set_vertex_elements( struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *elements ) + +static unsigned brw_translate_surface_format( unsigned id ) +{ + switch (id) { + case PIPE_FORMAT_R64_FLOAT: + return BRW_SURFACEFORMAT_R64_FLOAT; + case PIPE_FORMAT_R64G64_FLOAT: + return BRW_SURFACEFORMAT_R64G64_FLOAT; + case PIPE_FORMAT_R64G64B64_FLOAT: + return BRW_SURFACEFORMAT_R64G64B64_FLOAT; + case PIPE_FORMAT_R64G64B64A64_FLOAT: + return BRW_SURFACEFORMAT_R64G64B64A64_FLOAT; + + case PIPE_FORMAT_R32_FLOAT: + return BRW_SURFACEFORMAT_R32_FLOAT; + case PIPE_FORMAT_R32G32_FLOAT: + return BRW_SURFACEFORMAT_R32G32_FLOAT; + case PIPE_FORMAT_R32G32B32_FLOAT: + return BRW_SURFACEFORMAT_R32G32B32_FLOAT; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + return BRW_SURFACEFORMAT_R32G32B32A32_FLOAT; + + case PIPE_FORMAT_R32_UNORM: + return BRW_SURFACEFORMAT_R32_UNORM; + case PIPE_FORMAT_R32G32_UNORM: + return BRW_SURFACEFORMAT_R32G32_UNORM; + case PIPE_FORMAT_R32G32B32_UNORM: + return BRW_SURFACEFORMAT_R32G32B32_UNORM; + case PIPE_FORMAT_R32G32B32A32_UNORM: + return BRW_SURFACEFORMAT_R32G32B32A32_UNORM; + + case PIPE_FORMAT_R32_USCALED: + return BRW_SURFACEFORMAT_R32_USCALED; + case PIPE_FORMAT_R32G32_USCALED: + return BRW_SURFACEFORMAT_R32G32_USCALED; + case PIPE_FORMAT_R32G32B32_USCALED: + return BRW_SURFACEFORMAT_R32G32B32_USCALED; + case PIPE_FORMAT_R32G32B32A32_USCALED: + return BRW_SURFACEFORMAT_R32G32B32A32_USCALED; + + case PIPE_FORMAT_R32_SNORM: + return BRW_SURFACEFORMAT_R32_SNORM; + case PIPE_FORMAT_R32G32_SNORM: + return BRW_SURFACEFORMAT_R32G32_SNORM; + case PIPE_FORMAT_R32G32B32_SNORM: + return BRW_SURFACEFORMAT_R32G32B32_SNORM; + case PIPE_FORMAT_R32G32B32A32_SNORM: + return BRW_SURFACEFORMAT_R32G32B32A32_SNORM; + + case PIPE_FORMAT_R32_SSCALED: + return BRW_SURFACEFORMAT_R32_SSCALED; + case PIPE_FORMAT_R32G32_SSCALED: + return BRW_SURFACEFORMAT_R32G32_SSCALED; + case PIPE_FORMAT_R32G32B32_SSCALED: + return BRW_SURFACEFORMAT_R32G32B32_SSCALED; + case PIPE_FORMAT_R32G32B32A32_SSCALED: + return BRW_SURFACEFORMAT_R32G32B32A32_SSCALED; + + case PIPE_FORMAT_R16_UNORM: + return BRW_SURFACEFORMAT_R16_UNORM; + case PIPE_FORMAT_R16G16_UNORM: + return BRW_SURFACEFORMAT_R16G16_UNORM; + case PIPE_FORMAT_R16G16B16_UNORM: + return BRW_SURFACEFORMAT_R16G16B16_UNORM; + case PIPE_FORMAT_R16G16B16A16_UNORM: + return BRW_SURFACEFORMAT_R16G16B16A16_UNORM; + + case PIPE_FORMAT_R16_USCALED: + return BRW_SURFACEFORMAT_R16_USCALED; + case PIPE_FORMAT_R16G16_USCALED: + return BRW_SURFACEFORMAT_R16G16_USCALED; + case PIPE_FORMAT_R16G16B16_USCALED: + return BRW_SURFACEFORMAT_R16G16B16_USCALED; + case PIPE_FORMAT_R16G16B16A16_USCALED: + return BRW_SURFACEFORMAT_R16G16B16A16_USCALED; + + case PIPE_FORMAT_R16_SNORM: + return BRW_SURFACEFORMAT_R16_SNORM; + case PIPE_FORMAT_R16G16_SNORM: + return BRW_SURFACEFORMAT_R16G16_SNORM; + case PIPE_FORMAT_R16G16B16_SNORM: + return BRW_SURFACEFORMAT_R16G16B16_SNORM; + case PIPE_FORMAT_R16G16B16A16_SNORM: + return BRW_SURFACEFORMAT_R16G16B16A16_SNORM; + + case PIPE_FORMAT_R16_SSCALED: + return BRW_SURFACEFORMAT_R16_SSCALED; + case PIPE_FORMAT_R16G16_SSCALED: + return BRW_SURFACEFORMAT_R16G16_SSCALED; + case PIPE_FORMAT_R16G16B16_SSCALED: + return BRW_SURFACEFORMAT_R16G16B16_SSCALED; + case PIPE_FORMAT_R16G16B16A16_SSCALED: + return BRW_SURFACEFORMAT_R16G16B16A16_SSCALED; + + case PIPE_FORMAT_R8_UNORM: + return BRW_SURFACEFORMAT_R8_UNORM; + case PIPE_FORMAT_R8G8_UNORM: + return BRW_SURFACEFORMAT_R8G8_UNORM; + case PIPE_FORMAT_R8G8B8_UNORM: + return BRW_SURFACEFORMAT_R8G8B8_UNORM; + case PIPE_FORMAT_R8G8B8A8_UNORM: + return BRW_SURFACEFORMAT_R8G8B8A8_UNORM; + + case PIPE_FORMAT_R8_USCALED: + return BRW_SURFACEFORMAT_R8_USCALED; + case PIPE_FORMAT_R8G8_USCALED: + return BRW_SURFACEFORMAT_R8G8_USCALED; + case PIPE_FORMAT_R8G8B8_USCALED: + return BRW_SURFACEFORMAT_R8G8B8_USCALED; + case PIPE_FORMAT_R8G8B8A8_USCALED: + return BRW_SURFACEFORMAT_R8G8B8A8_USCALED; + + case PIPE_FORMAT_R8_SNORM: + return BRW_SURFACEFORMAT_R8_SNORM; + case PIPE_FORMAT_R8G8_SNORM: + return BRW_SURFACEFORMAT_R8G8_SNORM; + case PIPE_FORMAT_R8G8B8_SNORM: + return BRW_SURFACEFORMAT_R8G8B8_SNORM; + case PIPE_FORMAT_R8G8B8A8_SNORM: + return BRW_SURFACEFORMAT_R8G8B8A8_SNORM; + + case PIPE_FORMAT_R8_SSCALED: + return BRW_SURFACEFORMAT_R8_SSCALED; + case PIPE_FORMAT_R8G8_SSCALED: + return BRW_SURFACEFORMAT_R8G8_SSCALED; + case PIPE_FORMAT_R8G8B8_SSCALED: + return BRW_SURFACEFORMAT_R8G8B8_SSCALED; + case PIPE_FORMAT_R8G8B8A8_SSCALED: + return BRW_SURFACEFORMAT_R8G8B8A8_SSCALED; + + default: + assert(0); + return 0; + } +} + +static void brw_translate_vertex_elements(struct brw_context *brw, + struct brw_vertex_element_packet *brw_velems, + const struct pipe_vertex_element *attribs, + unsigned count) +{ + unsigned i; + + /* If the VS doesn't read any inputs (calculating vertex position from + * a state variable for some reason, for example), emit a single pad + * VERTEX_ELEMENT struct and bail. + * + * The stale VB state stays in place, but they don't do anything unless + * a VE loads from them. + */ + brw_velems->header.opcode = CMD_VERTEX_ELEMENT; + + if (count == 0) { + brw_velems->header.length = 1; + brw_velems->ve[0].ve0.src_offset = 0; + brw_velems->ve[0].ve0.src_format = BRW_SURFACEFORMAT_R32G32B32A32_FLOAT; + brw_velems->ve[0].ve0.valid = 1; + brw_velems->ve[0].ve0.vertex_buffer_index = 0; + brw_velems->ve[0].ve1.dst_offset = 0; + brw_velems->ve[0].ve1.vfcomponent0 = BRW_VE1_COMPONENT_STORE_0; + brw_velems->ve[0].ve1.vfcomponent1 = BRW_VE1_COMPONENT_STORE_0; + brw_velems->ve[0].ve1.vfcomponent2 = BRW_VE1_COMPONENT_STORE_0; + brw_velems->ve[0].ve1.vfcomponent3 = BRW_VE1_COMPONENT_STORE_1_FLT; + return; + } + + + /* Now emit vertex element (VEP) state packets. + * + */ + brw_velems->header.length = (1 + count * 2) - 2; + for (i = 0; i < count; i++) { + const struct pipe_vertex_element *input = &attribs[i]; + unsigned nr_components = util_format_get_nr_components(input->src_format); + + uint32_t format = brw_translate_surface_format( input->src_format ); + uint32_t comp0 = BRW_VE1_COMPONENT_STORE_SRC; + uint32_t comp1 = BRW_VE1_COMPONENT_STORE_SRC; + uint32_t comp2 = BRW_VE1_COMPONENT_STORE_SRC; + uint32_t comp3 = BRW_VE1_COMPONENT_STORE_SRC; + + switch (nr_components) { + case 0: comp0 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ + case 1: comp1 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ + case 2: comp2 = BRW_VE1_COMPONENT_STORE_0; /* fallthrough */ + case 3: comp3 = BRW_VE1_COMPONENT_STORE_1_FLT; + break; + } + + brw_velems->ve[i].ve0.src_offset = input->src_offset; + brw_velems->ve[i].ve0.src_format = format; + brw_velems->ve[i].ve0.valid = 1; + brw_velems->ve[i].ve0.vertex_buffer_index = input->vertex_buffer_index; + brw_velems->ve[i].ve1.vfcomponent0 = comp0; + brw_velems->ve[i].ve1.vfcomponent1 = comp1; + brw_velems->ve[i].ve1.vfcomponent2 = comp2; + brw_velems->ve[i].ve1.vfcomponent3 = comp3; + + if (BRW_IS_IGDNG(brw)) + brw_velems->ve[i].ve1.dst_offset = 0; + else + brw_velems->ve[i].ve1.dst_offset = i * 4; + } +} + +static void* brw_create_vertex_elements_state( struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *attribs ) { + /* note: for the brw_swtnl.c code (if ever we need draw fallback) we'd also need + store the original data */ struct brw_context *brw = brw_context(pipe); + struct brw_vertex_element_packet *velems; + assert(count <= BRW_VEP_MAX); + velems = (struct brw_vertex_element_packet *) MALLOC(sizeof(struct brw_vertex_element_packet)); + if (velems) { + brw_translate_vertex_elements(brw, velems, attribs, count); + } + return velems; +} - memcpy(brw->curr.vertex_element, elements, count * sizeof(elements[0])); - brw->curr.num_vertex_elements = count; +static void brw_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems) +{ + struct brw_context *brw = brw_context(pipe); + struct brw_vertex_element_packet *brw_velems = (struct brw_vertex_element_packet *) velems; + + brw->curr.velems = brw_velems; brw->state.dirty.mesa |= PIPE_NEW_VERTEX_ELEMENT; } +static void brw_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +{ + FREE( velems ); +} + static void brw_set_vertex_buffers(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_buffer *buffers) + unsigned count, + const struct pipe_vertex_buffer *buffers) { struct brw_context *brw = brw_context(pipe); unsigned i; @@ -49,7 +278,9 @@ void brw_pipe_vertex_init( struct brw_context *brw ) { brw->base.set_vertex_buffers = brw_set_vertex_buffers; - brw->base.set_vertex_elements = brw_set_vertex_elements; + brw->base.create_vertex_elements_state = brw_create_vertex_elements_state; + brw->base.bind_vertex_elements_state = brw_bind_vertex_elements_state; + brw->base.delete_vertex_elements_state = brw_delete_vertex_elements_state; } diff --git a/src/gallium/drivers/i965/brw_structs.h b/src/gallium/drivers/i965/brw_structs.h index bf10bc04de..e97ddeb5e1 100644 --- a/src/gallium/drivers/i965/brw_structs.h +++ b/src/gallium/drivers/i965/brw_structs.h @@ -28,7 +28,7 @@ * Authors: * Keith Whitwell */ - + #ifndef BRW_STRUCTS_H #define BRW_STRUCTS_H @@ -1149,7 +1149,7 @@ struct brw_vertex_element_state GLuint valid:1; GLuint vertex_buffer_index:5; } ve0; - + struct { GLuint dst_offset:8; -- cgit v1.2.3 From 2918edb46acf58b467e4351d627912f4c8cdb32c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:47:54 +0100 Subject: failover: adapt to new vertex element cso --- src/gallium/drivers/failover/fo_context.h | 3 +- src/gallium/drivers/failover/fo_state.c | 65 ++++++++++++++++++++-------- src/gallium/drivers/failover/fo_state_emit.c | 10 ++--- 3 files changed, 52 insertions(+), 26 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h index bb1a168ea7..4a754465bb 100644 --- a/src/gallium/drivers/failover/fo_context.h +++ b/src/gallium/drivers/failover/fo_context.h @@ -78,6 +78,7 @@ struct failover_context { const struct fo_state *rasterizer; const struct fo_state *fragment_shader; const struct fo_state *vertex_shader; + const struct fo_state *vertex_elements; struct pipe_blend_color blend_color; struct pipe_stencil_ref stencil_ref; @@ -89,10 +90,8 @@ struct failover_context { struct pipe_texture *vertex_textures[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_viewport_state viewport; struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; - struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; uint num_vertex_buffers; - uint num_vertex_elements; void *sw_sampler_state[PIPE_MAX_SAMPLERS]; void *hw_sampler_state[PIPE_MAX_SAMPLERS]; diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c index 970606a3f5..0247fb803b 100644 --- a/src/gallium/drivers/failover/fo_state.c +++ b/src/gallium/drivers/failover/fo_state.c @@ -255,9 +255,52 @@ failover_delete_vs_state(struct pipe_context *pipe, free(state); } + + +static void * +failover_create_vertex_elements_state( struct pipe_context *pipe, + unsigned count, + const struct pipe_vertex_element *velems ) +{ + struct fo_state *state = malloc(sizeof(struct fo_state)); + struct failover_context *failover = failover_context(pipe); + + state->sw_state = failover->sw->create_vertex_elements_state(failover->sw, count, velems); + state->hw_state = failover->hw->create_vertex_elements_state(failover->hw, count, velems); + + return state; +} + +static void +failover_bind_vertex_elements_state(struct pipe_context *pipe, + void *velems ) +{ + struct failover_context *failover = failover_context(pipe); + struct fo_state *state = (struct fo_state*)velems; + + failover->vertex_elements = state; + failover->dirty |= FO_NEW_VERTEX_ELEMENT; + failover->sw->bind_vertex_elements_state( failover->sw, velems ); + failover->hw->bind_vertex_elements_state( failover->hw, velems ); +} + +static void +failover_delete_vertex_elements_state( struct pipe_context *pipe, + void *velems ) +{ + struct fo_state *state = (struct fo_state*)velems; + struct failover_context *failover = failover_context(pipe); + + failover->sw->delete_vertex_elements_state(failover->sw, state->sw_state); + failover->hw->delete_vertex_elements_state(failover->hw, state->hw_state); + state->sw_state = 0; + state->hw_state = 0; + free(state); +} + static void failover_set_polygon_stipple( struct pipe_context *pipe, - const struct pipe_poly_stipple *stipple ) + const struct pipe_poly_stipple *stipple ) { struct failover_context *failover = failover_context(pipe); @@ -490,22 +533,6 @@ failover_set_vertex_buffers(struct pipe_context *pipe, } -static void -failover_set_vertex_elements(struct pipe_context *pipe, - unsigned count, - const struct pipe_vertex_element *vertex_elements) -{ - struct failover_context *failover = failover_context(pipe); - - memcpy(failover->vertex_elements, vertex_elements, - count * sizeof(vertex_elements[0])); - - failover->dirty |= FO_NEW_VERTEX_ELEMENT; - failover->num_vertex_elements = count; - failover->sw->set_vertex_elements( failover->sw, count, vertex_elements ); - failover->hw->set_vertex_elements( failover->hw, count, vertex_elements ); -} - void failover_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, @@ -543,6 +570,9 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.create_vs_state = failover_create_vs_state; failover->pipe.bind_vs_state = failover_bind_vs_state; failover->pipe.delete_vs_state = failover_delete_vs_state; + failover->pipe.create_vertex_elements_state = failover_create_vertex_elements_state; + failover->pipe.bind_vertex_elements_state = failover_bind_vertex_elements_state; + failover->pipe.delete_vertex_elements_state = failover_delete_vertex_elements_state; failover->pipe.set_blend_color = failover_set_blend_color; failover->pipe.set_stencil_ref = failover_set_stencil_ref; @@ -554,6 +584,5 @@ failover_init_state_functions( struct failover_context *failover ) failover->pipe.set_vertex_sampler_textures = failover_set_vertex_sampler_textures; failover->pipe.set_viewport_state = failover_set_viewport_state; failover->pipe.set_vertex_buffers = failover_set_vertex_buffers; - failover->pipe.set_vertex_elements = failover_set_vertex_elements; failover->pipe.set_constant_buffer = failover_set_constant_buffer; } diff --git a/src/gallium/drivers/failover/fo_state_emit.c b/src/gallium/drivers/failover/fo_state_emit.c index 5c00080842..09ca194497 100644 --- a/src/gallium/drivers/failover/fo_state_emit.c +++ b/src/gallium/drivers/failover/fo_state_emit.c @@ -81,6 +81,10 @@ failover_state_emit( struct failover_context *failover ) failover->sw->bind_vs_state( failover->sw, failover->vertex_shader->sw_state ); + if (failover->dirty & FO_NEW_VERTEX_ELEMENT) + failover->sw->bind_vertex_elements_state( failover->sw, + failover->vertex_elements->sw_state ); + if (failover->dirty & FO_NEW_STIPPLE) failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple ); @@ -116,11 +120,5 @@ failover_state_emit( struct failover_context *failover ) failover->vertex_buffers ); } - if (failover->dirty & FO_NEW_VERTEX_ELEMENT) { - failover->sw->set_vertex_elements( failover->sw, - failover->num_vertex_elements, - failover->vertex_elements ); - } - failover->dirty = 0; } -- cgit v1.2.3 From 881be308360ec8019f17bc970bece23e9395134f Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 18:48:05 +0100 Subject: identity: adapt to new vertex element cso --- src/gallium/drivers/identity/id_context.c | 54 ++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 8248b2a413..05a9dfab77 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -377,6 +377,42 @@ identity_delete_vs_state(struct pipe_context *_pipe, vs); } + +static void +identity_create_vertex_elements_state(struct pipe_context *_pipe, + unsigned num_elements, + const struct pipe_vertex_element *vertex_elements) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + pipe->create_vertex_elements_state(pipe, + num_elements, + vertex_elements); +} + +static void +identity_bind_vertex_elements_state(struct pipe_context *_pipe, + void *velems) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + pipe->bind_vertex_elements_state(pipe, + velems); +} + +static void +identity_delete_vertex_elements_state(struct pipe_context *_pipe, + void *velems) +{ + struct identity_context *id_pipe = identity_context(_pipe); + struct pipe_context *pipe = id_pipe->pipe; + + pipe->delete_vertex_elements_state(pipe, + velems); +} + static void identity_set_blend_color(struct pipe_context *_pipe, const struct pipe_blend_color *blend_color) @@ -563,20 +599,6 @@ identity_set_vertex_buffers(struct pipe_context *_pipe, num_buffers, buffers); } - -static void -identity_set_vertex_elements(struct pipe_context *_pipe, - unsigned num_elements, - const struct pipe_vertex_element *vertex_elements) -{ - struct identity_context *id_pipe = identity_context(_pipe); - struct pipe_context *pipe = id_pipe->pipe; - - pipe->set_vertex_elements(pipe, - num_elements, - vertex_elements); -} - static void identity_surface_copy(struct pipe_context *_pipe, struct pipe_surface *_dst, @@ -733,6 +755,9 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.create_vs_state = identity_create_vs_state; id_pipe->base.bind_vs_state = identity_bind_vs_state; id_pipe->base.delete_vs_state = identity_delete_vs_state; + id_pipe->base.create_vertex_elements_state = identity_create_vertex_elements_state; + id_pipe->base.bind_vertex_elements_state = identity_bind_vertex_elements_state; + id_pipe->base.delete_vertex_elements_state = identity_delete_vertex_elements_state; id_pipe->base.set_blend_color = identity_set_blend_color; id_pipe->base.set_stencil_ref = identity_set_stencil_ref; id_pipe->base.set_clip_state = identity_set_clip_state; @@ -744,7 +769,6 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.set_fragment_sampler_textures = identity_set_fragment_sampler_textures; id_pipe->base.set_vertex_sampler_textures = identity_set_vertex_sampler_textures; id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers; - id_pipe->base.set_vertex_elements = identity_set_vertex_elements; id_pipe->base.surface_copy = identity_surface_copy; id_pipe->base.surface_fill = identity_surface_fill; id_pipe->base.clear = identity_clear; -- cgit v1.2.3 From c863f30155f26d47dc45736ffbbc0e9d96009756 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Mon, 1 Mar 2010 19:00:40 +0100 Subject: util: Generate linear<->sRGB conversion tables. --- src/gallium/auxiliary/util/u_format_access.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_access.py b/src/gallium/auxiliary/util/u_format_access.py index 1c9be1b538..00424779d2 100644 --- a/src/gallium/auxiliary/util/u_format_access.py +++ b/src/gallium/auxiliary/util/u_format_access.py @@ -37,6 +37,7 @@ ''' +import math import sys from u_format_pack import * @@ -94,6 +95,20 @@ def native_type(format): assert False +def generate_srgb_tables(): + print 'static ubyte srgb_to_linear[256] = {' + for i in range(256): + print ' %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)) + print '};' + print + print 'static ubyte linear_to_srgb[256] = {' + print ' 0,' + for i in range(1, 256): + print ' %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)) + print '};' + print + + def generate_format_read(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to read pixels from a particular format''' @@ -305,6 +320,8 @@ def main(): print '#include "u_format_pack.h"' print + generate_srgb_tables() + type = Channel(FLOAT, False, 32) native_type = 'float' suffix = '4f' -- cgit v1.2.3 From 835a725684dc294f579bbb8e11ad767de7503eef Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:39:47 +0000 Subject: gallium: Remove PIPE_FORMAT_A8B8G8R8_SNORM. Its actually an alias for PIPE_FORMAT_R8G8B8A8_SNORM. --- src/gallium/include/pipe/p_format.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 79e4df7b4d..55f3a08c1a 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -121,7 +121,6 @@ enum pipe_format { PIPE_FORMAT_R8G8_SNORM = 75, PIPE_FORMAT_R8G8B8_SNORM = 76, PIPE_FORMAT_R8G8B8A8_SNORM = 77, - PIPE_FORMAT_A8B8G8R8_SNORM = 80, PIPE_FORMAT_X8B8G8R8_SNORM = 81, PIPE_FORMAT_R8_SSCALED = 82, PIPE_FORMAT_R8G8_SSCALED = 83, -- cgit v1.2.3 From a6c4c4486d66c857125fb7d6f1a21c002f5cb8cd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:40:02 +0000 Subject: util: Remove PIPE_FORMAT_A8B8G8R8_SNORM. --- src/gallium/auxiliary/util/u_format.csv | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index e9ec377fb1..45a2776c6c 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -87,7 +87,6 @@ PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, s PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb # Signed formats (typically used for bump map textures) -PIPE_FORMAT_A8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyzw, rgb PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb PIPE_FORMAT_X8UB8UG8SR8S_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb PIPE_FORMAT_B6UG5SR5S_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb -- cgit v1.2.3 From 971ab386c0c8b7fd261a41e9a38fc4f83f9ba3f6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:40:33 +0000 Subject: softpipe: Advertise PIPE_FORMAT_R8G8B8A8_SNORM instead. --- src/gallium/drivers/softpipe/sp_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 87415f4340..937b6a8439 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -162,7 +162,7 @@ softpipe_is_format_supported( struct pipe_screen *screen, case PIPE_FORMAT_R8G8_SNORM: case PIPE_FORMAT_B6UG5SR5S_NORM: case PIPE_FORMAT_X8UB8UG8SR8S_NORM: - case PIPE_FORMAT_A8B8G8R8_SNORM: + case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_NONE: return FALSE; default: -- cgit v1.2.3 From 568a3c73652f02e8b0fee7693578c8fd2013d97f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:41:05 +0000 Subject: r300: Remove PIPE_FORMAT_A8B8G8R8_SNORM. PIPE_FORMAT_R8G8B8A8_SNORM already listed. --- src/gallium/drivers/r300/r300_texture.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 5b674f6e57..ea474737b1 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -329,7 +329,6 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_R8G8B8A8_SRGB: case PIPE_FORMAT_R8G8B8X8_UNORM: case PIPE_FORMAT_R8G8B8X8_SRGB: - case PIPE_FORMAT_A8B8G8R8_SNORM: case PIPE_FORMAT_X8B8G8R8_SNORM: case PIPE_FORMAT_X8UB8UG8SR8S_NORM: return R300_COLOR_FORMAT_ARGB8888; @@ -467,7 +466,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) R300_C2_SEL_G | R300_C3_SEL_R; /* ABGR 32-bit outputs. */ - case PIPE_FORMAT_A8B8G8R8_SNORM: case PIPE_FORMAT_X8B8G8R8_SNORM: case PIPE_FORMAT_X8UB8UG8SR8S_NORM: case PIPE_FORMAT_A2B10G10R10_UNORM: -- cgit v1.2.3 From 3843548a67da4ad484eadfd9e65d56d581a49a82 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:09:03 +0000 Subject: gallium: Standardize on the LSB->MSB notation. Less confusing, and seems to gather more consensus. Below are the sed commands used. This and following commits are the result of applying this too to the whole tree, plus manual whitespaces fixes. s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_A8R8G8B8_UNORM/g s/\/PIPE_FORMAT_B8G8R8A8_UNORM/g s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_X8R8G8B8_UNORM/g s/\/PIPE_FORMAT_B8G8R8X8_UNORM/g s/\/PIPE_FORMAT_A8B8G8R8_UNORM/g s/\/PIPE_FORMAT_X8B8G8R8_UNORM/g s/\/PIPE_FORMAT_B5G5R5A1_UNORM/g s/\/PIPE_FORMAT_B4G4R4A4_UNORM/g s/\/PIPE_FORMAT_B5G6R5_UNORM/g s/\/PIPE_FORMAT_R10G10B10A2_UNORM/g s/\/PIPE_FORMAT_L8A8_UNORM/g s/\/PIPE_FORMAT_L8A8_SRGB/g s/\/PIPE_FORMAT_A8B8G8R8_SRGB/g s/\/PIPE_FORMAT_X8B8G8R8_SRGB/g s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_A8R8G8B8_SRGB/g s/\/PIPE_FORMAT_B8G8R8A8_SRGB/g s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_X8R8G8B8_SRGB/g s/\/PIPE_FORMAT_B8G8R8X8_SRGB/g s/\/PIPE_FORMAT_R8G8B8A8_SNORM/g s/\/PIPE_FORMAT_R8G8B8X8_SNORM/g s/\/PIPE_FORMAT_R8SG8SB8UX8U_NORM/g s/\/PIPE_FORMAT_R5SG5SB6U_NORM/g s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_S8Z24_UNORM/g s/\/PIPE_FORMAT_Z24S8_UNORM/g s/\/ASDGFSJKDGSDFGSJDFGREKT/g s/\/PIPE_FORMAT_X8Z24_UNORM/g s/\/PIPE_FORMAT_Z24X8_UNORM/g s/\/PIPE_FORMAT_UYVY/g s/\/PIPE_FORMAT_YUYV/g --- src/gallium/include/pipe/p_format.h | 54 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 55f3a08c1a..0314172de7 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -45,28 +45,28 @@ extern "C" { enum pipe_format { PIPE_FORMAT_NONE = 0, - PIPE_FORMAT_A8R8G8B8_UNORM = 1, - PIPE_FORMAT_X8R8G8B8_UNORM = 2, - PIPE_FORMAT_B8G8R8A8_UNORM = 3, - PIPE_FORMAT_B8G8R8X8_UNORM = 4, - PIPE_FORMAT_A1R5G5B5_UNORM = 5, - PIPE_FORMAT_A4R4G4B4_UNORM = 6, - PIPE_FORMAT_R5G6B5_UNORM = 7, - PIPE_FORMAT_A2B10G10R10_UNORM = 8, + PIPE_FORMAT_B8G8R8A8_UNORM = 1, + PIPE_FORMAT_B8G8R8X8_UNORM = 2, + PIPE_FORMAT_A8R8G8B8_UNORM = 3, + PIPE_FORMAT_X8R8G8B8_UNORM = 4, + PIPE_FORMAT_B5G5R5A1_UNORM = 5, + PIPE_FORMAT_B4G4R4A4_UNORM = 6, + PIPE_FORMAT_B5G6R5_UNORM = 7, + PIPE_FORMAT_R10G10B10A2_UNORM = 8, PIPE_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ PIPE_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ PIPE_FORMAT_I8_UNORM = 11, /**< ubyte intensity */ - PIPE_FORMAT_A8L8_UNORM = 12, /**< ubyte alpha, luminance */ + PIPE_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ PIPE_FORMAT_L16_UNORM = 13, /**< ushort luminance */ - PIPE_FORMAT_YCBCR = 14, - PIPE_FORMAT_YCBCR_REV = 15, + PIPE_FORMAT_UYVY = 14, + PIPE_FORMAT_YUYV = 15, PIPE_FORMAT_Z16_UNORM = 16, PIPE_FORMAT_Z32_UNORM = 17, PIPE_FORMAT_Z32_FLOAT = 18, - PIPE_FORMAT_S8Z24_UNORM = 19, - PIPE_FORMAT_Z24S8_UNORM = 20, - PIPE_FORMAT_X8Z24_UNORM = 21, - PIPE_FORMAT_Z24X8_UNORM = 22, + PIPE_FORMAT_Z24S8_UNORM = 19, + PIPE_FORMAT_S8Z24_UNORM = 20, + PIPE_FORMAT_Z24X8_UNORM = 21, + PIPE_FORMAT_X8Z24_UNORM = 22, PIPE_FORMAT_S8_UNORM = 23, /**< ubyte stencil */ PIPE_FORMAT_R64_FLOAT = 24, PIPE_FORMAT_R64G64_FLOAT = 25, @@ -112,7 +112,7 @@ enum pipe_format { PIPE_FORMAT_R8G8_UNORM = 65, PIPE_FORMAT_R8G8B8_UNORM = 66, PIPE_FORMAT_R8G8B8A8_UNORM = 67, - PIPE_FORMAT_R8G8B8X8_UNORM = 68, + PIPE_FORMAT_X8B8G8R8_UNORM = 68, PIPE_FORMAT_R8_USCALED = 69, PIPE_FORMAT_R8G8_USCALED = 70, PIPE_FORMAT_R8G8B8_USCALED = 71, @@ -121,7 +121,7 @@ enum pipe_format { PIPE_FORMAT_R8G8_SNORM = 75, PIPE_FORMAT_R8G8B8_SNORM = 76, PIPE_FORMAT_R8G8B8A8_SNORM = 77, - PIPE_FORMAT_X8B8G8R8_SNORM = 81, + PIPE_FORMAT_R8G8B8X8_SNORM = 81, PIPE_FORMAT_R8_SSCALED = 82, PIPE_FORMAT_R8G8_SSCALED = 83, PIPE_FORMAT_R8G8B8_SSCALED = 84, @@ -132,18 +132,18 @@ enum pipe_format { PIPE_FORMAT_R32G32B32A32_FIXED = 90, /* sRGB formats */ PIPE_FORMAT_L8_SRGB = 91, - PIPE_FORMAT_A8L8_SRGB = 92, + PIPE_FORMAT_L8A8_SRGB = 92, PIPE_FORMAT_R8G8B8_SRGB = 93, - PIPE_FORMAT_R8G8B8A8_SRGB = 94, - PIPE_FORMAT_R8G8B8X8_SRGB = 95, - PIPE_FORMAT_A8R8G8B8_SRGB = 96, - PIPE_FORMAT_X8R8G8B8_SRGB = 97, - PIPE_FORMAT_B8G8R8A8_SRGB = 98, - PIPE_FORMAT_B8G8R8X8_SRGB = 99, + PIPE_FORMAT_A8B8G8R8_SRGB = 94, + PIPE_FORMAT_X8B8G8R8_SRGB = 95, + PIPE_FORMAT_B8G8R8A8_SRGB = 96, + PIPE_FORMAT_B8G8R8X8_SRGB = 97, + PIPE_FORMAT_A8R8G8B8_SRGB = 98, + PIPE_FORMAT_X8R8G8B8_SRGB = 99, /* mixed formats */ - PIPE_FORMAT_X8UB8UG8SR8S_NORM = 100, - PIPE_FORMAT_B6UG5SR5S_NORM = 101, + PIPE_FORMAT_R8SG8SB8UX8U_NORM = 100, + PIPE_FORMAT_R5SG5SB6U_NORM = 101, /* compressed formats */ PIPE_FORMAT_DXT1_RGB = 102, @@ -157,7 +157,7 @@ enum pipe_format { PIPE_FORMAT_DXT3_SRGBA = 108, PIPE_FORMAT_DXT5_SRGBA = 109, - PIPE_FORMAT_R8G8B8A8_UNORM_REV = 110, + PIPE_FORMAT_A8B8G8R8_UNORM = 110, PIPE_FORMAT_COUNT }; -- cgit v1.2.3 From 712ba6e6b049c050af3ac1992aba009ebbe56ca5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:09:40 +0000 Subject: util: Rename pipe formats. --- src/gallium/auxiliary/util/u_debug.c | 2 +- src/gallium/auxiliary/util/u_format.csv | 55 ++++++++-------- src/gallium/auxiliary/util/u_gen_mipmap.c | 22 +++---- src/gallium/auxiliary/util/u_pack_color.h | 66 +++++++++---------- src/gallium/auxiliary/util/u_surface.c | 4 +- src/gallium/auxiliary/util/u_tile.c | 104 +++++++++++++++--------------- 6 files changed, 126 insertions(+), 127 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 858d52c6ef..94be682c4b 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -387,7 +387,7 @@ void debug_dump_image(const char *prefix, /* XXX this is a hack */ switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: r = 2; g = 1; b = 0; diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 45a2776c6c..43d69f1cd8 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -57,57 +57,57 @@ # resolutions for each sized internal format." # Typical rendertarget formats -PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb -PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb -PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb -PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb -PIPE_FORMAT_R8G8B8A8_UNORM_REV , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb -PIPE_FORMAT_R8G8B8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb -PIPE_FORMAT_A1R5G5B5_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb -PIPE_FORMAT_A4R4G4B4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb -PIPE_FORMAT_R5G6B5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb -PIPE_FORMAT_A2B10G10R10_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb +PIPE_FORMAT_B8G8R8A8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, rgb +PIPE_FORMAT_B8G8R8X8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, rgb +PIPE_FORMAT_A8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, rgb +PIPE_FORMAT_X8R8G8B8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, rgb +PIPE_FORMAT_A8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb +PIPE_FORMAT_X8B8G8R8_UNORM , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb +PIPE_FORMAT_B5G5R5A1_UNORM , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb +PIPE_FORMAT_B4G4R4A4_UNORM , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb +PIPE_FORMAT_B5G6R5_UNORM , plain, 1, 1, un5 , un6 , un5 , , zyx1, rgb +PIPE_FORMAT_R10G10B10A2_UNORM , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb # Luminance/Intensity/Alpha formats PIPE_FORMAT_L8_UNORM , plain, 1, 1, un8 , , , , xxx1, rgb PIPE_FORMAT_A8_UNORM , plain, 1, 1, un8 , , , , 000x, rgb PIPE_FORMAT_I8_UNORM , plain, 1, 1, un8 , , , , xxxx, rgb -PIPE_FORMAT_A8L8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb +PIPE_FORMAT_L8A8_UNORM , plain, 1, 1, un8 , un8 , , , xxxy, rgb PIPE_FORMAT_L16_UNORM , plain, 1, 1, un16, , , , xxx1, rgb # SRGB formats PIPE_FORMAT_L8_SRGB , plain, 1, 1, un8 , , , , xxx1, srgb -PIPE_FORMAT_A8L8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb +PIPE_FORMAT_L8A8_SRGB , plain, 1, 1, un8 , un8 , , , xxxy, srgb PIPE_FORMAT_R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , , xyz1, srgb -PIPE_FORMAT_R8G8B8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb -PIPE_FORMAT_R8G8B8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb -PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb -PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb -PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb -PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb +PIPE_FORMAT_A8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, srgb +PIPE_FORMAT_X8B8G8R8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , wzy1, srgb +PIPE_FORMAT_B8G8R8A8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyxw, srgb +PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, srgb +PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb +PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb # Signed formats (typically used for bump map textures) -PIPE_FORMAT_X8B8G8R8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb -PIPE_FORMAT_X8UB8UG8SR8S_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb -PIPE_FORMAT_B6UG5SR5S_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb +PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb +PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb +PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb # Depth-stencil formats PIPE_FORMAT_S8_UNORM , plain, 1, 1, un8 , , , , _x__, zs PIPE_FORMAT_Z16_UNORM , plain, 1, 1, un16, , , , x___, zs PIPE_FORMAT_Z32_UNORM , plain, 1, 1, un32, , , , x___, zs PIPE_FORMAT_Z32_FLOAT , plain, 1, 1, f32 , , , , x___, zs -PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs -PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs -PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un24, un8 , , , x___, zs -PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un8 , un24, , , y___, zs +PIPE_FORMAT_Z24S8_UNORM , plain, 1, 1, un24, un8 , , , xy__, zs +PIPE_FORMAT_S8Z24_UNORM , plain, 1, 1, un8 , un24, , , yx__, zs +PIPE_FORMAT_Z24X8_UNORM , plain, 1, 1, un24, un8 , , , x___, zs +PIPE_FORMAT_X8Z24_UNORM , plain, 1, 1, un8 , un24, , , y___, zs # YUV formats # http://www.fourcc.org/yuv.php#UYVY -PIPE_FORMAT_YCBCR , subsampled, 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_UYVY , subsampled, 2, 1, x32 , , , , xyz1, yuv # http://www.fourcc.org/yuv.php#YUYV (a.k.a http://www.fourcc.org/yuv.php#YUY2) # XXX: u_tile.c's ycbcr_get_tile_rgba actually interprets it as VYUY but the # intent should be to match D3DFMT_YUY2 -PIPE_FORMAT_YCBCR_REV , subsampled, 2, 1, x32 , , , , xyz1, yuv +PIPE_FORMAT_YUYV , subsampled, 2, 1, x32 , , , , xyz1, yuv # Compressed formats PIPE_FORMAT_DXT1_RGB , compressed, 4, 4, x64 , , , , xyz1, rgb @@ -120,7 +120,6 @@ PIPE_FORMAT_DXT3_SRGBA , compressed, 4, 4, x128, , , , xy PIPE_FORMAT_DXT5_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb # Old vector formats -# XXX: Swizzle notation is reversed for these! # See also: # - src/gallium/auxiliary/translate/translate_generic.c # - src/mesa/state_tracker/st_draw.c diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 1d7329d422..9390e8636f 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -922,29 +922,29 @@ format_to_type_comps(enum pipe_format pformat, { /* XXX I think this could be implemented in terms of the pf_*() functions */ switch (pformat) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_R8G8B8A8_SRGB: - case PIPE_FORMAT_R8G8B8X8_SRGB: - case PIPE_FORMAT_A8R8G8B8_SRGB: - case PIPE_FORMAT_X8R8G8B8_SRGB: + case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_A8B8G8R8_SRGB: + case PIPE_FORMAT_X8B8G8R8_SRGB: case PIPE_FORMAT_B8G8R8A8_SRGB: case PIPE_FORMAT_B8G8R8X8_SRGB: + case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_X8R8G8B8_SRGB: case PIPE_FORMAT_R8G8B8_SRGB: *datatype = DTYPE_UBYTE; *comps = 4; return; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: *datatype = DTYPE_USHORT_1_5_5_5_REV; *comps = 4; return; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: *datatype = DTYPE_USHORT_4_4_4_4; *comps = 4; return; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: *datatype = DTYPE_USHORT_5_6_5; *comps = 3; return; @@ -955,8 +955,8 @@ format_to_type_comps(enum pipe_format pformat, *datatype = DTYPE_UBYTE; *comps = 1; return; - case PIPE_FORMAT_A8L8_UNORM: - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_UNORM: + case PIPE_FORMAT_L8A8_SRGB: *datatype = DTYPE_UBYTE; *comps = 2; return; diff --git a/src/gallium/auxiliary/util/u_pack_color.h b/src/gallium/auxiliary/util/u_pack_color.h index 4e4ac7f3da..50f1b1670b 100644 --- a/src/gallium/auxiliary/util/u_pack_color.h +++ b/src/gallium/auxiliary/util/u_pack_color.h @@ -57,47 +57,47 @@ util_pack_color_ub(ubyte r, ubyte g, ubyte b, ubyte a, enum pipe_format format, union util_color *uc) { switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } return; - case PIPE_FORMAT_R8G8B8X8_UNORM: + case PIPE_FORMAT_X8B8G8R8_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: { uc->ui = (a << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: { uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | a; } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: { uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); } return; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: { uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); } return; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: { uc->us = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4); } @@ -153,7 +153,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, ubyte *r, ubyte *g, ubyte *b, ubyte *a) { switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 24) & 0xff); @@ -162,7 +162,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 0) & 0xff); } return; - case PIPE_FORMAT_R8G8B8X8_UNORM: + case PIPE_FORMAT_X8B8G8R8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 24) & 0xff); @@ -171,7 +171,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 16) & 0xff); @@ -180,7 +180,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 24) & 0xff); } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 16) & 0xff); @@ -189,7 +189,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 8) & 0xff); @@ -198,7 +198,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) ((p >> 0) & 0xff); } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: { uint p = uc->ui; *r = (ubyte) ((p >> 8) & 0xff); @@ -207,7 +207,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: { ushort p = uc->us; *r = (ubyte) (((p >> 8) & 0xf8) | ((p >> 13) & 0x7)); @@ -216,7 +216,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) 0xff; } return; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: { ushort p = uc->us; *r = (ubyte) (((p >> 7) & 0xf8) | ((p >> 12) & 0x7)); @@ -225,7 +225,7 @@ util_unpack_color_ub(enum pipe_format format, union util_color *uc, *a = (ubyte) (0xff * (p >> 15)); } return; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: { ushort p = uc->us; *r = (ubyte) (((p >> 4) & 0xf0) | ((p >> 8) & 0xf)); @@ -326,47 +326,47 @@ util_pack_color(const float rgba[4], enum pipe_format format, union util_color * } switch (format) { - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | a; } return; - case PIPE_FORMAT_R8G8B8X8_UNORM: + case PIPE_FORMAT_X8B8G8R8_UNORM: { uc->ui = (r << 24) | (g << 16) | (b << 8) | 0xff; } return; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: { uc->ui = (a << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: { uc->ui = (0xff << 24) | (r << 16) | (g << 8) | b; } return; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | a; } return; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: { uc->ui = (b << 24) | (g << 16) | (r << 8) | 0xff; } return; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: { uc->us = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); } return; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: { uc->us = ((a & 0x80) << 8) | ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | (b >> 3); } return; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: { uc->ub = ((a & 0xf0) << 8) | ((r & 0xf0) << 4) | ((g & 0xf0) << 0) | (b >> 4); } @@ -427,13 +427,13 @@ util_pack_z(enum pipe_format format, double z) return (uint) (z * 0xffffffff); case PIPE_FORMAT_Z32_FLOAT: return (uint)z; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: if (z == 1.0) return 0xffffff; return (uint) (z * 0xffffff); - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: if (z == 1.0) return 0xffffff00; return ((uint) (z * 0xffffff)) << 8; @@ -458,10 +458,10 @@ util_pack_z_stencil(enum pipe_format format, double z, uint s) unsigned packed = util_pack_z(format, z); switch (format) { - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: packed |= s << 24; break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: packed |= s; break; case PIPE_FORMAT_S8_UNORM: diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 948c1e76d0..33306bbc2a 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -54,9 +54,9 @@ util_create_rgba_surface(struct pipe_screen *screen, struct pipe_surface **surfaceOut) { static const enum pipe_format rgbaFormats[] = { - PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM_REV, + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, PIPE_FORMAT_NONE }; const uint target = PIPE_TEXTURE_2D; diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 6000e93a0b..79481b710b 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -108,7 +108,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt, -/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/ +/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/ static void a8r8g8b8_get_tile_rgba(const unsigned *src, @@ -155,7 +155,7 @@ a8r8g8b8_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_X8R8G8B8_UNORM ***/ +/*** PIPE_FORMAT_B8G8R8X8_UNORM ***/ static void x8r8g8b8_get_tile_rgba(const unsigned *src, @@ -201,7 +201,7 @@ x8r8g8b8_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_B8G8R8A8_UNORM ***/ +/*** PIPE_FORMAT_A8R8G8B8_UNORM ***/ static void b8g8r8a8_get_tile_rgba(const unsigned *src, @@ -248,7 +248,7 @@ b8g8r8a8_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_R8G8B8A8_UNORM_REV ***/ +/*** PIPE_FORMAT_A8B8G8R8_UNORM ***/ static void r8g8b8a8_get_tile_rgba(const unsigned *src, @@ -295,7 +295,7 @@ r8g8b8a8_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_A1R5G5B5_UNORM ***/ +/*** PIPE_FORMAT_B5G5R5A1_UNORM ***/ static void a1r5g5b5_get_tile_rgba(const ushort *src, @@ -346,7 +346,7 @@ a1r5g5b5_put_tile_rgba(ushort *dst, } -/*** PIPE_FORMAT_A4R4G4B4_UNORM ***/ +/*** PIPE_FORMAT_B4G4R4A4_UNORM ***/ static void a4r4g4b4_get_tile_rgba(const ushort *src, @@ -397,7 +397,7 @@ a4r4g4b4_put_tile_rgba(ushort *dst, } -/*** PIPE_FORMAT_R5G6B5_UNORM ***/ +/*** PIPE_FORMAT_B5G6R5_UNORM ***/ static void r5g6b5_get_tile_rgba(const ushort *src, @@ -691,7 +691,7 @@ r16g16b16a16_put_tile_rgba(short *dst, } -/*** PIPE_FORMAT_R8G8B8A8_SRGB ***/ +/*** PIPE_FORMAT_A8B8G8R8_SRGB ***/ /** * Convert an 8-bit sRGB value from non-linear space to a @@ -784,7 +784,7 @@ a8r8g8b8_srgb_put_tile_rgba(unsigned *dst, } -/*** PIPE_FORMAT_A8L8_SRGB ***/ +/*** PIPE_FORMAT_L8A8_SRGB ***/ static void a8l8_srgb_get_tile_rgba(const ushort *src, @@ -913,7 +913,7 @@ i8_put_tile_rgba(ubyte *dst, } -/*** PIPE_FORMAT_A8L8_UNORM ***/ +/*** PIPE_FORMAT_L8A8_UNORM ***/ static void a8l8_get_tile_rgba(const ushort *src, @@ -987,7 +987,7 @@ z32_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_S8Z24_UNORM ***/ +/*** PIPE_FORMAT_Z24S8_UNORM ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -1014,7 +1014,7 @@ s8z24_get_tile_rgba(const unsigned *src, } -/*** PIPE_FORMAT_Z24S8_UNORM ***/ +/*** PIPE_FORMAT_S8Z24_UNORM ***/ /** * Return Z component as four float in [0,1]. Stencil part ignored. @@ -1067,7 +1067,7 @@ z32f_get_tile_rgba(const float *src, } -/*** PIPE_FORMAT_YCBCR / PIPE_FORMAT_YCBCR_REV ***/ +/*** PIPE_FORMAT_UYVY / PIPE_FORMAT_YUYV ***/ /** * Convert YCbCr (or YCrCb) to RGBA. @@ -1162,25 +1162,25 @@ pipe_tile_raw_to_rgba(enum pipe_format format, float *dst, unsigned dst_stride) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: a8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: x8r8g8b8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: b8g8r8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: r8g8b8a8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: a1r5g5b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: a4r4g4b4_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: r5g6b5_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_R8G8B8_UNORM: @@ -1195,7 +1195,7 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_I8_UNORM: i8_get_tile_rgba((ubyte *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: a8l8_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_R16_SNORM: @@ -1204,10 +1204,10 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_R16G16B16A16_SNORM: r16g16b16a16_get_tile_rgba((short *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_B8G8R8A8_SRGB: a8r8g8b8_srgb_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_SRGB: a8l8_srgb_get_tile_rgba((ushort *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_L8_SRGB: @@ -1219,21 +1219,21 @@ pipe_tile_raw_to_rgba(enum pipe_format format, case PIPE_FORMAT_Z32_UNORM: z32_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: - s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); - break; case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: + s8z24_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); + break; + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: z24s8_get_tile_rgba((unsigned *) src, w, h, dst, dst_stride); break; case PIPE_FORMAT_Z32_FLOAT: z32f_get_tile_rgba((float *) src, w, h, dst, dst_stride); break; - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, FALSE); break; - case PIPE_FORMAT_YCBCR_REV: + case PIPE_FORMAT_YUYV: ycbcr_get_tile_rgba((ushort *) src, w, h, dst, dst_stride, TRUE); break; default: @@ -1262,7 +1262,7 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, if (!packed) return; - if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV) + if(format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) assert((x & 1) == 0); pipe_get_tile_raw(pt, x, y, w, h, packed, 0); @@ -1291,28 +1291,28 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, return; switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: a8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: x8r8g8b8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: b8g8r8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: r8g8b8a8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: a1r5g5b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: r5g6b5_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_R8G8B8_UNORM: r8g8b8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: a4r4g4b4_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_L8_UNORM: @@ -1324,7 +1324,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, case PIPE_FORMAT_I8_UNORM: i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: a8l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_R16_SNORM: @@ -1333,10 +1333,10 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, case PIPE_FORMAT_R16G16B16A16_SNORM: r16g16b16a16_put_tile_rgba((short *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_B8G8R8A8_SRGB: a8r8g8b8_srgb_put_tile_rgba((unsigned *) packed, w, h, p, src_stride); break; - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_SRGB: a8l8_srgb_put_tile_rgba((ushort *) packed, w, h, p, src_stride); break; case PIPE_FORMAT_L8_SRGB: @@ -1348,12 +1348,12 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, case PIPE_FORMAT_Z32_UNORM: /*z32_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: - /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ - break; case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: + /*s8z24_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ + break; + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: /*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/ break; default: @@ -1405,8 +1405,8 @@ pipe_get_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: { const uint *ptrc = (const uint *)(map + y * pt->stride + x*4); @@ -1420,8 +1420,8 @@ pipe_get_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: { const uint *ptrc = (const uint *)(map + y * pt->stride + x*4); @@ -1489,7 +1489,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); @@ -1503,7 +1503,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); for (i = 0; i < h; i++) { @@ -1516,7 +1516,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE); @@ -1530,7 +1530,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, } } break; - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: { uint *pDest = (uint *) (map + y * pt->stride + x*4); for (i = 0; i < h; i++) { -- cgit v1.2.3 From 7a61722f693a39cdeb4f5ab2e905f563f742d2e3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:09:55 +0000 Subject: draw: Rename pipe formats. --- src/gallium/auxiliary/draw/draw_pipe_vbuf.c | 2 +- src/gallium/auxiliary/draw/draw_pt_emit.c | 2 +- src/gallium/auxiliary/draw/draw_vs_aos_io.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c index d40c035240..2709957961 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_vbuf.c +++ b/src/gallium/auxiliary/draw/draw_pipe_vbuf.c @@ -262,7 +262,7 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim ) src_offset = 0; break; case EMIT_4UB: - output_format = PIPE_FORMAT_B8G8R8A8_UNORM; + output_format = PIPE_FORMAT_A8R8G8B8_UNORM; emit_sz = 4 * sizeof(ubyte); break; default: diff --git a/src/gallium/auxiliary/draw/draw_pt_emit.c b/src/gallium/auxiliary/draw/draw_pt_emit.c index 4fb53276bb..ae357b5122 100644 --- a/src/gallium/auxiliary/draw/draw_pt_emit.c +++ b/src/gallium/auxiliary/draw/draw_pt_emit.c @@ -112,7 +112,7 @@ void draw_pt_emit_prepare( struct pt_emit *emit, src_offset = 0; break; case EMIT_4UB: - output_format = PIPE_FORMAT_B8G8R8A8_UNORM; + output_format = PIPE_FORMAT_A8R8G8B8_UNORM; emit_sz = 4 * sizeof(ubyte); break; default: diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_io.c b/src/gallium/auxiliary/draw/draw_vs_aos_io.c index a6eb37d128..ece1ddde0c 100644 --- a/src/gallium/auxiliary/draw/draw_vs_aos_io.c +++ b/src/gallium/auxiliary/draw/draw_vs_aos_io.c @@ -191,7 +191,7 @@ static boolean load_input( struct aos_compilation *cp, case PIPE_FORMAT_R32G32B32A32_FLOAT: emit_load_R32G32B32A32(cp, dataXMM, src); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: emit_load_R8G8B8A8_UNORM(cp, dataXMM, src); emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W)); break; -- cgit v1.2.3 From a48975347126aacf3a82a5b3e3c69bffd491020a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:10:07 +0000 Subject: translate: Rename pipe formats. --- src/gallium/auxiliary/translate/translate_generic.c | 8 ++++---- src/gallium/auxiliary/translate/translate_sse.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index 24727d4988..c9ec2b32bf 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -392,10 +392,10 @@ static fetch_func get_fetch_func( enum pipe_format format ) case PIPE_FORMAT_R8G8B8A8_SSCALED: return &fetch_R8G8B8A8_SSCALED; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return &fetch_A8R8G8B8_UNORM; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return &fetch_B8G8R8A8_UNORM; case PIPE_FORMAT_R32_FIXED: @@ -551,10 +551,10 @@ static emit_func get_emit_func( enum pipe_format format ) case PIPE_FORMAT_R8G8B8A8_SSCALED: return &emit_R8G8B8A8_SSCALED; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return &emit_A8R8G8B8_UNORM; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return &emit_B8G8R8A8_UNORM; default: diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index c13e742738..03e093c11e 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -336,7 +336,7 @@ static boolean translate_attr( struct translate_sse *p, case PIPE_FORMAT_R32G32B32A32_FLOAT: emit_load_R32G32B32A32(p, dataXMM, srcECX); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: emit_load_R8G8B8A8_UNORM(p, dataXMM, srcECX); emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W)); break; @@ -360,7 +360,7 @@ static boolean translate_attr( struct translate_sse *p, case PIPE_FORMAT_R32G32B32A32_FLOAT: emit_store_R32G32B32A32(p, dstEAX, dataXMM); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W)); emit_store_R8G8B8A8_UNORM(p, dstEAX, dataXMM); break; -- cgit v1.2.3 From c456dd5b4be15b1fe842e03dd40da4505e79e3fa Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:10:41 +0000 Subject: dri: Rename pipe formats. --- src/gallium/state_trackers/dri/dri_drawable.c | 14 +++++++------- src/gallium/state_trackers/dri/dri_screen.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 4809b9090d..173f4041c8 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -349,11 +349,11 @@ dri_create_buffer(__DRIscreen * sPriv, if (visual->redBits == 8) { if (visual->alphaBits == 8) - drawable->color_format = PIPE_FORMAT_A8R8G8B8_UNORM; + drawable->color_format = PIPE_FORMAT_B8G8R8A8_UNORM; else - drawable->color_format = PIPE_FORMAT_X8R8G8B8_UNORM; + drawable->color_format = PIPE_FORMAT_B8G8R8X8_UNORM; } else { - drawable->color_format = PIPE_FORMAT_R5G6B5_UNORM; + drawable->color_format = PIPE_FORMAT_B5G6R5_UNORM; } switch(visual->depthBits) { @@ -367,12 +367,12 @@ dri_create_buffer(__DRIscreen * sPriv, case 24: if (visual->stencilBits == 0) { drawable->depth_stencil_format = (screen->d_depth_bits_last) ? - PIPE_FORMAT_X8Z24_UNORM: - PIPE_FORMAT_Z24X8_UNORM; + PIPE_FORMAT_Z24X8_UNORM: + PIPE_FORMAT_X8Z24_UNORM; } else { drawable->depth_stencil_format = (screen->sd_depth_bits_last) ? - PIPE_FORMAT_S8Z24_UNORM: - PIPE_FORMAT_Z24S8_UNORM; + PIPE_FORMAT_Z24S8_UNORM: + PIPE_FORMAT_S8Z24_UNORM; } break; case 32: diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c index 77d640227f..60bc560049 100644 --- a/src/gallium/state_trackers/dri/dri_screen.c +++ b/src/gallium/state_trackers/dri/dri_screen.c @@ -109,22 +109,22 @@ dri_fill_in_modes(struct dri_screen *screen, stencil_bits_array[0] = 0; depth_buffer_factor = 1; - pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, + pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM, + pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, + pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24S8_UNORM, + pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_A8R8G8B8_UNORM, + pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); - pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8R8G8B8_UNORM, + pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); @@ -139,7 +139,7 @@ dri_fill_in_modes(struct dri_screen *screen, pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); - pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_R5G6B5_UNORM, + pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0); } else { -- cgit v1.2.3 From ae3926011e6bd08ac921209cb4b189df4c255007 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:10:52 +0000 Subject: egl: Rename pipe formats. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 2 +- src/gallium/state_trackers/egl/kms/native_kms.c | 8 ++++---- src/gallium/state_trackers/egl/x11/native_dri2.c | 12 ++++++------ src/gallium/state_trackers/egl/x11/native_ximage.c | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 086e644e21..04268c71c5 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -1097,7 +1097,7 @@ egl_g3d_bind_tex_image(_EGLDriver *drv, _EGLDisplay *dpy, target_format = PIPE_FORMAT_R8G8B8_UNORM; break; case EGL_TEXTURE_RGBA: - target_format = PIPE_FORMAT_A8R8G8B8_UNORM; + target_format = PIPE_FORMAT_B8G8R8A8_UNORM; break; default: return _eglError(EGL_BAD_MATCH, "eglBindTexImage"); diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index ee6ab2e60b..aedf3d430c 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -609,9 +609,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs) /* always double-buffered */ nconf->mode.doubleBufferMode = TRUE; - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = PIPE_FORMAT_B8G8R8A8_UNORM; if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) { - format = PIPE_FORMAT_B8G8R8A8_UNORM; + format = PIPE_FORMAT_A8R8G8B8_UNORM; if (!kms_display_is_format_supported(&kdpy->base, format, TRUE)) format = PIPE_FORMAT_NONE; } @@ -625,9 +625,9 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs) nconf->mode.alphaBits = 8; nconf->mode.rgbBits = 32; - format = PIPE_FORMAT_S8Z24_UNORM; + format = PIPE_FORMAT_Z24S8_UNORM; if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) { - format = PIPE_FORMAT_Z24S8_UNORM; + format = PIPE_FORMAT_S8Z24_UNORM; if (!kms_display_is_format_supported(&kdpy->base, format, FALSE)) format = PIPE_FORMAT_NONE; } diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 8df58891a0..74d3d104b9 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -516,17 +516,17 @@ choose_color_format(const __GLcontextModes *mode, enum pipe_format formats[32]) switch (mode->rgbBits) { case 32: - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; break; case 24: - formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; formats[count++] = PIPE_FORMAT_B8G8R8X8_UNORM; - formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; + formats[count++] = PIPE_FORMAT_X8R8G8B8_UNORM; formats[count++] = PIPE_FORMAT_B8G8R8A8_UNORM; + formats[count++] = PIPE_FORMAT_A8R8G8B8_UNORM; break; case 16: - formats[count++] = PIPE_FORMAT_R5G6B5_UNORM; + formats[count++] = PIPE_FORMAT_B5G6R5_UNORM; break; default: break; @@ -547,12 +547,12 @@ choose_depth_stencil_format(const __GLcontextModes *mode, break; case 24: if (mode->stencilBits) { - formats[count++] = PIPE_FORMAT_S8Z24_UNORM; formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; } else { - formats[count++] = PIPE_FORMAT_X8Z24_UNORM; formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; } break; case 16: diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 8ba73f289d..a8633b1501 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -561,13 +561,13 @@ choose_format(const XVisualInfo *vinfo) /* TODO elaborate the formats */ switch (vinfo->depth) { case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + fmt = PIPE_FORMAT_B8G8R8A8_UNORM; break; case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + fmt = PIPE_FORMAT_B8G8R8X8_UNORM; break; case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; + fmt = PIPE_FORMAT_B5G6R5_UNORM; break; default: fmt = PIPE_FORMAT_NONE; @@ -620,8 +620,8 @@ ximage_display_get_configs(struct native_display *ndpy, int *num_configs) xconf->base.stencil_format = PIPE_FORMAT_NONE; /* create the second config with depth/stencil buffer */ if (j == 1) { - xconf->base.depth_format = PIPE_FORMAT_S8Z24_UNORM; - xconf->base.stencil_format = PIPE_FORMAT_S8Z24_UNORM; + xconf->base.depth_format = PIPE_FORMAT_Z24S8_UNORM; + xconf->base.stencil_format = PIPE_FORMAT_Z24S8_UNORM; mode->depthBits = 24; mode->stencilBits = 8; mode->haveDepthBuffer = TRUE; @@ -669,13 +669,13 @@ ximage_display_is_pixmap_supported(struct native_display *ndpy, depth = x11_drawable_get_depth(xdpy->xscr, (Drawable) pix); switch (depth) { case 32: - fmt = PIPE_FORMAT_A8R8G8B8_UNORM; + fmt = PIPE_FORMAT_B8G8R8A8_UNORM; break; case 24: - fmt = PIPE_FORMAT_X8R8G8B8_UNORM; + fmt = PIPE_FORMAT_B8G8R8X8_UNORM; break; case 16: - fmt = PIPE_FORMAT_R5G6B5_UNORM; + fmt = PIPE_FORMAT_B5G6R5_UNORM; break; default: fmt = PIPE_FORMAT_NONE; -- cgit v1.2.3 From 41b80461b77abbd595d7597bea2a2585875e8a74 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:11:04 +0000 Subject: glx: Rename pipe formats. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 228e6d0a50..68518b19b9 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -277,7 +277,7 @@ choose_pixel_format(XMesaVisual v) return PIPE_FORMAT_R8G8B8A8_UNORM; } else { - return PIPE_FORMAT_R8G8B8A8_UNORM_REV; + return PIPE_FORMAT_A8B8G8R8_UNORM; } } else if ( GET_REDMASK(v) == 0xff0000 @@ -286,10 +286,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; } else { - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_A8R8G8B8_UNORM; } } else if ( GET_REDMASK(v) == 0x0000ff00 @@ -298,10 +298,10 @@ choose_pixel_format(XMesaVisual v) && v->BitsPerPixel == 32) { if (native_byte_order) { /* no byteswapping needed */ - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_A8R8G8B8_UNORM; } else { - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; } } else if ( GET_REDMASK(v) == 0xf800 @@ -310,7 +310,7 @@ choose_pixel_format(XMesaVisual v) && native_byte_order && v->BitsPerPixel == 16) { /* 5-6-5 RGB */ - return PIPE_FORMAT_R5G6B5_UNORM; + return PIPE_FORMAT_B5G6R5_UNORM; } assert(0); @@ -333,8 +333,8 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits, const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); static enum pipe_format formats[] = { - PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM }; -- cgit v1.2.3 From d34a1a7028d76d783bbe0337c1b5613e37b31179 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:11:24 +0000 Subject: xorg: Rename pipe formats. --- src/gallium/state_trackers/xorg/xorg_crtc.c | 2 +- src/gallium/state_trackers/xorg/xorg_dri2.c | 8 ++++---- src/gallium/state_trackers/xorg/xorg_exa.c | 10 +++++----- src/gallium/state_trackers/xorg/xvmc/surface.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 221ce772af..000ec9048f 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -205,7 +205,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) templat.target = PIPE_TEXTURE_2D; templat.last_level = 0; templat.depth0 = 1; - templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templat.format = PIPE_FORMAT_B8G8R8A8_UNORM; templat.width0 = 64; templat.height0 = 64; diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c index 5b67392435..5fc85c0e98 100644 --- a/src/gallium/state_trackers/xorg/xorg_dri2.c +++ b/src/gallium/state_trackers/xorg/xorg_dri2.c @@ -116,12 +116,12 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form break; default: template.format = ms->ds_depth_bits_last ? - PIPE_FORMAT_X8Z24_UNORM : PIPE_FORMAT_Z24X8_UNORM; + PIPE_FORMAT_Z24X8_UNORM : PIPE_FORMAT_X8Z24_UNORM; break; } } else { template.format = ms->ds_depth_bits_last ? - PIPE_FORMAT_S8Z24_UNORM : PIPE_FORMAT_Z24S8_UNORM; + PIPE_FORMAT_Z24S8_UNORM : PIPE_FORMAT_S8Z24_UNORM; } template.width0 = pDraw->width; template.height0 = pDraw->height; @@ -431,11 +431,11 @@ xorg_dri2_init(ScreenPtr pScreen) dri2info.Wait = NULL; ms->d_depth_bits_last = - ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_X8Z24_UNORM, + ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); ms->ds_depth_bits_last = - ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_S8Z24_UNORM, + ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 665efdc0f0..a242e02ee7 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -118,22 +118,22 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_ { switch (depth) { case 32: - *format = PIPE_FORMAT_A8R8G8B8_UNORM; + *format = PIPE_FORMAT_B8G8R8A8_UNORM; *picture_format = PICT_a8r8g8b8; assert(*bbp == 32); break; case 24: - *format = PIPE_FORMAT_X8R8G8B8_UNORM; + *format = PIPE_FORMAT_B8G8R8X8_UNORM; *picture_format = PICT_x8r8g8b8; assert(*bbp == 32); break; case 16: - *format = PIPE_FORMAT_R5G6B5_UNORM; + *format = PIPE_FORMAT_B5G6R5_UNORM; *picture_format = PICT_r5g6b5; assert(*bbp == 16); break; case 15: - *format = PIPE_FORMAT_A1R5G5B5_UNORM; + *format = PIPE_FORMAT_B5G5R5A1_UNORM; *picture_format = PICT_x1r5g5b5; assert(*bbp == 16); break; @@ -144,7 +144,7 @@ exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_ break; case 4: case 1: - *format = PIPE_FORMAT_A8R8G8B8_UNORM; /* bad bad bad */ + *format = PIPE_FORMAT_B8G8R8A8_UNORM; /* bad bad bad */ break; default: assert(0); diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c index 0e39a390c6..87d1dfaace 100644 --- a/src/gallium/state_trackers/xorg/xvmc/surface.c +++ b/src/gallium/state_trackers/xorg/xvmc/surface.c @@ -101,7 +101,7 @@ CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, u memset(&template, 0, sizeof(struct pipe_texture)); template.target = PIPE_TEXTURE_2D; /* XXX: Needs to match the drawable's format? */ - template.format = PIPE_FORMAT_X8R8G8B8_UNORM; + template.format = PIPE_FORMAT_B8G8R8X8_UNORM; template.last_level = 0; template.width0 = width; template.height0 = height; -- cgit v1.2.3 From 5706d7fcaf3c3238c652593d5669b9f793c6cdce Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:11:30 +0000 Subject: wgl: Rename pipe formats. --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index b750b03695..f8edc560c5 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -74,17 +74,17 @@ struct stw_pf_depth_info static const struct stw_pf_color_info stw_pf_color[] = { /* no-alpha */ - { PIPE_FORMAT_X8R8G8B8_UNORM, { 8, 8, 8, 0}, {16, 8, 0, 0} }, - { PIPE_FORMAT_B8G8R8X8_UNORM, { 8, 8, 8, 0}, { 8, 16, 24, 0} }, - { PIPE_FORMAT_R5G6B5_UNORM, { 5, 6, 5, 0}, {11, 5, 0, 0} }, + { PIPE_FORMAT_B8G8R8X8_UNORM, { 8, 8, 8, 0}, {16, 8, 0, 0} }, + { PIPE_FORMAT_X8R8G8B8_UNORM, { 8, 8, 8, 0}, { 8, 16, 24, 0} }, + { PIPE_FORMAT_B5G6R5_UNORM, { 5, 6, 5, 0}, {11, 5, 0, 0} }, /* alpha */ - { PIPE_FORMAT_A8R8G8B8_UNORM, { 8, 8, 8, 8}, {16, 8, 0, 24} }, - { PIPE_FORMAT_B8G8R8A8_UNORM, { 8, 8, 8, 8}, { 8, 16, 24, 0} }, + { PIPE_FORMAT_B8G8R8A8_UNORM, { 8, 8, 8, 8}, {16, 8, 0, 24} }, + { PIPE_FORMAT_A8R8G8B8_UNORM, { 8, 8, 8, 8}, { 8, 16, 24, 0} }, #if 0 - { PIPE_FORMAT_A2B10G10R10_UNORM, {10, 10, 10, 2}, { 0, 10, 20, 30} }, + { PIPE_FORMAT_R10G10B10A2_UNORM, {10, 10, 10, 2}, { 0, 10, 20, 30} }, #endif - { PIPE_FORMAT_A1R5G5B5_UNORM, { 5, 5, 5, 1}, {10, 5, 0, 15} }, - { PIPE_FORMAT_A4R4G4B4_UNORM, { 4, 4, 4, 4}, {16, 4, 0, 12} } + { PIPE_FORMAT_B5G5R5A1_UNORM, { 5, 5, 5, 1}, {10, 5, 0, 15} }, + { PIPE_FORMAT_B4G4R4A4_UNORM, { 4, 4, 4, 4}, {16, 4, 0, 12} } }; @@ -92,12 +92,12 @@ static const struct stw_pf_depth_info stw_pf_depth_stencil[] = { /* pure depth */ { PIPE_FORMAT_Z32_UNORM, {32, 0} }, - { PIPE_FORMAT_Z24X8_UNORM, {24, 0} }, { PIPE_FORMAT_X8Z24_UNORM, {24, 0} }, + { PIPE_FORMAT_Z24X8_UNORM, {24, 0} }, { PIPE_FORMAT_Z16_UNORM, {16, 0} }, /* combined depth-stencil */ - { PIPE_FORMAT_S8Z24_UNORM, {24, 8} }, - { PIPE_FORMAT_Z24S8_UNORM, {24, 8} } + { PIPE_FORMAT_Z24S8_UNORM, {24, 8} }, + { PIPE_FORMAT_S8Z24_UNORM, {24, 8} } }; -- cgit v1.2.3 From b306308757c0ce3cf47a50bac12bb39f212ca6b2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:11:46 +0000 Subject: vega: Rename pipe formats. --- src/gallium/state_trackers/vega/api_filters.c | 2 +- src/gallium/state_trackers/vega/image.c | 10 +++++----- src/gallium/state_trackers/vega/mask.c | 2 +- src/gallium/state_trackers/vega/paint.c | 2 +- src/gallium/state_trackers/vega/vg_tracker.c | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 20c72c1ff5..02248ad433 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -67,7 +67,7 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_1D; - templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templ.format = PIPE_FORMAT_B8G8R8A8_UNORM; templ.last_level = 0; templ.width0 = color_data_len; templ.height0 = 1; diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 2e10965be4..41c979bfec 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -48,16 +48,16 @@ static enum pipe_format vg_format_to_pipe(VGImageFormat format) { switch(format) { case VG_sRGB_565: - return PIPE_FORMAT_R5G6B5_UNORM; + return PIPE_FORMAT_B5G6R5_UNORM; case VG_sRGBA_5551: - return PIPE_FORMAT_A1R5G5B5_UNORM; + return PIPE_FORMAT_B5G5R5A1_UNORM; case VG_sRGBA_4444: - return PIPE_FORMAT_A4R4G4B4_UNORM; + return PIPE_FORMAT_B4G4R4A4_UNORM; case VG_sL_8: case VG_lL_8: return PIPE_FORMAT_L8_UNORM; case VG_BW_1: - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; case VG_A_8: return PIPE_FORMAT_A8_UNORM; #ifdef OPENVG_VERSION_1_1 @@ -66,7 +66,7 @@ static enum pipe_format vg_format_to_pipe(VGImageFormat format) return PIPE_FORMAT_A8_UNORM; #endif default: - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; } } diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c index 467b95b751..839dc19a3b 100644 --- a/src/gallium/state_trackers/vega/mask.c +++ b/src/gallium/state_trackers/vega/mask.c @@ -488,7 +488,7 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height) memset(&pt, 0, sizeof(pt)); pt.target = PIPE_TEXTURE_2D; - pt.format = PIPE_FORMAT_A8R8G8B8_UNORM; + pt.format = PIPE_FORMAT_B8G8R8A8_UNORM; pt.last_level = 0; pt.width0 = width; pt.height0 = height; diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 3405d635f0..caf0c14b74 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -151,7 +151,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) memset(&templ, 0, sizeof(templ)); templ.target = PIPE_TEXTURE_1D; - templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templ.format = PIPE_FORMAT_B8G8R8A8_UNORM; templ.last_level = 0; templ.width0 = 1024; templ.height0 = 1; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index a94dfb160c..57d3baad7f 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -51,7 +51,7 @@ create_texture(struct pipe_context *pipe, enum pipe_format format, templ.format = format; } else { - templ.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templ.format = PIPE_FORMAT_B8G8R8A8_UNORM; } templ.target = PIPE_TEXTURE_2D; @@ -186,7 +186,7 @@ struct st_framebuffer * st_create_framebuffer(const void *visual, if (stencilFormat == depthFormat) stfb->dsrb = st_new_renderbuffer_fb(stencilFormat); else - stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_S8Z24_UNORM); + stfb->dsrb = st_new_renderbuffer_fb(PIPE_FORMAT_Z24S8_UNORM); /*### currently we always allocate it but it's possible it's not necessary if EGL_ALPHA_MASK_SIZE was 0 @@ -209,12 +209,12 @@ static void setup_new_alpha_mask(struct vg_context *ctx, struct pipe_texture *old_texture = stfb->alpha_mask; /* - we use PIPE_FORMAT_A8R8G8B8_UNORM because we want to render to + we use PIPE_FORMAT_B8G8R8A8_UNORM because we want to render to this texture and use it as a sampler, so while this wastes some space it makes both of those a lot simpler */ stfb->alpha_mask = - create_texture(pipe, PIPE_FORMAT_A8R8G8B8_UNORM, width, height); + create_texture(pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); if (!stfb->alpha_mask) { if (old_texture) @@ -327,7 +327,7 @@ void st_resize_framebuffer(struct st_framebuffer *stfb, setup_new_alpha_mask(ctx, stfb, width, height); pipe_texture_reference( &stfb->blend_texture, NULL ); - stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_A8R8G8B8_UNORM, + stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, width, height); } -- cgit v1.2.3 From 0b6e45e1ee55a63db5cb43fe863e054e13e87869 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:11:55 +0000 Subject: python: Rename pipe formats. --- src/gallium/state_trackers/python/st_device.c | 2 +- src/gallium/state_trackers/python/st_sample.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index a3798a5521..45e7841750 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -244,7 +244,7 @@ st_context_create(struct st_device *st_dev) memset( &templat, 0, sizeof( templat ) ); templat.target = PIPE_TEXTURE_2D; - templat.format = PIPE_FORMAT_A8R8G8B8_UNORM; + templat.format = PIPE_FORMAT_B8G8R8A8_UNORM; templat.width0 = 1; templat.height0 = 1; templat.depth0 = 1; diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c index 32a6551a87..e180815346 100644 --- a/src/gallium/state_trackers/python/st_sample.c +++ b/src/gallium/state_trackers/python/st_sample.c @@ -485,7 +485,7 @@ st_sample_generic_pixel_block(enum pipe_format format, w, h, rgba, rgba_stride); - if(format == PIPE_FORMAT_YCBCR || format == PIPE_FORMAT_YCBCR_REV) { + if(format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) { for(y = 0; y < h; ++y) { for(x = 0; x < w; ++x) { for(ch = 0; ch < 4; ++ch) { -- cgit v1.2.3 From c828f784e54fa3bec3c4295dfdffce0ae9fb5e9c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:12:09 +0000 Subject: cell: Rename pipe formats. --- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 30 +++++++++++----------- src/gallium/drivers/cell/ppu/cell_screen.c | 2 +- .../drivers/cell/ppu/cell_state_per_fragment.c | 4 +-- src/gallium/drivers/cell/spu/spu_command.c | 4 +-- src/gallium/drivers/cell/spu/spu_per_fragment_op.c | 18 ++++++------- 5 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c index 70683bb367..576d514741 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c @@ -304,7 +304,7 @@ unpack_colors(struct spe_function *f, spe_comment(f, 0, "Unpack framebuffer colors, convert to floats"); switch (color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: /* fbB = fbRGBA & mask */ spe_and(f, fbB_reg, fbRGBA_reg, mask0_reg); @@ -327,7 +327,7 @@ unpack_colors(struct spe_function *f, spe_roti(f, fbA_reg, fbA_reg, -24); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: /* fbA = fbRGBA & mask */ spe_and(f, fbA_reg, fbRGBA_reg, mask0_reg); @@ -1043,12 +1043,12 @@ gen_pack_colors(struct spe_function *f, spe_rotmi(f, a_reg, a_reg, -24); /* Shift the color bytes according to the surface format */ - if (color_format == PIPE_FORMAT_A8R8G8B8_UNORM) { + if (color_format == PIPE_FORMAT_B8G8R8A8_UNORM) { spe_roti(f, g_reg, g_reg, 8); /* green <<= 8 */ spe_roti(f, r_reg, r_reg, 16); /* red <<= 16 */ spe_roti(f, a_reg, a_reg, 24); /* alpha <<= 24 */ } - else if (color_format == PIPE_FORMAT_B8G8R8A8_UNORM) { + else if (color_format == PIPE_FORMAT_A8R8G8B8_UNORM) { spe_roti(f, r_reg, r_reg, 8); /* red <<= 8 */ spe_roti(f, g_reg, g_reg, 16); /* green <<= 16 */ spe_roti(f, b_reg, b_reg, 24); /* blue <<= 24 */ @@ -1096,14 +1096,14 @@ gen_colormask(struct spe_function *f, * end up, so we can mask them correctly. */ switch(color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: /* ARGB */ a_mask = 0xff000000; r_mask = 0x00ff0000; g_mask = 0x0000ff00; b_mask = 0x000000ff; break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: /* BGRA */ b_mask = 0xff000000; g_mask = 0x00ff0000; @@ -1859,8 +1859,8 @@ gen_depth_stencil(struct cell_context *cell, spe_comment(f, 0, "Fetch Z/stencil quad from tile"); switch(zs_format) { - case PIPE_FORMAT_S8Z24_UNORM: /* fall through */ - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: /* fall through */ + case PIPE_FORMAT_Z24X8_UNORM: /* prepare mask to extract Z vals from ZS vals */ spe_load_uint(f, zmask_reg, 0x00ffffff); @@ -1880,8 +1880,8 @@ gen_depth_stencil(struct cell_context *cell, spe_rotmi(f, fbS_reg, fbZS_reg, -24); break; - case PIPE_FORMAT_Z24S8_UNORM: /* fall through */ - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: /* fall through */ + case PIPE_FORMAT_X8Z24_UNORM: /* convert fragment Z from [0,1] to 32-bit ints */ spe_cfltu(f, fragZ_reg, fragZ_reg, 32); @@ -1969,13 +1969,13 @@ gen_depth_stencil(struct cell_context *cell, * fbS_reg has four 8-bit Z values in bits [7..0]. */ spe_comment(f, 0, "Store quad's depth/stencil values in tile"); - if (zs_format == PIPE_FORMAT_S8Z24_UNORM || - zs_format == PIPE_FORMAT_X8Z24_UNORM) { + if (zs_format == PIPE_FORMAT_Z24S8_UNORM || + zs_format == PIPE_FORMAT_Z24X8_UNORM) { spe_shli(f, fbS_reg, fbS_reg, 24); /* fbS = fbS << 24 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ } - else if (zs_format == PIPE_FORMAT_Z24S8_UNORM || - zs_format == PIPE_FORMAT_Z24X8_UNORM) { + else if (zs_format == PIPE_FORMAT_S8Z24_UNORM || + zs_format == PIPE_FORMAT_X8Z24_UNORM) { spe_shli(f, fbZ_reg, fbZ_reg, 8); /* fbZ = fbZ << 8 */ spe_or(f, fbZS_reg, fbS_reg, fbZ_reg); /* fbZS = fbS | fbZ */ } @@ -2015,7 +2015,7 @@ gen_depth_stencil(struct cell_context *cell, * code before the fragment shader to cull fragments/quads that are * totally occluded/discarded. * - * XXX we only support PIPE_FORMAT_Z24S8_UNORM z/stencil buffer right now. + * XXX we only support PIPE_FORMAT_S8Z24_UNORM z/stencil buffer right now. * * See the spu_default_fragment_ops() function to see how the per-fragment * operations would be done with ordinary C code. diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 449855f539..a43f8638dc 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -136,7 +136,7 @@ cell_is_format_supported( struct pipe_screen *screen, { /* cell supports most formats, XXX for now anyway */ if (format == PIPE_FORMAT_DXT5_RGBA || - format == PIPE_FORMAT_R8G8B8A8_SRGB) + format == PIPE_FORMAT_A8B8G8R8_SRGB) return FALSE; else return TRUE; diff --git a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c index 07be5e92ea..dc33e7ccc2 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c +++ b/src/gallium/drivers/cell/ppu/cell_state_per_fragment.c @@ -1251,7 +1251,7 @@ cell_generate_logic_op(struct spe_function *f, /* Convert fragment colors to framebuffer format in AoS layout. */ switch (surf->format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: data[0] = 0x00010203; data[1] = 0x10111213; data[2] = 0x04050607; @@ -1261,7 +1261,7 @@ cell_generate_logic_op(struct spe_function *f, data[6] = 0x80808080; data[7] = 0x80808080; break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: data[0] = 0x03020100; data[1] = 0x13121110; data[2] = 0x07060504; diff --git a/src/gallium/drivers/cell/spu/spu_command.c b/src/gallium/drivers/cell/spu/spu_command.c index 55bd85bde2..79f1fb7fb2 100644 --- a/src/gallium/drivers/cell/spu/spu_command.c +++ b/src/gallium/drivers/cell/spu/spu_command.c @@ -337,10 +337,10 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd) spu.fb.zsize = 4; spu.fb.zscale = (float) 0xffffffffu; break; - case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: spu.fb.zsize = 4; spu.fb.zscale = (float) 0x00ffffffu; break; 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 5328374080..2c9e7458af 100644 --- a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c +++ b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c @@ -138,14 +138,14 @@ spu_fallback_fragment_ops(uint x, uint y, if (spu.depth_stencil_alpha.stencil[0].enabled) { /* do stencil test */ - ASSERT(spu.fb.depth_format == PIPE_FORMAT_S8Z24_UNORM); + ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM); } else if (spu.depth_stencil_alpha.depth.enabled) { /* do depth test */ - ASSERT(spu.fb.depth_format == PIPE_FORMAT_S8Z24_UNORM || - spu.fb.depth_format == PIPE_FORMAT_X8Z24_UNORM); + ASSERT(spu.fb.depth_format == PIPE_FORMAT_Z24S8_UNORM || + spu.fb.depth_format == PIPE_FORMAT_Z24X8_UNORM); vector unsigned int ifragZ; vector unsigned int zmask; @@ -240,13 +240,13 @@ spu_fallback_fragment_ops(uint x, uint y, { vector float temp[4]; /* float colors in AOS form */ switch (spu.fb.color_format) { - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: temp[0] = spu_unpack_B8G8R8A8(fbc0); temp[1] = spu_unpack_B8G8R8A8(fbc1); temp[2] = spu_unpack_B8G8R8A8(fbc2); temp[3] = spu_unpack_B8G8R8A8(fbc3); break; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: temp[0] = spu_unpack_A8R8G8B8(fbc0); temp[1] = spu_unpack_A8R8G8B8(fbc1); temp[2] = spu_unpack_A8R8G8B8(fbc2); @@ -506,13 +506,13 @@ spu_fallback_fragment_ops(uint x, uint y, * Pack fragment float colors into 32-bit RGBA words. */ switch (spu.fb.color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: fragc0 = spu_pack_A8R8G8B8(frag_aos[0]); fragc1 = spu_pack_A8R8G8B8(frag_aos[1]); fragc2 = spu_pack_A8R8G8B8(frag_aos[2]); fragc3 = spu_pack_A8R8G8B8(frag_aos[3]); break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: fragc0 = spu_pack_B8G8R8A8(frag_aos[0]); fragc1 = spu_pack_B8G8R8A8(frag_aos[1]); fragc2 = spu_pack_B8G8R8A8(frag_aos[2]); @@ -532,7 +532,7 @@ spu_fallback_fragment_ops(uint x, uint y, /* Form bitmask depending on color buffer format and colormask bits */ switch (spu.fb.color_format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: if (spu.blend.rt[0].colormask & PIPE_MASK_R) cmask |= 0x00ff0000; /* red */ if (spu.blend.rt[0].colormask & PIPE_MASK_G) @@ -542,7 +542,7 @@ spu_fallback_fragment_ops(uint x, uint y, if (spu.blend.rt[0].colormask & PIPE_MASK_A) cmask |= 0xff000000; /* alpha */ break; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: if (spu.blend.rt[0].colormask & PIPE_MASK_R) cmask |= 0x0000ff00; /* red */ if (spu.blend.rt[0].colormask & PIPE_MASK_G) -- cgit v1.2.3 From b2b1e899f64ed8a96ea2df6ed45accd430d44363 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:12:19 +0000 Subject: i915g: Rename pipe formats. --- src/gallium/drivers/i915/i915_screen.c | 20 ++++++++++---------- src/gallium/drivers/i915/i915_state_emit.c | 8 ++++---- src/gallium/drivers/i915/i915_state_sampler.c | 20 ++++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index eec2b2895f..72bd263550 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -165,22 +165,22 @@ i915_is_format_supported(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format tex_supported[] = { - PIPE_FORMAT_R8G8B8A8_UNORM_REV, - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM, 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, + PIPE_FORMAT_L8A8_UNORM, + PIPE_FORMAT_UYVY, + PIPE_FORMAT_YUYV, + PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_NONE /* list terminator */ }; static const enum pipe_format surface_supported[] = { - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_NONE /* list terminator */ }; const enum pipe_format *list; diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index a3d4e3b04e..d2ab530d98 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -37,9 +37,9 @@ static unsigned translate_format( enum pipe_format format ) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return COLOR_BUF_ARGB8888; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return COLOR_BUF_RGB565; default: assert(0); @@ -50,7 +50,7 @@ static unsigned translate_format( enum pipe_format format ) static unsigned translate_depth_format( enum pipe_format zformat ) { switch (zformat) { - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return DEPTH_FRMT_24_FIXED_8_OTHER; case PIPE_FORMAT_Z16_UNORM: return DEPTH_FRMT_16_FIXED; @@ -259,7 +259,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) if (cbuf_surface) cformat = cbuf_surface->format; else - cformat = PIPE_FORMAT_A8R8G8B8_UNORM; /* arbitrary */ + cformat = PIPE_FORMAT_B8G8R8A8_UNORM; /* arbitrary */ cformat = translate_format(cformat); if (depth_surface) diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c index e5c6d87215..9813290b51 100644 --- a/src/gallium/drivers/i915/i915_state_sampler.c +++ b/src/gallium/drivers/i915/i915_state_sampler.c @@ -87,8 +87,8 @@ static void update_sampler(struct i915_context *i915, state[1] = sampler->state[1]; state[2] = sampler->state[2]; - if (pt->format == PIPE_FORMAT_YCBCR || - pt->format == PIPE_FORMAT_YCBCR_REV) + if (pt->format == PIPE_FORMAT_UYVY || + pt->format == PIPE_FORMAT_YUYV) state[0] |= SS2_COLORSPACE_CONVERSION; /* 3D textures don't seem to respect the border color. @@ -180,19 +180,19 @@ translate_texture_format(enum pipe_format pipeFormat) return MAPSURF_8BIT | MT_8BIT_I8; case PIPE_FORMAT_A8_UNORM: return MAPSURF_8BIT | MT_8BIT_A8; - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return MAPSURF_16BIT | MT_16BIT_AY88; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return MAPSURF_16BIT | MT_16BIT_RGB565; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return MAPSURF_16BIT | MT_16BIT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return MAPSURF_16BIT | MT_16BIT_ARGB4444; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return MAPSURF_32BIT | MT_32BIT_ARGB8888; - case PIPE_FORMAT_YCBCR_REV: + case PIPE_FORMAT_YUYV: return (MAPSURF_422 | MT_422_YCRCB_NORMAL); - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return (MAPSURF_422 | MT_422_YCRCB_SWAPY); #if 0 case PIPE_FORMAT_RGB_FXT1: @@ -210,7 +210,7 @@ translate_texture_format(enum pipe_format pipeFormat) case PIPE_FORMAT_RGBA_DXT5: return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5); #endif - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return (MAPSURF_32BIT | MT_32BIT_xI824); default: debug_printf("i915: translate_texture_format() bad image format %x\n", -- cgit v1.2.3 From 4710040617d0d7233da2c9c8fbdc41e79b39937a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:12:25 +0000 Subject: i965: Rename pipe formats. --- src/gallium/drivers/i965/brw_misc_state.c | 4 ++-- src/gallium/drivers/i965/brw_pipe_clear.c | 8 +++---- src/gallium/drivers/i965/brw_screen.c | 34 +++++++++++++-------------- src/gallium/drivers/i965/brw_screen_texture.c | 24 +++++++++---------- src/gallium/drivers/i965/brw_wm.c | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_misc_state.c b/src/gallium/drivers/i965/brw_misc_state.c index e4b24229db..e3f25bdf62 100644 --- a/src/gallium/drivers/i965/brw_misc_state.c +++ b/src/gallium/drivers/i965/brw_misc_state.c @@ -265,8 +265,8 @@ static int emit_depthbuffer(struct brw_context *brw) format = BRW_DEPTHFORMAT_D16_UNORM; cpp = 2; break; - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT; cpp = 4; break; diff --git a/src/gallium/drivers/i965/brw_pipe_clear.c b/src/gallium/drivers/i965/brw_pipe_clear.c index 452e1e89f9..d7048f769b 100644 --- a/src/gallium/drivers/i965/brw_pipe_clear.c +++ b/src/gallium/drivers/i965/brw_pipe_clear.c @@ -139,8 +139,8 @@ static void zstencil_clear(struct brw_context *brw, unsigned value; switch (bsurface->base.format) { - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: value = ((unsigned)(depth * MASK24) & MASK24); break; case PIPE_FORMAT_Z16_UNORM: @@ -152,8 +152,8 @@ static void zstencil_clear(struct brw_context *brw, } switch (bsurface->base.format) { - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: value = value | (stencil << 24); break; diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index b03a782a2f..66f3aad8b2 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -229,15 +229,15 @@ brw_is_format_supported(struct pipe_screen *screen, PIPE_FORMAT_L16_UNORM, /*PIPE_FORMAT_I16_UNORM,*/ /*PIPE_FORMAT_A16_UNORM,*/ - PIPE_FORMAT_A8L8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_A1R5G5B5_UNORM, - PIPE_FORMAT_A4R4G4B4_UNORM, - PIPE_FORMAT_X8R8G8B8_UNORM, - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_L8A8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B4G4R4A4_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, /* video */ - PIPE_FORMAT_YCBCR, - PIPE_FORMAT_YCBCR_REV, + PIPE_FORMAT_UYVY, + PIPE_FORMAT_YUYV, /* compressed */ /*PIPE_FORMAT_FXT1_RGBA,*/ PIPE_FORMAT_DXT1_RGB, @@ -245,14 +245,14 @@ brw_is_format_supported(struct pipe_screen *screen, PIPE_FORMAT_DXT3_RGBA, PIPE_FORMAT_DXT5_RGBA, /* sRGB */ - PIPE_FORMAT_R8G8B8A8_SRGB, - PIPE_FORMAT_A8L8_SRGB, + PIPE_FORMAT_A8B8G8R8_SRGB, + PIPE_FORMAT_L8A8_SRGB, PIPE_FORMAT_L8_SRGB, PIPE_FORMAT_DXT1_SRGB, /* depth */ PIPE_FORMAT_Z32_FLOAT, - PIPE_FORMAT_X8Z24_UNORM, - PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z16_UNORM, /* signed */ PIPE_FORMAT_R8G8_SNORM, @@ -260,15 +260,15 @@ brw_is_format_supported(struct pipe_screen *screen, PIPE_FORMAT_NONE /* list terminator */ }; static const enum pipe_format render_supported[] = { - PIPE_FORMAT_X8R8G8B8_UNORM, - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_NONE /* list terminator */ }; static const enum pipe_format depth_supported[] = { PIPE_FORMAT_Z32_FLOAT, - PIPE_FORMAT_X8Z24_UNORM, - PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_NONE /* list terminator */ }; diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index 38e9961398..e38fdf1869 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -85,32 +85,32 @@ static GLuint translate_tex_format( enum pipe_format pf ) return BRW_SURFACEFORMAT_A16_UNORM; */ - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return BRW_SURFACEFORMAT_L8A8_UNORM; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return BRW_SURFACEFORMAT_B5G6R5_UNORM; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return BRW_SURFACEFORMAT_B5G5R5A1_UNORM; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return BRW_SURFACEFORMAT_B4G4R4A4_UNORM; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return BRW_SURFACEFORMAT_R8G8B8X8_UNORM; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return BRW_SURFACEFORMAT_B8G8R8A8_UNORM; /* * Video formats */ - case PIPE_FORMAT_YCBCR_REV: + case PIPE_FORMAT_YUYV: return BRW_SURFACEFORMAT_YCRCB_NORMAL; - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return BRW_SURFACEFORMAT_YCRCB_SWAPUVY; /* @@ -137,10 +137,10 @@ static GLuint translate_tex_format( enum pipe_format pf ) * sRGB formats */ - case PIPE_FORMAT_R8G8B8A8_SRGB: + case PIPE_FORMAT_A8B8G8R8_SRGB: return BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB; - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_SRGB: return BRW_SURFACEFORMAT_L8A8_UNORM_SRGB; case PIPE_FORMAT_L8_SRGB: @@ -156,8 +156,8 @@ static GLuint translate_tex_format( enum pipe_format pf ) case PIPE_FORMAT_Z16_UNORM: return BRW_SURFACEFORMAT_I16_UNORM; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: return BRW_SURFACEFORMAT_I24X8_UNORM; case PIPE_FORMAT_Z32_FLOAT: diff --git a/src/gallium/drivers/i965/brw_wm.c b/src/gallium/drivers/i965/brw_wm.c index 5164c90ed6..dfb718e64f 100644 --- a/src/gallium/drivers/i965/brw_wm.c +++ b/src/gallium/drivers/i965/brw_wm.c @@ -254,10 +254,10 @@ static void brw_wm_populate_key( struct brw_context *brw, for (i = 0; i < brw->curr.num_textures; i++) { const struct brw_texture *tex = brw_texture(brw->curr.texture[i]); - if (tex->base.format == PIPE_FORMAT_YCBCR) + if (tex->base.format == PIPE_FORMAT_UYVY) key->yuvtex_mask |= 1 << i; - if (tex->base.format == PIPE_FORMAT_YCBCR_REV) + if (tex->base.format == PIPE_FORMAT_YUYV) key->yuvtex_swap_mask |= 1 << i; /* XXX: shadow texture -- cgit v1.2.3 From 33080a8454ef5d6443c9b7211ab1e71888679f9f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:12:38 +0000 Subject: llvmpipe: Rename pipe formats. --- src/gallium/drivers/llvmpipe/lp_test_format.c | 48 +++++++++++++-------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index 48828bd0a0..d05157991b 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -52,25 +52,25 @@ struct pixel_test_case struct pixel_test_case test_cases[] = { - {PIPE_FORMAT_R5G6B5_UNORM, 0x0000, {0.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_R5G6B5_UNORM, 0x001f, {0.0, 0.0, 1.0, 1.0}}, - {PIPE_FORMAT_R5G6B5_UNORM, 0x07e0, {0.0, 1.0, 0.0, 1.0}}, - {PIPE_FORMAT_R5G6B5_UNORM, 0xf800, {1.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_R5G6B5_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}}, - - {PIPE_FORMAT_A1R5G5B5_UNORM, 0x0000, {0.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_A1R5G5B5_UNORM, 0x001f, {0.0, 0.0, 1.0, 0.0}}, - {PIPE_FORMAT_A1R5G5B5_UNORM, 0x03e0, {0.0, 1.0, 0.0, 0.0}}, - {PIPE_FORMAT_A1R5G5B5_UNORM, 0x7c00, {1.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_A1R5G5B5_UNORM, 0x8000, {0.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_A1R5G5B5_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, 0x0000, {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, 0x001f, {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, 0x07e0, {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, 0xf800, {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_B5G5R5A1_UNORM, 0x0000, {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, 0x001f, {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, 0x03e0, {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, 0x7c00, {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, 0x8000, {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, 0xffff, {1.0, 1.0, 1.0, 1.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0x000000ff, {0.0, 0.0, 1.0, 0.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0x0000ff00, {0.0, 1.0, 0.0, 0.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0x00ff0000, {1.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0xff000000, {0.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_A8R8G8B8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0x000000ff, {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0x0000ff00, {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0x00ff0000, {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0xff000000, {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}}, #if 0 {PIPE_FORMAT_R8G8B8A8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}}, @@ -81,12 +81,12 @@ struct pixel_test_case test_cases[] = {PIPE_FORMAT_R8G8B8A8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}}, #endif - {PIPE_FORMAT_B8G8R8A8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_B8G8R8A8_UNORM, 0x000000ff, {0.0, 0.0, 0.0, 1.0}}, - {PIPE_FORMAT_B8G8R8A8_UNORM, 0x0000ff00, {1.0, 0.0, 0.0, 0.0}}, - {PIPE_FORMAT_B8G8R8A8_UNORM, 0x00ff0000, {0.0, 1.0, 0.0, 0.0}}, - {PIPE_FORMAT_B8G8R8A8_UNORM, 0xff000000, {0.0, 0.0, 1.0, 0.0}}, - {PIPE_FORMAT_B8G8R8A8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0x00000000, {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0x000000ff, {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0x0000ff00, {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0x00ff0000, {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0xff000000, {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, 0xffffffff, {1.0, 1.0, 1.0, 1.0}}, }; -- cgit v1.2.3 From c9f1db0a03b6d89f8b1113785aa961e6c9a398ef Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:13:32 +0000 Subject: nouveau: Rename pipe formats. --- src/gallium/drivers/nouveau/nv04_surface_2d.c | 34 +++++++++++++-------------- src/gallium/drivers/nv30/nv30_miptree.c | 8 +++---- src/gallium/drivers/nv30/nv30_screen.c | 22 ++++++++--------- src/gallium/drivers/nv30/nv30_state_fb.c | 10 ++++---- src/gallium/drivers/nv40/nv40_miptree.c | 4 ++-- src/gallium/drivers/nv40/nv40_screen.c | 20 ++++++++-------- src/gallium/drivers/nv40/nv40_state_fb.c | 10 ++++---- src/gallium/drivers/nv50/nv50_miptree.c | 6 ++--- src/gallium/drivers/nv50/nv50_screen.c | 28 +++++++++++----------- src/gallium/drivers/nv50/nv50_surface.c | 6 ++--- 10 files changed, 74 insertions(+), 74 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.c b/src/gallium/drivers/nouveau/nv04_surface_2d.c index 42c2ca932d..b074547c4d 100644 --- a/src/gallium/drivers/nouveau/nv04_surface_2d.c +++ b/src/gallium/drivers/nouveau/nv04_surface_2d.c @@ -18,15 +18,15 @@ nv04_surface_format(enum pipe_format format) case PIPE_FORMAT_I8_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8; case PIPE_FORMAT_R16_SNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5; - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32; default: return -1; @@ -39,14 +39,14 @@ nv04_rect_format(enum pipe_format format) switch (format) { case PIPE_FORMAT_A8_UNORM: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_Z16_UNORM: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5; - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8; default: return -1; @@ -61,15 +61,15 @@ nv04_scaled_image_format(enum pipe_format format) case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_I8_UNORM: return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_R16_SNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5; default: return -1; diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index c29c36e20a..697b1b92ff 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -88,11 +88,11 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) else { switch (pt->format) { /* TODO: Figure out which formats can be swizzled */ - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_R16_SNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_I8_UNORM: diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index aef37d303d..85433d2095 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -112,8 +112,8 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen, if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return TRUE; default: break; @@ -121,12 +121,12 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen, } else if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: return TRUE; case PIPE_FORMAT_Z16_UNORM: if (front) { - return (front->format == PIPE_FORMAT_R5G6B5_UNORM); + return (front->format == PIPE_FORMAT_B5G6R5_UNORM); } return TRUE; default: @@ -134,16 +134,16 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen, } } else { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return TRUE; default: break; diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 2ed2ea55e8..f7fe9833c7 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -66,14 +66,14 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) } switch (colour_format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8; break; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: case 0: rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8; break; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5; colour_bits = 16; break; @@ -86,8 +86,8 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16; zeta_bits = 16; break; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: case 0: rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8; break; diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c index ad1a9a5195..85d7e1f197 100644 --- a/src/gallium/drivers/nv40/nv40_miptree.c +++ b/src/gallium/drivers/nv40/nv40_miptree.c @@ -90,8 +90,8 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) else { switch (pt->format) { /* TODO: Figure out which formats can be swizzled */ - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_R16_SNORM: { if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE)) diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index edee4b9a3a..b216c5e38c 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -98,8 +98,8 @@ nv40_screen_surface_format_supported(struct pipe_screen *pscreen, { if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return TRUE; default: break; @@ -107,8 +107,8 @@ nv40_screen_surface_format_supported(struct pipe_screen *pscreen, } else if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_Z16_UNORM: return TRUE; default: @@ -116,17 +116,17 @@ nv40_screen_surface_format_supported(struct pipe_screen *pscreen, } } else { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_R16_SNORM: case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_Z16_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c index a58fe9ddb1..fd3fdfddc0 100644 --- a/src/gallium/drivers/nv40/nv40_state_fb.c +++ b/src/gallium/drivers/nv40/nv40_state_fb.c @@ -57,14 +57,14 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) rt_format = NV40TCL_RT_FORMAT_TYPE_LINEAR; switch (colour_format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: rt_format |= NV40TCL_RT_FORMAT_COLOR_X8R8G8B8; break; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: case 0: rt_format |= NV40TCL_RT_FORMAT_COLOR_A8R8G8B8; break; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: rt_format |= NV40TCL_RT_FORMAT_COLOR_R5G6B5; break; default: @@ -75,8 +75,8 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40) case PIPE_FORMAT_Z16_UNORM: rt_format |= NV40TCL_RT_FORMAT_ZETA_Z16; break; - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: case 0: rt_format |= NV40TCL_RT_FORMAT_ZETA_Z24S8; break; diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index 7297c74a83..3f9d869d7a 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -89,14 +89,14 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) case PIPE_FORMAT_Z32_FLOAT: tile_flags = 0x4800; break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: tile_flags = 0x1800; break; case PIPE_FORMAT_Z16_UNORM: tile_flags = 0x6c00; break; - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: tile_flags = 0x2800; break; case PIPE_FORMAT_R32G32B32A32_FLOAT: diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 2232461b9b..eed6031eaf 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -35,9 +35,9 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, { if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { switch (format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_R16G16B16A16_SNORM: case PIPE_FORMAT_R16G16B16A16_UNORM: case PIPE_FORMAT_R32G32B32A32_FLOAT: @@ -51,32 +51,32 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { case PIPE_FORMAT_Z32_FLOAT: - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return TRUE; default: break; } } else { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_SRGB: - case PIPE_FORMAT_X8R8G8B8_SRGB: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_SRGB: + case PIPE_FORMAT_B8G8R8X8_SRGB: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: case PIPE_FORMAT_L8_UNORM: case PIPE_FORMAT_A8_UNORM: case PIPE_FORMAT_I8_UNORM: - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: - case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z32_FLOAT: case PIPE_FORMAT_R16G16B16A16_SNORM: case PIPE_FORMAT_R16G16B16A16_UNORM: diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index 7405b67414..cabd148bc5 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -33,11 +33,11 @@ static INLINE int nv50_format(enum pipe_format format) { switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return NV50_2D_DST_FORMAT_A8R8G8B8_UNORM; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return NV50_2D_DST_FORMAT_X8R8G8B8_UNORM; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return NV50_2D_DST_FORMAT_R5G6B5_UNORM; case PIPE_FORMAT_A8_UNORM: return NV50_2D_DST_FORMAT_R8_UNORM; -- cgit v1.2.3 From d41ab94d35cb47effbd2582289298be4f13c50e4 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Mon, 1 Mar 2010 04:44:02 +0200 Subject: glapi.c: misc coscmetic for FreeTSD - move out of of the dispatch/context block to after corresponding init functions - use more consistent naming with corresponding init functions - XXX use _glthread_InitTSD() vs (void)_glthread_GetTSD() in _glapi_check_multithread() XXX --- src/gallium/state_trackers/wgl/stw_device.c | 4 ++-- src/mesa/glapi/glapi.c | 35 +++++++++++++++++++---------- src/mesa/glapi/glapi.h | 8 +++++++ src/mesa/glapi/glthread.c | 23 ++++++++++--------- src/mesa/glapi/glthread.h | 4 ++++ 5 files changed, 50 insertions(+), 24 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index e5fa6ac8eb..472a2a5379 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -47,7 +47,6 @@ #ifdef WIN32_THREADS extern _glthread_Mutex OneTimeLock; -extern void FreeAllTSD(void); #endif @@ -183,7 +182,8 @@ stw_cleanup(void) #ifdef WIN32_THREADS _glthread_DESTROY_MUTEX(OneTimeLock); - FreeAllTSD(); + + _glapi_destroy_multithread(); #endif #ifdef DEBUG diff --git a/src/mesa/glapi/glapi.c b/src/mesa/glapi/glapi.c index fe523073ca..056abd7233 100644 --- a/src/mesa/glapi/glapi.c +++ b/src/mesa/glapi/glapi.c @@ -118,15 +118,6 @@ _glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */ static _glthread_TSD ContextTSD; /**< Per-thread context pointer */ -#if defined(WIN32_THREADS) -void FreeTSD(_glthread_TSD *p); -void FreeAllTSD(void) -{ - FreeTSD(&_gl_DispatchTSD); - FreeTSD(&ContextTSD); -} -#endif /* defined(WIN32_THREADS) */ - #endif /* defined(THREADS) */ PUBLIC struct _glapi_table *_glapi_Dispatch = (struct _glapi_table *) __glapi_noop_table; @@ -140,6 +131,22 @@ PUBLIC void *_glapi_Context = NULL; #if defined(THREADS) && !defined(GLX_USE_TLS) +void +_glapi_init_multithread(void) +{ + _glthread_InitTSD(&_gl_DispatchTSD); + _glthread_InitTSD(&ContextTSD); +} + +void +_glapi_destroy_multithread(void) +{ +#ifdef WIN32_THREADS + _glthread_DestroyTSD(&_gl_DispatchTSD); + _glthread_DestroyTSD(&ContextTSD); +#endif +} + /** * Mutex for multithread check. */ @@ -168,9 +175,7 @@ _glapi_check_multithread(void) CHECK_MULTITHREAD_LOCK(); if (firstCall) { - /* initialize TSDs */ - (void) _glthread_GetTSD(&ContextTSD); - (void) _glthread_GetTSD(&_gl_DispatchTSD); + _glapi_init_multithread(void) knownID = _glthread_GetID(); firstCall = GL_FALSE; @@ -185,6 +190,12 @@ _glapi_check_multithread(void) #else +void +_glapi_init_multithread(void) { } + +void +_glapi_destroy_multithread(void) { } + PUBLIC void _glapi_check_multithread(void) { } diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 0abec5df76..2eae6d5c43 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -121,6 +121,14 @@ extern void *_glapi_Context; ** GL API public functions **/ +extern void +_glapi_init_multithread(void); + + +extern void +_glapi_destroy_multithread(void); + + extern void _glapi_check_multithread(void); diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c index be4e2f754d..15401d730e 100644 --- a/src/mesa/glapi/glthread.c +++ b/src/mesa/glapi/glthread.c @@ -190,17 +190,9 @@ _glthread_SetTSD(_glthread_TSD *tsd, void *ptr) */ #ifdef WIN32_THREADS -void FreeTSD(_glthread_TSD *p) +static void InsteadOf_exit(int nCode) { - if (p->initMagic==INIT_MAGIC) { - TlsFree(p->key); - p->initMagic=0; - } -} - -void InsteadOf_exit(int nCode) -{ - DWORD dwErr=GetLastError(); + DWORD dwErr = GetLastError(); } PUBLIC unsigned long @@ -222,6 +214,17 @@ _glthread_InitTSD(_glthread_TSD *tsd) } +void +_glthread_DestroyTSD(_glthread_TSD *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + return; + } + TlsFree(tsd->key); + tsd->initMagic = 0x0; +} + + void * _glthread_GetTSD(_glthread_TSD *tsd) { diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index be39501395..389c24204b 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -315,6 +315,10 @@ extern void _glthread_InitTSD(_glthread_TSD *); +extern void +_glthread_DestroyTSD(_glthread_TSD *); /* WIN32 only */ + + extern void * _glthread_GetTSD(_glthread_TSD *); -- cgit v1.2.3 From 5bf4ff7dabfffd0018382d440682bd5f7d418606 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 20:11:36 +0100 Subject: nv30: adapt to vertex element cso --- src/gallium/drivers/nv30/nv30_context.h | 8 ++++++-- src/gallium/drivers/nv30/nv30_state.c | 34 +++++++++++++++++++++++++++------ src/gallium/drivers/nv30/nv30_vbo.c | 8 ++++---- 3 files changed, 38 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index ca3d6aca7f..e48f531b94 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -108,6 +108,11 @@ struct nv30_state { struct nouveau_stateobj *hw[NV30_STATE_MAX]; }; +struct nv30_vtxelt_state { + struct pipe_vertex_element pipe[16]; + unsigned num_elements; +}; + struct nv30_context { struct pipe_context pipe; @@ -143,8 +148,7 @@ struct nv30_context { unsigned dirty_samplers; struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned vtxbuf_nr; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; - unsigned vtxelt_nr; + struct nv30_vtxelt_state *vtxelt; }; static INLINE struct nv30_context * diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c index d911c80707..24b15a63ac 100644 --- a/src/gallium/drivers/nv30/nv30_state.c +++ b/src/gallium/drivers/nv30/nv30_state.c @@ -669,15 +669,34 @@ nv30_set_vertex_buffers(struct pipe_context *pipe, unsigned count, /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/ } +static void * +nv30_vtxelts_state_create(struct pipe_context *pipe, + unsigned num_elements, + const struct pipe_vertex_element *elements) +{ + struct nv30_vtxelt_state *cso = CALLOC_STRUCT(nv30_vtxelt_state); + + assert(num_elements < 16); /* not doing fallbacks yet */ + cso->num_elements = num_elements; + memcpy(cso->pipe, elements, num_elements * sizeof(*elements)); + +/* nv30_vtxelt_construct(cso);*/ + + return (void *)cso; +} + static void -nv30_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *ve) +nv30_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso) { - struct nv30_context *nv30 = nv30_context(pipe); + FREE(hwcso); +} - memcpy(nv30->vtxelt, ve, sizeof(*ve) * count); - nv30->vtxelt_nr = count; +static void +nv30_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso) +{ + struct nv30_context *nv30 = nv30_context(pipe); + nv30->vtxelt = hwcso; nv30->dirty |= NV30_NEW_ARRAYS; /*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/ } @@ -722,7 +741,10 @@ nv30_init_state_functions(struct nv30_context *nv30) nv30->pipe.set_scissor_state = nv30_set_scissor_state; nv30->pipe.set_viewport_state = nv30_set_viewport_state; + nv30->pipe.create_vertex_elements_state = nv30_vtxelts_state_create; + nv30->pipe.delete_vertex_elements_state = nv30_vtxelts_state_delete; + nv30->pipe.bind_vertex_elements_state = nv30_vtxelts_state_bind; + nv30->pipe.set_vertex_buffers = nv30_set_vertex_buffers; - nv30->pipe.set_vertex_elements = nv30_set_vertex_elements; } diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c index e48823a913..f3856bb5a5 100644 --- a/src/gallium/drivers/nv30/nv30_vbo.c +++ b/src/gallium/drivers/nv30/nv30_vbo.c @@ -492,16 +492,16 @@ nv30_vbo_validate(struct nv30_context *nv30) int hw; vtxbuf = so_new(3, 17, 18); - so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt_nr); + so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt->num_elements); vtxfmt = so_new(1, 16, 0); - so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt_nr); + so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt->num_elements); - for (hw = 0; hw < nv30->vtxelt_nr; hw++) { + for (hw = 0; hw < nv30->vtxelt->num_elements; hw++) { struct pipe_vertex_element *ve; struct pipe_vertex_buffer *vb; unsigned type, ncomp; - ve = &nv30->vtxelt[hw]; + ve = &nv30->vtxelt->pipe[hw]; vb = &nv30->vtxbuf[ve->vertex_buffer_index]; if (!vb->stride) { -- cgit v1.2.3 From ddccf7797425097ee6562290d3476075c38220b0 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Mon, 1 Mar 2010 20:11:47 +0100 Subject: nv40: adapt to vertex element cso --- src/gallium/drivers/nv40/nv40_context.h | 9 ++++++-- src/gallium/drivers/nv40/nv40_state.c | 34 ++++++++++++++++++++++++------ src/gallium/drivers/nv40/nv40_state_emit.c | 2 +- src/gallium/drivers/nv40/nv40_vbo.c | 8 +++---- 4 files changed, 40 insertions(+), 13 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 4861924dac..f96f2b89bf 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -108,6 +108,12 @@ struct nv40_state { struct nouveau_stateobj *hw[NV40_STATE_MAX]; }; + +struct nv40_vtxelt_state { + struct pipe_vertex_element pipe[16]; + unsigned num_elements; +}; + struct nv40_context { struct pipe_context pipe; @@ -158,8 +164,7 @@ struct nv40_context { unsigned dirty_samplers; struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS]; unsigned vtxbuf_nr; - struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS]; - unsigned vtxelt_nr; + struct nv40_vtxelt_state *vtxelt; }; static INLINE struct nv40_context * diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c index 2073bf0735..449e246b8c 100644 --- a/src/gallium/drivers/nv40/nv40_state.c +++ b/src/gallium/drivers/nv40/nv40_state.c @@ -684,15 +684,34 @@ nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count, nv40->draw_dirty |= NV40_NEW_ARRAYS; } +static void * +nv40_vtxelts_state_create(struct pipe_context *pipe, + unsigned num_elements, + const struct pipe_vertex_element *elements) +{ + struct nv40_vtxelt_state *cso = CALLOC_STRUCT(nv40_vtxelt_state); + + assert(num_elements < 16); /* not doing fallbacks yet */ + cso->num_elements = num_elements; + memcpy(cso->pipe, elements, num_elements * sizeof(*elements)); + +/* nv40_vtxelt_construct(cso);*/ + + return (void *)cso; +} + static void -nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count, - const struct pipe_vertex_element *ve) +nv40_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso) { - struct nv40_context *nv40 = nv40_context(pipe); + FREE(hwcso); +} - memcpy(nv40->vtxelt, ve, sizeof(*ve) * count); - nv40->vtxelt_nr = count; +static void +nv40_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso) +{ + struct nv40_context *nv40 = nv40_context(pipe); + nv40->vtxelt = hwcso; nv40->dirty |= NV40_NEW_ARRAYS; nv40->draw_dirty |= NV40_NEW_ARRAYS; } @@ -737,7 +756,10 @@ nv40_init_state_functions(struct nv40_context *nv40) nv40->pipe.set_scissor_state = nv40_set_scissor_state; nv40->pipe.set_viewport_state = nv40_set_viewport_state; + nv40->pipe.create_vertex_elements_state = nv40_vtxelts_state_create; + nv40->pipe.delete_vertex_elements_state = nv40_vtxelts_state_delete; + nv40->pipe.bind_vertex_elements_state = nv40_vtxelts_state_bind; + nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers; - nv40->pipe.set_vertex_elements = nv40_set_vertex_elements; } diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c index 8990f303ce..297d71f4fa 100644 --- a/src/gallium/drivers/nv40/nv40_state_emit.c +++ b/src/gallium/drivers/nv40/nv40_state_emit.c @@ -174,7 +174,7 @@ nv40_state_validate_swtnl(struct nv40_context *nv40) if (nv40->draw_dirty & NV40_NEW_ARRAYS) { draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf); - draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt); + draw_set_vertex_elements(draw, nv40->vtxelt->num_elements, nv40->vtxelt->pipe); } nv40_state_do_validate(nv40, swtnl_states); diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c index 7812460d2e..fabdf4bf23 100644 --- a/src/gallium/drivers/nv40/nv40_vbo.c +++ b/src/gallium/drivers/nv40/nv40_vbo.c @@ -493,16 +493,16 @@ nv40_vbo_validate(struct nv40_context *nv40) int hw; vtxbuf = so_new(3, 17, 18); - so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr); + so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements); vtxfmt = so_new(1, 16, 0); - so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr); + so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt->num_elements); - for (hw = 0; hw < nv40->vtxelt_nr; hw++) { + for (hw = 0; hw < nv40->vtxelt->num_elements; hw++) { struct pipe_vertex_element *ve; struct pipe_vertex_buffer *vb; unsigned type, ncomp; - ve = &nv40->vtxelt[hw]; + ve = &nv40->vtxelt->pipe[hw]; vb = &nv40->vtxbuf[ve->vertex_buffer_index]; if (!vb->stride) { -- cgit v1.2.3 From 80f3cc36c511f62666162bca1d88c7746b98a27d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 1 Mar 2010 22:11:08 -0500 Subject: llvmpipe: implement some control-flow implements if/else/endif constructs and lays down the code for looping and others. we create a conditional execution mask which decides which of the four inputs are enabled for any store. it's used only if an execution mask is present, otherwise we go through a direct store. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 104 +++++++++++++++++++++--- 1 file changed, 93 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 4cf28a9f93..81b0ab760e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -52,6 +52,7 @@ #include "lp_bld_swizzle.h" #include "lp_bld_flow.h" #include "lp_bld_tgsi.h" +#include "lp_bld_debug.h" #define LP_MAX_TEMPS 256 @@ -81,6 +82,23 @@ #define QUAD_BOTTOM_LEFT 2 #define QUAD_BOTTOM_RIGHT 3 +#define LP_TGSI_MAX_NESTING 16 + +struct lp_exec_mask { + struct lp_build_context *bld; + + boolean has_mask; + + LLVMTypeRef int_vec_type; + + LLVMValueRef cond_stack[LP_TGSI_MAX_NESTING]; + int cond_stack_size; + LLVMValueRef cond_mask; + + LLVMValueRef exec_mask; + + LLVMValueRef inv_mask; +}; struct lp_build_tgsi_soa_context { @@ -97,9 +115,9 @@ struct lp_build_tgsi_soa_context LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS]; struct lp_build_mask_context *mask; + struct lp_exec_mask exec_mask; }; - static const unsigned char swizzle_left[4] = { QUAD_TOP_LEFT, QUAD_TOP_LEFT, @@ -124,6 +142,70 @@ swizzle_bottom[4] = { QUAD_BOTTOM_LEFT, QUAD_BOTTOM_RIGHT }; +static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context *bld) +{ + mask->bld = bld; + mask->has_mask = FALSE; + mask->cond_stack_size = 0; + + mask->int_vec_type = lp_build_int_vec_type(mask->bld->type); + mask->inv_mask = + LLVMConstSub(LLVMConstNull(mask->int_vec_type), + LLVMConstAllOnes(mask->int_vec_type)); +} + +static void lp_exec_mask_update(struct lp_exec_mask *mask) +{ + mask->exec_mask = mask->cond_mask; + if (mask->cond_stack_size > 0) + mask->has_mask = TRUE; +} + +static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, + LLVMValueRef val) +{ + mask->cond_stack[mask->cond_stack_size++] = mask->cond_mask; + mask->cond_mask = LLVMBuildBitCast(mask->bld->builder, val, + mask->int_vec_type, ""); + + lp_exec_mask_update(mask); +} + +static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask) +{ + LLVMValueRef prev_mask = mask->cond_stack[mask->cond_stack_size - 1]; + LLVMValueRef inv_mask = LLVMBuildXor(mask->bld->builder, + mask->cond_mask, + mask->inv_mask, ""); + mask->cond_mask = LLVMBuildAnd(mask->bld->builder, + inv_mask, + prev_mask, ""); + lp_exec_mask_update(mask); +} + +static void lp_exec_mask_cond_pop(struct lp_exec_mask *mask) +{ + mask->cond_mask = mask->cond_stack[--mask->cond_stack_size]; + lp_exec_mask_update(mask); +} + +static void lp_exec_mask_store(struct lp_exec_mask *mask, + LLVMValueRef val, + LLVMValueRef dst) +{ + if (mask->has_mask) { + LLVMValueRef real_val, dst_val; + + dst_val = LLVMBuildLoad(mask->bld->builder, dst, ""); + real_val = lp_build_select(mask->bld, + mask->exec_mask, + val, dst_val); + + LLVMBuildStore(mask->bld->builder, real_val, dst); + } else + LLVMBuildStore(mask->bld->builder, val, dst); +} + static LLVMValueRef emit_ddx(struct lp_build_tgsi_soa_context *bld, @@ -287,13 +369,13 @@ emit_store( switch( reg->Register.File ) { case TGSI_FILE_OUTPUT: - LLVMBuildStore(bld->base.builder, value, - bld->outputs[reg->Register.Index][chan_index]); + lp_exec_mask_store(&bld->exec_mask, value, + bld->outputs[reg->Register.Index][chan_index]); break; case TGSI_FILE_TEMPORARY: - LLVMBuildStore(bld->base.builder, value, - bld->temps[reg->Register.Index][chan_index]); + lp_exec_mask_store(&bld->exec_mask, value, + bld->temps[reg->Register.Index][chan_index]); break; case TGSI_FILE_ADDRESS: @@ -1272,8 +1354,8 @@ emit_instruction( break; case TGSI_OPCODE_IF: - /* FIXME */ - return 0; + tmp0 = emit_fetch(bld, inst, 0, CHAN_X); + lp_exec_mask_cond_push(&bld->exec_mask, tmp0); break; case TGSI_OPCODE_BGNFOR: @@ -1289,13 +1371,11 @@ emit_instruction( break; case TGSI_OPCODE_ELSE: - /* FIXME */ - return 0; + lp_exec_mask_cond_invert(&bld->exec_mask); break; case TGSI_OPCODE_ENDIF: - /* FIXME */ - return 0; + lp_exec_mask_cond_pop(&bld->exec_mask); break; case TGSI_OPCODE_ENDFOR: @@ -1458,6 +1538,8 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, bld.consts_ptr = consts_ptr; bld.sampler = sampler; + lp_exec_mask_init(&bld.exec_mask, &bld.base); + tgsi_parse_init( &parse, tokens ); while( !tgsi_parse_end_of_tokens( &parse ) ) { -- cgit v1.2.3 From c1c7fa5192c4fb3f51fb67c81e58713d61ff0c93 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 2 Mar 2010 01:15:02 -0800 Subject: i915g: Add assert to check for null pointer dereference. --- src/gallium/drivers/i915/i915_state_emit.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c index a3d4e3b04e..ecbcabb440 100644 --- a/src/gallium/drivers/i915/i915_state_emit.c +++ b/src/gallium/drivers/i915/i915_state_emit.c @@ -244,6 +244,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) OUT_BATCH(_3DSTATE_BUF_INFO_CMD); + assert(tex); OUT_BATCH(BUF_3D_ID_DEPTH | BUF_3D_PITCH(tex->stride) | /* pitch in bytes */ ztile); -- cgit v1.2.3 From ff9ddf4d39be9e36d3e1dd9e10e889efa40dfb1e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 2 Mar 2010 02:37:45 +0100 Subject: util/blitter: Fix the viewport transformation for Z coordinates When clearing buffers, the depth is specified in the range [0, 1] and should be passed through blitter "as is". --- src/gallium/auxiliary/util/u_blitter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index f93c69d193..0ba09d33bf 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -320,11 +320,11 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx, /* viewport */ ctx->viewport.scale[0] = 0.5f * width; ctx->viewport.scale[1] = 0.5f * height; - ctx->viewport.scale[2] = 0.5f; + ctx->viewport.scale[2] = 1.0f; ctx->viewport.scale[3] = 1.0f; ctx->viewport.translate[0] = 0.5f * width; ctx->viewport.translate[1] = 0.5f * height; - ctx->viewport.translate[2] = 0.5f; + ctx->viewport.translate[2] = 0.0f; ctx->viewport.translate[3] = 0.0f; ctx->pipe->set_viewport_state(ctx->pipe, &ctx->viewport); -- cgit v1.2.3 From b5cfa6f1966557106a7033b2c80769d64c72ce4c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:13:41 +0000 Subject: r300: Rename pipe formats. --- src/gallium/drivers/r300/r300_blit.c | 4 +- src/gallium/drivers/r300/r300_screen.c | 6 +-- src/gallium/drivers/r300/r300_state.c | 4 +- src/gallium/drivers/r300/r300_texture.c | 82 ++++++++++++++++----------------- 4 files changed, 48 insertions(+), 48 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 32d05749bd..0e2d6c5b42 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -141,10 +141,10 @@ void r300_surface_copy(struct pipe_context* pipe, new_format = PIPE_FORMAT_I8_UNORM; break; case 2: - new_format = PIPE_FORMAT_A4R4G4B4_UNORM; + new_format = PIPE_FORMAT_B4G4R4A4_UNORM; break; case 4: - new_format = PIPE_FORMAT_A8R8G8B8_UNORM; + new_format = PIPE_FORMAT_B8G8R8A8_UNORM; break; default: debug_printf("r300: surface_copy: Unhandled format: %s. Falling back to software.\n" diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 6a55570571..d397a8eb2b 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -210,9 +210,9 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, { uint32_t retval = 0; boolean is_r500 = r300_screen(screen)->caps->is_r500; - boolean is_z24 = format == PIPE_FORMAT_Z24X8_UNORM || - format == PIPE_FORMAT_Z24S8_UNORM; - boolean is_color2101010 = format == PIPE_FORMAT_A2B10G10R10_UNORM; + boolean is_z24 = format == PIPE_FORMAT_X8Z24_UNORM || + format == PIPE_FORMAT_S8Z24_UNORM; + boolean is_color2101010 = format == PIPE_FORMAT_R10G10B10A2_UNORM; if (target >= PIPE_MAX_TEXTURE_TYPES) { debug_printf("r300: Implementation error: Received bogus texture " diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 12bf083871..6c23045561 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -356,7 +356,7 @@ static void r300_set_blend_color(struct pipe_context* pipe, (struct r300_blend_color_state*)r300->blend_color_state.state; union util_color uc; - util_pack_color(color->color, PIPE_FORMAT_A8R8G8B8_UNORM, &uc); + util_pack_color(color->color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); state->blend_color = uc.ui; /* XXX if FP16 blending is enabled, we should use the FP16 format */ @@ -869,7 +869,7 @@ static void* sampler->filter1 |= r300_anisotropy(state->max_anisotropy); - util_pack_color(state->border_color, PIPE_FORMAT_A8R8G8B8_UNORM, &uc); + util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); sampler->border_color = uc.ui; /* R500-specific fixups and optimizations */ diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index ea474737b1..44cfe82a57 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -92,8 +92,8 @@ static uint32_t r300_translate_texformat(enum pipe_format format) switch (format) { case PIPE_FORMAT_Z16_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, X16); - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP); default: return ~0; /* Unsupported. */ @@ -104,9 +104,9 @@ static uint32_t r300_translate_texformat(enum pipe_format format) result |= R300_TX_FORMAT_YUV_TO_RGB; switch (format) { - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return R300_EASY_TX_FORMAT(X, Y, Z, ONE, YVYU422) | result; - case PIPE_FORMAT_YCBCR_REV: + case PIPE_FORMAT_YUYV: return R300_EASY_TX_FORMAT(X, Y, Z, ONE, VYUY422) | result; default: return ~0; /* Unsupported/unknown. */ @@ -308,31 +308,31 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) return R300_COLOR_FORMAT_I8; /* 16-bit buffers. */ - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return R300_COLOR_FORMAT_RGB565; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return R300_COLOR_FORMAT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return R300_COLOR_FORMAT_ARGB4444; /* 32-bit buffers. */ - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_SRGB: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_SRGB: case PIPE_FORMAT_B8G8R8A8_UNORM: case PIPE_FORMAT_B8G8R8A8_SRGB: case PIPE_FORMAT_B8G8R8X8_UNORM: case PIPE_FORMAT_B8G8R8X8_SRGB: - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_X8R8G8B8_SRGB: + case PIPE_FORMAT_A8B8G8R8_UNORM: case PIPE_FORMAT_R8G8B8A8_SNORM: - case PIPE_FORMAT_R8G8B8A8_SRGB: - case PIPE_FORMAT_R8G8B8X8_UNORM: - case PIPE_FORMAT_R8G8B8X8_SRGB: - case PIPE_FORMAT_X8B8G8R8_SNORM: - case PIPE_FORMAT_X8UB8UG8SR8S_NORM: + case PIPE_FORMAT_A8B8G8R8_SRGB: + case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_X8B8G8R8_SRGB: + case PIPE_FORMAT_R8G8B8X8_SNORM: + case PIPE_FORMAT_R8SG8SB8UX8U_NORM: return R300_COLOR_FORMAT_ARGB8888; - case PIPE_FORMAT_A2B10G10R10_UNORM: + case PIPE_FORMAT_R10G10B10A2_UNORM: return R500_COLOR_FORMAT_ARGB2101010; /* R5xx-only? */ /* 64-bit buffers. */ @@ -349,9 +349,9 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) #endif /* YUV buffers. */ - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return R300_COLOR_FORMAT_YVYU; - case PIPE_FORMAT_YCBCR_REV: + case PIPE_FORMAT_YUYV: return R300_COLOR_FORMAT_VYUY; default: return ~0; /* Unsupported. */ @@ -366,9 +366,9 @@ static uint32_t r300_translate_zsformat(enum pipe_format format) case PIPE_FORMAT_Z16_UNORM: return R300_DEPTHFORMAT_16BIT_INT_Z; /* 24-bit depth, ignored stencil */ - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: /* 24-bit depth, 8-bit stencil */ - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL; default: return ~0; /* Unsupported. */ @@ -435,40 +435,40 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) return modifier | R300_C2_SEL_R; /* ARGB 32-bit outputs. */ - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_SRGB: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_SRGB: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8A8_SRGB: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8X8_SRGB: return modifier | R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A; /* BGRA 32-bit outputs. */ - case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_B8G8R8A8_SRGB: - case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_B8G8R8X8_SRGB: + case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_X8R8G8B8_SRGB: return modifier | R300_C0_SEL_A | R300_C1_SEL_R | R300_C2_SEL_G | R300_C3_SEL_B; /* RGBA 32-bit outputs. */ - case PIPE_FORMAT_R8G8B8A8_UNORM_REV: + case PIPE_FORMAT_A8B8G8R8_UNORM: case PIPE_FORMAT_R8G8B8A8_SNORM: - case PIPE_FORMAT_R8G8B8A8_SRGB: - case PIPE_FORMAT_R8G8B8X8_UNORM: - case PIPE_FORMAT_R8G8B8X8_SRGB: + case PIPE_FORMAT_A8B8G8R8_SRGB: + case PIPE_FORMAT_X8B8G8R8_UNORM: + case PIPE_FORMAT_X8B8G8R8_SRGB: return modifier | R300_C0_SEL_A | R300_C1_SEL_B | R300_C2_SEL_G | R300_C3_SEL_R; /* ABGR 32-bit outputs. */ - case PIPE_FORMAT_X8B8G8R8_SNORM: - case PIPE_FORMAT_X8UB8UG8SR8S_NORM: - case PIPE_FORMAT_A2B10G10R10_UNORM: + case PIPE_FORMAT_R8G8B8X8_SNORM: + case PIPE_FORMAT_R8SG8SB8UX8U_NORM: + case PIPE_FORMAT_R10G10B10A2_UNORM: /* RGBA high precision outputs (same swizzles as ABGR low precision) */ case PIPE_FORMAT_R16G16B16A16_UNORM: case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -867,7 +867,7 @@ r300_video_surface_create(struct pipe_screen *screen, memset(&template, 0, sizeof(struct pipe_texture)); template.target = PIPE_TEXTURE_2D; - template.format = PIPE_FORMAT_X8R8G8B8_UNORM; + template.format = PIPE_FORMAT_B8G8R8X8_UNORM; template.last_level = 0; template.width0 = util_next_power_of_two(width); template.height0 = util_next_power_of_two(height); -- cgit v1.2.3 From b7b07b0029c4c17603c97467dda0a487417c2477 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:13:57 +0000 Subject: softpipe: Rename pipe formats. --- src/gallium/drivers/softpipe/sp_quad_depth_test.c | 24 +++++++++++------------ src/gallium/drivers/softpipe/sp_screen.c | 8 ++++---- src/gallium/drivers/softpipe/sp_texture.c | 2 +- src/gallium/drivers/softpipe/sp_tile_cache.c | 6 +++--- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index dab9565443..4815a0d49f 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -73,8 +73,8 @@ get_depth_stencil_values( struct depth_data *data, data->bzzzz[j] = tile->data.depth32[y][x]; } break; - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); @@ -82,8 +82,8 @@ get_depth_stencil_values( struct depth_data *data, data->stencilVals[j] = tile->data.depth32[y][x] >> 24; } break; - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); @@ -146,8 +146,8 @@ convert_quad_depth( struct depth_data *data, } } break; - case PIPE_FORMAT_X8Z24_UNORM: - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: { float scale = (float) ((1 << 24) - 1); @@ -156,8 +156,8 @@ convert_quad_depth( struct depth_data *data, } } break; - case PIPE_FORMAT_Z24X8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: { float scale = (float) ((1 << 24) - 1); @@ -189,7 +189,7 @@ write_depth_stencil_values( struct depth_data *data, tile->data.depth16[y][x] = (ushort) data->bzzzz[j]; } break; - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_Z32_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); @@ -197,21 +197,21 @@ write_depth_stencil_values( struct depth_data *data, tile->data.depth32[y][x] = data->bzzzz[j]; } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); tile->data.depth32[y][x] = (data->stencilVals[j] << 24) | data->bzzzz[j]; } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); tile->data.depth32[y][x] = (data->bzzzz[j] << 8) | data->stencilVals[j]; } break; - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: for (j = 0; j < QUAD_SIZE; j++) { int x = quad->input.x0 % TILE_SIZE + (j & 1); int y = quad->input.y0 % TILE_SIZE + (j >> 1); diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 937b6a8439..6ec63fe698 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -152,16 +152,16 @@ softpipe_is_format_supported( struct pipe_screen *screen, switch(format) { case PIPE_FORMAT_L16_UNORM: - case PIPE_FORMAT_YCBCR_REV: - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_YUYV: + case PIPE_FORMAT_UYVY: case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: case PIPE_FORMAT_DXT3_RGBA: case PIPE_FORMAT_DXT5_RGBA: case PIPE_FORMAT_Z32_FLOAT: case PIPE_FORMAT_R8G8_SNORM: - case PIPE_FORMAT_B6UG5SR5S_NORM: - case PIPE_FORMAT_X8UB8UG8SR8S_NORM: + case PIPE_FORMAT_R5SG5SB6U_NORM: + case PIPE_FORMAT_R8SG8SB8UX8U_NORM: case PIPE_FORMAT_R8G8B8A8_SNORM: case PIPE_FORMAT_NONE: return FALSE; diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 371c4e2025..32d261b5ff 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -426,7 +426,7 @@ softpipe_video_surface_create(struct pipe_screen *screen, memset(&template, 0, sizeof(struct pipe_texture)); template.target = PIPE_TEXTURE_2D; - template.format = PIPE_FORMAT_X8R8G8B8_UNORM; + template.format = PIPE_FORMAT_B8G8R8X8_UNORM; template.last_level = 0; /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */ template.width0 = util_next_power_of_two(width); diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 1b50bd7ffe..3b30954ac8 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -162,10 +162,10 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, PIPE_TRANSFER_READ_WRITE, 0, 0, ps->width, ps->height); - tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM || - ps->format == PIPE_FORMAT_X8Z24_UNORM || - ps->format == PIPE_FORMAT_Z24S8_UNORM || + tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24S8_UNORM || ps->format == PIPE_FORMAT_Z24X8_UNORM || + ps->format == PIPE_FORMAT_S8Z24_UNORM || + ps->format == PIPE_FORMAT_X8Z24_UNORM || ps->format == PIPE_FORMAT_Z16_UNORM || ps->format == PIPE_FORMAT_Z32_UNORM || ps->format == PIPE_FORMAT_S8_UNORM); -- cgit v1.2.3 From b34d138d8453d45f29632d4dcbe040be11265d26 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:14:12 +0000 Subject: svga: Rename pipe formats. --- src/gallium/drivers/svga/svga_pipe_clear.c | 4 +-- src/gallium/drivers/svga/svga_pipe_misc.c | 4 +-- src/gallium/drivers/svga/svga_pipe_sampler.c | 2 +- src/gallium/drivers/svga/svga_screen.c | 18 +++++------ src/gallium/drivers/svga/svga_screen_texture.c | 38 +++++++++++------------ src/gallium/drivers/svga/svga_state_framebuffer.c | 2 +- src/gallium/drivers/svga/svga_state_need_swtnl.c | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c index 409b3b41cb..8483a3fad7 100644 --- a/src/gallium/drivers/svga/svga_pipe_clear.c +++ b/src/gallium/drivers/svga/svga_pipe_clear.c @@ -54,7 +54,7 @@ try_clear(struct svga_context *svga, if ((buffers & PIPE_CLEAR_COLOR) && fb->cbufs[0]) { flags |= SVGA3D_CLEAR_COLOR; - util_pack_color(rgba, PIPE_FORMAT_A8R8G8B8_UNORM, &uc); + util_pack_color(rgba, PIPE_FORMAT_B8G8R8A8_UNORM, &uc); rect.w = fb->cbufs[0]->width; rect.h = fb->cbufs[0]->height; @@ -63,7 +63,7 @@ try_clear(struct svga_context *svga, if ((buffers & PIPE_CLEAR_DEPTHSTENCIL) && fb->zsbuf) { flags |= SVGA3D_CLEAR_DEPTH; - if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) + if (svga->curr.framebuffer.zsbuf->format == PIPE_FORMAT_S8Z24_UNORM) flags |= SVGA3D_CLEAR_STENCIL; rect.w = MAX2(rect.w, fb->zsbuf->width); diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c index 49b43bebc2..95bf0e6f91 100644 --- a/src/gallium/drivers/svga/svga_pipe_misc.c +++ b/src/gallium/drivers/svga/svga_pipe_misc.c @@ -118,10 +118,10 @@ static void svga_set_framebuffer_state(struct pipe_context *pipe, case PIPE_FORMAT_Z16_UNORM: svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D16; break; - case PIPE_FORMAT_S8Z24_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: svga->curr.depthscale = 1.0f / DEPTH_BIAS_SCALE_FACTOR_D24S8; break; case PIPE_FORMAT_Z32_UNORM: diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index 224c4f4c18..acba2b8f9d 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -201,7 +201,7 @@ static void svga_set_sampler_textures(struct pipe_context *pipe, if (!texture[i]) continue; - if (texture[i]->format == PIPE_FORMAT_A8R8G8B8_SRGB) + if (texture[i]->format == PIPE_FORMAT_B8G8R8A8_SRGB) flag_srgb |= 1 << i; if (texture[i]->target == PIPE_TEXTURE_1D) diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 414ac52e1f..6022c38cfc 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -196,23 +196,23 @@ svga_translate_format_cap(enum pipe_format format) { switch(format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_A8R8G8B8; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_X8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_R5G6B5; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_A1R5G5B5; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_A4R4G4B4; case PIPE_FORMAT_Z16_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D16; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D24S8; - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: return SVGA3D_DEVCAP_SURFACEFMT_Z_D24X8; case PIPE_FORMAT_A8_UNORM: @@ -254,8 +254,8 @@ svga_is_format_supported( struct pipe_screen *screen, /* Often unsupported/problematic. This means we end up with the same * visuals for all virtual hardware implementations. */ - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return FALSE; /* Simulate ability to render into compressed textures */ diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 12f3531a1d..e9792e063e 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -59,21 +59,21 @@ svga_translate_format(enum pipe_format format) { switch(format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return SVGA3D_A8R8G8B8; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return SVGA3D_X8R8G8B8; /* Required for GL2.1: */ - case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_B8G8R8A8_SRGB: return SVGA3D_A8R8G8B8; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return SVGA3D_R5G6B5; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return SVGA3D_A1R5G5B5; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return SVGA3D_A4R4G4B4; @@ -83,9 +83,9 @@ svga_translate_format(enum pipe_format format) */ case PIPE_FORMAT_Z16_UNORM: return SVGA3D_Z_D16; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return SVGA3D_Z_D24S8; - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: return SVGA3D_Z_D24X8; case PIPE_FORMAT_A8_UNORM: @@ -111,13 +111,13 @@ SVGA3dSurfaceFormat svga_translate_format_render(enum pipe_format format) { switch(format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: case PIPE_FORMAT_Z32_UNORM: case PIPE_FORMAT_Z16_UNORM: case PIPE_FORMAT_L8_UNORM: @@ -403,9 +403,9 @@ svga_texture_blanket(struct pipe_screen * screen, if (sbuf->key.format == 1) - tex->base.format = PIPE_FORMAT_X8R8G8B8_UNORM; + tex->base.format = PIPE_FORMAT_B8G8R8X8_UNORM; else if (sbuf->key.format == 2) - tex->base.format = PIPE_FORMAT_A8R8G8B8_UNORM; + tex->base.format = PIPE_FORMAT_B8G8R8A8_UNORM; pipe_reference_init(&tex->base.reference, 1); tex->base.screen = screen; @@ -462,9 +462,9 @@ svga_screen_texture_wrap_surface(struct pipe_screen *screen, if (format == 1) - tex->base.format = PIPE_FORMAT_X8R8G8B8_UNORM; + tex->base.format = PIPE_FORMAT_B8G8R8X8_UNORM; else if (format == 2) - tex->base.format = PIPE_FORMAT_A8R8G8B8_UNORM; + tex->base.format = PIPE_FORMAT_B8G8R8A8_UNORM; pipe_reference_init(&tex->base.reference, 1); tex->base.screen = screen; diff --git a/src/gallium/drivers/svga/svga_state_framebuffer.c b/src/gallium/drivers/svga/svga_state_framebuffer.c index b4cafb8f21..7b12c66f94 100644 --- a/src/gallium/drivers/svga/svga_state_framebuffer.c +++ b/src/gallium/drivers/svga/svga_state_framebuffer.c @@ -70,7 +70,7 @@ static int emit_framebuffer( struct svga_context *svga, return ret; if (curr->zsbuf && - curr->zsbuf->format == PIPE_FORMAT_Z24S8_UNORM) { + curr->zsbuf->format == PIPE_FORMAT_S8Z24_UNORM) { ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_STENCIL, curr->zsbuf); if (ret != PIPE_OK) return ret; diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index dd13a89d24..d3644fecad 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -43,7 +43,7 @@ svga_translate_vertex_format(enum pipe_format format) case PIPE_FORMAT_R32G32_FLOAT: return SVGA3D_DECLTYPE_FLOAT2; case PIPE_FORMAT_R32G32B32_FLOAT: return SVGA3D_DECLTYPE_FLOAT3; case PIPE_FORMAT_R32G32B32A32_FLOAT: return SVGA3D_DECLTYPE_FLOAT4; - case PIPE_FORMAT_B8G8R8A8_UNORM: return SVGA3D_DECLTYPE_D3DCOLOR; + case PIPE_FORMAT_A8R8G8B8_UNORM: return SVGA3D_DECLTYPE_D3DCOLOR; case PIPE_FORMAT_R8G8B8A8_USCALED: return SVGA3D_DECLTYPE_UBYTE4; case PIPE_FORMAT_R16G16_SSCALED: return SVGA3D_DECLTYPE_SHORT2; case PIPE_FORMAT_R16G16B16A16_SSCALED: return SVGA3D_DECLTYPE_SHORT4; -- cgit v1.2.3 From 907d5611b2d17efaf7e243ff766b04de957267d0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:14:26 +0000 Subject: drm/nouveau: Rename pipe formats. --- src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index c814d986b1..0d05f316c4 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -119,9 +119,9 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, enum pipe_format format; if (nvdri->bpp == 16) - format = PIPE_FORMAT_R5G6B5_UNORM; + format = PIPE_FORMAT_B5G6R5_UNORM; else - format = PIPE_FORMAT_A8R8G8B8_UNORM; + format = PIPE_FORMAT_B8G8R8A8_UNORM; nvws->front = dri_surface_from_handle(api, nvws->pscreen, nvdri->front_offset, -- cgit v1.2.3 From 4028fab89296346b1ae267e589d41c5ff4a5bab6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 1 Mar 2010 18:14:31 +0000 Subject: gdi: Rename pipe formats. --- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c index e9e5990cf5..a9fa03b8e5 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c @@ -75,8 +75,8 @@ gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, enum pipe_format format ) { switch(format) { - case PIPE_FORMAT_X8R8G8B8_UNORM: - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: return TRUE; /* TODO: Support other formats possible with BMPs, as described in -- cgit v1.2.3 From 7a31bed4b1d2aa099a8af02d9ab8dee33e0c1858 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 2 Mar 2010 11:30:23 +0000 Subject: util: Tweak comment for D3D10-like formats. --- src/gallium/auxiliary/util/u_format.csv | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index 43d69f1cd8..c9766e6207 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -119,7 +119,9 @@ PIPE_FORMAT_DXT1_SRGBA , compressed, 4, 4, x64 , , , , xy PIPE_FORMAT_DXT3_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb PIPE_FORMAT_DXT5_SRGBA , compressed, 4, 4, x128, , , , xyzw, srgb -# Old vector formats +# Straightforward D3D10-like formats (also used for +# vertex buffer element description) +# # See also: # - src/gallium/auxiliary/translate/translate_generic.c # - src/mesa/state_tracker/st_draw.c -- cgit v1.2.3 From 5fe2ce28b6e9fba181c13c6f49b57b3dd68fe88e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 2 Mar 2010 14:41:35 +0000 Subject: llvmpipe: reorganize transfer usage Move transfer creation and mapping to the "scene" object, and out of the rasterizer. The rasterizer operates on already-mapped framebuffers only, and no longer needs a screen or context pointer. The scene object has access to a pipe_context, and this reorg prepares for moving transfer functionality from the screen to the context. --- src/gallium/drivers/llvmpipe/lp_context.c | 2 +- src/gallium/drivers/llvmpipe/lp_rast.c | 310 +++++++++------------------- src/gallium/drivers/llvmpipe/lp_rast.h | 21 +- src/gallium/drivers/llvmpipe/lp_rast_priv.h | 50 +++-- src/gallium/drivers/llvmpipe/lp_scene.c | 248 +++++++++++++++++----- src/gallium/drivers/llvmpipe/lp_scene.h | 34 ++- src/gallium/drivers/llvmpipe/lp_setup.c | 36 ++-- src/gallium/drivers/llvmpipe/lp_setup.h | 2 +- 8 files changed, 379 insertions(+), 324 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index 9120226de0..e31ae6a3fc 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -183,7 +183,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) if (debug_get_bool_option( "LP_NO_RAST", FALSE )) llvmpipe->no_rast = TRUE; - llvmpipe->setup = lp_setup_create( screen, + llvmpipe->setup = lp_setup_create( &llvmpipe->pipe, llvmpipe->draw ); if (!llvmpipe->setup) goto fail; diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 82c006d78b..dd77bb30d1 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -42,114 +42,60 @@ #include "lp_scene.h" -/** - * Begin the rasterization phase. - * Map the framebuffer surfaces. Initialize the 'rast' state. +/* Begin rasterizing a scene: */ static boolean lp_rast_begin( struct lp_rasterizer *rast, - const struct pipe_framebuffer_state *fb, - boolean write_color, - boolean write_zstencil ) + struct lp_scene *scene ) { - struct pipe_screen *screen = rast->screen; - struct pipe_surface *cbuf, *zsbuf; + const struct pipe_framebuffer_state *fb = &scene->fb; + boolean write_color = fb->nr_cbufs != 0; + boolean write_zstencil = fb->zsbuf != NULL; int i; - LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); + rast->curr_scene = scene; - util_copy_framebuffer_state(&rast->state.fb, fb); + LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); + rast->state.nr_cbufs = scene->fb.nr_cbufs; rast->state.write_zstencil = write_zstencil; rast->state.write_color = write_color; - - rast->check_for_clipped_tiles = (fb->width % TILE_SIZE != 0 || - fb->height % TILE_SIZE != 0); - - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { - cbuf = rast->state.fb.cbufs[i]; - if (cbuf) { - rast->cbuf_transfer[i] = screen->get_tex_transfer(rast->screen, - cbuf->texture, - cbuf->face, - cbuf->level, - cbuf->zslice, - PIPE_TRANSFER_READ_WRITE, - 0, 0, - cbuf->width, - cbuf->height); - if (!rast->cbuf_transfer[i]) - goto fail; - - rast->cbuf_map[i] = screen->transfer_map(rast->screen, - rast->cbuf_transfer[i]); - if (!rast->cbuf_map[i]) - goto fail; - } + for (i = 0; i < rast->state.nr_cbufs; i++) { + rast->cbuf[i].map = scene->cbuf_map[i]; + rast->cbuf[i].format = scene->cbuf_transfer[i]->texture->format; + rast->cbuf[i].width = scene->cbuf_transfer[i]->width; + rast->cbuf[i].height = scene->cbuf_transfer[i]->height; + rast->cbuf[i].stride = scene->cbuf_transfer[i]->stride; } - zsbuf = rast->state.fb.zsbuf; - if (zsbuf) { - rast->zsbuf_transfer = screen->get_tex_transfer(rast->screen, - zsbuf->texture, - zsbuf->face, - zsbuf->level, - zsbuf->zslice, - PIPE_TRANSFER_READ_WRITE, - 0, 0, - zsbuf->width, - zsbuf->height); - if (!rast->zsbuf_transfer) - goto fail; - - rast->zsbuf_map = screen->transfer_map(rast->screen, - rast->zsbuf_transfer); - if (!rast->zsbuf_map) - goto fail; + if (write_zstencil) { + rast->zsbuf.map = scene->zsbuf_map; + rast->zsbuf.stride = scene->zsbuf_transfer->stride; + rast->zsbuf.blocksize = + util_format_get_blocksize(scene->zsbuf_transfer->texture->format); } + lp_scene_bin_iter_begin( scene ); + return TRUE; - -fail: - /* Unmap and release transfers? - */ - return FALSE; } -/** - * Finish the rasterization phase. - * Unmap framebuffer surfaces. - */ static void lp_rast_end( struct lp_rasterizer *rast ) { - struct pipe_screen *screen = rast->screen; - unsigned i; - - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { - if (rast->cbuf_map[i]) - screen->transfer_unmap(screen, rast->cbuf_transfer[i]); - - if (rast->cbuf_transfer[i]) - screen->tex_transfer_destroy(rast->cbuf_transfer[i]); - - rast->cbuf_transfer[i] = NULL; - rast->cbuf_map[i] = NULL; - } + int i; - if (rast->zsbuf_map) - screen->transfer_unmap(screen, rast->zsbuf_transfer); + lp_scene_reset( rast->curr_scene ); - if (rast->zsbuf_transfer) - screen->tex_transfer_destroy(rast->zsbuf_transfer); + for (i = 0; i < rast->state.nr_cbufs; i++) + rast->cbuf[i].map = NULL; - rast->zsbuf_transfer = NULL; - rast->zsbuf_map = NULL; + rast->zsbuf.map = NULL; + rast->curr_scene = NULL; } - /** * Begining rasterization of a tile. * \param x window X position of the tile, in pixels @@ -189,7 +135,7 @@ lp_rast_clear_color(struct lp_rasterizer_task *task, clear_color[1] == clear_color[2] && clear_color[2] == clear_color[3]) { /* clear to grayscale value {x, x, x, x} */ - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { + for (i = 0; i < rast->state.nr_cbufs; i++) { memset(color_tile[i], clear_color[0], TILE_SIZE * TILE_SIZE * 4); } } @@ -200,7 +146,7 @@ lp_rast_clear_color(struct lp_rasterizer_task *task, * works. */ const unsigned chunk = TILE_SIZE / 4; - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { + for (i = 0; i < rast->state.nr_cbufs; i++) { uint8_t *c = color_tile[i]; unsigned j; for (j = 0; j < 4 * TILE_SIZE; j++) { @@ -232,17 +178,17 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, struct lp_rasterizer *rast = task->rast; const unsigned tile_x = task->x; const unsigned tile_y = task->y; - const unsigned height = TILE_SIZE/TILE_VECTOR_HEIGHT; - const unsigned width = TILE_SIZE*TILE_VECTOR_HEIGHT; - unsigned block_size = util_format_get_blocksize(rast->zsbuf_transfer->texture->format); + const unsigned height = TILE_SIZE / TILE_VECTOR_HEIGHT; + const unsigned width = TILE_SIZE * TILE_VECTOR_HEIGHT; + unsigned block_size = rast->zsbuf.blocksize; uint8_t *dst; - unsigned dst_stride = rast->zsbuf_transfer->stride*TILE_VECTOR_HEIGHT; + unsigned dst_stride = rast->zsbuf.stride * TILE_VECTOR_HEIGHT; unsigned i, j; LP_DBG(DEBUG_RAST, "%s 0x%x\n", __FUNCTION__, arg.clear_zstencil); - assert(rast->zsbuf_map); - if (!rast->zsbuf_map) + assert(rast->zsbuf.map); + if (!rast->zsbuf.map) return; LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); @@ -278,8 +224,8 @@ lp_rast_clear_zstencil(struct lp_rasterizer_task *task, } break; default: - assert(0); - break; + assert(0); + break; } } @@ -298,25 +244,16 @@ lp_rast_load_color(struct lp_rasterizer_task *task, LP_DBG(DEBUG_RAST, "%s at %u, %u\n", __FUNCTION__, x, y); - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { - struct pipe_transfer *transfer = rast->cbuf_transfer[i]; - int w = TILE_SIZE; - int h = TILE_SIZE; - - if (x >= transfer->width || y >= transfer->height) + for (i = 0; i < rast->state.nr_cbufs; i++) { + if (x >= rast->cbuf[i].width || y >= rast->cbuf[i].height) continue; - assert(w >= 0); - assert(h >= 0); - assert(w <= TILE_SIZE); - assert(h <= TILE_SIZE); - - lp_tile_read_4ub(transfer->texture->format, + lp_tile_read_4ub(rast->cbuf[i].format, task->tile.color[i], - rast->cbuf_map[i], - transfer->stride, + rast->cbuf[i].map, + rast->cbuf[i].stride, x, y, - w, h); + TILE_SIZE, TILE_SIZE); LP_COUNT(nr_color_tile_load); } @@ -366,7 +303,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task, block_offset = ((y / 4) * (16 * 16) + (x / 4) * 16); /* color buffer */ - for (i = 0; i < rast->state.fb.nr_cbufs; i++) + for (i = 0; i < rast->state.nr_cbufs; i++) color[i] = tile->color[i] + 4 * block_offset; /* depth buffer */ @@ -423,7 +360,7 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, block_offset = ((iy / 4) * (16 * 16) + (ix / 4) * 16); /* color buffer */ - for (i = 0; i < rast->state.fb.nr_cbufs; i++) + for (i = 0; i < rast->state.nr_cbufs; i++) color[i] = tile->color[i] + 4 * block_offset; /* depth buffer */ @@ -516,51 +453,33 @@ lp_rast_store_color(struct lp_rasterizer_task *task) const unsigned x = task->x, y = task->y; unsigned i; - for (i = 0; i < rast->state.fb.nr_cbufs; i++) { - struct pipe_transfer *transfer = rast->cbuf_transfer[i]; - int w = TILE_SIZE; - int h = TILE_SIZE; - - if (x >= transfer->width) + for (i = 0; i < rast->state.nr_cbufs; i++) { + if (x >= rast->cbuf[i].width) continue; - if (y >= transfer->height) + if (y >= rast->cbuf[i].height) continue; - LP_DBG(DEBUG_RAST, "%s [%u] %d,%d %dx%d\n", __FUNCTION__, - task->thread_index, x, y, w, h); + LP_DBG(DEBUG_RAST, "%s [%u] %d,%d\n", __FUNCTION__, + task->thread_index, x, y); if (LP_DEBUG & DEBUG_SHOW_SUBTILES) outline_subtiles(task->tile.color[i]); else if (LP_DEBUG & DEBUG_SHOW_TILES) outline_tile(task->tile.color[i]); - lp_tile_write_4ub(transfer->texture->format, + lp_tile_write_4ub(rast->cbuf[i].format, task->tile.color[i], - rast->cbuf_map[i], - transfer->stride, + rast->cbuf[i].map, + rast->cbuf[i].stride, x, y, - w, h); + TILE_SIZE, TILE_SIZE); LP_COUNT(nr_color_tile_store); } } -/** - * Write the rasterizer's tiles to the framebuffer. - */ -static void -lp_rast_end_tile(struct lp_rasterizer_task *task) -{ - struct lp_rasterizer *rast = task->rast; - - LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); - - if (rast->state.write_color) - lp_rast_store_color(task); -} - /** * Signal on a fence. This is called during bin execution/rasterization. @@ -586,23 +505,6 @@ lp_rast_fence(struct lp_rasterizer_task *task, } -/** - * When all the threads are done rasterizing a scene, one thread will - * call this function to reset the scene and put it onto the empty queue. - */ -static void -release_scene( struct lp_rasterizer *rast, - struct lp_scene *scene ) -{ - util_unreference_framebuffer_state( &scene->fb ); - - lp_scene_reset( scene ); - - assert(lp_scene_is_empty(scene)); - - lp_scene_enqueue( rast->empty_scenes, scene ); - rast->curr_scene = NULL; -} /** @@ -620,7 +522,7 @@ rasterize_bin(struct lp_rasterizer_task *task, struct cmd_block *block; unsigned k; - lp_rast_start_tile( task, x, y ); + lp_rast_start_tile( task, x * TILE_SIZE, y * TILE_SIZE ); /* simply execute each of the commands in the block list */ for (block = commands->head; block; block = block->next) { @@ -629,7 +531,14 @@ rasterize_bin(struct lp_rasterizer_task *task, } } - lp_rast_end_tile( task ); + /* Write the rasterizer's tiles to the framebuffer. + */ + if (task->rast->state.write_color) + lp_rast_store_color(task); + + /* Free data for this bin. + */ + lp_scene_bin_reset( task->rast->curr_scene, x, y); } @@ -714,8 +623,7 @@ is_empty_bin( const struct cmd_bin *bin ) */ static void rasterize_scene(struct lp_rasterizer_task *task, - struct lp_scene *scene, - bool write_depth) + struct lp_scene *scene) { /* loop over scene bins, rasterize each */ #if 0 @@ -724,7 +632,7 @@ rasterize_scene(struct lp_rasterizer_task *task, for (i = 0; i < scene->tiles_x; i++) { for (j = 0; j < scene->tiles_y; j++) { struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); - rasterize_bin(task, bin, i * TILE_SIZE, j * TILE_SIZE); + rasterize_bin(task, bin, i, j); } } } @@ -736,7 +644,7 @@ rasterize_scene(struct lp_rasterizer_task *task, assert(scene); while ((bin = lp_scene_bin_iter_next(scene, &x, &y))) { if (!is_empty_bin( bin )) - rasterize_bin(task, bin, x * TILE_SIZE, y * TILE_SIZE); + rasterize_bin(task, bin, x, y); } } #endif @@ -747,44 +655,20 @@ rasterize_scene(struct lp_rasterizer_task *task, * Called by setup module when it has something for us to render. */ void -lp_rasterize_scene( struct lp_rasterizer *rast, - struct lp_scene *scene, - const struct pipe_framebuffer_state *fb, - bool write_depth ) +lp_rast_queue_scene( struct lp_rasterizer *rast, + struct lp_scene *scene) { - boolean debug = false; - LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__); - if (debug) { - unsigned x, y; - debug_printf("rasterize scene:\n"); - debug_printf(" data size: %u\n", lp_scene_data_size(scene)); - for (y = 0; y < scene->tiles_y; y++) { - for (x = 0; x < scene->tiles_x; x++) { - debug_printf(" bin %u, %u size: %u\n", x, y, - lp_scene_bin_size(scene, x, y)); - } - } - } - - /* save framebuffer state in the bin */ - util_copy_framebuffer_state(&scene->fb, fb); - scene->write_depth = write_depth; - if (rast->num_threads == 0) { /* no threading */ - lp_rast_begin( rast, fb, - fb->nr_cbufs != 0, /* always write color if cbufs present */ - fb->zsbuf != NULL && write_depth ); + lp_rast_begin( rast, scene ); - lp_scene_bin_iter_begin( scene ); - rasterize_scene( &rast->tasks[0], scene, write_depth ); + rasterize_scene( &rast->tasks[0], scene ); - release_scene( rast, scene ); - - lp_rast_end( rast ); + lp_scene_reset( scene ); + rast->curr_scene = NULL; } else { /* threaded rendering! */ @@ -796,14 +680,26 @@ lp_rasterize_scene( struct lp_rasterizer *rast, for (i = 0; i < rast->num_threads; i++) { pipe_semaphore_signal(&rast->tasks[i].work_ready); } + } + + LP_DBG(DEBUG_SETUP, "%s done \n", __FUNCTION__); +} + + +void +lp_rast_finish( struct lp_rasterizer *rast ) +{ + if (rast->num_threads == 0) { + /* nothing to do */ + } + else { + int i; /* wait for work to complete */ for (i = 0; i < rast->num_threads; i++) { pipe_semaphore_wait(&rast->tasks[i].work_done); } } - - LP_DBG(DEBUG_SETUP, "%s done \n", __FUNCTION__); } @@ -834,19 +730,8 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data ) * - get next scene to rasterize * - map the framebuffer surfaces */ - const struct pipe_framebuffer_state *fb; - boolean write_depth; - - rast->curr_scene = lp_scene_dequeue( rast->full_scenes, TRUE ); - - lp_scene_bin_iter_begin( rast->curr_scene ); - - fb = &rast->curr_scene->fb; - write_depth = rast->curr_scene->write_depth; - - lp_rast_begin( rast, fb, - fb->nr_cbufs != 0, - fb->zsbuf != NULL && write_depth ); + lp_rast_begin( rast, + lp_scene_dequeue( rast->full_scenes, TRUE ) ); } /* Wait for all threads to get here so that threads[1+] don't @@ -857,25 +742,23 @@ static PIPE_THREAD_ROUTINE( thread_func, init_data ) /* do work */ if (debug) debug_printf("thread %d doing work\n", task->thread_index); + rasterize_scene(task, - rast->curr_scene, - rast->curr_scene->write_depth); + rast->curr_scene); /* wait for all threads to finish with this scene */ pipe_barrier_wait( &rast->barrier ); + /* XXX: shouldn't be necessary: + */ if (task->thread_index == 0) { - /* thread[0]: - * - release the scene object - * - unmap the framebuffer surfaces - */ - release_scene( rast, rast->curr_scene ); lp_rast_end( rast ); } /* signal done with work */ if (debug) debug_printf("thread %d done working\n", task->thread_index); + pipe_semaphore_signal(&task->work_done); } @@ -918,7 +801,7 @@ create_rast_threads(struct lp_rasterizer *rast) * processing them. */ struct lp_rasterizer * -lp_rast_create( struct pipe_screen *screen, struct lp_scene_queue *empty ) +lp_rast_create( void ) { struct lp_rasterizer *rast; unsigned i, cbuf; @@ -927,9 +810,6 @@ lp_rast_create( struct pipe_screen *screen, struct lp_scene_queue *empty ) if(!rast) return NULL; - rast->screen = screen; - - rast->empty_scenes = empty; rast->full_scenes = lp_scene_queue_create(); for (i = 0; i < Elements(rast->tasks); i++) { @@ -957,8 +837,6 @@ void lp_rast_destroy( struct lp_rasterizer *rast ) { unsigned i, cbuf; - util_unreference_framebuffer_state(&rast->state.fb); - for (i = 0; i < Elements(rast->tasks); i++) { for (cbuf = 0; cbuf < PIPE_MAX_COLOR_BUFS; cbuf++ ) align_free(rast->tasks[i].tile.color[cbuf]); diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index 1ed2700191..d91c45eb2b 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -43,10 +43,8 @@ struct lp_rasterizer; struct lp_scene; -struct lp_scene_queue; struct lp_fence; struct cmd_bin; -struct pipe_screen; /** For sub-pixel positioning */ #define FIXED_ORDER 4 @@ -129,18 +127,21 @@ struct lp_rast_triangle { -struct lp_rasterizer *lp_rast_create( struct pipe_screen *screen, - struct lp_scene_queue *empty ); +struct lp_rasterizer * +lp_rast_create( void ); -void lp_rast_destroy( struct lp_rasterizer * ); +void +lp_rast_destroy( struct lp_rasterizer * ); -unsigned lp_rast_get_num_threads( struct lp_rasterizer * ); +unsigned +lp_rast_get_num_threads( struct lp_rasterizer * ); -void lp_rasterize_scene( struct lp_rasterizer *rast, - struct lp_scene *scene, - const struct pipe_framebuffer_state *fb, - bool write_depth ); +void +lp_rast_queue_scene( struct lp_rasterizer *rast, + struct lp_scene *scene ); +void +lp_rast_finish( struct lp_rasterizer *rast ); union lp_rast_cmd_arg { diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h index abc5a9ad89..39bf2c2587 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h +++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h @@ -38,8 +38,6 @@ #define MAX_THREADS 8 /* XXX probably temporary here */ -struct pipe_transfer; -struct pipe_screen; struct lp_rasterizer; @@ -82,20 +80,26 @@ struct lp_rasterizer_task */ struct lp_rasterizer { - boolean clipped_tile; - boolean check_for_clipped_tiles; boolean exit_flag; /* Framebuffer stuff */ - struct pipe_screen *screen; - struct pipe_transfer *cbuf_transfer[PIPE_MAX_COLOR_BUFS]; - struct pipe_transfer *zsbuf_transfer; - void *cbuf_map[PIPE_MAX_COLOR_BUFS]; - uint8_t *zsbuf_map; + struct { + void *map; + unsigned stride; + unsigned width; + unsigned height; + enum pipe_format format; + } cbuf[PIPE_MAX_COLOR_BUFS]; + + struct { + uint8_t *map; + unsigned stride; + unsigned blocksize; + } zsbuf; struct { - struct pipe_framebuffer_state fb; + unsigned nr_cbufs; boolean write_color; boolean write_zstencil; unsigned clear_color; @@ -105,7 +109,14 @@ struct lp_rasterizer /** The incoming queue of scenes ready to rasterize */ struct lp_scene_queue *full_scenes; - /** The outgoing queue of processed scenes to return to setup modulee */ + + /** + * The outgoing queue of processed scenes to return to setup module + * + * XXX: while scenes are per-context but the rasterizer is + * (potentially) shared, these empty scenes should be returned to + * the context which created them rather than retained here. + */ struct lp_scene_queue *empty_scenes; /** The scene currently being rasterized by the threads */ @@ -137,17 +148,18 @@ lp_rast_depth_pointer( struct lp_rasterizer *rast, unsigned x, unsigned y ) { void * depth; + assert((x % TILE_VECTOR_WIDTH) == 0); assert((y % TILE_VECTOR_HEIGHT) == 0); - if(!rast->zsbuf_map) + + if (!rast->zsbuf.map) return NULL; - assert(rast->zsbuf_transfer); - depth = rast->zsbuf_map + - y*rast->zsbuf_transfer->stride + - TILE_VECTOR_HEIGHT*x*util_format_get_blocksize(rast->zsbuf_transfer->texture->format); -#ifdef DEBUG + + depth = (rast->zsbuf.map + + rast->zsbuf.stride * y + + rast->zsbuf.blocksize * x * TILE_VECTOR_HEIGHT); + assert(lp_check_alignment(depth, 16)); -#endif return depth; } @@ -175,7 +187,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task, block_offset = (iy / 4) * (16 * 16) + (ix / 4) * 16; /* color buffer */ - for (i = 0; i < rast->state.fb.nr_cbufs; i++) + for (i = 0; i < rast->state.nr_cbufs; i++) color[i] = tile->color[i] + 4 * block_offset; depth = lp_rast_depth_pointer(rast, x, y); diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index cba0e21298..72492c0f0c 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -29,44 +29,67 @@ #include "util/u_memory.h" #include "util/u_inlines.h" #include "util/u_simple_list.h" +#include "util/u_surface.h" #include "lp_scene.h" +#include "lp_scene_queue.h" +#include "lp_debug.h" struct lp_scene * -lp_scene_create(void) +lp_scene_create( struct pipe_context *pipe, + struct lp_scene_queue *queue ) { + unsigned i, j; struct lp_scene *scene = CALLOC_STRUCT(lp_scene); - if (scene) - lp_scene_init(scene); + if (!scene) + return NULL; + + scene->pipe = pipe; + scene->empty_queue = queue; + + for (i = 0; i < TILES_X; i++) { + for (j = 0; j < TILES_Y; j++) { + struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); + bin->commands.head = bin->commands.tail = CALLOC_STRUCT(cmd_block); + } + } + + scene->data.head = + scene->data.tail = CALLOC_STRUCT(data_block); + + make_empty_list(&scene->textures); + + pipe_mutex_init(scene->mutex); + return scene; } +/** + * Free all data associated with the given scene, and free(scene). + */ void lp_scene_destroy(struct lp_scene *scene) { - lp_scene_reset(scene); - lp_scene_free_bin_data(scene); - FREE(scene); -} + unsigned i, j; + lp_scene_reset(scene); -void -lp_scene_init(struct lp_scene *scene) -{ - unsigned i, j; for (i = 0; i < TILES_X; i++) for (j = 0; j < TILES_Y; j++) { struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); - bin->commands.head = bin->commands.tail = CALLOC_STRUCT(cmd_block); + assert(bin->commands.head == bin->commands.tail); + FREE(bin->commands.head); + bin->commands.head = NULL; + bin->commands.tail = NULL; } - scene->data.head = - scene->data.tail = CALLOC_STRUCT(data_block); + FREE(scene->data.head); + scene->data.head = NULL; - make_empty_list(&scene->textures); + pipe_mutex_destroy(scene->mutex); - pipe_mutex_init(scene->mutex); + FREE(scene); } @@ -92,6 +115,9 @@ lp_scene_is_empty(struct lp_scene *scene ) } +/* Free data for one particular bin. May be called from the + * rasterizer thread(s). + */ void lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y) { @@ -115,7 +141,8 @@ lp_scene_bin_reset(struct lp_scene *scene, unsigned x, unsigned y) /** - * Set scene to empty state. + * Free all the temporary data in a scene. May be called from the + * rasterizer thread(s). */ void lp_scene_reset(struct lp_scene *scene ) @@ -162,40 +189,8 @@ lp_scene_reset(struct lp_scene *scene ) } -/** - * Free all data associated with the given bin, but don't free(scene). - */ -void -lp_scene_free_bin_data(struct lp_scene *scene) -{ - unsigned i, j; - - for (i = 0; i < TILES_X; i++) - for (j = 0; j < TILES_Y; j++) { - struct cmd_bin *bin = lp_scene_get_bin(scene, i, j); - /* lp_reset_scene() should have been already called */ - assert(bin->commands.head == bin->commands.tail); - FREE(bin->commands.head); - bin->commands.head = NULL; - bin->commands.tail = NULL; - } - - FREE(scene->data.head); - scene->data.head = NULL; - - pipe_mutex_destroy(scene->mutex); -} - -void -lp_scene_set_framebuffer_size( struct lp_scene *scene, - unsigned width, unsigned height ) -{ - assert(lp_scene_is_empty(scene)); - scene->tiles_x = align(width, TILE_SIZE) / TILE_SIZE; - scene->tiles_y = align(height, TILE_SIZE) / TILE_SIZE; -} void @@ -393,3 +388,158 @@ end: pipe_mutex_unlock(scene->mutex); return bin; } + + +/** + * Prepare this scene for the rasterizer. + * Map the framebuffer surfaces. Initialize the 'rast' state. + */ +static boolean +lp_scene_map_buffers( struct lp_scene *scene ) +{ + struct pipe_screen *screen = scene->pipe->screen; + struct pipe_surface *cbuf, *zsbuf; + int i; + + LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__); + + + /* Map all color buffers + */ + for (i = 0; i < scene->fb.nr_cbufs; i++) { + cbuf = scene->fb.cbufs[i]; + if (cbuf) { + scene->cbuf_transfer[i] = screen->get_tex_transfer(screen, + cbuf->texture, + cbuf->face, + cbuf->level, + cbuf->zslice, + PIPE_TRANSFER_READ_WRITE, + 0, 0, + cbuf->width, + cbuf->height); + if (!scene->cbuf_transfer[i]) + goto fail; + + scene->cbuf_map[i] = screen->transfer_map(screen, + scene->cbuf_transfer[i]); + if (!scene->cbuf_map[i]) + goto fail; + } + } + + /* Map the zsbuffer + */ + zsbuf = scene->fb.zsbuf; + if (zsbuf) { + scene->zsbuf_transfer = screen->get_tex_transfer(screen, + zsbuf->texture, + zsbuf->face, + zsbuf->level, + zsbuf->zslice, + PIPE_TRANSFER_READ_WRITE, + 0, 0, + zsbuf->width, + zsbuf->height); + if (!scene->zsbuf_transfer) + goto fail; + + scene->zsbuf_map = screen->transfer_map(screen, + scene->zsbuf_transfer); + if (!scene->zsbuf_map) + goto fail; + } + + return TRUE; + +fail: + /* Unmap and release transfers? + */ + return FALSE; +} + + + +/** + * Called after rasterizer as finished rasterizing a scene. + * + * We want to call this from the pipe_context's current thread to + * avoid having to have mutexes on the transfer functions. + */ +static void +lp_scene_unmap_buffers( struct lp_scene *scene ) +{ + struct pipe_screen *screen = scene->pipe->screen; + unsigned i; + + for (i = 0; i < scene->fb.nr_cbufs; i++) { + if (scene->cbuf_map[i]) + screen->transfer_unmap(screen, scene->cbuf_transfer[i]); + + if (scene->cbuf_transfer[i]) + screen->tex_transfer_destroy(scene->cbuf_transfer[i]); + + scene->cbuf_transfer[i] = NULL; + scene->cbuf_map[i] = NULL; + } + + if (scene->zsbuf_map) + screen->transfer_unmap(screen, scene->zsbuf_transfer); + + if (scene->zsbuf_transfer) + screen->tex_transfer_destroy(scene->zsbuf_transfer); + + scene->zsbuf_transfer = NULL; + scene->zsbuf_map = NULL; + + util_unreference_framebuffer_state( &scene->fb ); +} + + +void lp_scene_begin_binning( struct lp_scene *scene, + struct pipe_framebuffer_state *fb ) +{ + assert(lp_scene_is_empty(scene)); + + util_copy_framebuffer_state(&scene->fb, fb); + + scene->tiles_x = align(fb->width, TILE_SIZE) / TILE_SIZE; + scene->tiles_y = align(fb->height, TILE_SIZE) / TILE_SIZE; +} + + +void lp_scene_rasterize( struct lp_scene *scene, + struct lp_rasterizer *rast, + boolean write_depth ) +{ + if (0) { + unsigned x, y; + debug_printf("rasterize scene:\n"); + debug_printf(" data size: %u\n", lp_scene_data_size(scene)); + for (y = 0; y < scene->tiles_y; y++) { + for (x = 0; x < scene->tiles_x; x++) { + debug_printf(" bin %u, %u size: %u\n", x, y, + lp_scene_bin_size(scene, x, y)); + } + } + } + + + scene->write_depth = (scene->fb.zsbuf != NULL && + write_depth); + + lp_scene_map_buffers( scene ); + + /* Enqueue the scene for rasterization, then immediately wait for + * it to finish. + */ + lp_rast_queue_scene( rast, scene ); + + /* Currently just wait for the rasterizer to finish. Some + * threading interactions need to be worked out, particularly once + * transfers become per-context: + */ + lp_rast_finish( rast ); + lp_scene_unmap_buffers( scene ); + lp_scene_enqueue( scene->empty_queue, scene ); +} diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h index 8d725cd437..739ac22908 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.h +++ b/src/gallium/drivers/llvmpipe/lp_scene.h @@ -39,6 +39,7 @@ #include "lp_tile_soa.h" #include "lp_rast.h" +struct lp_scene_queue; /* We're limited to 2K by 2K for 32bit fixed point rasterization. * Will need a 64-bit version for larger framebuffers. @@ -112,8 +113,14 @@ struct texture_ref { * scenes: */ struct lp_scene { - struct cmd_bin tile[TILES_X][TILES_Y]; - struct data_block_list data; + struct pipe_context *pipe; + struct pipe_transfer *cbuf_transfer[PIPE_MAX_COLOR_BUFS]; + struct pipe_transfer *zsbuf_transfer; + + /* Scene's buffers are mapped at the time the scene is enqueued: + */ + void *cbuf_map[PIPE_MAX_COLOR_BUFS]; + uint8_t *zsbuf_map; /** the framebuffer to render the scene into */ struct pipe_framebuffer_state fb; @@ -131,25 +138,28 @@ struct lp_scene { int curr_x, curr_y; /**< for iterating over bins */ pipe_mutex mutex; + + /* Where to place this scene once it has been rasterized: + */ + struct lp_scene_queue *empty_queue; + + struct cmd_bin tile[TILES_X][TILES_Y]; + struct data_block_list data; }; -struct lp_scene *lp_scene_create(void); +struct lp_scene *lp_scene_create(struct pipe_context *pipe, + struct lp_scene_queue *empty_queue); void lp_scene_destroy(struct lp_scene *scene); -void lp_scene_init(struct lp_scene *scene); boolean lp_scene_is_empty(struct lp_scene *scene ); void lp_scene_reset(struct lp_scene *scene ); -void lp_scene_free_bin_data(struct lp_scene *scene); - -void lp_scene_set_framebuffer_size( struct lp_scene *scene, - unsigned width, unsigned height ); void lp_bin_new_data_block( struct data_block_list *list ); @@ -296,5 +306,13 @@ lp_scene_bin_iter_begin( struct lp_scene *scene ); struct cmd_bin * lp_scene_bin_iter_next( struct lp_scene *scene, int *bin_x, int *bin_y ); +void +lp_scene_rasterize( struct lp_scene *scene, + struct lp_rasterizer *rast, + boolean write_depth ); + +void +lp_scene_begin_binning( struct lp_scene *scene, + struct pipe_framebuffer_state *fb ); #endif /* LP_BIN_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 3aec9de373..aebed85fbb 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -66,11 +66,8 @@ lp_setup_get_current_scene(struct setup_context *setup) assert(lp_scene_is_empty(setup->scene)); - if(0)lp_scene_reset( setup->scene ); /* XXX temporary? */ - - lp_scene_set_framebuffer_size(setup->scene, - setup->fb.width, - setup->fb.height); + lp_scene_begin_binning(setup->scene, + &setup->fb ); } return setup->scene; } @@ -135,13 +132,12 @@ static void reset_context( struct setup_context *setup ) /** Rasterize all scene's bins */ static void lp_setup_rasterize_scene( struct setup_context *setup, - boolean write_depth ) + boolean write_depth ) { struct lp_scene *scene = lp_setup_get_current_scene(setup); - lp_rasterize_scene(setup->rast, - scene, - &setup->fb, + lp_scene_rasterize(scene, + setup->rast, write_depth); reset_context( setup ); @@ -246,19 +242,16 @@ void lp_setup_bind_framebuffer( struct setup_context *setup, const struct pipe_framebuffer_state *fb ) { - struct lp_scene *scene = lp_setup_get_current_scene(setup); - LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__); + /* Flush any old scene. + */ set_scene_state( setup, SETUP_FLUSHED ); - /* re-get scene pointer, may have a new scene after flushing */ - (void) scene; - scene = lp_setup_get_current_scene(setup); - + /* Set new state. This will be picked up later when we next need a + * scene. + */ util_copy_framebuffer_state(&setup->fb, fb); - - lp_scene_set_framebuffer_size(scene, setup->fb.width, setup->fb.height); } @@ -683,7 +676,7 @@ lp_setup_destroy( struct setup_context *setup ) * it. */ struct setup_context * -lp_setup_create( struct pipe_screen *screen, +lp_setup_create( struct pipe_context *pipe, struct draw_context *draw ) { unsigned i; @@ -698,7 +691,9 @@ lp_setup_create( struct pipe_screen *screen, if (!setup->empty_scenes) goto fail; - setup->rast = lp_rast_create( screen, setup->empty_scenes ); + /* XXX: move this to the screen and share between contexts: + */ + setup->rast = lp_rast_create(); if (!setup->rast) goto fail; @@ -711,7 +706,8 @@ lp_setup_create( struct pipe_screen *screen, /* create some empty scenes */ for (i = 0; i < MAX_SCENES; i++) { - setup->scenes[i] = lp_scene_create(); + setup->scenes[i] = lp_scene_create( pipe, setup->empty_scenes ); + lp_scene_enqueue(setup->empty_scenes, setup->scenes[i]); } diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h index 0e155a7dc3..17c112b528 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.h +++ b/src/gallium/drivers/llvmpipe/lp_setup.h @@ -62,7 +62,7 @@ struct lp_fragment_shader; struct lp_jit_context; struct setup_context * -lp_setup_create( struct pipe_screen *screen, +lp_setup_create( struct pipe_context *pipe, struct draw_context *draw ); void -- cgit v1.2.3 From 0c616da24114a22e7a6ad6e333cf4e836a91e95f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 2 Mar 2010 15:02:29 +0000 Subject: llvmpipe: remove some ifdefs No longer any need to protect expensive asserts with #ifdef DEBUG. --- src/gallium/drivers/llvmpipe/lp_rast.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index dd77bb30d1..0f83eea685 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -342,7 +342,6 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, unsigned ix, iy; int block_offset; -#ifdef DEBUG assert(state); /* Sanity checks */ @@ -351,7 +350,6 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, assert((x % 4) == 0); assert((y % 4) == 0); -#endif ix = x % TILE_SIZE; iy = y % TILE_SIZE; @@ -367,15 +365,12 @@ void lp_rast_shade_quads( struct lp_rasterizer_task *task, depth = lp_rast_depth_pointer(rast, x, y); - -#ifdef DEBUG assert(lp_check_alignment(tile->color[0], 16)); assert(lp_check_alignment(state->jit_context.blend_color, 16)); assert(lp_check_alignment(inputs->step[0], 16)); assert(lp_check_alignment(inputs->step[1], 16)); assert(lp_check_alignment(inputs->step[2], 16)); -#endif /* run shader */ state->jit_function[1]( &state->jit_context, -- cgit v1.2.3 From faf8215bae70f020420242dc812ef141fdcf5417 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 2 Mar 2010 10:18:29 -0500 Subject: llvmpipe: improve based on review from Jose and fix else clauses else was broken in the outter most else statemants, plus the code didn't need an inverted mask to compute the inverse of the current condition. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 81b0ab760e..ae866243a9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -96,8 +96,6 @@ struct lp_exec_mask { LLVMValueRef cond_mask; LLVMValueRef exec_mask; - - LLVMValueRef inv_mask; }; struct lp_build_tgsi_soa_context @@ -149,9 +147,6 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context mask->cond_stack_size = 0; mask->int_vec_type = lp_build_int_vec_type(mask->bld->type); - mask->inv_mask = - LLVMConstSub(LLVMConstNull(mask->int_vec_type), - LLVMConstAllOnes(mask->int_vec_type)); } static void lp_exec_mask_update(struct lp_exec_mask *mask) @@ -174,9 +169,15 @@ static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, static void lp_exec_mask_cond_invert(struct lp_exec_mask *mask) { LLVMValueRef prev_mask = mask->cond_stack[mask->cond_stack_size - 1]; - LLVMValueRef inv_mask = LLVMBuildXor(mask->bld->builder, - mask->cond_mask, - mask->inv_mask, ""); + LLVMValueRef inv_mask = LLVMBuildNot(mask->bld->builder, + mask->cond_mask, ""); + + /* means that we didn't have any mask before and that + * we were fully enabled */ + if (mask->cond_stack_size <= 1) { + prev_mask = LLVMConstAllOnes(mask->int_vec_type); + } + mask->cond_mask = LLVMBuildAnd(mask->bld->builder, inv_mask, prev_mask, ""); -- cgit v1.2.3 From aaa2d548ed46636f6558494dc035f40bff445deb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 2 Mar 2010 17:26:40 +0000 Subject: nouveau: Rename pipe formats. These format uses were being hiden by pre-processor magic and were missed in the previous search'n'replace. --- src/gallium/drivers/nv30/nv30_fragtex.c | 14 +++++++------- src/gallium/drivers/nv40/nv40_fragtex.c | 14 +++++++------- src/gallium/drivers/nv50/nv50_state_validate.c | 10 +++++----- src/gallium/drivers/nv50/nv50_tex.c | 20 ++++++++++---------- 4 files changed, 29 insertions(+), 29 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index 9f4a104f67..f7d98f3f20 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -23,17 +23,17 @@ struct nv30_texture_format { static struct nv30_texture_format nv30_texture_formats[] = { - _(X8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, ONE, X, Y, Z, W), - _(A8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W), - _(A1R5G5B5_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W), - _(A4R4G4B4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W), - _(R5G6B5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W), + _(B8G8R8X8_UNORM, A8R8G8B8, S1, S1, S1, ONE, X, Y, Z, W), + _(B8G8R8A8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W), + _(B5G5R5A1_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W), + _(B4G4R4A4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W), + _(B5G6R5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W), _(L8_UNORM , L8 , S1, S1, S1, ONE, X, X, X, X), _(A8_UNORM , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X), _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X), - _(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y), + _(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y), _(Z16_UNORM , R5G6B5 , S1, S1, S1, ONE, X, X, X, X), - _(Z24S8_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X), + _(S8Z24_UNORM , A8R8G8B8, S1, S1, S1, ONE, X, X, X, X), _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W), _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W), _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W), diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c index 7a28d577b1..b60118922a 100644 --- a/src/gallium/drivers/nv40/nv40_fragtex.c +++ b/src/gallium/drivers/nv40/nv40_fragtex.c @@ -25,18 +25,18 @@ struct nv40_texture_format { static struct nv40_texture_format nv40_texture_formats[] = { - _(X8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), - _(A8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), - _(A1R5G5B5_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), - _(A4R4G4B4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), - _(R5G6B5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), + _(B8G8R8X8_UNORM, A8R8G8B8, S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), + _(B8G8R8A8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), + _(B5G5R5A1_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), + _(B4G4R4A4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), + _(B5G6R5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), _(L8_UNORM , L8 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), _(A8_UNORM , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X, 0, 0, 0, 0), _(R16_SNORM , A16 , ZERO, ZERO, S1, ONE, X, X, X, Y, 1, 1, 1, 1), _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X, 0, 0, 0, 0), - _(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y, 0, 0, 0, 0), + _(L8A8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y, 0, 0, 0, 0), _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), - _(Z24S8_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), + _(S8Z24_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X, 0, 0, 0, 0), _(DXT1_RGB , DXT1 , S1, S1, S1, ONE, X, Y, Z, W, 0, 0, 0, 0), _(DXT1_RGBA , DXT1 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), _(DXT3_RGBA , DXT3 , S1, S1, S1, S1, X, Y, Z, W, 0, 0, 0, 0), diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index a91b31015e..63dfd8cb29 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -71,9 +71,9 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->cbufs[i]->format) { - NV50_CBUF_FORMAT_CASE(A8R8G8B8_UNORM); - NV50_CBUF_FORMAT_CASE(X8R8G8B8_UNORM); - NV50_CBUF_FORMAT_CASE(R5G6B5_UNORM); + NV50_CBUF_FORMAT_CASE(B8G8R8A8_UNORM); + NV50_CBUF_FORMAT_CASE(B8G8R8X8_UNORM); + NV50_CBUF_FORMAT_CASE(B5G6R5_UNORM); NV50_CBUF_FORMAT_CASE(R16G16B16A16_SNORM); NV50_CBUF_FORMAT_CASE(R16G16B16A16_UNORM); NV50_CBUF_FORMAT_CASE(R32G32B32A32_FLOAT); @@ -112,9 +112,9 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->zsbuf->format) { - NV50_ZETA_FORMAT_CASE(S8Z24_UNORM); - NV50_ZETA_FORMAT_CASE(X8Z24_UNORM); NV50_ZETA_FORMAT_CASE(Z24S8_UNORM); + NV50_ZETA_FORMAT_CASE(Z24X8_UNORM); + NV50_ZETA_FORMAT_CASE(S8Z24_UNORM); NV50_ZETA_FORMAT_CASE(Z32_FLOAT); default: NOUVEAU_ERR("AIIII unknown format %s\n", diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 9f1a171303..de0560e20c 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -49,28 +49,28 @@ struct nv50_texture_format { static const struct nv50_texture_format nv50_tex_format_list[] = { - _(A8R8G8B8_UNORM, UNORM, C2, C1, C0, C3, 8_8_8_8), - _(A8R8G8B8_SRGB, UNORM, C2, C1, C0, C3, 8_8_8_8), - _(X8R8G8B8_UNORM, UNORM, C2, C1, C0, ONE, 8_8_8_8), - _(X8R8G8B8_SRGB, UNORM, C2, C1, C0, ONE, 8_8_8_8), - _(A1R5G5B5_UNORM, UNORM, C2, C1, C0, C3, 1_5_5_5), - _(A4R4G4B4_UNORM, UNORM, C2, C1, C0, C3, 4_4_4_4), + _(B8G8R8A8_UNORM, UNORM, C2, C1, C0, C3, 8_8_8_8), + _(B8G8R8A8_SRGB, UNORM, C2, C1, C0, C3, 8_8_8_8), + _(B8G8R8X8_UNORM, UNORM, C2, C1, C0, ONE, 8_8_8_8), + _(B8G8R8X8_SRGB, UNORM, C2, C1, C0, ONE, 8_8_8_8), + _(B5G5R5A1_UNORM, UNORM, C2, C1, C0, C3, 1_5_5_5), + _(B4G4R4A4_UNORM, UNORM, C2, C1, C0, C3, 4_4_4_4), - _(R5G6B5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5), + _(B5G6R5_UNORM, UNORM, C2, C1, C0, ONE, 5_6_5), _(L8_UNORM, UNORM, C0, C0, C0, ONE, 8), _(A8_UNORM, UNORM, ZERO, ZERO, ZERO, C0, 8), _(I8_UNORM, UNORM, C0, C0, C0, C0, 8), - _(A8L8_UNORM, UNORM, C0, C0, C0, C1, 8_8), + _(L8A8_UNORM, UNORM, C0, C0, C0, C1, 8_8), _(DXT1_RGB, UNORM, C0, C1, C2, ONE, DXT1), _(DXT1_RGBA, UNORM, C0, C1, C2, C3, DXT1), _(DXT3_RGBA, UNORM, C0, C1, C2, C3, DXT3), _(DXT5_RGBA, UNORM, C0, C1, C2, C3, DXT5), - _MIXED(Z24S8_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8), - _MIXED(S8Z24_UNORM, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24), + _MIXED(S8Z24_UNORM, UINT, UNORM, UINT, UINT, C1, C1, C1, ONE, 24_8), + _MIXED(Z24S8_UNORM, UNORM, UINT, UINT, UINT, C0, C0, C0, ONE, 8_24), _(R16G16B16A16_SNORM, UNORM, C0, C1, C2, C3, 16_16_16_16), _(R16G16B16A16_UNORM, SNORM, C0, C1, C2, C3, 16_16_16_16), -- cgit v1.2.3 From 20443f969d78efb8437083b39b9ddcf4c08aa6cf Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 2 Mar 2010 19:16:39 +0100 Subject: nv50: fix RT formats after format rename fixes Getting rid of the evil pre-processor magic, but not changing our internal format naming convention (at least for now). --- src/gallium/drivers/nv50/nv50_state_validate.c | 54 +++++++++++++++++--------- 1 file changed, 36 insertions(+), 18 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 63dfd8cb29..c974cc92dc 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -25,12 +25,6 @@ #include "nv50_context.h" #include "nouveau/nouveau_stateobj.h" -#define NV50_CBUF_FORMAT_CASE(n) \ - case PIPE_FORMAT_##n: so_data(so, NV50TCL_RT_FORMAT_##n); break - -#define NV50_ZETA_FORMAT_CASE(n) \ - case PIPE_FORMAT_##n: so_data(so, NV50TCL_ZETA_FORMAT_##n); break - static void nv50_state_validate_fb(struct nv50_context *nv50) { @@ -71,14 +65,30 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_reloc (so, bo, fb->cbufs[i]->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->cbufs[i]->format) { - NV50_CBUF_FORMAT_CASE(B8G8R8A8_UNORM); - NV50_CBUF_FORMAT_CASE(B8G8R8X8_UNORM); - NV50_CBUF_FORMAT_CASE(B5G6R5_UNORM); - NV50_CBUF_FORMAT_CASE(R16G16B16A16_SNORM); - NV50_CBUF_FORMAT_CASE(R16G16B16A16_UNORM); - NV50_CBUF_FORMAT_CASE(R32G32B32A32_FLOAT); - NV50_CBUF_FORMAT_CASE(R16G16_SNORM); - NV50_CBUF_FORMAT_CASE(R16G16_UNORM); + case PIPE_FORMAT_B8G8R8A8_UNORM: + so_data(so, NV50TCL_RT_FORMAT_A8R8G8B8_UNORM); + break; + case PIPE_FORMAT_B8G8R8X8_UNORM: + so_data(so, NV50TCL_RT_FORMAT_X8R8G8B8_UNORM); + break; + case PIPE_FORMAT_B5G6R5_UNORM: + so_data(so, NV50TCL_RT_FORMAT_R5G6B5_UNORM); + break; + case PIPE_FORMAT_R16G16B16A16_SNORM: + so_data(so, NV50TCL_RT_FORMAT_R16G16B16A16_SNORM); + break; + case PIPE_FORMAT_R16G16B16A16_UNORM: + so_data(so, NV50TCL_RT_FORMAT_R16G16B16A16_UNORM); + break; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + so_data(so, NV50TCL_RT_FORMAT_R32G32B32A32_FLOAT); + break; + case PIPE_FORMAT_R16G16_SNORM: + so_data(so, NV50TCL_RT_FORMAT_R16G16_SNORM); + break; + case PIPE_FORMAT_R16G16_UNORM: + so_data(so, NV50TCL_RT_FORMAT_R16G16_UNORM); + break; default: NOUVEAU_ERR("AIIII unknown format %s\n", util_format_name(fb->cbufs[i]->format)); @@ -112,10 +122,18 @@ nv50_state_validate_fb(struct nv50_context *nv50) so_reloc (so, bo, fb->zsbuf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RDWR, 0, 0); switch (fb->zsbuf->format) { - NV50_ZETA_FORMAT_CASE(Z24S8_UNORM); - NV50_ZETA_FORMAT_CASE(Z24X8_UNORM); - NV50_ZETA_FORMAT_CASE(S8Z24_UNORM); - NV50_ZETA_FORMAT_CASE(Z32_FLOAT); + case PIPE_FORMAT_Z24S8_UNORM: + so_data(so, NV50TCL_ZETA_FORMAT_S8Z24_UNORM); + break; + case PIPE_FORMAT_Z24X8_UNORM: + so_data(so, NV50TCL_ZETA_FORMAT_X8Z24_UNORM); + break; + case PIPE_FORMAT_S8Z24_UNORM: + so_data(so, NV50TCL_ZETA_FORMAT_Z24S8_UNORM); + break; + case PIPE_FORMAT_Z32_FLOAT: + so_data(so, NV50TCL_ZETA_FORMAT_Z32_FLOAT); + break; default: NOUVEAU_ERR("AIIII unknown format %s\n", util_format_name(fb->zsbuf->format)); -- cgit v1.2.3 From 4240987cecdaaaeb2d6188f7c83ff4cb8e670c59 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 2 Mar 2010 18:40:03 -0800 Subject: r300g: Make velem CSO actually work. glxgears runs again. --- src/gallium/drivers/r300/r300_blit.c | 2 +- src/gallium/drivers/r300/r300_context.h | 2 +- src/gallium/drivers/r300/r300_state.c | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c index 2f9650df1b..297768e5cf 100644 --- a/src/gallium/drivers/r300/r300_blit.c +++ b/src/gallium/drivers/r300/r300_blit.c @@ -34,7 +34,7 @@ static void r300_blitter_save_states(struct r300_context* r300) util_blitter_save_rasterizer(r300->blitter, r300->rs_state.state); util_blitter_save_fragment_shader(r300->blitter, r300->fs); util_blitter_save_vertex_shader(r300->blitter, r300->vs); - util_blitter_save_vertex_elements(r300->blitter, r300->vs); + util_blitter_save_vertex_elements(r300->blitter, r300->velems); } /* Clear currently bound buffers. */ diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 0ee0ab47a6..f372743c5b 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -249,7 +249,7 @@ struct r300_vertex_info { struct r300_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; }; extern struct pipe_viewport_state r300_viewport_identity; diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index ceac690fc4..995664d900 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1061,13 +1061,14 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* attribs) { - /*XXX could precalculate state here instead of later */ struct r300_velems_state *velems; + + /*XXX should precalculate state here instead of later */ assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct r300_velems_state *) MALLOC(sizeof(struct r300_velems_state) + count * sizeof(*attribs)); + velems = CALLOC_STRUCT(r300_velems_state); if (velems) { - velems->count = count; - memcpy(velems->velem, attribs, sizeof(*attribs) * count); + velems->count = count; + memcpy(velems->velem, attribs, sizeof(struct pipe_vertex_element) * count); } return velems; } @@ -1078,6 +1079,10 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe, struct r300_context *r300 = r300_context(pipe); struct r300_velems_state *r300_velems = (struct r300_velems_state *) velems; + if (velems == NULL) { + return; + } + r300->velems = r300_velems; if (r300->draw) { @@ -1094,7 +1099,7 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe, static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) { - FREE( velems ); + FREE(velems); } static void* r300_create_vs_state(struct pipe_context* pipe, -- cgit v1.2.3 From 4cb7642ff3ba390e2918d71220625a837bf8a7b9 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 2 Mar 2010 19:14:09 -0800 Subject: r300g: Use a macro to consolidate general state handling. My God, I've reinvented R300_STATECHANGE. Forgive me. :C --- src/gallium/drivers/r300/r300_state.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index a983ec7b5b..1f6f99d3e5 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -43,6 +43,12 @@ /* r300_state: Functions used to intialize state context by translating * Gallium state objects into semi-native r300 state objects. */ +#define UPDATE_STATE(cso, atom) \ + if (cso != atom.state) { \ + atom.state = cso; \ + atom.dirty = TRUE; \ + } + static boolean blend_discard_if_src_alpha_0(unsigned srcRGB, unsigned srcA, unsigned dstRGB, unsigned dstA) { @@ -328,8 +334,7 @@ static void r300_bind_blend_state(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); - r300->blend_state.state = state; - r300->blend_state.dirty = TRUE; + UPDATE_STATE(state, r300->blend_state); } /* Free blend state. */ @@ -478,11 +483,8 @@ static void r300_bind_dsa_state(struct pipe_context* pipe, void* state) { struct r300_context* r300 = r300_context(pipe); - struct r300_screen* r300screen = r300_screen(pipe->screen); - r300->dsa_state.state = state; - r300->dsa_state.size = r300screen->caps->is_r500 ? 8 : 6; - r300->dsa_state.dirty = TRUE; + UPDATE_STATE(state, r300->dsa_state); } /* Free DSA state. */ @@ -813,13 +815,13 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; - r300->rs_state.dirty = TRUE; } else { r300->polygon_offset_enabled = FALSE; } - r300->rs_state.state = rs; + UPDATE_STATE(state, r300->rs_state); r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0); + /* XXX Why is this still needed, dammit!? */ r300->scissor_state.dirty = TRUE; r300->viewport_state.dirty = TRUE; @@ -1114,9 +1116,8 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300_translate_vertex_shader(r300, vs); } - r300->vs_state.state = vs; + UPDATE_STATE(shader, r300->vs_state); r300->vs_state.size = vs->code.length + 9; - r300->vs_state.dirty = TRUE; r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ r300->vap_output_state.dirty = TRUE; -- cgit v1.2.3 From af36b050eb2c801faecbd2b239d96df71fec5287 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 10:54:35 +0000 Subject: gallivm: Rename lp_bld_misc -> lp_bld_init. --- src/gallium/auxiliary/Makefile | 2 +- src/gallium/auxiliary/SConscript | 2 +- src/gallium/auxiliary/gallivm/lp_bld_init.cpp | 75 +++++++++++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_init.h | 56 ++++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 75 --------------------------- src/gallium/auxiliary/gallivm/lp_bld_misc.h | 56 -------------------- 6 files changed, 133 insertions(+), 133 deletions(-) create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_init.cpp create mode 100644 src/gallium/auxiliary/gallivm/lp_bld_init.h delete mode 100644 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp delete mode 100644 src/gallium/auxiliary/gallivm/lp_bld_misc.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 60f9c2ae3c..1d0930e024 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -158,7 +158,7 @@ GALLIVM_SOURCES = \ gallivm/lp_bld_type.c GALLIVM_CPP_SOURCES = \ - gallivm/lp_bld_misc.cpp + gallivm/lp_bld_init.cpp GENERATED_SOURCES = \ indices/u_indices_gen.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index 47de50bf3e..f365c4bbdd 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -192,7 +192,7 @@ if drawllvm: 'gallivm/lp_bld_interp.c', 'gallivm/lp_bld_intr.c', 'gallivm/lp_bld_logic.c', - 'gallivm/lp_bld_misc.cpp', + 'gallivm/lp_bld_init.cpp', 'gallivm/lp_bld_pack.c', 'gallivm/lp_bld_sample.c', 'gallivm/lp_bld_sample_soa.c', diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init.cpp new file mode 100644 index 0000000000..6b559db159 --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.cpp @@ -0,0 +1,75 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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_config.h" + +#include "lp_bld_init.h" + + +#ifndef LLVM_NATIVE_ARCH + +namespace llvm { + extern void LinkInJIT(); +} + + +void +LLVMLinkInJIT(void) +{ + llvm::LinkInJIT(); +} + + +extern "C" int X86TargetMachineModule; + + +int +LLVMInitializeNativeTarget(void) +{ +#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) + X86TargetMachineModule = 1; +#endif + return 0; +} + + +#endif + + +/* + * Hack to allow the linking of release LLVM static libraries on a debug build. + * + * See also: + * - http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/7234ea2b-0042-42ed-b4e2-5d8644dfb57d + */ +#if defined(_MSC_VER) && defined(_DEBUG) +#include +extern "C" { + _CRTIMP void __cdecl _invalid_parameter_noinfo(void) {} +} +#endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h new file mode 100644 index 0000000000..6a8ab8e5db --- /dev/null +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -0,0 +1,56 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef LP_BLD_INIT_H +#define LP_BLD_INIT_H + + +#include "llvm/Config/config.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifndef LLVM_NATIVE_ARCH + +void +LLVMLinkInJIT(void); + +int +LLVMInitializeNativeTarget(void); + +#endif /* !LLVM_NATIVE_ARCH */ + + +#ifdef __cplusplus +} +#endif + + +#endif /* !LP_BLD_INIT_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp deleted file mode 100644 index 6e79438ead..0000000000 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 VMWARE 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_config.h" - -#include "lp_bld_misc.h" - - -#ifndef LLVM_NATIVE_ARCH - -namespace llvm { - extern void LinkInJIT(); -} - - -void -LLVMLinkInJIT(void) -{ - llvm::LinkInJIT(); -} - - -extern "C" int X86TargetMachineModule; - - -int -LLVMInitializeNativeTarget(void) -{ -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) - X86TargetMachineModule = 1; -#endif - return 0; -} - - -#endif - - -/* - * Hack to allow the linking of release LLVM static libraries on a debug build. - * - * See also: - * - http://social.msdn.microsoft.com/Forums/en-US/vclanguage/thread/7234ea2b-0042-42ed-b4e2-5d8644dfb57d - */ -#if defined(_MSC_VER) && defined(_DEBUG) -#include -extern "C" { - _CRTIMP void __cdecl _invalid_parameter_noinfo(void) {} -} -#endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h deleted file mode 100644 index 0e787e0b9c..0000000000 --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef LP_BLD_MISC_H -#define LP_BLD_MISC_H - - -#include "llvm/Config/config.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef LLVM_NATIVE_ARCH - -void -LLVMLinkInJIT(void); - -int -LLVMInitializeNativeTarget(void); - -#endif /* !LLVM_NATIVE_ARCH */ - - -#ifdef __cplusplus -} -#endif - - -#endif /* !LP_BLD_MISC_H */ -- cgit v1.2.3 From f58ca9b02bb4b19d57dfe38016626a89c3757de6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 11:17:16 +0000 Subject: llvmpipe: Update for lp_bld_init.h rename. --- src/gallium/drivers/llvmpipe/lp_test_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c index 14ff00469b..b08872b2b5 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_main.c +++ b/src/gallium/drivers/llvmpipe/lp_test_main.c @@ -37,7 +37,7 @@ #include "util/u_cpu_detect.h" #include "gallivm/lp_bld_const.h" -#include "gallivm/lp_bld_misc.h" +#include "gallivm/lp_bld_init.h" #include "lp_test.h" -- cgit v1.2.3 From a9e6da7b4cd2019e5ac501bfa1d1aeff49e1982c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 12:00:08 +0000 Subject: gallivm: Centralize initialization. Fix stack alignment issues on Windows. --- src/gallium/auxiliary/gallivm/lp_bld_init.cpp | 44 ++++++++++++--------------- src/gallium/auxiliary/gallivm/lp_bld_init.h | 11 +------ 2 files changed, 20 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.cpp b/src/gallium/auxiliary/gallivm/lp_bld_init.cpp index 6b559db159..067397a520 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.cpp +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.cpp @@ -26,39 +26,34 @@ **************************************************************************/ +#include +#include +#include + #include "pipe/p_config.h" #include "lp_bld_init.h" -#ifndef LLVM_NATIVE_ARCH - -namespace llvm { - extern void LinkInJIT(); -} +extern "C" void LLVMLinkInJIT(); -void -LLVMLinkInJIT(void) +extern "C" void +lp_build_init(void) { - llvm::LinkInJIT(); -} - - -extern "C" int X86TargetMachineModule; - - -int -LLVMInitializeNativeTarget(void) -{ -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) - X86TargetMachineModule = 1; +#if defined(PIPE_OS_WINDOWS) && defined(PIPE_ARCH_X86) + /* + * This is mis-detected on some hardware / software combinations. + */ + llvm::StackAlignment = 4; + llvm::RealignStack = true; #endif - return 0; -} + /* Same as LLVMInitializeNativeTarget(); */ + llvm::InitializeNativeTarget(); -#endif + LLVMLinkInJIT(); +} /* @@ -69,7 +64,6 @@ LLVMInitializeNativeTarget(void) */ #if defined(_MSC_VER) && defined(_DEBUG) #include -extern "C" { - _CRTIMP void __cdecl _invalid_parameter_noinfo(void) {} -} +extern "C" _CRTIMP void __cdecl +_invalid_parameter_noinfo(void) {} #endif diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.h b/src/gallium/auxiliary/gallivm/lp_bld_init.h index 6a8ab8e5db..07f50d1c43 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.h @@ -30,22 +30,13 @@ #define LP_BLD_INIT_H -#include "llvm/Config/config.h" - #ifdef __cplusplus extern "C" { #endif -#ifndef LLVM_NATIVE_ARCH - void -LLVMLinkInJIT(void); - -int -LLVMInitializeNativeTarget(void); - -#endif /* !LLVM_NATIVE_ARCH */ +lp_build_init(void); #ifdef __cplusplus -- cgit v1.2.3 From 9f9b44222f45a4548070c1019674abe173e2f253 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 12:00:25 +0000 Subject: llvmpipe: Centralize LLVM initialization. --- src/gallium/drivers/llvmpipe/lp_jit.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_test_main.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index d3d7e26882..b666ffc804 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -37,6 +37,7 @@ #include "util/u_memory.h" #include "util/u_cpu_detect.h" +#include "gallivm/lp_bld_init.h" #include "lp_debug.h" #include "lp_screen.h" #include "gallivm/lp_bld_intr.h" @@ -148,8 +149,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) util_cpu_caps.has_sse4_1 = 0; #endif - LLVMLinkInJIT(); - LLVMInitializeNativeTarget(); + lp_build_init(); screen->module = LLVMModuleCreateWithName("llvmpipe"); diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c index b08872b2b5..f9dce8b9c2 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_main.c +++ b/src/gallium/drivers/llvmpipe/lp_test_main.c @@ -380,8 +380,7 @@ int main(int argc, char **argv) n = atoi(argv[i]); } - LLVMLinkInJIT(); - LLVMInitializeNativeTarget(); + lp_build_init(); util_cpu_detect(); -- cgit v1.2.3 From 7b7b66781b373c8930706b321934477e3325be2c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 12:07:39 +0000 Subject: llvmpipe: Linux is no longer a dependency. Llvmpipe builds and runs fine on windows too. --- src/gallium/drivers/llvmpipe/README | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README index ae2c1ba943..bf4c9a5727 100644 --- a/src/gallium/drivers/llvmpipe/README +++ b/src/gallium/drivers/llvmpipe/README @@ -49,8 +49,6 @@ To do (probably by this order): Requirements ============ - - Linux - - A x86 or amd64 processor. 64bit mode is preferred. Support for sse2 is strongly encouraged. Support for ssse3, and sse4.1 will -- cgit v1.2.3 From c51f7a48cde970c06a42a9ca195a2d1cf808fd2c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 13:07:56 +0000 Subject: r300: Remove PIPE_FORMAT_R8G8B8X8_SNORM support. --- src/gallium/drivers/r300/r300_texture.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 44cfe82a57..c0144f64b4 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -329,7 +329,6 @@ static uint32_t r300_translate_colorformat(enum pipe_format format) case PIPE_FORMAT_A8B8G8R8_SRGB: case PIPE_FORMAT_X8B8G8R8_UNORM: case PIPE_FORMAT_X8B8G8R8_SRGB: - case PIPE_FORMAT_R8G8B8X8_SNORM: case PIPE_FORMAT_R8SG8SB8UX8U_NORM: return R300_COLOR_FORMAT_ARGB8888; case PIPE_FORMAT_R10G10B10A2_UNORM: @@ -466,7 +465,6 @@ static uint32_t r300_translate_out_fmt(enum pipe_format format) R300_C2_SEL_G | R300_C3_SEL_R; /* ABGR 32-bit outputs. */ - case PIPE_FORMAT_R8G8B8X8_SNORM: case PIPE_FORMAT_R8SG8SB8UX8U_NORM: case PIPE_FORMAT_R10G10B10A2_UNORM: /* RGBA high precision outputs (same swizzles as ABGR low precision) */ -- cgit v1.2.3 From a5b56c815328c0227926323c40896426bb66d227 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 13:08:08 +0000 Subject: util: Remove PIPE_FORMAT_R8G8B8X8_SNORM information. --- src/gallium/auxiliary/util/u_format.csv | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv index c9766e6207..96a0fa6550 100644 --- a/src/gallium/auxiliary/util/u_format.csv +++ b/src/gallium/auxiliary/util/u_format.csv @@ -86,8 +86,7 @@ PIPE_FORMAT_B8G8R8X8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , zyx1, s PIPE_FORMAT_A8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzwx, srgb PIPE_FORMAT_X8R8G8B8_SRGB , plain, 1, 1, un8 , un8 , un8 , un8 , yzw1, srgb -# Signed formats (typically used for bump map textures) -PIPE_FORMAT_R8G8B8X8_SNORM , plain, 1, 1, sn8 , sn8 , sn8 , sn8 , xyz1, rgb +# Mixed-sign formats (typically used for bump map textures) PIPE_FORMAT_R8SG8SB8UX8U_NORM , plain, 1, 1, sn8 , sn8 , un8 , x8 , xyz1, rgb PIPE_FORMAT_R5SG5SB6U_NORM , plain, 1, 1, sn5 , sn5 , un6 , , xyz1, rgb -- cgit v1.2.3 From f7e403b129456df3bbb445eea42bae7376ecc59d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 13:08:23 +0000 Subject: gallium: Remove PIPE_FORMAT_R8G8B8X8_SNORM. --- src/gallium/include/pipe/p_format.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index 0314172de7..cbf3273ec8 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -121,7 +121,6 @@ enum pipe_format { PIPE_FORMAT_R8G8_SNORM = 75, PIPE_FORMAT_R8G8B8_SNORM = 76, PIPE_FORMAT_R8G8B8A8_SNORM = 77, - PIPE_FORMAT_R8G8B8X8_SNORM = 81, PIPE_FORMAT_R8_SSCALED = 82, PIPE_FORMAT_R8G8_SSCALED = 83, PIPE_FORMAT_R8G8B8_SSCALED = 84, -- cgit v1.2.3 From 4d5dd82558fcf1f6fcfdb95b225a4e3f842a9133 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 18:47:29 +0000 Subject: llvmpipe: Ensure context is flushed when destroying shaders. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 90dae3f910..c4b79dd415 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -974,6 +974,13 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs) assert(fs != llvmpipe->fs); (void) llvmpipe; + /* + * XXX: we need to flush the context until we have some sort of reference + * counting in fragment shaders as they may still be binned + */ + draw_flush(llvmpipe->draw); + lp_setup_flush(llvmpipe->setup, 0); + variant = shader->variants; while(variant) { struct lp_fragment_shader_variant *next = variant->next; -- cgit v1.2.3 From 4053d337035a17c3bded6458093acf56d1878cba Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 3 Mar 2010 19:55:31 +0000 Subject: llvmpipe: Store the original triangle coordinates in the debug build. For debugging purposes only. --- src/gallium/drivers/llvmpipe/lp_rast.h | 4 ++++ src/gallium/drivers/llvmpipe/lp_setup_tri.c | 9 +++++++++ 2 files changed, 13 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h index d91c45eb2b..dc5fc5fc7d 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.h +++ b/src/gallium/drivers/llvmpipe/lp_rast.h @@ -98,6 +98,10 @@ struct lp_rast_shader_inputs { * Objects of this type are put into the setup_context::data buffer. */ struct lp_rast_triangle { +#ifdef DEBUG + float v[3][2]; +#endif + /* one-pixel sized trivial accept offsets for each plane */ int ei1; int ei2; diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c index a8bf540803..e75412ac9a 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c @@ -297,6 +297,15 @@ do_triangle_ccw(struct setup_context *setup, tri = alloc_triangle(scene, setup->fs.nr_inputs, &tri_bytes); +#ifdef DEBUG + tri->v[0][0] = v1[0][0]; + tri->v[1][0] = v2[0][0]; + tri->v[2][0] = v3[0][0]; + tri->v[0][1] = v1[0][1]; + tri->v[1][1] = v2[0][1]; + tri->v[2][1] = v3[0][1]; +#endif + tri->dx12 = x1 - x2; tri->dx23 = x2 - x3; tri->dx31 = x3 - x1; -- cgit v1.2.3 From fcf438e9e03f6e75bca4a49ad372fe7c4b1abbf8 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Feb 2010 18:49:33 -0800 Subject: mesa: Remove support for creating color-index visuals Remove the rgbMode and indexBits parameters from _mesa_create_visual and _mesa_initialize_visual. These values are now hardcoded to GL_TRUE and 0. Signed-off-by: Ian Romanick --- src/gallium/state_trackers/glx/xlib/xm_api.c | 3 +-- src/mesa/drivers/beos/GLView.cpp | 4 +--- src/mesa/drivers/fbdev/glfbdev.c | 6 +++--- src/mesa/drivers/glslcompiler/glslcompiler.c | 4 ++-- src/mesa/drivers/osmesa/osmesa.c | 4 +--- src/mesa/drivers/windows/gdi/wmesa.c | 4 +--- src/mesa/drivers/windows/gldirect/dglcontext.c | 2 -- src/mesa/drivers/x11/xm_api.c | 3 +-- src/mesa/main/context.c | 15 +++++---------- src/mesa/main/context.h | 6 +----- 10 files changed, 16 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 68518b19b9..217bdeff75 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -746,10 +746,9 @@ XMesaVisual XMesaCreateVisual( Display *display, } _mesa_initialize_visual( &v->mesa_visual, - rgb_flag, db_flag, stereo_flag, + db_flag, stereo_flag, red_bits, green_bits, blue_bits, alpha_bits, - v->mesa_visual.indexBits, depth_size, stencil_size, accum_red_size, accum_green_size, diff --git a/src/mesa/drivers/beos/GLView.cpp b/src/mesa/drivers/beos/GLView.cpp index 9e4a7ebe56..a029f6b200 100644 --- a/src/mesa/drivers/beos/GLView.cpp +++ b/src/mesa/drivers/beos/GLView.cpp @@ -297,11 +297,9 @@ BGLView::BGLView(BRect rect, char *name, MesaDriver * md = new MesaDriver(); // examine option flags and create gl_context struct - GLvisual * visual = _mesa_create_visual( rgbFlag, - dblFlag, + GLvisual * visual = _mesa_create_visual( dblFlag, stereoFlag, red, green, blue, alpha, - index, depth, stencil, accum, accum, accum, accum, diff --git a/src/mesa/drivers/fbdev/glfbdev.c b/src/mesa/drivers/fbdev/glfbdev.c index e6ece69a64..0ea2796eaa 100644 --- a/src/mesa/drivers/fbdev/glfbdev.c +++ b/src/mesa/drivers/fbdev/glfbdev.c @@ -327,7 +327,7 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, const int *attrib; GLboolean dbFlag = GL_FALSE, stereoFlag = GL_FALSE; GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits = 0; - GLint indexBits = 0, depthBits = 0, stencilBits = 0; + GLint depthBits = 0, stencilBits = 0; GLint accumRedBits = 0, accumGreenBits = 0; GLint accumBlueBits = 0, accumAlphaBits = 0; GLint numSamples = 0; @@ -414,9 +414,9 @@ glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo, } } - if (!_mesa_initialize_visual(&vis->glvisual, GL_TRUE, dbFlag, stereoFlag, + if (!_mesa_initialize_visual(&vis->glvisual, dbFlag, stereoFlag, redBits, greenBits, blueBits, alphaBits, - indexBits, depthBits, stencilBits, + depthBits, stencilBits, accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits, numSamples)) { diff --git a/src/mesa/drivers/glslcompiler/glslcompiler.c b/src/mesa/drivers/glslcompiler/glslcompiler.c index 448029dace..66035a4a43 100644 --- a/src/mesa/drivers/glslcompiler/glslcompiler.c +++ b/src/mesa/drivers/glslcompiler/glslcompiler.c @@ -113,9 +113,9 @@ CreateContext(void) GLcontext *ctx; CompilerContext *cc; - vis = _mesa_create_visual(GL_TRUE, GL_FALSE, GL_FALSE, /* RGB */ + vis = _mesa_create_visual(GL_FALSE, GL_FALSE, /* RGB */ 8, 8, 8, 8, /* color */ - 0, 0, 0, /* z, stencil */ + 0, 0, /* z, stencil */ 0, 0, 0, 0, 1); /* accum */ buf = _mesa_create_framebuffer(vis); diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c index bb6dbdf1c0..e20507ae92 100644 --- a/src/mesa/drivers/osmesa/osmesa.c +++ b/src/mesa/drivers/osmesa/osmesa.c @@ -1116,14 +1116,12 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits, osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); if (osmesa) { - osmesa->gl_visual = _mesa_create_visual( GL_TRUE, /* rgbMode */ - GL_FALSE, /* double buffer */ + osmesa->gl_visual = _mesa_create_visual( GL_FALSE, /* double buffer */ GL_FALSE, /* stereo */ redBits, greenBits, blueBits, alphaBits, - 0, depthBits, stencilBits, accumBits, diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 2fdcb387be..91ddc3615a 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1461,12 +1461,10 @@ WMesaContext WMesaCreateContext(HDC hDC, break; } /* Create visual based on flags */ - visual = _mesa_create_visual(rgb_flag, - db_flag, /* db_flag */ + visual = _mesa_create_visual(db_flag, /* db_flag */ GL_FALSE, /* stereo */ red_bits, green_bits, blue_bits, /* color RGB */ alpha_flag ? alpha_bits : 0, /* color A */ - 0, /* index bits */ DEFAULT_SOFTWARE_DEPTH_BITS, /* depth_bits */ 8, /* stencil_bits */ 16,16,16, /* accum RGB */ diff --git a/src/mesa/drivers/windows/gldirect/dglcontext.c b/src/mesa/drivers/windows/gldirect/dglcontext.c index e9c23d1ccb..a420b36ffb 100644 --- a/src/mesa/drivers/windows/gldirect/dglcontext.c +++ b/src/mesa/drivers/windows/gldirect/dglcontext.c @@ -1377,14 +1377,12 @@ SkipPrimaryCreate: #ifdef _USE_GLD3_WGL lpCtx->glVis = _mesa_create_visual( - GL_TRUE, // RGB mode bDouble, /* double buffer */ GL_FALSE, // stereo lpPFD->cRedBits, lpPFD->cGreenBits, lpPFD->cBlueBits, dwAlphaBits, - 0, // index bits dwDepthBits, dwStencilBits, lpPFD->cAccumRedBits, // accum bits diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index c59df55166..a1723fa37b 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1443,10 +1443,9 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, } _mesa_initialize_visual( &v->mesa_visual, - GL_TRUE, db_flag, stereo_flag, + db_flag, stereo_flag, red_bits, green_bits, blue_bits, alpha_bits, - v->mesa_visual.indexBits, depth_size, stencil_size, accum_red_size, accum_green_size, diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 4ecbb5ecf6..b827d54176 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -184,7 +184,6 @@ _mesa_notifySwapBuffers(__GLcontext *ctx) * Allocates a GLvisual structure and initializes it via * _mesa_initialize_visual(). * - * \param rgbFlag GL_TRUE for RGB(A) mode, GL_FALSE for Color Index mode. * \param dbFlag double buffering * \param stereoFlag stereo buffer * \param depthBits requested bits per depth buffer value. Any value in [0, 32] @@ -206,14 +205,12 @@ _mesa_notifySwapBuffers(__GLcontext *ctx) * \note Need to add params for level and numAuxBuffers (at least) */ GLvisual * -_mesa_create_visual( GLboolean rgbFlag, - GLboolean dbFlag, +_mesa_create_visual( GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, - GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, @@ -224,9 +221,9 @@ _mesa_create_visual( GLboolean rgbFlag, { GLvisual *vis = (GLvisual *) calloc(1, sizeof(GLvisual)); if (vis) { - if (!_mesa_initialize_visual(vis, rgbFlag, dbFlag, stereoFlag, + if (!_mesa_initialize_visual(vis, dbFlag, stereoFlag, redBits, greenBits, blueBits, alphaBits, - indexBits, depthBits, stencilBits, + depthBits, stencilBits, accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits, numSamples)) { @@ -248,14 +245,12 @@ _mesa_create_visual( GLboolean rgbFlag, */ GLboolean _mesa_initialize_visual( GLvisual *vis, - GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, - GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, @@ -277,7 +272,7 @@ _mesa_initialize_visual( GLvisual *vis, assert(accumBlueBits >= 0); assert(accumAlphaBits >= 0); - vis->rgbMode = rgbFlag; + vis->rgbMode = GL_TRUE; vis->doubleBufferMode = dbFlag; vis->stereoMode = stereoFlag; @@ -287,7 +282,7 @@ _mesa_initialize_visual( GLvisual *vis, vis->alphaBits = alphaBits; vis->rgbBits = redBits + greenBits + blueBits; - vis->indexBits = indexBits; + vis->indexBits = 0; vis->depthBits = depthBits; vis->stencilBits = stencilBits; diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index c3be1063f8..09bf1777da 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -60,14 +60,12 @@ struct _glapi_table; /*@{*/ extern GLvisual * -_mesa_create_visual( GLboolean rgbFlag, - GLboolean dbFlag, +_mesa_create_visual( GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, - GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, @@ -78,14 +76,12 @@ _mesa_create_visual( GLboolean rgbFlag, extern GLboolean _mesa_initialize_visual( GLvisual *v, - GLboolean rgbFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint redBits, GLint greenBits, GLint blueBits, GLint alphaBits, - GLint indexBits, GLint depthBits, GLint stencilBits, GLint accumRedBits, -- cgit v1.2.3 From 016fc30839f0fb67bb37d4a7353a7e38749deab5 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 3 Mar 2010 16:02:45 -0800 Subject: Remove support for GCC older than 3.3.0 Signed-off-by: Ian Romanick --- include/GL/gl.h | 3 +-- include/GL/glut.h | 2 +- src/egl/main/eglcompiler.h | 5 ++--- src/gallium/include/pipe/p_compiler.h | 7 +++---- src/glx/XF86dri.c | 2 +- src/glx/glxclient.h | 2 +- src/glx/indirect_vertex_program.c | 2 +- src/glx/pixelstore.c | 2 +- src/mesa/glapi/glapi.h | 2 +- src/mesa/main/compiler.h | 10 ++++------ src/mesa/main/imports.h | 4 +--- src/mesa/x86/assyntax.h | 2 +- 12 files changed, 18 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/include/GL/gl.h b/include/GL/gl.h index 3fce3dfc0a..8e5f1383ff 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -67,8 +67,7 @@ #elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */ # define GLAPI extern # define GLAPIENTRY __stdcall -#elif (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ - || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +#elif defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define GLAPI __attribute__((visibility("default"))) # define GLAPIENTRY #endif /* WIN32 && !CYGWIN */ diff --git a/include/GL/glut.h b/include/GL/glut.h index d9fc938dc7..a282635205 100644 --- a/include/GL/glut.h +++ b/include/GL/glut.h @@ -103,7 +103,7 @@ extern "C" { # define GLUTAPI extern #endif -#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#elif defined(__GNUC__) # define GLUTAPIENTRY # define GLUTAPIENTRYV diff --git a/src/egl/main/eglcompiler.h b/src/egl/main/eglcompiler.h index d844fbb0ef..401a9cf56a 100644 --- a/src/egl/main/eglcompiler.h +++ b/src/egl/main/eglcompiler.h @@ -64,8 +64,7 @@ /** * Function visibility */ -#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ - || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PUBLIC __attribute__((visibility("default"))) #else # define PUBLIC @@ -79,7 +78,7 @@ #ifndef __FUNCTION__ # if defined(__VMS) # define __FUNCTION__ "VMS$NL:" -# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \ +# elif (!defined __GNUC__) && (!defined __xlC__) && \ (!defined(_MSC_VER) || _MSC_VER < 1300) # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ (defined(__SUNPRO_C) && defined(__C99FEATURES__)) diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index c7d3507494..b93b38310a 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -106,8 +106,7 @@ typedef unsigned char boolean; /* Function visibility */ #ifndef PUBLIC -# if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ - || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) # define PUBLIC __attribute__((visibility("default"))) # else # define PUBLIC @@ -119,7 +118,7 @@ typedef unsigned char boolean; * If we're not using gcc, define __FUNCTION__ as a cpp symbol here. */ #ifndef __FUNCTION__ -# if (!defined(__GNUC__) || (__GNUC__ < 2)) +# if !defined(__GNUC__) # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ (defined(__SUNPRO_C) && defined(__C99FEATURES__)) # define __FUNCTION__ __func__ @@ -145,7 +144,7 @@ typedef unsigned char boolean; -#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) +#if defined(__GNUC__) #define PIPE_DEPRECATED __attribute__((__deprecated__)) #else #define PIPE_DEPRECATED diff --git a/src/glx/XF86dri.c b/src/glx/XF86dri.c index 248d96ac5d..fdbdd43000 100644 --- a/src/glx/XF86dri.c +++ b/src/glx/XF86dri.c @@ -45,7 +45,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86dristr.h" -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#if defined(__GNUC__) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) #else diff --git a/src/glx/glxclient.h b/src/glx/glxclient.h index 04ce781c43..8e5dc785dd 100644 --- a/src/glx/glxclient.h +++ b/src/glx/glxclient.h @@ -69,7 +69,7 @@ * We also need to define a USED attribute, so the optimizer doesn't * inline a static function that we later use in an alias. - ajax */ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 +#if defined(__GNUC__) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) #else diff --git a/src/glx/indirect_vertex_program.c b/src/glx/indirect_vertex_program.c index 3313ac008a..d822a7ee56 100644 --- a/src/glx/indirect_vertex_program.c +++ b/src/glx/indirect_vertex_program.c @@ -30,7 +30,7 @@ #include "indirect_vertex_array.h" #include -#if !defined __GNUC__ || __GNUC__ < 3 +#if !defined(__GNUC__) # define __builtin_expect(x, y) x #endif diff --git a/src/glx/pixelstore.c b/src/glx/pixelstore.c index 8b51b5d8b7..dc193b9f74 100644 --- a/src/glx/pixelstore.c +++ b/src/glx/pixelstore.c @@ -31,7 +31,7 @@ #include "glxclient.h" #include "indirect.h" -#if !defined __GNUC__ || __GNUC__ < 3 +#if !defined(__GNUC__) # define __builtin_expect(x, y) x #endif diff --git a/src/mesa/glapi/glapi.h b/src/mesa/glapi/glapi.h index 2eae6d5c43..1ca2e4beff 100644 --- a/src/mesa/glapi/glapi.h +++ b/src/mesa/glapi/glapi.h @@ -62,7 +62,7 @@ typedef void (*_glapi_proc)(void); /* generic function pointer */ #endif -#if defined(__GNUC__) && (__GNUC__ >= 3) +#if defined(__GNUC__) # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) #else diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h index 9cef99f67a..05e69e56a6 100644 --- a/src/mesa/main/compiler.h +++ b/src/mesa/main/compiler.h @@ -173,8 +173,7 @@ extern "C" { * We also need to define a USED attribute, so the optimizer doesn't * inline a static function that we later use in an alias. - ajax */ -#if (defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303) \ - || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +#if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) #else @@ -197,7 +196,7 @@ extern "C" { /** * __builtin_expect macros */ -#if (!defined(__GNUC__) || __GNUC__ < 3) && (!defined(__IBMC__) || __IBMC__ < 900) +#if !defined(__GNUC__) # define __builtin_expect(x, y) x #endif @@ -210,7 +209,7 @@ extern "C" { #ifndef __FUNCTION__ # if defined(__VMS) # define __FUNCTION__ "VMS$NL:" -# elif ((!defined __GNUC__) || (__GNUC__ < 2)) && (!defined __xlC__) && \ +# elif !defined(__GNUC__) && !defined(__xlC__) && \ (!defined(_MSC_VER) || _MSC_VER < 1300) # if (__STDC_VERSION__ >= 199901L) /* C99 */ || \ (defined(__SUNPRO_C) && defined(__C99FEATURES__)) @@ -322,8 +321,7 @@ static INLINE GLuint CPU_TO_LE32(GLuint x) * LONGSTRING macro * gcc -pedantic warns about long string literals, LONGSTRING silences that. */ -#if !defined(__GNUC__) || (__GNUC__ < 2) || \ - ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 7)) +#if !defined(__GNUC__) # define LONGSTRING #else # define LONGSTRING __extension__ diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index ac3a7b5d61..fb4a00eca7 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -240,9 +240,7 @@ static INLINE int GET_FLOAT_BITS( float x ) /*** *** IROUND: return (as an integer) float rounded to nearest integer ***/ -#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) && \ - (!(defined(__BEOS__) || defined(__HAIKU__)) || \ - (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95))) +#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) static INLINE int iround(float f) { int r; diff --git a/src/mesa/x86/assyntax.h b/src/mesa/x86/assyntax.h index de1f6a48de..4a41812f6b 100644 --- a/src/mesa/x86/assyntax.h +++ b/src/mesa/x86/assyntax.h @@ -1737,7 +1737,7 @@ SECTION _DATA public align=16 class=DATA use32 flat */ #if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) # define HIDDEN(x) .hidden x -#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) +#elif defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__) # pragma GCC visibility push(default) # define HIDDEN(x) .hidden x #else -- cgit v1.2.3 From f4113012e0b0defa0ddb8ff3b7f6a518df9ac1e0 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 3 Mar 2010 18:20:01 -0800 Subject: wgl: Fix mingw32 build. This was missed in commit fcf438e9e03f6e75bca4a49ad372fe7c4b1abbf8. --- src/gallium/state_trackers/wgl/stw_pixelformat.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c index f8edc560c5..bc28f31ed1 100644 --- a/src/gallium/state_trackers/wgl/stw_pixelformat.c +++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c @@ -271,14 +271,12 @@ stw_pixelformat_visual(GLvisual *visual, memset(visual, 0, sizeof *visual); _mesa_initialize_visual( visual, - (pfi->pfd.iPixelType == PFD_TYPE_RGBA) ? GL_TRUE : GL_FALSE, (pfi->pfd.dwFlags & PFD_DOUBLEBUFFER) ? GL_TRUE : GL_FALSE, (pfi->pfd.dwFlags & PFD_STEREO) ? GL_TRUE : GL_FALSE, pfi->pfd.cRedBits, pfi->pfd.cGreenBits, pfi->pfd.cBlueBits, pfi->pfd.cAlphaBits, - (pfi->pfd.iPixelType == PFD_TYPE_COLORINDEX) ? pfi->pfd.cColorBits : 0, pfi->pfd.cDepthBits, pfi->pfd.cStencilBits, pfi->pfd.cAccumRedBits, -- cgit v1.2.3 From 4b61fd22a87342bafc3da2264b68537c6eb80375 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 13:22:21 +0000 Subject: r300g: remove dead r300_get_texture_buffer function --- src/gallium/drivers/r300/r300_context.c | 16 ++++++++++------ src/gallium/drivers/r300/r300_texture.c | 18 ------------------ src/gallium/drivers/r300/r300_texture.h | 6 ++---- src/gallium/drivers/r300/r300_winsys.h | 5 ----- 4 files changed, 12 insertions(+), 33 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 86b98a4ba5..6308d3a087 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -72,11 +72,8 @@ r300_is_texture_referenced(struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level) { - struct pipe_buffer* buf = 0; - - r300_get_texture_buffer(pipe->screen, texture, &buf, NULL); - - return pipe->is_buffer_referenced(pipe, buf); + return pipe->is_buffer_referenced(pipe, + ((struct r300_texture *)texture)->buffer); } static unsigned int @@ -86,7 +83,14 @@ r300_is_buffer_referenced(struct pipe_context *pipe, /* This only checks to see whether actual hardware buffers are * referenced. Since we use managed BOs and transfers, it's actually not * possible for pipe_buffers to ever reference the actual hardware, so - * buffers are never referenced. */ + * buffers are never referenced. + */ + + /* XXX: that doesn't make sense given that + * r300_is_texture_referenced is implemented on top of this + * function and hardware can certainly refer to textures + * directly... + */ return 0; } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 3b39207a45..93224e8d20 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -974,21 +974,3 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen) screen->video_surface_destroy= r300_video_surface_destroy; } -boolean r300_get_texture_buffer(struct pipe_screen* screen, - struct pipe_texture* texture, - struct pipe_buffer** buffer, - unsigned* stride) -{ - struct r300_texture* tex = (struct r300_texture*)texture; - if (!tex) { - return FALSE; - } - - pipe_buffer_reference(buffer, tex->buffer); - - if (stride) { - *stride = r300_texture_get_stride(r300_screen(screen), tex, 0); - } - - return TRUE; -} diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 46a5fb6188..138b62784e 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -60,13 +60,11 @@ r300_video_surface(struct pipe_video_surface *pvs) return (struct r300_video_surface *)pvs; } -#ifndef R300_WINSYS_H - +/* Used internally for texture_is_referenced() + */ boolean r300_get_texture_buffer(struct pipe_screen* screen, struct pipe_texture* texture, struct pipe_buffer** buffer, unsigned* stride); -#endif /* R300_WINSYS_H */ - #endif /* R300_TEXTURE_H */ diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 40fb8a95ca..ddf2b79003 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -40,11 +40,6 @@ struct radeon_winsys; struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys); -boolean r300_get_texture_buffer(struct pipe_screen* screen, - struct pipe_texture* texture, - struct pipe_buffer** buffer, - unsigned* stride); - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 86e146df977d8df97026291c46aa4adfc13309e1 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 13:22:37 +0000 Subject: softpipe: remove dead get_texture_buffer function --- src/gallium/drivers/softpipe/sp_texture.c | 20 -------------------- src/gallium/drivers/softpipe/sp_winsys.h | 6 ------ 2 files changed, 26 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index d3997854b2..44710d9992 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -475,24 +475,4 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) } -/** - * Return pipe_buffer handle and stride for given texture object. - * XXX used for??? - */ -boolean -softpipe_get_texture_buffer( struct pipe_texture *texture, - struct pipe_buffer **buf, - unsigned *stride ) -{ - struct softpipe_texture *tex = (struct softpipe_texture *) texture; - - if (!tex) - return FALSE; - pipe_buffer_reference(buf, tex->buffer); - - if (stride) - *stride = tex->stride[0]; - - return TRUE; -} diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h index 6e3920c49b..edc49f256d 100644 --- a/src/gallium/drivers/softpipe/sp_winsys.h +++ b/src/gallium/drivers/softpipe/sp_winsys.h @@ -60,12 +60,6 @@ struct pipe_screen *softpipe_create_screen( struct pipe_winsys * ); */ struct pipe_screen *softpipe_create_screen_malloc(void); -boolean -softpipe_get_texture_buffer( struct pipe_texture *texture, - struct pipe_buffer **buf, - unsigned *stride ); - - #ifdef __cplusplus } #endif -- cgit v1.2.3 From 3bd622d64ec3826d3563a5cd9790cd7accc123b4 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Mar 2010 14:36:51 +0000 Subject: nouveau: Conversion to winsys handle Not the best conversion that could be done. --- src/gallium/drivers/nouveau/nouveau_screen.c | 72 ++++++++++++++++++++++ .../winsys/drm/nouveau/drm/nouveau_drm_api.c | 72 ++-------------------- 2 files changed, 78 insertions(+), 66 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 3c2f771b51..2013eef0c5 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -4,6 +4,7 @@ #include "util/u_memory.h" #include "util/u_inlines.h" +#include "util/u_format.h" #include #include @@ -12,6 +13,9 @@ #include "nouveau_winsys.h" #include "nouveau_screen.h" +/* XXX this should go away */ +#include "state_tracker/drm_api.h" + static const char * nouveau_screen_get_name(struct pipe_screen *pscreen) { @@ -231,6 +235,71 @@ nouveau_screen_fence_finish(struct pipe_screen *screen, return 0; } + +/* + * Both texture_{from|get}_handle use drm api defines directly which they + * shouldn't do. The problem is that from|get are pipe functions and as + * such they should be defined in the pipe level. If nouveau had a propper + * winsys interface we would have added from|get to that interface using + * the winsys_handle struct as done with other drivers. However this code + * calls directly into the libdrm_nouveau.so functions (nouveau_bo_*). So + * we need to translate the handle into something they understand. + */ +static struct pipe_texture * +nouveau_screen_texture_from_handle(struct pipe_screen *pscreen, + const struct pipe_texture *templ, + struct winsys_handle *whandle) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct pipe_texture *pt; + struct pipe_buffer *pb; + int ret; + + pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*)); + if (!pb) + return NULL; + + ret = nouveau_bo_handle_ref(dev, whandle->handle, (struct nouveau_bo**)(pb+1)); + if (ret) { + debug_printf("%s: ref name 0x%08x failed with %d\n", + __func__, whandle->handle, ret); + FREE(pb); + return NULL; + } + + pipe_reference_init(&pb->reference, 1); + pb->screen = pscreen; + pb->alignment = 0; + pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | + PIPE_BUFFER_USAGE_CPU_READ_WRITE; + pb->size = nouveau_bo(pb)->size; + pt = pscreen->texture_blanket(pscreen, templ, &whandle->stride, pb); + pipe_buffer_reference(&pb, NULL); + return pt; +} + +static boolean +nouveau_screen_texture_get_handle(struct pipe_screen *pscreen, + struct pipe_texture *pt, + struct winsys_handle *whandle) +{ + struct nouveau_miptree *mt = nouveau_miptree(pt); + + if (!mt || !mt->bo) + return false; + + whandle->stride = util_format_get_stride(mt->base.format, mt->base.width0); + + if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { + return nouveau_bo_handle_get(mt->bo, &whandle->handle) == 0; + } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { + whandle->handle = mt->bo->handle; + return TRUE; + } else { + return FALSE; + } +} + int nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) { @@ -258,6 +327,9 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) pscreen->fence_signalled = nouveau_screen_fence_signalled; pscreen->fence_finish = nouveau_screen_fence_finish; + pscreen->texture_from_handle = nouveau_screen_texture_from_handle; + pscreen->texture_get_handle = nouveau_screen_texture_get_handle; + return 0; } diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c index 80b5a4c091..af9e92edd9 100644 --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c @@ -21,6 +21,7 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen, struct pipe_surface *ps = NULL; struct pipe_texture *pt = NULL; struct pipe_texture tmpl; + struct winsys_handle whandle; memset(&tmpl, 0, sizeof(tmpl)); tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT; @@ -31,8 +32,11 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen, tmpl.width0 = width; tmpl.height0 = height; - pt = api->texture_from_shared_handle(api, pscreen, &tmpl, - "front buffer", pitch, handle); + memset(&whandle, 0, sizeof(whandle)); + whandle.stride = pitch; + whandle.handle = handle; + + pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle); if (!pt) return NULL; @@ -142,74 +146,10 @@ nouveau_drm_create_screen(struct drm_api *api, int fd, return nvws->pscreen; } -static struct pipe_texture * -nouveau_drm_pt_from_name(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *templ, const char *name, - unsigned stride, unsigned handle) -{ - struct nouveau_device *dev = nouveau_screen(pscreen)->device; - struct pipe_texture *pt; - struct pipe_buffer *pb; - int ret; - - pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*)); - if (!pb) - return NULL; - - ret = nouveau_bo_handle_ref(dev, handle, (struct nouveau_bo**)(pb+1)); - if (ret) { - debug_printf("%s: ref name 0x%08x failed with %d\n", - __func__, handle, ret); - FREE(pb); - return NULL; - } - - pipe_reference_init(&pb->reference, 1); - pb->screen = pscreen; - pb->alignment = 0; - pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | - PIPE_BUFFER_USAGE_CPU_READ_WRITE; - pb->size = nouveau_bo(pb)->size; - pt = pscreen->texture_blanket(pscreen, templ, &stride, pb); - pipe_buffer_reference(&pb, NULL); - return pt; -} - -static boolean -nouveau_drm_name_from_pt(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *pt, unsigned *stride, - unsigned *handle) -{ - struct nouveau_miptree *mt = nouveau_miptree(pt); - - if (!mt || !mt->bo) - return false; - - return nouveau_bo_handle_get(mt->bo, handle) == 0; -} - -static boolean -nouveau_drm_handle_from_pt(struct drm_api *api, struct pipe_screen *pscreen, - struct pipe_texture *pt, unsigned *stride, - unsigned *handle) -{ - struct nouveau_miptree *mt = nouveau_miptree(pt); - - if (!mt || !mt->bo) - return false; - - *handle = mt->bo->handle; - *stride = util_format_get_stride(mt->base.format, mt->base.width0); - return true; -} - struct drm_api drm_api_hooks = { .name = "nouveau", .driver_name = "nouveau", .create_screen = nouveau_drm_create_screen, - .texture_from_shared_handle = nouveau_drm_pt_from_name, - .shared_handle_from_texture = nouveau_drm_name_from_pt, - .local_handle_from_texture = nouveau_drm_handle_from_pt, }; struct drm_api * -- cgit v1.2.3 From caa8a365c512d477b9698e79f55da9c041eb1bef Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 4 Mar 2010 14:57:44 +0000 Subject: svga: Forgot one bit in rebase --- src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c index 0e3dad84a5..657544dcb2 100644 --- a/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c +++ b/src/gallium/winsys/drm/vmware/core/vmw_screen_dri.c @@ -365,9 +365,6 @@ static struct drm_api vmw_drm_api_hooks = { .name = "vmwgfx", .driver_name = "vmwgfx", .create_screen = vmw_drm_create_screen, - .texture_from_shared_handle = vmw_drm_texture_from_handle, - .shared_handle_from_texture = vmw_drm_handle_from_texture, - .local_handle_from_texture = vmw_drm_handle_from_texture, }; struct drm_api* drm_api_create() -- cgit v1.2.3 From 94ce4eb3c27706d992226d847d123c46b14b1c4f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 16:09:33 +0000 Subject: softpipe: rework to use the llvmpipe winsys Promote the llvmpipe winsys more or less unchanged to state_trackers/sw_winsys.h. Some minor breakages: - softpipe::texture_blanket is broken, but scheduled for removal anyway. - haven't fixed up g3vdl yet. --- src/gallium/drivers/llvmpipe/lp_screen.c | 8 +- src/gallium/drivers/llvmpipe/lp_screen.h | 4 +- src/gallium/drivers/llvmpipe/lp_setup.c | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 8 +- src/gallium/drivers/llvmpipe/lp_texture.h | 5 +- src/gallium/drivers/llvmpipe/lp_winsys.h | 125 ------- src/gallium/drivers/softpipe/Makefile | 4 +- src/gallium/drivers/softpipe/SConscript | 4 +- src/gallium/drivers/softpipe/sp_buffer.c | 118 +++++++ src/gallium/drivers/softpipe/sp_buffer.h | 55 +++ src/gallium/drivers/softpipe/sp_context.c | 2 +- src/gallium/drivers/softpipe/sp_draw_arrays.c | 96 +----- src/gallium/drivers/softpipe/sp_screen.c | 43 ++- src/gallium/drivers/softpipe/sp_screen.h | 12 + src/gallium/drivers/softpipe/sp_state_fs.c | 20 +- src/gallium/drivers/softpipe/sp_texture.c | 115 +++---- src/gallium/drivers/softpipe/sp_texture.h | 11 +- src/gallium/drivers/softpipe/sp_winsys.c | 245 -------------- src/gallium/drivers/softpipe/sp_winsys.h | 73 ---- src/gallium/include/state_tracker/sw_winsys.h | 121 +++++++ src/gallium/winsys/gdi/SConscript | 2 +- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 157 +-------- src/gallium/winsys/gdi/gdi_softpipe_winsys.c | 239 ++----------- src/gallium/winsys/xlib/Makefile | 1 + src/gallium/winsys/xlib/SConscript | 4 +- src/gallium/winsys/xlib/xlib.c | 4 +- src/gallium/winsys/xlib/xlib.h | 7 + src/gallium/winsys/xlib/xlib_llvmpipe.c | 363 +------------------- src/gallium/winsys/xlib/xlib_softpipe.c | 464 +------------------------- src/gallium/winsys/xlib/xlib_sw_winsys.c | 394 ++++++++++++++++++++++ 30 files changed, 897 insertions(+), 1809 deletions(-) delete mode 100644 src/gallium/drivers/llvmpipe/lp_winsys.h create mode 100644 src/gallium/drivers/softpipe/sp_buffer.c create mode 100644 src/gallium/drivers/softpipe/sp_buffer.h delete mode 100644 src/gallium/drivers/softpipe/sp_winsys.c delete mode 100644 src/gallium/drivers/softpipe/sp_winsys.h create mode 100644 src/gallium/include/state_tracker/sw_winsys.h create mode 100644 src/gallium/winsys/xlib/xlib_sw_winsys.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f84ede675b..8816440a50 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -167,7 +167,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, unsigned geom_flags ) { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; const struct util_format_description *format_desc; format_desc = util_format_description(format); @@ -258,7 +258,7 @@ llvmpipe_flush_frontbuffer(struct pipe_screen *_screen, void *context_private) { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; struct llvmpipe_texture *texture = llvmpipe_texture(surface->texture); assert(texture->dt); @@ -271,7 +271,7 @@ static void llvmpipe_destroy_screen( struct pipe_screen *_screen ) { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; lp_jit_screen_cleanup(screen); @@ -288,7 +288,7 @@ llvmpipe_destroy_screen( struct pipe_screen *_screen ) * Note: we're not presently subclassing pipe_screen (no llvmpipe_screen). */ struct pipe_screen * -llvmpipe_create_screen(struct llvmpipe_winsys *winsys) +llvmpipe_create_screen(struct sw_winsys *winsys) { struct llvmpipe_screen *screen = CALLOC_STRUCT(llvmpipe_screen); diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 4a1b4d6f3e..3211822b53 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -43,14 +43,14 @@ #include "pipe/p_defines.h" -struct llvmpipe_winsys; +struct sw_winsys; struct llvmpipe_screen { struct pipe_screen base; - struct llvmpipe_winsys *winsys; + struct sw_winsys *winsys; LLVMModuleRef module; LLVMExecutionEngineRef engine; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index aebed85fbb..72b19d0b05 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -479,7 +479,7 @@ lp_setup_set_sampler_textures( struct setup_context *setup, */ struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen); - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; jit_tex->data = winsys->displaytarget_map(winsys, lp_tex->dt, PIPE_BUFFER_USAGE_CPU_READ); assert(jit_tex->data); diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 7f45635542..aed9ed6175 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -93,7 +93,7 @@ static boolean llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen, struct llvmpipe_texture *lpt) { - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; /* Round up the surface size to a multiple of the tile size to * avoid tile clipping. @@ -187,7 +187,7 @@ llvmpipe_texture_destroy(struct pipe_texture *pt) if (lpt->dt) { /* display target */ - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; winsys->displaytarget_destroy(winsys, lpt->dt); } else { @@ -357,7 +357,7 @@ llvmpipe_transfer_map( struct pipe_screen *_screen, if (lpt->dt) { /* display target */ - struct llvmpipe_winsys *winsys = screen->winsys; + struct sw_winsys *winsys = screen->winsys; map = winsys->displaytarget_map(winsys, lpt->dt, pipe_transfer_buffer_flags(transfer)); @@ -398,7 +398,7 @@ llvmpipe_transfer_unmap(struct pipe_screen *screen, if (lpt->dt) { /* display target */ - struct llvmpipe_winsys *winsys = lp_screen->winsys; + struct sw_winsys *winsys = lp_screen->winsys; winsys->displaytarget_unmap(winsys, lpt->dt); } } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 87c905bc02..6a6d9f9222 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -35,7 +35,8 @@ struct pipe_context; struct pipe_screen; struct llvmpipe_context; -struct llvmpipe_displaytarget; + +struct sw_displaytarget; struct llvmpipe_texture @@ -49,7 +50,7 @@ struct llvmpipe_texture * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET * usage. */ - struct llvmpipe_displaytarget *dt; + struct sw_displaytarget *dt; /** * Malloc'ed data for regular textures, or a mapping to dt above. diff --git a/src/gallium/drivers/llvmpipe/lp_winsys.h b/src/gallium/drivers/llvmpipe/lp_winsys.h deleted file mode 100644 index ce11fa9304..0000000000 --- a/src/gallium/drivers/llvmpipe/lp_winsys.h +++ /dev/null @@ -1,125 +0,0 @@ -/************************************************************************** - * - * Copyright 2007-2009 VMware, Inc. - * 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. - * - **************************************************************************/ - -/** - * @file - * llvmpipe public interface. - */ - - -#ifndef LP_WINSYS_H -#define LP_WINSYS_H - - -#include "pipe/p_compiler.h" /* for boolean */ -#include "pipe/p_format.h" - - -#ifdef __cplusplus -extern "C" { -#endif - - -struct pipe_screen; -struct pipe_context; - - -/** - * Opaque pointer. - */ -struct llvmpipe_displaytarget; - - -/** - * This is the interface that llvmpipe expects any window system - * hosting it to implement. - * - * llvmpipe is for the most part a self sufficient driver. The only thing it - * does not know is how to display a surface. - */ -struct llvmpipe_winsys -{ - void - (*destroy)( struct llvmpipe_winsys *ws ); - - boolean - (*is_displaytarget_format_supported)( struct llvmpipe_winsys *ws, - enum pipe_format format ); - - /** - * Allocate storage for a render target. - * - * Often surfaces which are meant to be blitted to the front screen (i.e., - * display targets) must be allocated with special characteristics, memory - * pools, or obtained directly from the windowing system. - * - * This callback is invoked by the pipe_screen when creating a texture marked - * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying - * storage. - */ - struct llvmpipe_displaytarget * - (*displaytarget_create)( struct llvmpipe_winsys *ws, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride ); - - void * - (*displaytarget_map)( struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - unsigned flags ); - - void - (*displaytarget_unmap)( struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt ); - - /** - * @sa pipe_screen:flush_frontbuffer. - * - * This call will likely become asynchronous eventually. - */ - void - (*displaytarget_display)( struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - void *context_private ); - - void - (*displaytarget_destroy)( struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt ); -}; - - - -struct pipe_screen * -llvmpipe_create_screen( struct llvmpipe_winsys * ); - - -#ifdef __cplusplus -} -#endif - -#endif /* LP_WINSYS_H */ diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index e4ac49fa85..1c6e4ae076 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -6,6 +6,7 @@ LIBNAME = softpipe C_SOURCES = \ sp_fs_exec.c \ sp_fs_sse.c \ + sp_buffer.c \ sp_clear.c \ sp_flush.c \ sp_query.c \ @@ -32,7 +33,6 @@ C_SOURCES = \ sp_tex_tile_cache.c \ sp_tile_cache.c \ sp_surface.c \ - sp_video_context.c \ - sp_winsys.c + sp_video_context.c include ../../Makefile.template diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript index 3042e556c6..27ab00b036 100644 --- a/src/gallium/drivers/softpipe/SConscript +++ b/src/gallium/drivers/softpipe/SConscript @@ -7,6 +7,7 @@ softpipe = env.ConvenienceLibrary( source = [ 'sp_fs_exec.c', 'sp_fs_sse.c', + 'sp_buffer.c', 'sp_clear.c', 'sp_context.c', 'sp_draw_arrays.c', @@ -33,8 +34,7 @@ softpipe = env.ConvenienceLibrary( 'sp_tex_tile_cache.c', 'sp_texture.c', 'sp_tile_cache.c', - 'sp_video_context.c', - 'sp_winsys.c' + 'sp_video_context.c' ]) Export('softpipe') diff --git a/src/gallium/drivers/softpipe/sp_buffer.c b/src/gallium/drivers/softpipe/sp_buffer.c new file mode 100644 index 0000000000..8f39025086 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_buffer.c @@ -0,0 +1,118 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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 "util/u_inlines.h" +#include "util/u_memory.h" +#include "util/u_math.h" + +#include "sp_screen.h" +#include "sp_buffer.h" + + +static void * +softpipe_buffer_map(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned flags) +{ + struct softpipe_buffer *softpipe_buf = softpipe_buffer(buf); + return softpipe_buf->data; +} + + +static void +softpipe_buffer_unmap(struct pipe_screen *screen, + struct pipe_buffer *buf) +{ +} + + +static void +softpipe_buffer_destroy(struct pipe_buffer *buf) +{ + struct softpipe_buffer *sbuf = softpipe_buffer(buf); + + if (!sbuf->userBuffer) + align_free(sbuf->data); + + FREE(sbuf); +} + + +static struct pipe_buffer * +softpipe_buffer_create(struct pipe_screen *screen, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct softpipe_buffer *buffer = CALLOC_STRUCT(softpipe_buffer); + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.screen = screen; + buffer->base.alignment = MAX2(alignment, 16); + buffer->base.usage = usage; + buffer->base.size = size; + + buffer->data = align_malloc(size, alignment); + + return &buffer->base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +softpipe_user_buffer_create(struct pipe_screen *screen, + void *ptr, + unsigned bytes) +{ + struct softpipe_buffer *buffer; + + buffer = CALLOC_STRUCT(softpipe_buffer); + if(!buffer) + return NULL; + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.screen = screen; + buffer->base.size = bytes; + buffer->userBuffer = TRUE; + buffer->data = ptr; + + return &buffer->base; +} + + +void +softpipe_init_screen_buffer_funcs(struct pipe_screen *screen) +{ + screen->buffer_create = softpipe_buffer_create; + screen->user_buffer_create = softpipe_user_buffer_create; + screen->buffer_map = softpipe_buffer_map; + screen->buffer_unmap = softpipe_buffer_unmap; + screen->buffer_destroy = softpipe_buffer_destroy; +} diff --git a/src/gallium/drivers/softpipe/sp_buffer.h b/src/gallium/drivers/softpipe/sp_buffer.h new file mode 100644 index 0000000000..9d8e56a176 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_buffer.h @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef SP_BUFFER_H +#define SP_BUFFER_H + +#include "pipe/p_compiler.h" +#include "pipe/p_state.h" + + +struct softpipe_buffer +{ + struct pipe_buffer base; + boolean userBuffer; /** Is this a user-space buffer? */ + void *data; +}; + + +/** Cast wrapper */ +static INLINE struct softpipe_buffer * +softpipe_buffer( struct pipe_buffer *buf ) +{ + return (struct softpipe_buffer *)buf; +} + + +void +softpipe_init_screen_buffer_funcs(struct pipe_screen *screen); + + +#endif /* SP_BUFFER_H */ diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index ddc35bcd62..53eecd1cbf 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -210,7 +210,7 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE ); softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", FALSE ); - softpipe->pipe.winsys = screen->winsys; + softpipe->pipe.winsys = NULL; softpipe->pipe.screen = screen; softpipe->pipe.destroy = softpipe_destroy; softpipe->pipe.priv = priv; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index b2acc36bf7..0899e1145a 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -40,83 +40,13 @@ #include "sp_context.h" #include "sp_query.h" #include "sp_state.h" +#include "sp_buffer.h" #include "draw/draw_context.h" -static void -softpipe_map_constant_buffers(struct softpipe_context *sp) -{ - struct pipe_winsys *ws = sp->pipe.winsys; - uint i; - - for (i = 0; i < PIPE_SHADER_TYPES; i++) { - uint j; - - for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { - if (sp->constants[i][j] && sp->constants[i][j]->size) { - sp->mapped_constants[i][j] = ws->buffer_map(ws, - sp->constants[i][j], - PIPE_BUFFER_USAGE_CPU_READ); - } - } - } - - for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { - if (sp->constants[PIPE_SHADER_VERTEX][i]) { - draw_set_mapped_constant_buffer(sp->draw, - PIPE_SHADER_VERTEX, - i, - sp->mapped_constants[PIPE_SHADER_VERTEX][i], - sp->constants[PIPE_SHADER_VERTEX][i]->size); - } - if (sp->constants[PIPE_SHADER_GEOMETRY][i]) { - draw_set_mapped_constant_buffer(sp->draw, - PIPE_SHADER_GEOMETRY, - i, - sp->mapped_constants[PIPE_SHADER_GEOMETRY][i], - sp->constants[PIPE_SHADER_GEOMETRY][i]->size); - } - } -} - - -static void -softpipe_unmap_constant_buffers(struct softpipe_context *sp) -{ - struct pipe_winsys *ws = sp->pipe.winsys; - uint i; - /* really need to flush all prims since the vert/frag shaders const buffers - * are going away now. - */ - draw_flush(sp->draw); - - for (i = 0; i < PIPE_MAX_CONSTANT_BUFFERS; i++) { - draw_set_mapped_constant_buffer(sp->draw, - PIPE_SHADER_VERTEX, - i, - NULL, - 0); - draw_set_mapped_constant_buffer(sp->draw, - PIPE_SHADER_GEOMETRY, - i, - NULL, - 0); - } - - for (i = 0; i < PIPE_SHADER_TYPES; i++) { - uint j; - - for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) { - if (sp->constants[i][j] && sp->constants[i][j]->size) { - ws->buffer_unmap(ws, sp->constants[i][j]); - } - sp->mapped_constants[i][j] = NULL; - } - } -} /** @@ -261,25 +191,16 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe, } softpipe_map_transfers(sp); - softpipe_map_constant_buffers(sp); /* Map vertex buffers */ for (i = 0; i < sp->num_vertex_buffers; i++) { - void *buf; - - buf = pipe_buffer_map(pipe->screen, - sp->vertex_buffer[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + void *buf = softpipe_buffer(sp->vertex_buffer[i].buffer)->data; draw_set_mapped_vertex_buffer(draw, i, buf); } /* Map index buffer, if present */ if (indexBuffer) { - void *mapped_indexes; - - mapped_indexes = pipe_buffer_map(pipe->screen, - indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + void *mapped_indexes = softpipe_buffer(indexBuffer)->data; draw_set_mapped_element_buffer_range(draw, indexSize, minIndex, @@ -300,15 +221,18 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe, /* unmap vertex/index buffers - will cause draw module to flush */ for (i = 0; i < sp->num_vertex_buffers; i++) { draw_set_mapped_vertex_buffer(draw, i, NULL); - pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer); } if (indexBuffer) { draw_set_mapped_element_buffer(draw, 0, NULL); - pipe_buffer_unmap(pipe->screen, indexBuffer); } - /* Note: leave drawing surfaces mapped */ - softpipe_unmap_constant_buffers(sp); + /* + * TODO: Flush only when a user vertex/index buffer is present + * (or even better, modify draw module to do this + * internally when this condition is seen?) + */ + draw_flush(draw); + /* Note: leave drawing surfaces mapped */ sp->dirty_render_cache = TRUE; } diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 6ec63fe698..107631f6b5 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -32,10 +32,12 @@ #include "pipe/p_defines.h" #include "pipe/p_screen.h" +#include "state_tracker/sw_winsys.h" + #include "sp_texture.h" -#include "sp_winsys.h" #include "sp_screen.h" #include "sp_context.h" +#include "sp_buffer.h" static const char * @@ -145,6 +147,8 @@ softpipe_is_format_supported( struct pipe_screen *screen, unsigned tex_usage, unsigned geom_flags ) { + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + assert(target == PIPE_TEXTURE_1D || target == PIPE_TEXTURE_2D || target == PIPE_TEXTURE_3D || @@ -166,15 +170,25 @@ softpipe_is_format_supported( struct pipe_screen *screen, case PIPE_FORMAT_NONE: return FALSE; default: - return TRUE; + break; } + + if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { + if(!winsys->is_displaytarget_format_supported(winsys, format)) + return FALSE; + } + + /* XXX: this is often a lie. Pull in logic from llvmpipe to fix. + */ + return TRUE; } static void softpipe_destroy_screen( struct pipe_screen *screen ) { - struct pipe_winsys *winsys = screen->winsys; + struct softpipe_screen *sp_screen = softpipe_screen(screen); + struct sw_winsys *winsys = sp_screen->winsys; if(winsys->destroy) winsys->destroy(winsys); @@ -183,21 +197,37 @@ softpipe_destroy_screen( struct pipe_screen *screen ) } +/* This is often overriden by the co-state tracker. + */ +static void +softpipe_flush_frontbuffer(struct pipe_screen *_screen, + struct pipe_surface *surface, + void *context_private) +{ + struct softpipe_screen *screen = softpipe_screen(_screen); + struct sw_winsys *winsys = screen->winsys; + struct softpipe_texture *texture = softpipe_texture(surface->texture); + + assert(texture->dt); + if (texture->dt) + winsys->displaytarget_display(winsys, texture->dt, context_private); +} /** * Create a new pipe_screen object * Note: we're not presently subclassing pipe_screen (no softpipe_screen). */ struct pipe_screen * -softpipe_create_screen(struct pipe_winsys *winsys) +softpipe_create_screen(struct sw_winsys *winsys) { struct softpipe_screen *screen = CALLOC_STRUCT(softpipe_screen); if (!screen) return NULL; - screen->base.winsys = winsys; + screen->winsys = winsys; + screen->base.winsys = NULL; screen->base.destroy = softpipe_destroy_screen; screen->base.get_name = softpipe_get_name; @@ -206,9 +236,10 @@ softpipe_create_screen(struct pipe_winsys *winsys) screen->base.get_paramf = softpipe_get_paramf; screen->base.is_format_supported = softpipe_is_format_supported; screen->base.context_create = softpipe_create_context; + screen->base.flush_frontbuffer = softpipe_flush_frontbuffer; softpipe_init_screen_texture_funcs(&screen->base); - u_simple_screen_init(&screen->base); + softpipe_init_screen_buffer_funcs(&screen->base); return &screen->base; } diff --git a/src/gallium/drivers/softpipe/sp_screen.h b/src/gallium/drivers/softpipe/sp_screen.h index 3d4bfd3e84..4d7d8bada2 100644 --- a/src/gallium/drivers/softpipe/sp_screen.h +++ b/src/gallium/drivers/softpipe/sp_screen.h @@ -35,10 +35,13 @@ #include "pipe/p_defines.h" +struct sw_winsys; struct softpipe_screen { struct pipe_screen base; + struct sw_winsys *winsys; + /* Increments whenever textures are modified. Contexts can track * this. */ @@ -55,4 +58,13 @@ softpipe_screen( struct pipe_screen *pipe ) } + +/** + * Create a softpipe screen that uses the + * given winsys for allocating buffers. + */ +struct pipe_screen *softpipe_create_screen( struct sw_winsys * ); + + + #endif /* SP_SCREEN_H */ diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index c88e213751..cd0e905bc9 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -28,6 +28,7 @@ #include "sp_context.h" #include "sp_state.h" #include "sp_fs.h" +#include "sp_buffer.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -163,26 +164,35 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs) FREE( state ); } - - void softpipe_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_buffer *buf) + struct pipe_buffer *constants) { struct softpipe_context *softpipe = softpipe_context(pipe); + unsigned size = constants ? constants->size : 0; + const void *data = constants ? softpipe_buffer(constants)->data : NULL; assert(shader < PIPE_SHADER_TYPES); - assert(index < PIPE_MAX_CONSTANT_BUFFERS); + assert(index == 0); + + if(softpipe->constants[shader][index] == constants) + return; draw_flush(softpipe->draw); /* note: reference counting */ - pipe_buffer_reference(&softpipe->constants[shader][index], buf); + pipe_buffer_reference(&softpipe->constants[shader][index], constants); + + if(shader == PIPE_SHADER_VERTEX) { + draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, 0, + data, size); + } softpipe->dirty |= SP_NEW_CONSTANTS; } + void * softpipe_create_gs_state(struct pipe_context *pipe, const struct pipe_shader_state *templ) diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 32d261b5ff..9641652da8 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -40,7 +40,8 @@ #include "sp_context.h" #include "sp_texture.h" #include "sp_screen.h" -#include "sp_winsys.h" + +#include "state_tracker/sw_winsys.h" /** @@ -72,11 +73,9 @@ softpipe_texture_layout(struct pipe_screen *screen, depth = u_minify(depth, 1); } - spt->buffer = screen->buffer_create(screen, 32, - PIPE_BUFFER_USAGE_PIXEL, - buffer_size); + spt->data = align_malloc(buffer_size, 16); - return spt->buffer != NULL; + return spt->data != NULL; } @@ -87,19 +86,18 @@ static boolean softpipe_displaytarget_layout(struct pipe_screen *screen, struct softpipe_texture * spt) { - unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE | - PIPE_BUFFER_USAGE_GPU_READ_WRITE); - unsigned tex_usage = spt->base.tex_usage; - - spt->buffer = screen->surface_buffer_create( screen, - spt->base.width0, - spt->base.height0, - spt->base.format, - usage, - tex_usage, - &spt->stride[0]); - - return spt->buffer != NULL; + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + + /* Round up the surface size to a multiple of the tile size? + */ + spt->dt = winsys->displaytarget_create(winsys, + spt->base.format, + spt->base.width0, + spt->base.height0, + 16, + &spt->stride[0] ); + + return spt->dt != NULL; } @@ -149,37 +147,29 @@ softpipe_texture_blanket(struct pipe_screen * screen, const unsigned *stride, struct pipe_buffer *buffer) { - struct softpipe_texture *spt; - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - spt = CALLOC_STRUCT(softpipe_texture); - if (!spt) - return NULL; - - spt->base = *base; - pipe_reference_init(&spt->base.reference, 1); - spt->base.screen = screen; - spt->stride[0] = stride[0]; - - pipe_buffer_reference(&spt->buffer, buffer); - - return &spt->base; + /* Texture blanket is going away. + */ + debug_printf("softpipe_texture_blanket() not implemented!"); + return NULL; } static void softpipe_texture_destroy(struct pipe_texture *pt) { + struct softpipe_screen *screen = softpipe_screen(pt->screen); struct softpipe_texture *spt = softpipe_texture(pt); - pipe_buffer_reference(&spt->buffer, NULL); + if (spt->dt) { + /* display target */ + struct sw_winsys *winsys = screen->winsys; + winsys->displaytarget_destroy(winsys, spt->dt); + } + else { + /* regular texture */ + align_free(spt->data); + } + FREE(spt); } @@ -359,9 +349,20 @@ softpipe_transfer_map( struct pipe_screen *screen, spt = softpipe_texture(transfer->texture); format = transfer->texture->format; - map = pipe_buffer_map(screen, spt->buffer, pipe_transfer_buffer_flags(transfer)); - if (map == NULL) - return NULL; + if (spt->dt) { + /* display target */ + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + + map = winsys->displaytarget_map(winsys, spt->dt, + pipe_transfer_buffer_flags(transfer)); + if (map == NULL) + return NULL; + } + else { + map = spt->data; + if (map == NULL) + return NULL; + } /* May want to different things here depending on read/write nature * of the map: @@ -393,7 +394,11 @@ softpipe_transfer_unmap(struct pipe_screen *screen, assert(transfer->texture); spt = softpipe_texture(transfer->texture); - pipe_buffer_unmap( screen, spt->buffer ); + if (spt->dt) { + /* display target */ + struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + winsys->displaytarget_unmap(winsys, spt->dt); + } if (transfer->usage & PIPE_TRANSFER_WRITE) { /* Mark the texture as dirty to expire the tile caches. */ @@ -474,24 +479,4 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) } -/** - * Return pipe_buffer handle and stride for given texture object. - * XXX used for??? - */ -boolean -softpipe_get_texture_buffer( struct pipe_texture *texture, - struct pipe_buffer **buf, - unsigned *stride ) -{ - struct softpipe_texture *tex = (struct softpipe_texture *) texture; - if (!tex) - return FALSE; - - pipe_buffer_reference(buf, tex->buffer); - - if (stride) - *stride = tex->stride[0]; - - return TRUE; -} diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h index 2ef64e1e7c..e8d17ce7da 100644 --- a/src/gallium/drivers/softpipe/sp_texture.h +++ b/src/gallium/drivers/softpipe/sp_texture.h @@ -45,9 +45,16 @@ struct softpipe_texture unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS]; unsigned stride[PIPE_MAX_TEXTURE_LEVELS]; - /* The data is held here: + /** + * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET + * usage. + */ + struct sw_displaytarget *dt; + + /** + * Malloc'ed data for regular textures, or a mapping to dt above. */ - struct pipe_buffer *buffer; + void *data; /* True if texture images are power-of-two in all dimensions: */ diff --git a/src/gallium/drivers/softpipe/sp_winsys.c b/src/gallium/drivers/softpipe/sp_winsys.c deleted file mode 100644 index 0a6245ed2c..0000000000 --- a/src/gallium/drivers/softpipe/sp_winsys.c +++ /dev/null @@ -1,245 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * @file - * Malloc softpipe winsys. Uses malloc for all memory allocations. - * - * @author Keith Whitwell - * @author Brian Paul - * @author Jose Fonseca - */ - - -#include "util/u_simple_screen.h"/* port to just p_screen */ -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "util/u_inlines.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "sp_winsys.h" - - -struct st_softpipe_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; -}; - - -/** Cast wrapper */ -static INLINE struct st_softpipe_buffer * -st_softpipe_buffer( struct pipe_buffer *buf ) -{ - return (struct st_softpipe_buffer *)buf; -} - - -static void * -st_softpipe_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer *buf, - unsigned flags) -{ - struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); - st_softpipe_buf->mapped = st_softpipe_buf->data; - return st_softpipe_buf->mapped; -} - - -static void -st_softpipe_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer *buf) -{ - struct st_softpipe_buffer *st_softpipe_buf = st_softpipe_buffer(buf); - st_softpipe_buf->mapped = NULL; -} - - -static void -st_softpipe_buffer_destroy(struct pipe_buffer *buf) -{ - struct st_softpipe_buffer *oldBuf = st_softpipe_buffer(buf); - - if (oldBuf->data) { - if (!oldBuf->userBuffer) - align_free(oldBuf->data); - - oldBuf->data = NULL; - } - - FREE(oldBuf); -} - - -static void -st_softpipe_flush_frontbuffer(struct pipe_winsys *winsys, - struct pipe_surface *surf, - void *context_private) -{ -} - - - -static const char * -st_softpipe_get_name(struct pipe_winsys *winsys) -{ - return "softpipe"; -} - - -static struct pipe_buffer * -st_softpipe_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct st_softpipe_buffer *buffer = CALLOC_STRUCT(st_softpipe_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - buffer->data = align_malloc(size, alignment); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -st_softpipe_user_buffer_create(struct pipe_winsys *winsys, - void *ptr, - unsigned bytes) -{ - struct st_softpipe_buffer *buffer; - - buffer = CALLOC_STRUCT(st_softpipe_buffer); - if(!buffer) - return NULL; - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - - return &buffer->base; -} - - -static struct pipe_buffer * -st_softpipe_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -st_softpipe_fence_reference(struct pipe_winsys *winsys, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -st_softpipe_fence_signalled(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -st_softpipe_fence_finish(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static void -st_softpipe_destroy(struct pipe_winsys *winsys) -{ - FREE(winsys); -} - - -struct pipe_screen * -softpipe_create_screen_malloc(void) -{ - static struct pipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = CALLOC_STRUCT(pipe_winsys); - if(!winsys) - return NULL; - - winsys->destroy = st_softpipe_destroy; - - winsys->buffer_create = st_softpipe_buffer_create; - winsys->user_buffer_create = st_softpipe_user_buffer_create; - winsys->buffer_map = st_softpipe_buffer_map; - winsys->buffer_unmap = st_softpipe_buffer_unmap; - winsys->buffer_destroy = st_softpipe_buffer_destroy; - - winsys->surface_buffer_create = st_softpipe_surface_buffer_create; - - winsys->fence_reference = st_softpipe_fence_reference; - winsys->fence_signalled = st_softpipe_fence_signalled; - winsys->fence_finish = st_softpipe_fence_finish; - - winsys->flush_frontbuffer = st_softpipe_flush_frontbuffer; - winsys->get_name = st_softpipe_get_name; - - screen = softpipe_create_screen(winsys); - if(!screen) - st_softpipe_destroy(winsys); - - return screen; -} diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h deleted file mode 100644 index 6e3920c49b..0000000000 --- a/src/gallium/drivers/softpipe/sp_winsys.h +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -/* This is the interface that softpipe requires any window system - * hosting it to implement. This is the only include file in softpipe - * which is public. - */ - - -#ifndef SP_WINSYS_H -#define SP_WINSYS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "pipe/p_defines.h" - -struct pipe_screen; -struct pipe_winsys; -struct pipe_context; -struct pipe_texture; -struct pipe_buffer; - - - -/** - * Create a softpipe screen that uses the - * given winsys for allocating buffers. - */ -struct pipe_screen *softpipe_create_screen( struct pipe_winsys * ); - -/** - * Create a softpipe screen that uses - * regular malloc to create all its buffers. - */ -struct pipe_screen *softpipe_create_screen_malloc(void); - -boolean -softpipe_get_texture_buffer( struct pipe_texture *texture, - struct pipe_buffer **buf, - unsigned *stride ); - - -#ifdef __cplusplus -} -#endif - -#endif /* SP_WINSYS_H */ diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h new file mode 100644 index 0000000000..719c3f3eee --- /dev/null +++ b/src/gallium/include/state_tracker/sw_winsys.h @@ -0,0 +1,121 @@ +/************************************************************************** + * + * Copyright 2007-2009 VMware, Inc. + * 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. + * + **************************************************************************/ + +/** + * @file + * Software rasterizer winsys. + */ + + +#ifndef SW_WINSYS_H +#define SW_WINSYS_H + + +#include "pipe/p_compiler.h" /* for boolean */ +#include "pipe/p_format.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +struct pipe_screen; +struct pipe_context; + + +/** + * Opaque pointer. + */ +struct sw_displaytarget; + + +/** + * This is the interface that sw expects any window system + * hosting it to implement. + * + * sw is for the most part a self sufficient driver. The only thing it + * does not know is how to display a surface. + */ +struct sw_winsys +{ + void + (*destroy)( struct sw_winsys *ws ); + + boolean + (*is_displaytarget_format_supported)( struct sw_winsys *ws, + enum pipe_format format ); + + /** + * Allocate storage for a render target. + * + * Often surfaces which are meant to be blitted to the front screen (i.e., + * display targets) must be allocated with special characteristics, memory + * pools, or obtained directly from the windowing system. + * + * This callback is invoked by the pipe_screen when creating a texture marked + * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying + * storage. + */ + struct sw_displaytarget * + (*displaytarget_create)( struct sw_winsys *ws, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride ); + + void * + (*displaytarget_map)( struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags ); + + void + (*displaytarget_unmap)( struct sw_winsys *ws, + struct sw_displaytarget *dt ); + + /** + * @sa pipe_screen:flush_frontbuffer. + * + * This call will likely become asynchronous eventually. + */ + void + (*displaytarget_display)( struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private ); + + void + (*displaytarget_destroy)( struct sw_winsys *ws, + struct sw_displaytarget *dt ); +}; + + + +#ifdef __cplusplus +} +#endif + +#endif /* SW_WINSYS_H */ diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 4cbc86f331..4b32aa27e1 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -18,7 +18,7 @@ if env['platform'] == 'windows': 'ws2_32', ]) - sources = [] + sources = ['gdi_sw_winsys.c'] drivers = [] if 'softpipe' in env['drivers']: diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c index a9fa03b8e5..3d317c70dd 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c @@ -36,153 +36,8 @@ #include -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "llvmpipe/lp_winsys.h" +#include "gdi_winsys.h" #include "llvmpipe/lp_texture.h" -#include "stw_winsys.h" - - -struct gdi_llvmpipe_displaytarget -{ - enum pipe_format format; - unsigned width; - unsigned height; - unsigned stride; - - unsigned size; - - void *data; - - BITMAPINFO bmi; -}; - - -/** Cast wrapper */ -static INLINE struct gdi_llvmpipe_displaytarget * -gdi_llvmpipe_displaytarget( struct llvmpipe_displaytarget *buf ) -{ - return (struct gdi_llvmpipe_displaytarget *)buf; -} - - -static boolean -gdi_llvmpipe_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, - enum pipe_format format ) -{ - switch(format) { - case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_B8G8R8A8_UNORM: - return TRUE; - - /* TODO: Support other formats possible with BMPs, as described in - * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */ - - default: - return FALSE; - } -} - - -static void * -gdi_llvmpipe_displaytarget_map(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - unsigned flags ) -{ - struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt); - - return gdt->data; -} - - -static void -gdi_llvmpipe_displaytarget_unmap(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt ) -{ - -} - - -static void -gdi_llvmpipe_displaytarget_destroy(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt) -{ - struct gdi_llvmpipe_displaytarget *gdt = gdi_llvmpipe_displaytarget(dt); - - align_free(gdt->data); - FREE(gdt); -} - - -static struct llvmpipe_displaytarget * -gdi_llvmpipe_displaytarget_create(struct llvmpipe_winsys *winsys, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) -{ - struct gdi_llvmpipe_displaytarget *gdt; - unsigned cpp; - unsigned bpp; - - gdt = CALLOC_STRUCT(gdi_llvmpipe_displaytarget); - if(!gdt) - goto no_gdt; - - gdt->format = format; - gdt->width = width; - gdt->height = height; - - bpp = util_format_get_blocksizebits(format); - cpp = util_format_get_blocksize(format); - - gdt->stride = align(width * cpp, alignment); - gdt->size = gdt->stride * height; - - gdt->data = align_malloc(gdt->size, alignment); - if(!gdt->data) - goto no_data; - - gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp; - gdt->bmi.bmiHeader.biHeight= -(long)height; - gdt->bmi.bmiHeader.biPlanes = 1; - gdt->bmi.bmiHeader.biBitCount = bpp; - gdt->bmi.bmiHeader.biCompression = BI_RGB; - gdt->bmi.bmiHeader.biSizeImage = 0; - gdt->bmi.bmiHeader.biXPelsPerMeter = 0; - gdt->bmi.bmiHeader.biYPelsPerMeter = 0; - gdt->bmi.bmiHeader.biClrUsed = 0; - gdt->bmi.bmiHeader.biClrImportant = 0; - - *stride = gdt->stride; - return (struct llvmpipe_displaytarget *)gdt; - -no_data: - FREE(gdt); -no_gdt: - return NULL; -} - - -static void -gdi_llvmpipe_displaytarget_display(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt, - void *context_private) -{ - assert(0); -} - - -static void -gdi_llvmpipe_destroy(struct llvmpipe_winsys *winsys) -{ - FREE(winsys); -} static struct pipe_screen * @@ -191,18 +46,10 @@ gdi_llvmpipe_screen_create(void) static struct llvmpipe_winsys *winsys; struct pipe_screen *screen; - winsys = CALLOC_STRUCT(llvmpipe_winsys); + winsys = gdi_create_sw_winsys(); if(!winsys) goto no_winsys; - winsys->destroy = gdi_llvmpipe_destroy; - winsys->is_displaytarget_format_supported = gdi_llvmpipe_is_displaytarget_format_supported; - winsys->displaytarget_create = gdi_llvmpipe_displaytarget_create; - winsys->displaytarget_map = gdi_llvmpipe_displaytarget_map; - winsys->displaytarget_unmap = gdi_llvmpipe_displaytarget_unmap; - winsys->displaytarget_display = gdi_llvmpipe_displaytarget_display; - winsys->displaytarget_destroy = gdi_llvmpipe_displaytarget_destroy; - screen = llvmpipe_create_screen(winsys); if(!screen) goto no_screen; diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c index 71360e55aa..56e84fd066 100644 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2008 Tungsten Graphics, Inc., Bismarck, ND., USA + * Copyright 2009 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -28,257 +28,58 @@ /** * @file - * Softpipe support. + * LLVMpipe support. * - * @author Keith Whitwell - * @author Brian Paul - * @author Jose Fonseca + * @author Jose Fonseca */ #include -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "softpipe/sp_winsys.h" +#include "gdi_winsys.h" #include "softpipe/sp_texture.h" -#include "stw_winsys.h" - - -struct gdi_softpipe_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; -}; - - -/** Cast wrapper */ -static INLINE struct gdi_softpipe_buffer * -gdi_softpipe_buffer( struct pipe_buffer *buf ) -{ - return (struct gdi_softpipe_buffer *)buf; -} - - -static void * -gdi_softpipe_buffer_map(struct pipe_winsys *winsys, - struct pipe_buffer *buf, - unsigned flags) -{ - struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf); - gdi_softpipe_buf->mapped = gdi_softpipe_buf->data; - return gdi_softpipe_buf->mapped; -} - - -static void -gdi_softpipe_buffer_unmap(struct pipe_winsys *winsys, - struct pipe_buffer *buf) -{ - struct gdi_softpipe_buffer *gdi_softpipe_buf = gdi_softpipe_buffer(buf); - gdi_softpipe_buf->mapped = NULL; -} - - -static void -gdi_softpipe_buffer_destroy(struct pipe_buffer *buf) -{ - struct gdi_softpipe_buffer *oldBuf = gdi_softpipe_buffer(buf); - - if (oldBuf->data) { - if (!oldBuf->userBuffer) - align_free(oldBuf->data); - - oldBuf->data = NULL; - } - - FREE(oldBuf); -} - - -static const char * -gdi_softpipe_get_name(struct pipe_winsys *winsys) -{ - return "softpipe"; -} - - -static struct pipe_buffer * -gdi_softpipe_buffer_create(struct pipe_winsys *winsys, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct gdi_softpipe_buffer *buffer = CALLOC_STRUCT(gdi_softpipe_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - buffer->data = align_malloc(size, alignment); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -gdi_softpipe_user_buffer_create(struct pipe_winsys *winsys, - void *ptr, - unsigned bytes) -{ - struct gdi_softpipe_buffer *buffer; - - buffer = CALLOC_STRUCT(gdi_softpipe_buffer); - if(!buffer) - return NULL; - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - - return &buffer->base; -} - - -static struct pipe_buffer * -gdi_softpipe_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -gdi_softpipe_dummy_flush_frontbuffer(struct pipe_winsys *winsys, - struct pipe_surface *surface, - void *context_private) -{ - assert(0); -} - - -static void -gdi_softpipe_fence_reference(struct pipe_winsys *winsys, - struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -gdi_softpipe_fence_signalled(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -gdi_softpipe_fence_finish(struct pipe_winsys *winsys, - struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static void -gdi_softpipe_destroy(struct pipe_winsys *winsys) -{ - FREE(winsys); -} static struct pipe_screen * gdi_softpipe_screen_create(void) { - static struct pipe_winsys *winsys; + static struct softpipe_winsys *winsys; struct pipe_screen *screen; - winsys = CALLOC_STRUCT(pipe_winsys); + winsys = gdi_create_sw_winsys(); if(!winsys) - return NULL; - - winsys->destroy = gdi_softpipe_destroy; - - winsys->buffer_create = gdi_softpipe_buffer_create; - winsys->user_buffer_create = gdi_softpipe_user_buffer_create; - winsys->buffer_map = gdi_softpipe_buffer_map; - winsys->buffer_unmap = gdi_softpipe_buffer_unmap; - winsys->buffer_destroy = gdi_softpipe_buffer_destroy; - - winsys->surface_buffer_create = gdi_softpipe_surface_buffer_create; - - winsys->fence_reference = gdi_softpipe_fence_reference; - winsys->fence_signalled = gdi_softpipe_fence_signalled; - winsys->fence_finish = gdi_softpipe_fence_finish; - - winsys->flush_frontbuffer = gdi_softpipe_dummy_flush_frontbuffer; - winsys->get_name = gdi_softpipe_get_name; + goto no_winsys; screen = softpipe_create_screen(winsys); if(!screen) - gdi_softpipe_destroy(winsys); + goto no_screen; return screen; + +no_screen: + FREE(winsys); +no_winsys: + return NULL; } + + static void gdi_softpipe_present(struct pipe_screen *screen, struct pipe_surface *surface, HDC hDC) { struct softpipe_texture *texture; - struct gdi_softpipe_buffer *buffer; - BITMAPINFO bmi; + struct gdi_softpipe_displaytarget *gdt; texture = softpipe_texture(surface->texture); - - buffer = gdi_softpipe_buffer(texture->buffer); - - memset(&bmi, 0, sizeof(BITMAPINFO)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = texture->stride[surface->level] / util_format_get_blocksize(surface->format); - bmi.bmiHeader.biHeight= -(long)surface->height; - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = util_format_get_blocksizebits(surface->format); - bmi.bmiHeader.biCompression = BI_RGB; - bmi.bmiHeader.biSizeImage = 0; - bmi.bmiHeader.biXPelsPerMeter = 0; - bmi.bmiHeader.biYPelsPerMeter = 0; - bmi.bmiHeader.biClrUsed = 0; - bmi.bmiHeader.biClrImportant = 0; + gdt = gdi_softpipe_displaytarget(texture->dt); StretchDIBits(hDC, - 0, 0, surface->width, surface->height, - 0, 0, surface->width, surface->height, - buffer->data, &bmi, 0, SRCCOPY); + 0, 0, gdt->width, gdt->height, + 0, 0, gdt->width, gdt->height, + gdt->data, &gdt->bmi, 0, SRCCOPY); } diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 824c666ae3..129300423a 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -29,6 +29,7 @@ DEFINES += \ XLIB_WINSYS_SOURCES = \ xlib.c \ xlib_cell.c \ + xlib_sw_winsys.c \ xlib_llvmpipe.c \ xlib_softpipe.c diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 8c9d318af2..92e508ee50 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -36,7 +36,7 @@ drivers = [trace] if 'softpipe' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') - sources += ['xlib_softpipe.c'] + sources += ['xlib_softpipe.c', 'xlib_sw_winsys.c'] drivers += [softpipe] if 'llvmpipe' in env['drivers']: @@ -44,7 +44,7 @@ if 'llvmpipe' in env['drivers']: if 'LLVM_VERSION' in env: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Tool('udis86') - sources += ['xlib_llvmpipe.c'] + sources += ['xlib_llvmpipe.c', 'xlib_sw_winsys.c'] drivers += [llvmpipe] if 'cell' in env['drivers']: diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c index 67617a470d..9b91c980d1 100644 --- a/src/gallium/winsys/xlib/xlib.c +++ b/src/gallium/winsys/xlib/xlib.c @@ -33,9 +33,7 @@ #include "xlib.h" #include "xm_winsys.h" - -#include -#include +#include "util/u_debug.h" /* Todo, replace all this with callback-structs provided by the * individual implementations. diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h index 8e091d0c08..7f9f910b88 100644 --- a/src/gallium/winsys/xlib/xlib.h +++ b/src/gallium/winsys/xlib/xlib.h @@ -9,5 +9,12 @@ extern struct xm_driver xlib_softpipe_driver; extern struct xm_driver xlib_llvmpipe_driver; extern struct xm_driver xlib_cell_driver; +/* Internal: + */ +struct sw_winsys; +struct sw_displaytarget; +struct sw_winsys *xlib_create_sw_winsys( void ); +void xlib_sw_display(struct xmesa_buffer *xm_buffer, + struct sw_displaytarget *dt); #endif diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c index 6cebd4c201..9929ba52e7 100644 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c @@ -33,367 +33,16 @@ */ -#if defined(GALLIUM_LLVMPIPE) - -#include "xm_api.h" -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "llvmpipe/lp_winsys.h" -#include "llvmpipe/lp_texture.h" #include "xlib.h" -/** - * Subclass of pipe_buffer for Xlib winsys. - * Low-level OS/window system memory buffer - */ -struct xm_displaytarget -{ - enum pipe_format format; - unsigned width; - unsigned height; - unsigned stride; - - void *data; - void *mapped; - - XImage *tempImage; -#ifdef USE_XSHM - int shm; - XShmSegmentInfo shminfo; -#endif -}; - - -/** - * Subclass of llvmpipe_winsys for Xlib winsys - */ -struct xmesa_llvmpipe_winsys -{ - struct llvmpipe_winsys base; -/* struct xmesa_visual *xm_visual; */ -}; - - - -/** Cast wrapper */ -static INLINE struct xm_displaytarget * -xm_displaytarget( struct llvmpipe_displaytarget *dt ) -{ - return (struct xm_displaytarget *)dt; -} - - -/** - * X Shared Memory Image extension code - */ - -#ifdef USE_XSHM - -static volatile int mesaXErrorFlag = 0; - -/** - * Catches potential Xlib errors. - */ -static int -mesaHandleXError(Display *dpy, XErrorEvent *event) -{ - (void) dpy; - (void) event; - mesaXErrorFlag = 1; - return 0; -} - - -static char *alloc_shm(struct xm_displaytarget *buf, unsigned size) -{ - XShmSegmentInfo *const shminfo = & buf->shminfo; - - shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); - if (shminfo->shmid < 0) { - return NULL; - } - - shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); - if (shminfo->shmaddr == (char *) -1) { - shmctl(shminfo->shmid, IPC_RMID, 0); - return NULL; - } - - shminfo->readOnly = False; - return shminfo->shmaddr; -} - - -/** - * Allocate a shared memory XImage back buffer for the given XMesaBuffer. - */ -static void -alloc_shm_ximage(struct xm_displaytarget *xm_buffer, - 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... - */ - int (*old_handler)(Display *, XErrorEvent *); - - xm_buffer->tempImage = XShmCreateImage(xmb->xm_visual->display, - xmb->xm_visual->visinfo->visual, - xmb->xm_visual->visinfo->depth, - ZPixmap, - NULL, - &xm_buffer->shminfo, - width, height); - if (xm_buffer->tempImage == NULL) { - xm_buffer->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, &xm_buffer->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(xm_buffer->tempImage); - xm_buffer->tempImage = NULL; - xm_buffer->shm = 0; - (void) XSetErrorHandler(old_handler); - return; - } - - xm_buffer->shm = 1; -} - -#endif /* USE_XSHM */ - -static boolean -xm_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, - enum pipe_format format ) -{ - /* TODO: check visuals or other sensible thing here */ - return TRUE; -} - - -static void * -xm_displaytarget_map(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - unsigned flags) -{ - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - xm_dt->mapped = xm_dt->data; - return xm_dt->mapped; -} - -static void -xm_displaytarget_unmap(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt) -{ - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - xm_dt->mapped = NULL; -} - -static void -xm_displaytarget_destroy(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt) -{ - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - - if (xm_dt->data) { -#ifdef USE_XSHM - if (xm_dt->shminfo.shmid >= 0) { - shmdt(xm_dt->shminfo.shmaddr); - shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0); - - xm_dt->shminfo.shmid = -1; - xm_dt->shminfo.shmaddr = (char *) -1; - } - else -#endif - FREE(xm_dt->data); - } - - FREE(xm_dt); -} - - -/** - * Display/copy the image in the surface into the X window specified - * by the XMesaBuffer. - */ -static void -xm_llvmpipe_display(struct xmesa_buffer *xm_buffer, - struct llvmpipe_displaytarget *dt) -{ - XImage *ximage; - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); - static boolean no_swap = 0; - static boolean firsttime = 1; - - if (firsttime) { - no_swap = getenv("SP_NO_RAST") != NULL; - firsttime = 0; - } - - if (no_swap) - return; - -#ifdef USE_XSHM - if (xm_dt->shm) - { - if (xm_dt->tempImage == NULL) - { - assert(util_format_get_blockwidth(xm_dt->format) == 1); - assert(util_format_get_blockheight(xm_dt->format) == 1); - alloc_shm_ximage(xm_dt, xm_buffer, - xm_dt->stride / util_format_get_blocksize(xm_dt->format), - xm_dt->height); - } - - ximage = xm_dt->tempImage; - ximage->data = xm_dt->data; - - /* _debug_printf("XSHM\n"); */ - XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, - ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); - } - else -#endif - { - /* display image in Window */ - ximage = xm_dt->tempImage; - ximage->data = xm_dt->data; - - /* check that the XImage has been previously initialized */ - assert(ximage->format); - assert(ximage->bitmap_unit); - - /* update XImage's fields */ - ximage->width = xm_dt->width; - ximage->height = xm_dt->height; - ximage->bytes_per_line = xm_dt->stride; - - /* _debug_printf("XPUT\n"); */ - XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, - ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); - } -} - -/** - * Display/copy the image in the surface into the X window specified - * by the XMesaBuffer. - */ -static void -xm_displaytarget_display(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - void *context_private) -{ - XMesaContext xmctx = (XMesaContext) context_private; - struct xmesa_buffer *xm_buffer = xmctx->xm_buffer; - xm_llvmpipe_display(xm_buffer, dt); -} - -static struct llvmpipe_displaytarget * -xm_displaytarget_create(struct llvmpipe_winsys *winsys, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) -{ - struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget); - unsigned nblocksy, size; - - xm_dt = CALLOC_STRUCT(xm_displaytarget); - if(!xm_dt) - goto no_xm_dt; - - xm_dt->format = format; - xm_dt->width = width; - xm_dt->height = height; - - nblocksy = util_format_get_nblocksy(format, height); - xm_dt->stride = align(util_format_get_stride(format, width), alignment); - size = xm_dt->stride * nblocksy; - -#ifdef USE_XSHM - if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) - { - xm_dt->shminfo.shmid = -1; - xm_dt->shminfo.shmaddr = (char *) -1; - xm_dt->shm = TRUE; - - xm_dt->data = alloc_shm(xm_dt, size); - if(!xm_dt->data) - goto no_data; - } -#endif - - if(!xm_dt->data) { - xm_dt->data = align_malloc(size, alignment); - if(!xm_dt->data) - goto no_data; - } - - *stride = xm_dt->stride; - return (struct llvmpipe_displaytarget *)xm_dt; - -no_data: - FREE(xm_dt); -no_xm_dt: - return NULL; -} - - -static void -xm_destroy( struct llvmpipe_winsys *ws ) -{ - FREE(ws); -} - - -static struct llvmpipe_winsys * -xlib_create_llvmpipe_winsys( void ) -{ - struct xmesa_llvmpipe_winsys *ws; - - ws = CALLOC_STRUCT(xmesa_llvmpipe_winsys); - if (!ws) - return NULL; - - ws->base.destroy = xm_destroy; - - ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported; - - ws->base.displaytarget_create = xm_displaytarget_create; - ws->base.displaytarget_map = xm_displaytarget_map; - ws->base.displaytarget_unmap = xm_displaytarget_unmap; - ws->base.displaytarget_destroy = xm_displaytarget_destroy; - - ws->base.displaytarget_display = xm_displaytarget_display; - - return &ws->base; -} +#if defined(GALLIUM_LLVMPIPE) +#include "llvmpipe/lp_texture.h" +#include "llvmpipe/lp_winsys.h" +#include "state_tracker/sw_winsys.h" static struct pipe_screen * xlib_create_llvmpipe_screen( void ) @@ -401,7 +50,7 @@ xlib_create_llvmpipe_screen( void ) struct llvmpipe_winsys *winsys; struct pipe_screen *screen; - winsys = xlib_create_llvmpipe_winsys(); + winsys = xlib_create_sw_winsys(); if (winsys == NULL) return NULL; @@ -427,7 +76,7 @@ xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer, assert(texture->dt); if (texture->dt) - xm_llvmpipe_display(xm_buffer, texture->dt); + xlib_sw_display(xm_buffer, texture->dt); } diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 716338aef4..df93de551c 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -26,461 +26,19 @@ * **************************************************************************/ -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "xm_api.h" - -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "softpipe/sp_winsys.h" -#include "softpipe/sp_texture.h" #include "xlib.h" - -/** - * Subclass of pipe_buffer for Xlib winsys. - * Low-level OS/window system memory buffer - */ -struct xm_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; - - XImage *tempImage; -#ifdef USE_XSHM - boolean shm; /** Is this a shared memory buffer? */ - XShmSegmentInfo shminfo; -#endif -}; - - -/** - * Subclass of pipe_winsys for Xlib winsys - */ -struct xmesa_pipe_winsys -{ - struct pipe_winsys base; -/* struct xmesa_visual *xm_visual; */ -}; - - - -/** Cast wrapper */ -static INLINE struct xm_buffer * -xm_buffer( struct pipe_buffer *buf ) -{ - return (struct xm_buffer *)buf; -} - - -/** - * X Shared Memory Image extension code - */ - -#ifdef USE_XSHM - -static volatile int mesaXErrorFlag = 0; - -/** - * Catches potential Xlib errors. - */ -static int -mesaHandleXError(Display *dpy, XErrorEvent *event) -{ - (void) dpy; - (void) event; - mesaXErrorFlag = 1; - return 0; -} - - -static char *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 NULL; - } - - shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); - if (shminfo->shmaddr == (char *) -1) { - shmctl(shminfo->shmid, IPC_RMID, 0); - return NULL; - } - - shminfo->readOnly = False; - return shminfo->shmaddr; -} - - -/** - * 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... - */ - int (*old_handler)(Display *, 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 = FALSE; - 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 = FALSE; - (void) XSetErrorHandler(old_handler); - return; - } - - b->shm = TRUE; -} - -#endif /* USE_XSHM */ - - - -/* Most callbacks map direcly onto dri_bufmgr operations: - */ -static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = xm_buf->data; - return xm_buf->mapped; -} - -static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = NULL; -} - -static void -xm_buffer_destroy(struct pipe_buffer *buf) -{ - struct xm_buffer *oldBuf = xm_buffer(buf); - - /* - * Note oldBuf->data may point to one of three things: - * 1. XShm shared memory image data - * 2. User-provided (wrapped) memory, see xm_user_buffer_create() - * 3. Regular, malloc'd memory - * We need to be careful with freeing that data now. - */ - - if (oldBuf->data) { -#ifdef USE_XSHM - if (oldBuf->shminfo.shmid >= 0) { - shmdt(oldBuf->shminfo.shmaddr); - shmctl(oldBuf->shminfo.shmid, IPC_RMID, 0); - - oldBuf->shminfo.shmid = -1; - oldBuf->shminfo.shmaddr = (char *) -1; - } - - if (oldBuf->shm) { - oldBuf->data = NULL; - } - - if (oldBuf->tempImage) { - XDestroyImage(oldBuf->tempImage); - oldBuf->tempImage = NULL; - } -#endif - - if (oldBuf->data && !oldBuf->userBuffer) { - /* this was regular malloc'd memory */ - align_free(oldBuf->data); - } - - oldBuf->data = NULL; - } - - free(oldBuf); -} - - -/** - * Display/copy the image in the surface into the X window specified - * by the XMesaBuffer. - */ -static void -xlib_softpipe_display_surface(struct xmesa_buffer *b, - struct pipe_surface *surf) -{ - XImage *ximage; - struct softpipe_texture *spt = softpipe_texture(surf->texture); - struct xm_buffer *xm_buf = xm_buffer(spt->buffer); - static boolean no_swap = 0; - static boolean firsttime = 1; - - if (firsttime) { - no_swap = getenv("SP_NO_RAST") != NULL; - firsttime = 0; - } - - if (no_swap) - return; - -#ifdef USE_XSHM - if (xm_buf->shm) - { - if (xm_buf->tempImage == NULL) - { - assert(util_format_get_blockwidth(surf->texture->format) == 1); - assert(util_format_get_blockheight(surf->texture->format) == 1); - alloc_shm_ximage(xm_buf, b, spt->stride[surf->level] / - util_format_get_blocksize(surf->texture->format), surf->height); - } - - ximage = xm_buf->tempImage; - ximage->data = xm_buf->data; - - /* _debug_printf("XSHM\n"); */ - XShmPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, 0, 0, surf->width, surf->height, False); - } - else -#endif - { - /* display image in Window */ - ximage = b->tempImage; - ximage->data = xm_buf->data; - - /* check that the XImage has been previously initialized */ - assert(ximage->format); - assert(ximage->bitmap_unit); - - /* update XImage's fields */ - ximage->width = surf->width; - ximage->height = surf->height; - ximage->bytes_per_line = spt->stride[surf->level]; - - /* _debug_printf("XPUT\n"); */ - XPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, 0, 0, surf->width, surf->height); - } -} - - -static void -xm_flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *surf, - void *context_private) -{ - /* - * The front color buffer is actually just another XImage buffer. - * This function copies that XImage to the actual X Window. - */ - XMesaContext xmctx = (XMesaContext) context_private; - xlib_softpipe_display_surface(xmctx->xm_buffer, surf); - xmesa_check_and_update_buffer_size(xmctx, xmctx->xm_buffer); -} - - - -static const char * -xm_get_name(struct pipe_winsys *pws) -{ - return "Xlib"; -} - - -static struct pipe_buffer * -xm_buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->data = align_malloc(size, max(alignment, 16)); - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - - return &buffer->base; -} - - -static struct pipe_buffer * -xm_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy, size; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - size = *stride * nblocksy; - -#ifdef USE_XSHM - if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) - { - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - buffer->userBuffer = FALSE; - buffer->shminfo.shmid = -1; - buffer->shminfo.shmaddr = (char *) -1; - buffer->shm = TRUE; - - buffer->data = alloc_shm(buffer, size); - if (!buffer->data) - goto out; - - return &buffer->base; - - out: - if (buffer) - FREE(buffer); - } -#endif - - - return winsys->buffer_create(winsys, alignment, - usage, - size); -} - - -/* - * Fence functions - basically nothing to do, as we don't create any actual - * fence objects. - */ - -static void -xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - - -static struct pipe_winsys * -xlib_create_softpipe_winsys( void ) -{ - static struct xmesa_pipe_winsys *ws = NULL; - - if (!ws) { - ws = CALLOC_STRUCT(xmesa_pipe_winsys); - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->base.buffer_create = xm_buffer_create; - ws->base.user_buffer_create = xm_user_buffer_create; - ws->base.buffer_map = xm_buffer_map; - ws->base.buffer_unmap = xm_buffer_unmap; - ws->base.buffer_destroy = xm_buffer_destroy; - - ws->base.surface_buffer_create = xm_surface_buffer_create; - - ws->base.fence_reference = xm_fence_reference; - ws->base.fence_signalled = xm_fence_signalled; - ws->base.fence_finish = xm_fence_finish; - - ws->base.flush_frontbuffer = xm_flush_frontbuffer; - ws->base.get_name = xm_get_name; - } - - return &ws->base; -} - +#include "softpipe/sp_texture.h" +#include "softpipe/sp_screen.h" +#include "state_tracker/sw_winsys.h" static struct pipe_screen * xlib_create_softpipe_screen( void ) { - struct pipe_winsys *winsys; + struct sw_winsys *winsys; struct pipe_screen *screen; - winsys = xlib_create_softpipe_winsys(); + winsys = xlib_create_sw_winsys(); if (winsys == NULL) return NULL; @@ -498,6 +56,18 @@ fail: } +static void +xlib_softpipe_display_surface(struct xmesa_buffer *xm_buffer, + struct pipe_surface *surf) +{ + struct softpipe_texture *texture = softpipe_texture(surf->texture); + + assert(texture->dt); + if (texture->dt) + xlib_sw_display(xm_buffer, texture->dt); +} + + struct xm_driver xlib_softpipe_driver = { .create_pipe_screen = xlib_create_softpipe_screen, diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c new file mode 100644 index 0000000000..e4b02ba093 --- /dev/null +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -0,0 +1,394 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/* + * Authors: + * Keith Whitwell + * Brian Paul + */ + + + +#include "xm_api.h" + +#undef ASSERT +#undef Elements + +#include "pipe/p_format.h" +#include "pipe/p_context.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "state_tracker/sw_winsys.h" + +#include "xlib.h" + +/** + * Subclass of pipe_buffer for Xlib winsys. + * Low-level OS/window system memory buffer + */ +struct xm_displaytarget +{ + enum pipe_format format; + unsigned width; + unsigned height; + unsigned stride; + + void *data; + void *mapped; + + XImage *tempImage; +#ifdef USE_XSHM + int shm; + XShmSegmentInfo shminfo; +#endif +}; + + +/** + * Subclass of sw_winsys for Xlib winsys + */ +struct xmesa_sw_winsys +{ + struct sw_winsys base; +/* struct xmesa_visual *xm_visual; */ +}; + + + +/** Cast wrapper */ +static INLINE struct xm_displaytarget * +xm_displaytarget( struct sw_displaytarget *dt ) +{ + return (struct xm_displaytarget *)dt; +} + + +/** + * X Shared Memory Image extension code + */ + +#ifdef USE_XSHM + +static volatile int mesaXErrorFlag = 0; + +/** + * Catches potential Xlib errors. + */ +static int +mesaHandleXError(Display *dpy, XErrorEvent *event) +{ + (void) dpy; + (void) event; + mesaXErrorFlag = 1; + return 0; +} + + +static char *alloc_shm(struct xm_displaytarget *buf, unsigned size) +{ + XShmSegmentInfo *const shminfo = & buf->shminfo; + + shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); + if (shminfo->shmid < 0) { + return NULL; + } + + shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); + if (shminfo->shmaddr == (char *) -1) { + shmctl(shminfo->shmid, IPC_RMID, 0); + return NULL; + } + + shminfo->readOnly = False; + return shminfo->shmaddr; +} + + +/** + * Allocate a shared memory XImage back buffer for the given XMesaBuffer. + */ +static void +alloc_shm_ximage(struct xm_displaytarget *xm_buffer, + 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... + */ + int (*old_handler)(Display *, XErrorEvent *); + + xm_buffer->tempImage = XShmCreateImage(xmb->xm_visual->display, + xmb->xm_visual->visinfo->visual, + xmb->xm_visual->visinfo->depth, + ZPixmap, + NULL, + &xm_buffer->shminfo, + width, height); + if (xm_buffer->tempImage == NULL) { + xm_buffer->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, &xm_buffer->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(xm_buffer->tempImage); + xm_buffer->tempImage = NULL; + xm_buffer->shm = 0; + (void) XSetErrorHandler(old_handler); + return; + } + + xm_buffer->shm = 1; +} + +#endif /* USE_XSHM */ + +static boolean +xm_is_displaytarget_format_supported( struct sw_winsys *ws, + enum pipe_format format ) +{ + /* TODO: check visuals or other sensible thing here */ + return TRUE; +} + + +static void * +xm_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = xm_dt->data; + return xm_dt->mapped; +} + +static void +xm_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + xm_dt->mapped = NULL; +} + +static void +xm_displaytarget_destroy(struct sw_winsys *ws, + struct sw_displaytarget *dt) +{ + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + + if (xm_dt->data) { +#ifdef USE_XSHM + if (xm_dt->shminfo.shmid >= 0) { + shmdt(xm_dt->shminfo.shmaddr); + shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0); + + xm_dt->shminfo.shmid = -1; + xm_dt->shminfo.shmaddr = (char *) -1; + } + else +#endif + FREE(xm_dt->data); + } + + FREE(xm_dt); +} + + +/** + * Display/copy the image in the surface into the X window specified + * by the XMesaBuffer. + */ +void +xlib_sw_display(struct xmesa_buffer *xm_buffer, + struct sw_displaytarget *dt) +{ + XImage *ximage; + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + static boolean no_swap = 0; + static boolean firsttime = 1; + + if (firsttime) { + no_swap = getenv("SP_NO_RAST") != NULL; + firsttime = 0; + } + + if (no_swap) + return; + +#ifdef USE_XSHM + if (xm_dt->shm) + { + if (xm_dt->tempImage == NULL) + { + assert(util_format_get_blockwidth(xm_dt->format) == 1); + assert(util_format_get_blockheight(xm_dt->format) == 1); + alloc_shm_ximage(xm_dt, xm_buffer, + xm_dt->stride / util_format_get_blocksize(xm_dt->format), + xm_dt->height); + } + + ximage = xm_dt->tempImage; + ximage->data = xm_dt->data; + + /* _debug_printf("XSHM\n"); */ + XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); + } + else +#endif + { + /* display image in Window */ + ximage = xm_dt->tempImage; + ximage->data = xm_dt->data; + + /* check that the XImage has been previously initialized */ + assert(ximage->format); + assert(ximage->bitmap_unit); + + /* update XImage's fields */ + ximage->width = xm_dt->width; + ximage->height = xm_dt->height; + ximage->bytes_per_line = xm_dt->stride; + + /* _debug_printf("XPUT\n"); */ + XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); + } +} + +/** + * Display/copy the image in the surface into the X window specified + * by the XMesaBuffer. + */ +static void +xm_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) +{ + XMesaContext xmctx = (XMesaContext) context_private; + struct xmesa_buffer *xm_buffer = xmctx->xm_buffer; + xm_sw_display(xm_buffer, dt); +} + + +static struct sw_displaytarget * +xm_displaytarget_create(struct sw_winsys *winsys, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget); + unsigned nblocksy, size; + + xm_dt = CALLOC_STRUCT(xm_displaytarget); + if(!xm_dt) + goto no_xm_dt; + + xm_dt->format = format; + xm_dt->width = width; + xm_dt->height = height; + + nblocksy = util_format_get_nblocksy(format, height); + xm_dt->stride = align(util_format_get_stride(format, width), alignment); + size = xm_dt->stride * nblocksy; + +#ifdef USE_XSHM + if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) + { + xm_dt->shminfo.shmid = -1; + xm_dt->shminfo.shmaddr = (char *) -1; + xm_dt->shm = TRUE; + + xm_dt->data = alloc_shm(xm_dt, size); + if(!xm_dt->data) + goto no_data; + } +#endif + + if(!xm_dt->data) { + xm_dt->data = align_malloc(size, alignment); + if(!xm_dt->data) + goto no_data; + } + + *stride = xm_dt->stride; + return (struct sw_displaytarget *)xm_dt; + +no_data: + FREE(xm_dt); +no_xm_dt: + return NULL; +} + + +static void +xm_destroy( struct sw_winsys *ws ) +{ + FREE(ws); +} + + +struct sw_winsys * +xlib_create_sw_winsys( void ) +{ + struct xmesa_sw_winsys *ws; + + ws = CALLOC_STRUCT(xmesa_sw_winsys); + if (!ws) + return NULL; + + ws->base.destroy = xm_destroy; + + ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported; + + ws->base.displaytarget_create = xm_displaytarget_create; + ws->base.displaytarget_map = xm_displaytarget_map; + ws->base.displaytarget_unmap = xm_displaytarget_unmap; + ws->base.displaytarget_destroy = xm_displaytarget_destroy; + + ws->base.displaytarget_display = xm_displaytarget_display; + + return &ws->base; +} + -- cgit v1.2.3 From 23e951d0da5802fec70996e46ad6f0abc411594c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 16:23:05 +0000 Subject: gallium: fix llvmpipe after winsys move --- src/gallium/drivers/llvmpipe/lp_buffer.c | 2 +- src/gallium/drivers/llvmpipe/lp_screen.c | 3 ++- src/gallium/drivers/llvmpipe/lp_screen.h | 3 +++ src/gallium/drivers/llvmpipe/lp_setup.c | 2 +- src/gallium/drivers/llvmpipe/lp_texture.c | 2 +- src/gallium/winsys/xlib/xlib_llvmpipe.c | 5 +++-- src/gallium/winsys/xlib/xlib_softpipe.c | 1 + 7 files changed, 12 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_buffer.c b/src/gallium/drivers/llvmpipe/lp_buffer.c index 9eda972081..dab20cb639 100644 --- a/src/gallium/drivers/llvmpipe/lp_buffer.c +++ b/src/gallium/drivers/llvmpipe/lp_buffer.c @@ -30,10 +30,10 @@ #include "util/u_memory.h" #include "util/u_math.h" -#include "lp_winsys.h" #include "lp_screen.h" #include "lp_buffer.h" +#include "state_tracker/sw_winsys.h" static void * llvmpipe_buffer_map(struct pipe_screen *screen, diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 8816440a50..6759e39e01 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -34,12 +34,13 @@ #include "lp_texture.h" #include "lp_buffer.h" #include "lp_fence.h" -#include "lp_winsys.h" #include "lp_jit.h" #include "lp_screen.h" #include "lp_context.h" #include "lp_debug.h" +#include "state_tracker/sw_winsys.h" + #ifdef DEBUG int LP_DEBUG = 0; diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 3211822b53..0c86283605 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -76,4 +76,7 @@ llvmpipe_screen( struct pipe_screen *pipe ) } +struct pipe_screen * +llvmpipe_create_screen(struct sw_winsys *winsys); + #endif /* LP_SCREEN_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 72b19d0b05..fe60eb0437 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -46,7 +46,7 @@ #include "lp_rast.h" #include "lp_setup_context.h" #include "lp_screen.h" -#include "lp_winsys.h" +#include "state_tracker/sw_winsys.h" #include "draw/draw_context.h" #include "draw/draw_vbuf.h" diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index aed9ed6175..ac3d62dc96 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -42,7 +42,7 @@ #include "lp_screen.h" #include "lp_texture.h" #include "lp_tile_size.h" -#include "lp_winsys.h" +#include "state_tracker/sw_winsys.h" /** diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c index 9929ba52e7..cb559f9080 100644 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c @@ -41,13 +41,14 @@ #if defined(GALLIUM_LLVMPIPE) #include "llvmpipe/lp_texture.h" -#include "llvmpipe/lp_winsys.h" +#include "llvmpipe/lp_screen.h" #include "state_tracker/sw_winsys.h" +#include "util/u_debug.h" static struct pipe_screen * xlib_create_llvmpipe_screen( void ) { - struct llvmpipe_winsys *winsys; + struct sw_winsys *winsys; struct pipe_screen *screen; winsys = xlib_create_sw_winsys(); diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index df93de551c..47fec4313b 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -31,6 +31,7 @@ #include "softpipe/sp_texture.h" #include "softpipe/sp_screen.h" #include "state_tracker/sw_winsys.h" +#include "util/u_debug.h" static struct pipe_screen * xlib_create_softpipe_screen( void ) -- cgit v1.2.3 From c549593931ef08bb48e601189fa97c86b5e780b2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 16:33:45 +0000 Subject: gallium: remove redundant includes --- src/gallium/drivers/cell/ppu/cell_context.c | 1 - src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 1 - src/gallium/drivers/cell/ppu/cell_screen.c | 1 - src/gallium/drivers/cell/ppu/cell_state_shader.c | 1 - src/gallium/drivers/cell/ppu/cell_texture.c | 1 - src/gallium/drivers/cell/ppu/cell_vertex_shader.c | 1 - src/gallium/drivers/failover/fo_context.c | 1 - src/gallium/drivers/i915/i915_debug_fp.c | 1 - src/gallium/drivers/softpipe/sp_draw_arrays.c | 1 - src/gallium/drivers/softpipe/sp_screen.c | 2 -- 10 files changed, 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index 5bff9869fd..4751ca8957 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -36,7 +36,6 @@ #include "pipe/p_defines.h" #include "pipe/p_format.h" #include "util/u_memory.h" -#include "util/u_simple_screen.h" #include "pipe/p_screen.h" #include "draw/draw_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index bffd0fac6f..db28c26ca8 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -33,7 +33,6 @@ #include "pipe/p_defines.h" #include "pipe/p_context.h" -#include "util/u_simple_screen.h" #include "util/u_inlines.h" #include "cell_context.h" diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index a43f8638dc..77bd849a15 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -28,7 +28,6 @@ #include "util/u_memory.h" #include "util/u_simple_screen.h" -#include "util/u_simple_screen.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c index 9b2f86fdfb..bc6127d7e7 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c @@ -28,7 +28,6 @@ #include "pipe/p_defines.h" #include "util/u_memory.h" #include "util/u_inlines.h" -#include "util/u_simple_screen.h" #include "draw/draw_context.h" #include "tgsi/tgsi_parse.h" diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index fad290dfa0..a5f426795d 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -34,7 +34,6 @@ #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "util/u_inlines.h" -#include "util/u_simple_screen.h" #include "util/u_format.h" #include "util/u_math.h" diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c index cf8cd41159..3d389d6ea3 100644 --- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c @@ -31,7 +31,6 @@ #include "pipe/p_defines.h" #include "pipe/p_context.h" -#include "util/u_simple_screen.h" #include "util/u_math.h" #include "cell_context.h" diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c index 2ccc5d3e60..659e40cbf0 100644 --- a/src/gallium/drivers/failover/fo_context.c +++ b/src/gallium/drivers/failover/fo_context.c @@ -27,7 +27,6 @@ #include "pipe/p_defines.h" -#include "util/u_simple_screen.h" #include "util/u_memory.h" #include "pipe/p_context.h" diff --git a/src/gallium/drivers/i915/i915_debug_fp.c b/src/gallium/drivers/i915/i915_debug_fp.c index 066e7392d1..f41c51f299 100644 --- a/src/gallium/drivers/i915/i915_debug_fp.c +++ b/src/gallium/drivers/i915/i915_debug_fp.c @@ -28,7 +28,6 @@ #include "i915_reg.h" #include "i915_debug.h" -#include "util/u_simple_screen.h" #include "util/u_debug.h" diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index 0899e1145a..7b77eb239f 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -33,7 +33,6 @@ #include "pipe/p_defines.h" #include "pipe/p_context.h" -#include "util/u_simple_screen.h" #include "util/u_inlines.h" #include "util/u_prim.h" diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 107631f6b5..9eb3ff6875 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -27,8 +27,6 @@ #include "util/u_memory.h" -#include "util/u_simple_screen.h" -#include "util/u_simple_screen.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" -- cgit v1.2.3 From 3b6a991728ccb174f19de8b9752241cd4f21398e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 4 Mar 2010 16:50:22 +0000 Subject: softpipe: fix constant buffer tracking after rework --- src/gallium/drivers/softpipe/sp_state_fs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index cd0e905bc9..2b089c2831 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -176,19 +176,17 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, assert(shader < PIPE_SHADER_TYPES); assert(index == 0); - if(softpipe->constants[shader][index] == constants) - return; - draw_flush(softpipe->draw); /* note: reference counting */ pipe_buffer_reference(&softpipe->constants[shader][index], constants); if(shader == PIPE_SHADER_VERTEX) { - draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, 0, + draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index, data, size); } + softpipe->mapped_constants[shader][index] = data; softpipe->dirty |= SP_NEW_CONSTANTS; } -- cgit v1.2.3 From 38110fd1c3a6c57d1ff089d546a3456ca1a78da8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 26 Feb 2010 17:44:10 -0700 Subject: gallivm: clarify unsigned vs. signed integer type construction The lp_int_type() function was creating an unsigned type. So rename that function to lp_uint_type() and create new lp_int_type() that creates a signed type. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 38 +++++++++++------------ src/gallium/auxiliary/gallivm/lp_bld_type.c | 20 ++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_type.h | 4 +++ 3 files changed, 43 insertions(+), 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index e268862282..64698c660e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -70,8 +70,8 @@ struct lp_build_sample_context struct lp_build_context coord_bld; /** Integer coordinates */ - struct lp_type int_coord_type; - struct lp_build_context int_coord_bld; + struct lp_type uint_coord_type; + struct lp_build_context uint_coord_bld; /** Output texels type and build context */ struct lp_type texel_type; @@ -90,7 +90,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef offset; LLVMValueRef packed; - offset = lp_build_sample_offset(&bld->int_coord_bld, + offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, x, y, y_stride, data_ptr); @@ -121,7 +121,7 @@ lp_build_sample_packed(struct lp_build_sample_context *bld, { LLVMValueRef offset; - offset = lp_build_sample_offset(&bld->int_coord_bld, + offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, x, y, y_stride, data_ptr); @@ -145,10 +145,10 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld, boolean is_pot, unsigned wrap_mode) { - struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; LLVMValueRef length_minus_one; - length_minus_one = lp_build_sub(int_coord_bld, length, int_coord_bld->one); + length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); switch(wrap_mode) { case PIPE_TEX_WRAP_REPEAT: @@ -161,8 +161,8 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld, break; case PIPE_TEX_WRAP_CLAMP: - coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero); - coord = lp_build_min(int_coord_bld, coord, length_minus_one); + coord = lp_build_max(uint_coord_bld, coord, uint_coord_bld->zero); + coord = lp_build_min(uint_coord_bld, coord, length_minus_one); break; case PIPE_TEX_WRAP_CLAMP_TO_EDGE: @@ -174,8 +174,8 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld, /* FIXME */ _debug_printf("llvmpipe: failed to translate texture wrap mode %s\n", util_dump_tex_wrap(wrap_mode, TRUE)); - coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero); - coord = lp_build_min(int_coord_bld, coord, length_minus_one); + coord = lp_build_max(uint_coord_bld, coord, uint_coord_bld->zero); + coord = lp_build_min(uint_coord_bld, coord, length_minus_one); break; default: @@ -249,8 +249,8 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s); y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t); - x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one); - y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one); + x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one); + y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one); x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s); y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t); @@ -358,8 +358,8 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s); y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t); - x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one); - y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one); + x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one); + y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one); x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s); y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t); @@ -545,10 +545,10 @@ lp_build_sample_soa(LLVMBuilderRef builder, bld.dynamic_state = dynamic_state; bld.format_desc = util_format_description(static_state->format); bld.coord_type = type; - bld.int_coord_type = lp_int_type(type); + bld.uint_coord_type = lp_uint_type(type); bld.texel_type = type; lp_build_context_init(&bld.coord_bld, builder, bld.coord_type); - lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type); + lp_build_context_init(&bld.uint_coord_bld, builder, bld.uint_coord_type); lp_build_context_init(&bld.texel_bld, builder, bld.texel_type); /* Get the dynamic state */ @@ -561,9 +561,9 @@ lp_build_sample_soa(LLVMBuilderRef builder, t = coords[1]; p = coords[2]; - width = lp_build_broadcast_scalar(&bld.int_coord_bld, width); - height = lp_build_broadcast_scalar(&bld.int_coord_bld, height); - stride = lp_build_broadcast_scalar(&bld.int_coord_bld, stride); + width = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); + height = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); + stride = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride); if(static_state->target == PIPE_TEXTURE_1D) t = bld.coord_bld.zero; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index 8270cd057f..c327ba045a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -178,6 +178,25 @@ lp_build_int32_vec4_type(void) } +/** + * Create unsigned integer type variation of given type. + */ +struct lp_type +lp_uint_type(struct lp_type type) +{ + struct lp_type res_type; + + memset(&res_type, 0, sizeof res_type); + res_type.width = type.width; + res_type.length = type.length; + + return res_type; +} + + +/** + * Create signed integer type variation of given type. + */ struct lp_type lp_int_type(struct lp_type type) { @@ -186,6 +205,7 @@ lp_int_type(struct lp_type type) memset(&res_type, 0, sizeof res_type); res_type.width = type.width; res_type.length = type.length; + res_type.sign = 1; return res_type; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 62ee05be4d..16946cc28a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -256,6 +256,10 @@ LLVMTypeRef lp_build_int32_vec4_type(void); +struct lp_type +lp_uint_type(struct lp_type type); + + struct lp_type lp_int_type(struct lp_type type); -- cgit v1.2.3 From 7d230dae70e8caa67cc6bd7501f892d44c40a5d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 08:36:26 -0700 Subject: gallivm: added lp_build_negate() --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 8 ++++++++ src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 ++++ 2 files changed, 12 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index bbce31f9eb..f60a7a213a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -668,6 +668,14 @@ lp_build_abs(struct lp_build_context *bld, } +LLVMValueRef +lp_build_negate(struct lp_build_context *bld, + LLVMValueRef a) +{ + return LLVMBuildNeg(bld->builder, a, ""); +} + + LLVMValueRef lp_build_sgn(struct lp_build_context *bld, LLVMValueRef a) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index da84b7ca02..2d19ec06b4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -116,6 +116,10 @@ LLVMValueRef lp_build_abs(struct lp_build_context *bld, LLVMValueRef a); +LLVMValueRef +lp_build_negate(struct lp_build_context *bld, + LLVMValueRef a); + LLVMValueRef lp_build_sgn(struct lp_build_context *bld, LLVMValueRef a); -- cgit v1.2.3 From 6464d81e779e8c05ef96c9e5dab4422ff1f25464 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 09:45:34 -0700 Subject: gallivm: added lp_build_set_sign() --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 35 +++++++++++++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 ++++ 2 files changed, 39 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index f60a7a213a..42ae9f6a22 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -717,6 +717,41 @@ lp_build_sgn(struct lp_build_context *bld, } +/** + * Set the sign of float vector 'a' according to 'sign'. + * If sign==0, return abs(a). + * If sign==1, return -abs(a); + * Other values for sign produce undefined results. + */ +LLVMValueRef +lp_build_set_sign(struct lp_build_context *bld, + LLVMValueRef a, LLVMValueRef sign) +{ + const struct lp_type type = bld->type; + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); + LLVMTypeRef vec_type = lp_build_vec_type(type); + LLVMValueRef shift = lp_build_int_const_scalar(type, type.width - 1); + LLVMValueRef mask = lp_build_int_const_scalar(type, + ~((unsigned long long) 1 << (type.width - 1))); + LLVMValueRef val, res; + + assert(type.floating); + + /* val = reinterpret_cast(a) */ + val = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); + /* val = val & mask */ + val = LLVMBuildAnd(bld->builder, val, mask, ""); + /* sign = sign << shift */ + sign = LLVMBuildShl(bld->builder, sign, shift, ""); + /* res = val | sign */ + res = LLVMBuildOr(bld->builder, val, sign, ""); + /* res = reinterpret_cast(res) */ + res = LLVMBuildBitCast(bld->builder, res, vec_type, ""); + + return res; +} + + /** * Convert vector of int to vector of float. */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 2d19ec06b4..866349d8cb 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -124,6 +124,10 @@ LLVMValueRef lp_build_sgn(struct lp_build_context *bld, LLVMValueRef a); +LLVMValueRef +lp_build_set_sign(struct lp_build_context *bld, + LLVMValueRef a, LLVMValueRef sign); + LLVMValueRef lp_build_int_to_float(struct lp_build_context *bld, LLVMValueRef a); -- cgit v1.2.3 From 516bad2272aa9bb3c85516e0023ddd2ed236dcef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 10:50:26 -0700 Subject: gallivm: added lp_build_fract() --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 13 +++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 ++++ 2 files changed, 17 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 42ae9f6a22..32f9e5201c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -899,6 +899,19 @@ lp_build_ceil(struct lp_build_context *bld, } +/** + * Return fractional part of 'a' computed as a - floor(f) + * Typically used in texture coord arithmetic. + */ +LLVMValueRef +lp_build_fract(struct lp_build_context *bld, + LLVMValueRef a) +{ + assert(bld->type.floating); + return lp_build_sub(bld, a, lp_build_floor(bld, a)); +} + + /** * Convert to integer, through whichever rounding method that's fastest, * typically truncating toward zero. diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 866349d8cb..55385e3a66 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -148,6 +148,10 @@ LLVMValueRef lp_build_trunc(struct lp_build_context *bld, LLVMValueRef a); +LLVMValueRef +lp_build_fract(struct lp_build_context *bld, + LLVMValueRef a); + LLVMValueRef lp_build_ifloor(struct lp_build_context *bld, LLVMValueRef a); -- cgit v1.2.3 From 4c0c728b2a3c8ebee09ddacd1390be31b1a73e23 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 10:51:31 -0700 Subject: gallivm: rework and implement more texture wrap modes All the texture wrap modes are now implemented for linear and nearest sampling. However, texture border color is not yet supported so some wrap modes will produce int coords outside the texture bounds. We'll get garbage values insted of the texture border color for now. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 508 +++++++++++++++++++--- 1 file changed, 448 insertions(+), 60 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 64698c660e..1ba139c6cd 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -69,10 +69,14 @@ struct lp_build_sample_context struct lp_type coord_type; struct lp_build_context coord_bld; - /** Integer coordinates */ + /** Unsigned integer coordinates */ struct lp_type uint_coord_type; struct lp_build_context uint_coord_bld; + /** Signed integer coordinates */ + struct lp_type int_coord_type; + struct lp_build_context int_coord_bld; + /** Output texels type and build context */ struct lp_type texel_type; struct lp_build_context texel_bld; @@ -138,14 +142,74 @@ lp_build_sample_packed(struct lp_build_sample_context *bld, } +/** + * Helper to compute the mirror function for the PIPE_WRAP_MIRROR modes. + */ +static LLVMValueRef +lp_build_coord_mirror(struct lp_build_sample_context *bld, + LLVMValueRef coord) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + LLVMValueRef fract, flr, isOdd; + + /* fract = coord - floor(coord) */ + fract = lp_build_sub(coord_bld, coord, lp_build_floor(coord_bld, coord)); + + /* flr = ifloor(coord); */ + flr = lp_build_ifloor(coord_bld, coord); + + /* isOdd = flr & 1 */ + isOdd = LLVMBuildAnd(bld->builder, flr, int_coord_bld->one, ""); + + /* make coord positive or negative depending on isOdd */ + coord = lp_build_set_sign(coord_bld, fract, isOdd); + + /* convert isOdd to float */ + isOdd = lp_build_int_to_float(coord_bld, isOdd); + + /* add isOdd to coord */ + coord = lp_build_add(coord_bld, coord, isOdd); + + return coord; +} + + +/** + * We only support a few wrap modes in lp_build_sample_wrap_int() at this time. + * Return whether the given mode is supported by that function. + */ +static boolean +is_simple_wrap_mode(int mode) +{ + switch (mode) { + case PIPE_TEX_WRAP_REPEAT: + case PIPE_TEX_WRAP_CLAMP: + case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + return TRUE; + default: + return FALSE; + } +} + + +/** + * Build LLVM code for texture wrap mode, for scaled integer texcoords. + * \param coord the incoming texcoord (s,t,r or q) scaled to the texture size + * \param length the texture size along one dimension + * \param is_pot if TRUE, length is a power of two + * \param wrap_mode one of PIPE_TEX_WRAP_x + */ static LLVMValueRef -lp_build_sample_wrap(struct lp_build_sample_context *bld, - LLVMValueRef coord, - LLVMValueRef length, - boolean is_pot, - unsigned wrap_mode) +lp_build_sample_wrap_int(struct lp_build_sample_context *bld, + LLVMValueRef coord, + LLVMValueRef length, + boolean is_pot, + unsigned wrap_mode) { struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; LLVMValueRef length_minus_one; length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); @@ -161,12 +225,12 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld, break; case PIPE_TEX_WRAP_CLAMP: - coord = lp_build_max(uint_coord_bld, coord, uint_coord_bld->zero); - coord = lp_build_min(uint_coord_bld, coord, length_minus_one); - break; - case PIPE_TEX_WRAP_CLAMP_TO_EDGE: case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + coord = lp_build_max(int_coord_bld, coord, int_coord_bld->zero); + coord = lp_build_min(int_coord_bld, coord, length_minus_one); + break; + case PIPE_TEX_WRAP_MIRROR_REPEAT: case PIPE_TEX_WRAP_MIRROR_CLAMP: case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: @@ -186,6 +250,332 @@ lp_build_sample_wrap(struct lp_build_sample_context *bld, } +/** + * Build LLVM code for texture wrap mode for linear filtering. + * \param x0_out returns first integer texcoord + * \param x1_out returns second integer texcoord + * \param weight_out returns linear interpolation weight + */ +static void +lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, + LLVMValueRef coord, + LLVMValueRef length, + boolean is_pot, + unsigned wrap_mode, + LLVMValueRef *x0_out, + LLVMValueRef *x1_out, + LLVMValueRef *weight_out) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; + LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0); + LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5); + LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length); + LLVMValueRef length_minus_one; + LLVMValueRef length_f_minus_one; + LLVMValueRef coord0, coord1, weight; + + /* XXX check for normalized vs. unnormalized coords */ + + length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); + length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); + + switch(wrap_mode) { + case PIPE_TEX_WRAP_REPEAT: + /* mul by size and subtract 0.5 */ + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); + /* convert to int */ + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(uint_coord_bld, coord0, uint_coord_bld->one); + /* compute lerp weight */ + weight = lp_build_fract(coord_bld, coord); + /* repeat wrap */ + if (is_pot) { + coord0 = LLVMBuildAnd(bld->builder, coord0, length_minus_one, ""); + coord1 = LLVMBuildAnd(bld->builder, coord1, length_minus_one, ""); + } + else { + /* Signed remainder won't give the right results for negative + * dividends but unsigned remainder does.*/ + coord0 = LLVMBuildURem(bld->builder, coord0, length, ""); + coord1 = LLVMBuildURem(bld->builder, coord1, length, ""); + } + break; + + case PIPE_TEX_WRAP_CLAMP: + coord = lp_build_mul(coord_bld, coord, length_f); + weight = lp_build_fract(coord_bld, coord); + coord0 = lp_build_clamp(coord_bld, coord, coord_bld->zero, + length_f_minus_one); + coord1 = lp_build_add(coord_bld, coord, coord_bld->one); + coord1 = lp_build_clamp(coord_bld, coord1, coord_bld->zero, + length_f_minus_one); + coord0 = lp_build_ifloor(coord_bld, coord0); + coord1 = lp_build_ifloor(coord_bld, coord1); + break; + + case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + /* clamp to [0,1] */ + coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, coord_bld->one); + /* mul by tex size and subtract 0.5 */ + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); + /* compute lerp weight */ + weight = lp_build_fract(coord_bld, coord); + /* coord0 = floor(coord); */ + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + /* coord0 = max(coord0, 0) */ + coord0 = lp_build_max(int_coord_bld, coord0, int_coord_bld->zero); + /* coord1 = min(coord1, length-1) */ + coord1 = lp_build_min(int_coord_bld, coord1, length_minus_one); + break; + + case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + { + LLVMValueRef min, max; + /* min = -1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + /* scale coord to length (and sub 0.5?) */ + coord = lp_build_mul(coord_bld, coord, length_f); + /* compute lerp weight */ + weight = lp_build_fract(coord_bld, coord); + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); + /* convert to int */ + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + } + break; + + case PIPE_TEX_WRAP_MIRROR_REPEAT: + /* compute mirror function */ + coord = lp_build_coord_mirror(bld, coord); + + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); + + /* compute lerp weight */ + weight = lp_build_fract(coord_bld, coord); + + /* convert to int coords */ + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + + /* coord0 = max(coord0, 0) */ + coord0 = lp_build_max(int_coord_bld, coord0, int_coord_bld->zero); + /* coord1 = min(coord1, length-1) */ + coord1 = lp_build_min(int_coord_bld, coord1, length_minus_one); + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP: + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + weight = lp_build_fract(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, length_f_minus_one); + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + weight = lp_build_fract(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, min, max); + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + } + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: + { + LLVMValueRef min, max; + /* min = -1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + weight = lp_build_fract(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, min, max); + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + } + break; + + default: + assert(0); + } + + *x0_out = coord0; + *x1_out = coord1; + *weight_out = weight; +} + + +/** + * Build LLVM code for texture wrap mode for nearest filtering. + * \param coord the incoming texcoord (nominally in [0,1]) + * \param length the texture size along one dimension, as int + * \param is_pot if TRUE, length is a power of two + * \param wrap_mode one of PIPE_TEX_WRAP_x + */ +static LLVMValueRef +lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, + LLVMValueRef coord, + LLVMValueRef length, + boolean is_pot, + unsigned wrap_mode) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + struct lp_build_context *uint_coord_bld = &bld->uint_coord_bld; + LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0); + LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length); + LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); + LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); + LLVMValueRef icoord; + + /* XXX check for normalized vs. unnormalized coords */ + + switch(wrap_mode) { + case PIPE_TEX_WRAP_REPEAT: + coord = lp_build_mul(coord_bld, coord, length_f); + icoord = lp_build_ifloor(coord_bld, coord); + if (is_pot) + icoord = LLVMBuildAnd(bld->builder, icoord, length_minus_one, ""); + else + /* Signed remainder won't give the right results for negative + * dividends but unsigned remainder does.*/ + icoord = LLVMBuildURem(bld->builder, icoord, length, ""); + break; + + case PIPE_TEX_WRAP_CLAMP: + /* mul by size */ + coord = lp_build_mul(coord_bld, coord, length_f); + /* floor */ + icoord = lp_build_ifloor(coord_bld, coord); + /* clamp to [0, size-1]. Note: int coord builder type */ + icoord = lp_build_clamp(int_coord_bld, icoord, int_coord_bld->zero, + length_minus_one); + break; + + case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); + icoord = lp_build_ifloor(coord_bld, coord); + } + break; + + case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + /* Note: this is the same as CLAMP_TO_EDGE, except min = -min */ + { + LLVMValueRef min, max; + /* min = -1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); + icoord = lp_build_ifloor(coord_bld, coord); + } + break; + + case PIPE_TEX_WRAP_MIRROR_REPEAT: + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + + /* compute mirror function */ + coord = lp_build_coord_mirror(bld, coord); + + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); + icoord = lp_build_ifloor(coord_bld, coord); + } + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP: + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, length_f_minus_one); + icoord = lp_build_ifloor(coord_bld, coord); + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_clamp(coord_bld, coord, min, max); + icoord = lp_build_ifloor(coord_bld, coord); + } + break; + + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_clamp(coord_bld, coord, min, max); + icoord = lp_build_ifloor(coord_bld, coord); + } + break; + + default: + assert(0); + } + + return icoord; +} + + +/** + * Sample 2D texture with nearest filtering. + */ static void lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, LLVMValueRef s, @@ -196,16 +586,15 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, LLVMValueRef data_ptr, LLVMValueRef *texel) { - LLVMValueRef x; - LLVMValueRef y; + LLVMValueRef x, y; - x = lp_build_ifloor(&bld->coord_bld, s); - y = lp_build_ifloor(&bld->coord_bld, t); - lp_build_name(x, "tex.x.floor"); - lp_build_name(y, "tex.y.floor"); + x = lp_build_sample_wrap_nearest(bld, s, width, + bld->static_state->pot_width, + bld->static_state->wrap_s); + y = lp_build_sample_wrap_nearest(bld, t, height, + bld->static_state->pot_height, + bld->static_state->wrap_t); - x = lp_build_sample_wrap(bld, x, width, bld->static_state->pot_width, bld->static_state->wrap_s); - y = lp_build_sample_wrap(bld, y, height, bld->static_state->pot_height, bld->static_state->wrap_t); lp_build_name(x, "tex.x.wrapped"); lp_build_name(y, "tex.y.wrapped"); @@ -213,6 +602,9 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, } +/** + * Sample 2D texture with bilinear filtering. + */ static void lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, LLVMValueRef s, @@ -223,9 +615,6 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, LLVMValueRef data_ptr, LLVMValueRef *texel) { - LLVMValueRef half; - LLVMValueRef s_ipart; - LLVMValueRef t_ipart; LLVMValueRef s_fpart; LLVMValueRef t_fpart; LLVMValueRef x0, x1; @@ -233,27 +622,10 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, LLVMValueRef neighbors[2][2][4]; unsigned chan; - half = lp_build_const_scalar(bld->coord_type, 0.5); - s = lp_build_sub(&bld->coord_bld, s, half); - t = lp_build_sub(&bld->coord_bld, t, half); - - s_ipart = lp_build_floor(&bld->coord_bld, s); - t_ipart = lp_build_floor(&bld->coord_bld, t); - - s_fpart = lp_build_sub(&bld->coord_bld, s, s_ipart); - t_fpart = lp_build_sub(&bld->coord_bld, t, t_ipart); - - x0 = lp_build_itrunc(&bld->coord_bld, s_ipart); - y0 = lp_build_itrunc(&bld->coord_bld, t_ipart); - - x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s); - y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t); - - x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one); - y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one); - - x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s); - y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t); + lp_build_sample_wrap_linear(bld, s, width, bld->static_state->pot_width, + bld->static_state->wrap_s, &x0, &x1, &s_fpart); + lp_build_sample_wrap_linear(bld, t, height, bld->static_state->pot_height, + bld->static_state->wrap_t, &y0, &y1, &t_fpart); lp_build_sample_texel_soa(bld, x0, y0, stride, data_ptr, neighbors[0][0]); lp_build_sample_texel_soa(bld, x1, y0, stride, data_ptr, neighbors[0][1]); @@ -334,20 +706,33 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, h16_vec_type = lp_build_vec_type(h16.type); u8n_vec_type = lp_build_vec_type(u8n.type); + if (bld->static_state->normalized_coords) { + LLVMTypeRef coord_vec_type = lp_build_vec_type(bld->coord_type); + LLVMValueRef fp_width = LLVMBuildSIToFP(bld->builder, width, coord_vec_type, ""); + LLVMValueRef fp_height = LLVMBuildSIToFP(bld->builder, height, coord_vec_type, ""); + s = lp_build_mul(&bld->coord_bld, s, fp_width); + t = lp_build_mul(&bld->coord_bld, t, fp_height); + } + + /* scale coords by 256 (8 fractional bits) */ s = lp_build_mul_imm(&bld->coord_bld, s, 256); t = lp_build_mul_imm(&bld->coord_bld, t, 256); + /* convert float to int */ s = LLVMBuildFPToSI(builder, s, i32_vec_type, ""); t = LLVMBuildFPToSI(builder, t, i32_vec_type, ""); + /* subtract 0.5 (add -128) */ i32_c128 = lp_build_int_const_scalar(i32.type, -128); s = LLVMBuildAdd(builder, s, i32_c128, ""); t = LLVMBuildAdd(builder, t, i32_c128, ""); + /* compute floor (shift right 8) */ i32_c8 = lp_build_int_const_scalar(i32.type, 8); s_ipart = LLVMBuildAShr(builder, s, i32_c8, ""); t_ipart = LLVMBuildAShr(builder, t, i32_c8, ""); + /* compute fractional part (AND with 0xff) */ i32_c255 = lp_build_int_const_scalar(i32.type, 255); s_fpart = LLVMBuildAnd(builder, s, i32_c255, ""); t_fpart = LLVMBuildAnd(builder, t, i32_c255, ""); @@ -355,14 +740,18 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, x0 = s_ipart; y0 = t_ipart; - x0 = lp_build_sample_wrap(bld, x0, width, bld->static_state->pot_width, bld->static_state->wrap_s); - y0 = lp_build_sample_wrap(bld, y0, height, bld->static_state->pot_height, bld->static_state->wrap_t); + x1 = lp_build_add(&bld->int_coord_bld, x0, bld->int_coord_bld.one); + y1 = lp_build_add(&bld->int_coord_bld, y0, bld->int_coord_bld.one); - x1 = lp_build_add(&bld->uint_coord_bld, x0, bld->uint_coord_bld.one); - y1 = lp_build_add(&bld->uint_coord_bld, y0, bld->uint_coord_bld.one); + x0 = lp_build_sample_wrap_int(bld, x0, width, bld->static_state->pot_width, + bld->static_state->wrap_s); + y0 = lp_build_sample_wrap_int(bld, y0, height, bld->static_state->pot_height, + bld->static_state->wrap_t); - x1 = lp_build_sample_wrap(bld, x1, width, bld->static_state->pot_width, bld->static_state->wrap_s); - y1 = lp_build_sample_wrap(bld, y1, height, bld->static_state->pot_height, bld->static_state->wrap_t); + x1 = lp_build_sample_wrap_int(bld, x1, width, bld->static_state->pot_width, + bld->static_state->wrap_s); + y1 = lp_build_sample_wrap_int(bld, y1, height, bld->static_state->pot_height, + bld->static_state->wrap_t); /* * Transform 4 x i32 in @@ -546,9 +935,11 @@ lp_build_sample_soa(LLVMBuilderRef builder, bld.format_desc = util_format_description(static_state->format); bld.coord_type = type; bld.uint_coord_type = lp_uint_type(type); + bld.int_coord_type = lp_int_type(type); bld.texel_type = type; lp_build_context_init(&bld.coord_bld, builder, bld.coord_type); lp_build_context_init(&bld.uint_coord_bld, builder, bld.uint_coord_type); + lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type); lp_build_context_init(&bld.texel_bld, builder, bld.texel_type); /* Get the dynamic state */ @@ -568,23 +959,20 @@ lp_build_sample_soa(LLVMBuilderRef builder, if(static_state->target == PIPE_TEXTURE_1D) t = bld.coord_bld.zero; - if(static_state->normalized_coords) { - LLVMTypeRef coord_vec_type = lp_build_vec_type(bld.coord_type); - LLVMValueRef fp_width = LLVMBuildSIToFP(builder, width, coord_vec_type, ""); - LLVMValueRef fp_height = LLVMBuildSIToFP(builder, height, coord_vec_type, ""); - s = lp_build_mul(&bld.coord_bld, s, fp_width); - t = lp_build_mul(&bld.coord_bld, t, fp_height); - } - switch (static_state->min_img_filter) { case PIPE_TEX_FILTER_NEAREST: - lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, stride, data_ptr, texel); + lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, + stride, data_ptr, texel); break; case PIPE_TEX_FILTER_LINEAR: - if(lp_format_is_rgba8(bld.format_desc)) - lp_build_sample_2d_linear_aos(&bld, s, t, width, height, stride, data_ptr, texel); + if(lp_format_is_rgba8(bld.format_desc) && + is_simple_wrap_mode(static_state->wrap_s) && + is_simple_wrap_mode(static_state->wrap_t)) + lp_build_sample_2d_linear_aos(&bld, s, t, width, height, + stride, data_ptr, texel); else - lp_build_sample_2d_linear_soa(&bld, s, t, width, height, stride, data_ptr, texel); + lp_build_sample_2d_linear_soa(&bld, s, t, width, height, + stride, data_ptr, texel); break; default: assert(0); -- cgit v1.2.3 From 566390bedf4e5f24b5234e9dc08ecb1a6fd4d13b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 4 Mar 2010 12:46:20 -0800 Subject: r300g: Fix indexbuf upper limits. Wine tends to pessimistically use ~0 for its max index, but r300s only can go up to 2^24-1, causing the kernel checker to freak out. Civ4 is marginally improved now. Still crashes, but not as bad. --- src/gallium/drivers/r300/r300_render.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 770a92be74..6c891029a5 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -273,9 +273,14 @@ static void r300_emit_draw_elements(struct r300_context *r300, CS_LOCALS(r300); assert((start * indexSize) % 4 == 0); + assert(count < (1 << 24)); + + DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", + count, minIndex, maxIndex); + + maxIndex = MIN2(maxIndex, ((1 << 24) - 1)); if (alt_num_verts) { - assert(count < (1 << 24)); BEGIN_CS(16); OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); } else { -- cgit v1.2.3 From 877f2356b2ab7caa16beed496f36eca64ee201e1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:49:39 -0700 Subject: gallivm: comments --- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index 41ac81b744..2726747eae 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -45,6 +45,7 @@ /** * Build code to compare two values 'a' and 'b' of 'type' using the given func. * \param func one of PIPE_FUNC_x + * The result values will be 0 for false or ~0 for true. */ LLVMValueRef lp_build_compare(LLVMBuilderRef builder, @@ -311,6 +312,7 @@ lp_build_compare(LLVMBuilderRef builder, /** * Build code to compare two values 'a' and 'b' using the given func. * \param func one of PIPE_FUNC_x + * The result values will be 0 for false or ~0 for true. */ LLVMValueRef lp_build_cmp(struct lp_build_context *bld, @@ -322,6 +324,9 @@ lp_build_cmp(struct lp_build_context *bld, } +/** + * Return mask ? a : b; + */ LLVMValueRef lp_build_select(struct lp_build_context *bld, LLVMValueRef mask, -- cgit v1.2.3 From ad1456a4447bff8a1dac69723663c698d6abbe81 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:52:37 -0700 Subject: llvmpipe: new comment --- src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index 2533275dc1..515c9089dd 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -145,6 +145,10 @@ lp_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler) } +/** + * Fetch filtered values from texture. + * The 'texel' parameter returns four vectors corresponding to R, G, B, A. + */ static void lp_llvm_sampler_soa_emit_fetch_texel(struct lp_build_sampler_soa *base, LLVMBuilderRef builder, -- cgit v1.2.3 From 71c05689528d7987bfb99c3afe04e456887bc7b7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:52:19 -0700 Subject: gallivm: added question/comment --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index ae866243a9..5f2c2a54ee 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -1126,6 +1126,7 @@ emit_instruction( break; case TGSI_OPCODE_TEX: + /* XXX what about dst0 writemask? */ emit_tex( bld, inst, FALSE, FALSE, dst0 ); break; -- cgit v1.2.3 From 946edea794646443abde05363294fed430d8d6f1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:52:01 -0700 Subject: gallivm: added texture border_color field --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 9 +++++++++ src/gallium/auxiliary/gallivm/lp_bld_sample.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index a133b56ac5..55ac2e9436 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -44,6 +44,11 @@ #include "lp_bld_sample.h" +/** + * Initialize lp_sampler_static_state object with the gallium sampler + * and texture state. + * The former is considered to be static and the later dynamic. + */ void lp_sampler_static_state(struct lp_sampler_static_state *state, const struct pipe_texture *texture, @@ -70,6 +75,10 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, state->min_mip_filter = sampler->min_mip_filter; state->mag_img_filter = sampler->mag_img_filter; state->compare_mode = sampler->compare_mode; + state->border_color[0] = sampler->border_color[0]; + state->border_color[1] = sampler->border_color[1]; + state->border_color[2] = sampler->border_color[2]; + state->border_color[3] = sampler->border_color[3]; if(sampler->compare_mode != PIPE_TEX_COMPARE_NONE) { state->compare_func = sampler->compare_func; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 39edcf13d1..a791d88612 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -70,6 +70,7 @@ struct lp_sampler_static_state unsigned compare_mode:1; unsigned compare_func:3; unsigned normalized_coords:1; + float border_color[4]; }; -- cgit v1.2.3 From 2b5c5c0dcf16062676ecfdf5efb7de650a4c5938 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:50:19 -0700 Subject: gallivm: implement texture border color, plus tweaks to some wrap modes The progs/test/texwrap demo looks pretty good, but there are still some tiny differences from softpipe. There may be a sub-pixel texcoord interpolation error somewhere. There's some room for optimization. Many of the wrap modes compute intermediate values that are constant for the texture size (see the min/max values). These could be computed earlier and stored somewhere for later use. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 152 ++++++++++++++++++---- 1 file changed, 129 insertions(+), 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 1ba139c6cd..fe41d5ee49 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -83,17 +83,92 @@ struct lp_build_sample_context }; +/** + * Does the given texture wrap mode allow sampling the texture border color? + * XXX maybe move this into gallium util code. + */ +static boolean +wrap_mode_uses_border_color(unsigned mode) +{ + switch (mode) { + case PIPE_TEX_WRAP_REPEAT: + case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + case PIPE_TEX_WRAP_MIRROR_REPEAT: + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: + return FALSE; + case PIPE_TEX_WRAP_CLAMP: + case PIPE_TEX_WRAP_CLAMP_TO_BORDER: + case PIPE_TEX_WRAP_MIRROR_CLAMP: + case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: + return TRUE; + default: + assert(0 && "unexpected wrap mode"); + return FALSE; + } +} + + + +/** + * Gen code to fetch a texel from a texture at int coords (x, y). + * The result, texel, will be: + * texel[0] = red values + * texel[1] = green values + * texel[2] = blue values + * texel[3] = alpha values + */ static void lp_build_sample_texel_soa(struct lp_build_sample_context *bld, + LLVMValueRef width, + LLVMValueRef height, LLVMValueRef x, LLVMValueRef y, LLVMValueRef y_stride, LLVMValueRef data_ptr, LLVMValueRef *texel) { + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; LLVMValueRef offset; LLVMValueRef packed; + LLVMValueRef use_border = NULL; + + /* use_border = x < 0 || x >= width || y < 0 || y >= height */ + if (wrap_mode_uses_border_color(bld->static_state->wrap_s)) { + LLVMValueRef b1, b2; + b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, x, int_coord_bld->zero); + b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, x, width); + use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2"); + } + + if (wrap_mode_uses_border_color(bld->static_state->wrap_t)) { + LLVMValueRef b1, b2; + b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, y, int_coord_bld->zero); + b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, y, height); + if (use_border) { + use_border = LLVMBuildOr(bld->builder, use_border, b1, "ub_or_b1"); + use_border = LLVMBuildOr(bld->builder, use_border, b2, "ub_or_b2"); + } + else { + use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2"); + } + } + /* + * Note: if we find an app which frequently samples the texture border + * we might want to implement a true conditional here to avoid sampling + * the texture whenever possible (since that's quite a bit of code). + * Ex: + * if (use_border) { + * texel = border_color; + * } + * else { + * texel = sample_texture(coord); + * } + * As it is now, we always sample the texture, then selectively replace + * the texel color results with the border color. + */ + + /* convert x,y coords to linear offset from start of texture, in bytes */ offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, x, y, y_stride, @@ -103,16 +178,30 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, assert(bld->format_desc->block.height == 1); assert(bld->format_desc->block.bits <= bld->texel_type.width); + /* gather the texels from the texture */ packed = lp_build_gather(bld->builder, bld->texel_type.length, bld->format_desc->block.bits, bld->texel_type.width, data_ptr, offset); + /* convert texels to float rgba */ lp_build_unpack_rgba_soa(bld->builder, bld->format_desc, bld->texel_type, packed, texel); + + if (use_border) { + /* select texel color or border color depending on use_border */ + int chan; + for (chan = 0; chan < 4; chan++) { + LLVMValueRef border_chan = + lp_build_const_scalar(bld->texel_type, + bld->static_state->border_color[chan]); + texel[chan] = lp_build_select(&bld->texel_bld, use_border, + border_chan, texel[chan]); + } + } } @@ -180,14 +269,14 @@ lp_build_coord_mirror(struct lp_build_sample_context *bld, * Return whether the given mode is supported by that function. */ static boolean -is_simple_wrap_mode(int mode) +is_simple_wrap_mode(unsigned mode) { switch (mode) { case PIPE_TEX_WRAP_REPEAT: case PIPE_TEX_WRAP_CLAMP: case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - case PIPE_TEX_WRAP_CLAMP_TO_BORDER: return TRUE; + case PIPE_TEX_WRAP_CLAMP_TO_BORDER: default: return FALSE; } @@ -339,14 +428,15 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, /* min = -1.0 / (2 * length) */ min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); min = lp_build_negate(coord_bld, min); - /* max = length - min */ - max = lp_build_sub(coord_bld, length_f, min); + /* max = 1.0 - min */ + max = lp_build_sub(coord_bld, coord_bld->one, min); + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); /* scale coord to length (and sub 0.5?) */ coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); /* compute lerp weight */ weight = lp_build_fract(coord_bld, coord); - /* coord = clamp(coord, min, max) */ - coord = lp_build_clamp(coord_bld, coord, min, max); /* convert to int */ coord0 = lp_build_ifloor(coord_bld, coord); coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); @@ -375,12 +465,21 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, break; case PIPE_TEX_WRAP_MIRROR_CLAMP: - coord = lp_build_abs(coord_bld, coord); - coord = lp_build_mul(coord_bld, coord, length_f); - weight = lp_build_fract(coord_bld, coord); - coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, length_f_minus_one); - coord0 = lp_build_ifloor(coord_bld, coord); - coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + { + LLVMValueRef min, max; + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = 1.0 - min */ + max = lp_build_sub(coord_bld, coord_bld->one, min); + + coord = lp_build_abs(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, min, max); + coord = lp_build_mul(coord_bld, coord, length_f); + if(0)coord = lp_build_sub(coord_bld, coord, half); + weight = lp_build_fract(coord_bld, coord); + coord0 = lp_build_ifloor(coord_bld, coord); + coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); + } break; case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE: @@ -388,13 +487,14 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, LLVMValueRef min, max; /* min = 1.0 / (2 * length) */ min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - /* max = length - min */ - max = lp_build_sub(coord_bld, length_f, min); + /* max = 1.0 - min */ + max = lp_build_sub(coord_bld, coord_bld->one, min); coord = lp_build_abs(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, min, max); coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); weight = lp_build_fract(coord_bld, coord); - coord = lp_build_clamp(coord_bld, coord, min, max); coord0 = lp_build_ifloor(coord_bld, coord); coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); } @@ -406,13 +506,14 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, /* min = -1.0 / (2 * length) */ min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); min = lp_build_negate(coord_bld, min); - /* max = length - min */ - max = lp_build_sub(coord_bld, length_f, min); + /* max = 1.0 - min */ + max = lp_build_sub(coord_bld, coord_bld->one, min); coord = lp_build_abs(coord_bld, coord); + coord = lp_build_clamp(coord_bld, coord, min, max); coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); weight = lp_build_fract(coord_bld, coord); - coord = lp_build_clamp(coord_bld, coord, min, max); coord0 = lp_build_ifloor(coord_bld, coord); coord1 = lp_build_add(int_coord_bld, coord0, int_coord_bld->one); } @@ -598,7 +699,7 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, lp_build_name(x, "tex.x.wrapped"); lp_build_name(y, "tex.y.wrapped"); - lp_build_sample_texel_soa(bld, x, y, stride, data_ptr, texel); + lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_ptr, texel); } @@ -627,10 +728,10 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, lp_build_sample_wrap_linear(bld, t, height, bld->static_state->pot_height, bld->static_state->wrap_t, &y0, &y1, &t_fpart); - lp_build_sample_texel_soa(bld, x0, y0, stride, data_ptr, neighbors[0][0]); - lp_build_sample_texel_soa(bld, x1, y0, stride, data_ptr, neighbors[0][1]); - lp_build_sample_texel_soa(bld, x0, y1, stride, data_ptr, neighbors[1][0]); - lp_build_sample_texel_soa(bld, x1, y1, stride, data_ptr, neighbors[1][1]); + lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_ptr, neighbors[0][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_ptr, neighbors[0][1]); + lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_ptr, neighbors[1][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_ptr, neighbors[1][1]); /* TODO: Don't interpolate missing channels */ for(chan = 0; chan < 4; ++chan) { @@ -907,6 +1008,11 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, } +/** + * Build texture sampling code. + * 'texel' will return a vector of four LLVMValueRefs corresponding to + * R, G, B, A. + */ void lp_build_sample_soa(LLVMBuilderRef builder, const struct lp_sampler_static_state *static_state, -- cgit v1.2.3 From b37c54150058c07ab2d3db2d7e5891a457b51e76 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 4 Mar 2010 15:53:41 -0700 Subject: softpipe: minor tweaks to texture filtering code --- src/gallium/drivers/softpipe/sp_tex_sample.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index ecd6b39863..b3a79732b4 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -55,7 +55,7 @@ static INLINE float frac(float f) { - return f - util_ifloor(f); + return f - floorf(f); } @@ -201,11 +201,9 @@ wrap_nearest_mirror_repeat(const float s[4], unsigned size, int icoord[4]) const float max = 1.0F - min; for (ch = 0; ch < 4; ch++) { const int flr = util_ifloor(s[ch]); - float u; + float u = frac(s[ch]); if (flr & 1) - u = 1.0F - (s[ch] - (float) flr); - else - u = s[ch] - (float) flr; + u = 1.0F - u; if (u < min) icoord[ch] = 0; else if (u > max) @@ -358,11 +356,9 @@ wrap_linear_mirror_repeat(const float s[4], unsigned size, uint ch; for (ch = 0; ch < 4; ch++) { const int flr = util_ifloor(s[ch]); - float u; + float u = frac(s[ch]); if (flr & 1) - u = 1.0F - (s[ch] - (float) flr); - else - u = s[ch] - (float) flr; + u = 1.0F - u; u = u * size - 0.5F; icoord0[ch] = util_ifloor(u); icoord1[ch] = icoord0[ch] + 1; -- cgit v1.2.3 From e38f28ddedd6d4902ae18b1bf243e67d4b16decb Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 21 Feb 2010 10:58:22 +0800 Subject: st/egl: Add event support to the native display interface. There is only invalid_surface event right now. When EGL receives the event, it sets the force_validate flag of the context binding to the surface. This helps skip an unnecessary check. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 23 +++++++++++++++++- src/gallium/state_trackers/egl/common/native.h | 27 +++++++++++++++++++++- src/gallium/state_trackers/egl/kms/native_kms.c | 13 ++++++++--- src/gallium/state_trackers/egl/kms/native_kms.h | 2 ++ src/gallium/state_trackers/egl/x11/native_dri2.c | 20 +++++++++++++--- src/gallium/state_trackers/egl/x11/native_x11.c | 7 +++--- src/gallium/state_trackers/egl/x11/native_x11.h | 8 +++++-- src/gallium/state_trackers/egl/x11/native_ximage.c | 20 +++++++++++++++- 8 files changed, 106 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 04268c71c5..ddb1ef1bf1 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -531,6 +531,24 @@ egl_g3d_update_buffer(struct pipe_screen *screen, void *context_private) egl_g3d_validate_context(gctx->base.Resource.Display, &gctx->base); } +static void +egl_g3d_invalid_surface(struct native_display *ndpy, + struct native_surface *nsurf, + unsigned int seq_num) +{ + /* XXX not thread safe? */ + struct egl_g3d_surface *gsurf = egl_g3d_surface(nsurf->user_data); + struct egl_g3d_context *gctx = egl_g3d_context(gsurf->base.CurrentContext); + + /* set force_validate to skip an unnecessary check */ + if (gctx) + gctx->force_validate = TRUE; +} + +static struct native_event_handler egl_g3d_native_event_handler = { + .invalid_surface = egl_g3d_invalid_surface +}; + static EGLBoolean egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy) { @@ -575,12 +593,14 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, } dpy->DriverData = gdpy; - gdpy->native = native_create_display(dpy->NativeDisplay); + gdpy->native = native_create_display(dpy->NativeDisplay, + &egl_g3d_native_event_handler); if (!gdpy->native) { _eglError(EGL_NOT_INITIALIZED, "eglInitialize(no usable display)"); goto fail; } + gdpy->native->user_data = (void *) dpy; gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; gdpy->native->screen->update_buffer = egl_g3d_update_buffer; @@ -776,6 +796,7 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, return NULL; } + nsurf->user_data = &gsurf->base; gsurf->native = nsurf; gsurf->render_att = (gsurf->base.RenderBuffer == EGL_SINGLE_BUFFER) ? diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 4f9758545a..1bf2804db5 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -69,6 +69,11 @@ struct native_probe { }; struct native_surface { + /** + * Available for caller's use. + */ + void *user_data; + void (*destroy)(struct native_surface *nsurf); /** @@ -143,6 +148,11 @@ struct native_display { */ struct pipe_screen *screen; + /** + * Available for caller's use. + */ + void *user_data; + void (*destroy)(struct native_display *ndpy); /** @@ -238,6 +248,20 @@ struct native_display_modeset { const struct native_mode *nmode); }; +/** + * The handler for events that a native display may generate. The events are + * generated asynchronously and the handler may be called by any thread at any + * time. + */ +struct native_event_handler { + /** + * This function is called when a surface needs to be validated. + */ + void (*invalid_surface)(struct native_display *ndpy, + struct native_surface *nsurf, + unsigned int seq_num); +}; + /** * Test whether an attachment is set in the mask. */ @@ -267,6 +291,7 @@ const char * native_get_name(void); struct native_display * -native_create_display(EGLNativeDisplayType dpy); +native_create_display(EGLNativeDisplayType dpy, + struct native_event_handler *handler); #endif /* _NATIVE_H_ */ diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index aedf3d430c..90c82eaf6c 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -201,6 +201,8 @@ kms_surface_swap_buffers(struct native_surface *nsurf) /* the front/back textures are swapped */ ksurf->sequence_number++; + kdpy->event_handler->invalid_surface(&kdpy->base, + &ksurf->base, ksurf->sequence_number); return TRUE; } @@ -762,7 +764,9 @@ static struct native_display_modeset kms_display_modeset = { }; static struct native_display * -kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) +kms_create_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler, + struct drm_api *api) { struct kms_display *kdpy; @@ -770,6 +774,8 @@ kms_create_display(EGLNativeDisplayType dpy, struct drm_api *api) if (!kdpy) return NULL; + kdpy->event_handler = event_handler; + kdpy->api = api; if (!kdpy->api) { _eglLog(_EGL_WARNING, "failed to create DRM API"); @@ -845,7 +851,8 @@ native_get_name(void) } struct native_display * -native_create_display(EGLNativeDisplayType dpy) +native_create_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler) { struct native_display *ndpy = NULL; @@ -853,7 +860,7 @@ native_create_display(EGLNativeDisplayType dpy) drm_api = drm_api_create(); if (drm_api) - ndpy = kms_create_display(dpy, drm_api); + ndpy = kms_create_display(dpy, event_handler, drm_api); return ndpy; } diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h index 095186e3cf..f9cbcb158b 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.h +++ b/src/gallium/state_trackers/egl/kms/native_kms.h @@ -53,6 +53,8 @@ struct kms_crtc { struct kms_display { struct native_display base; + struct native_event_handler *event_handler; + int fd; struct drm_api *api; drmModeResPtr resources; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 74d3d104b9..858033e1c1 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -48,6 +48,8 @@ struct dri2_display { Display *dpy; boolean own_dpy; + struct native_event_handler *event_handler; + struct drm_api *api; struct x11_screen *xscr; int xscr_number; @@ -324,8 +326,11 @@ dri2_surface_flush_frontbuffer(struct native_surface *nsurf) DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft); /* force buffers to be updated in next validation call */ - if (!dri2_surface_receive_events(&dri2surf->base)) + if (!dri2_surface_receive_events(&dri2surf->base)) { dri2surf->server_stamp++; + dri2dpy->event_handler->invalid_surface(&dri2dpy->base, + &dri2surf->base, dri2surf->server_stamp); + } return TRUE; } @@ -353,8 +358,11 @@ dri2_surface_swap_buffers(struct native_surface *nsurf) DRI2BufferFrontLeft, DRI2BufferFakeFrontLeft); /* force buffers to be updated in next validation call */ - if (!dri2_surface_receive_events(&dri2surf->base)) + if (!dri2_surface_receive_events(&dri2surf->base)) { dri2surf->server_stamp++; + dri2dpy->event_handler->invalid_surface(&dri2dpy->base, + &dri2surf->base, dri2surf->server_stamp); + } return TRUE; } @@ -737,7 +745,10 @@ dri2_display_invalidate_buffers(struct x11_screen *xscr, Drawable drawable, return; dri2surf = dri2_surface(nsurf); + dri2surf->server_stamp++; + dri2dpy->event_handler->invalid_surface(&dri2dpy->base, + &dri2surf->base, dri2surf->server_stamp); } /** @@ -796,7 +807,9 @@ dri2_display_hash_table_compare(void *key1, void *key2) } struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) +x11_create_dri2_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler, + struct drm_api *api) { struct dri2_display *dri2dpy; @@ -804,6 +817,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api) if (!dri2dpy) return NULL; + dri2dpy->event_handler = event_handler; dri2dpy->api = api; dri2dpy->dpy = dpy; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 3add95d0ac..7b4fe63fa0 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -126,7 +126,8 @@ native_get_name(void) } struct native_display * -native_create_display(EGLNativeDisplayType dpy) +native_create_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler) { struct native_display *ndpy = NULL; boolean force_sw; @@ -136,7 +137,7 @@ native_create_display(EGLNativeDisplayType dpy) force_sw = debug_get_bool_option("EGL_SOFTWARE", FALSE); if (api && !force_sw) { - ndpy = x11_create_dri2_display(dpy, api); + ndpy = x11_create_dri2_display(dpy, event_handler, api); } if (!ndpy) { @@ -150,7 +151,7 @@ native_create_display(EGLNativeDisplayType dpy) */ use_shm = FALSE; _eglLog(level, "use software%s fallback", (use_shm) ? " (SHM)" : ""); - ndpy = x11_create_ximage_display(dpy, use_shm); + ndpy = x11_create_ximage_display(dpy, event_handler, use_shm); } return ndpy; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h index 622ddac5df..8c6a7d9349 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.h +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -29,9 +29,13 @@ #include "common/native.h" struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); +x11_create_ximage_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler, + boolean use_xshm); struct native_display * -x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); +x11_create_dri2_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler, + struct drm_api *api); #endif /* _NATIVE_X11_H_ */ diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index a8633b1501..5e0270c296 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -56,6 +56,8 @@ struct ximage_display { struct x11_screen *xscr; int xscr_number; + struct native_event_handler *event_handler; + boolean use_xshm; struct pipe_winsys *winsys; @@ -228,6 +230,16 @@ ximage_surface_update_geometry(struct native_surface *nsurf) return updated; } +static void +ximage_surface_notify_invalid(struct native_surface *nsurf) +{ + struct ximage_surface *xsurf = ximage_surface(nsurf); + struct ximage_display *xdpy = xsurf->xdpy; + + xdpy->event_handler->invalid_surface(&xdpy->base, + &xsurf->base, xsurf->server_stamp); +} + /** * Update the buffers of the surface. It is a slow function due to the * round-trip to the server. @@ -339,6 +351,7 @@ ximage_surface_flush_frontbuffer(struct native_surface *nsurf) NATIVE_ATTACHMENT_FRONT_LEFT); /* force buffers to be updated in next validation call */ xsurf->server_stamp++; + ximage_surface_notify_invalid(&xsurf->base); return ret; } @@ -354,6 +367,7 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) ret = ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); /* force buffers to be updated in next validation call */ xsurf->server_stamp++; + ximage_surface_notify_invalid(&xsurf->base); xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; @@ -703,7 +717,9 @@ ximage_display_destroy(struct native_display *ndpy) } struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) +x11_create_ximage_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler, + boolean use_xshm) { struct ximage_display *xdpy; @@ -728,6 +744,8 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) return NULL; } + xdpy->event_handler = event_handler; + xdpy->use_xshm = (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); -- cgit v1.2.3 From 89a75b763467d83d4d402c91db55548682be14f0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 5 Mar 2010 10:40:15 +0800 Subject: st/egl: Move modeset interface to native_modeset.h. native.h is getting more and more complex. Move the independent modeset interface to native_modeset.h to simplify native.h a little. --- src/gallium/state_trackers/egl/common/native.h | 57 +------------- .../state_trackers/egl/common/native_modeset.h | 87 ++++++++++++++++++++++ 2 files changed, 89 insertions(+), 55 deletions(-) create mode 100644 src/gallium/state_trackers/egl/common/native_modeset.h (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 1bf2804db5..4533b3abf9 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -34,6 +34,8 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" +#include "native_modeset.h" + /** * Only color buffers are listed. The others are allocated privately through, * for example, st_renderbuffer_alloc_storage(). @@ -122,18 +124,6 @@ struct native_config { boolean scanout_bit; }; -struct native_connector { - int dummy; -}; - -struct native_mode { - const char *desc; - int width, height; - int refresh_rate; -}; - -struct native_display_modeset; - /** * A pipe winsys abstracts the OS. A pipe screen abstracts the graphcis * hardware. A native display consists of a pipe winsys, a pipe screen, and @@ -205,49 +195,6 @@ struct native_display { const struct native_display_modeset *modeset; }; -/** - * Mode setting interface of the native display. It exposes the mode setting - * capabilities of the underlying graphics hardware. - */ -struct native_display_modeset { - /** - * Get the available physical connectors and the number of CRTCs. - */ - const struct native_connector **(*get_connectors)(struct native_display *ndpy, - int *num_connectors, - int *num_crtcs); - - /** - * Get the current supported modes of a connector. The returned modes may - * change every time this function is called and those from previous calls - * might become invalid. - */ - const struct native_mode **(*get_modes)(struct native_display *ndpy, - const struct native_connector *nconn, - int *num_modes); - - /** - * Create a scan-out surface. Required unless no config has - * GLX_SCREEN_BIT_MESA set. - */ - struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, - const struct native_config *nconf, - uint width, uint height); - - /** - * Program the CRTC to output the surface to the given connectors with the - * given mode. When surface is not given, the CRTC is disabled. - * - * This interface does not export a way to query capabilities of the CRTCs. - * The native display usually needs to dynamically map the index to a CRTC - * that supports the given connectors. - */ - boolean (*program)(struct native_display *ndpy, int crtc_idx, - struct native_surface *nsurf, uint x, uint y, - const struct native_connector **nconns, int num_nconns, - const struct native_mode *nmode); -}; - /** * The handler for events that a native display may generate. The events are * generated asynchronously and the handler may be called by any thread at any diff --git a/src/gallium/state_trackers/egl/common/native_modeset.h b/src/gallium/state_trackers/egl/common/native_modeset.h new file mode 100644 index 0000000000..71dc3ec860 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/native_modeset.h @@ -0,0 +1,87 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2009-2010 Chia-I Wu + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _NATIVE_MODESET_H_ +#define _NATIVE_MODESET_H_ + +#include "pipe/p_compiler.h" + +struct native_display; +struct native_surface; +struct native_config; + +struct native_connector { + int dummy; +}; + +struct native_mode { + const char *desc; + int width, height; + int refresh_rate; +}; + +/** + * Mode setting interface of the native display. It exposes the mode setting + * capabilities of the underlying graphics hardware. + */ +struct native_display_modeset { + /** + * Get the available physical connectors and the number of CRTCs. + */ + const struct native_connector **(*get_connectors)(struct native_display *ndpy, + int *num_connectors, + int *num_crtcs); + + /** + * Get the current supported modes of a connector. The returned modes may + * change every time this function is called and those from previous calls + * might become invalid. + */ + const struct native_mode **(*get_modes)(struct native_display *ndpy, + const struct native_connector *nconn, + int *num_modes); + + /** + * Create a scan-out surface. Required unless no config has + * GLX_SCREEN_BIT_MESA set. + */ + struct native_surface *(*create_scanout_surface)(struct native_display *ndpy, + const struct native_config *nconf, + uint width, uint height); + + /** + * Program the CRTC to output the surface to the given connectors with the + * given mode. When surface is not given, the CRTC is disabled. + * + * This interface does not export a way to query capabilities of the CRTCs. + * The native display usually needs to dynamically map the index to a CRTC + * that supports the given connectors. + */ + boolean (*program)(struct native_display *ndpy, int crtc_idx, + struct native_surface *nsurf, uint x, uint y, + const struct native_connector **nconns, int num_nconns, + const struct native_mode *nmode); +}; + +#endif /* _NATIVE_MODESET_H_ */ -- cgit v1.2.3 From fade8a6eb639d633cfdbba4a3ba3aa3cc5c04fa6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 5 Mar 2010 11:00:15 +0800 Subject: st/egl: Add get_param to native display interface. get_param can be used to query the parameters of a native display. There is only NATIVE_PARAM_USE_NATIVE_BUFFER right now. It queries whether the window/pixmap surfaces use the native buffers instead of private buffers. --- src/gallium/state_trackers/egl/common/native.h | 16 ++++++++++++++++ src/gallium/state_trackers/egl/kms/native_kms.c | 16 ++++++++++++++++ src/gallium/state_trackers/egl/x11/native_dri2.c | 20 ++++++++++++++++++++ src/gallium/state_trackers/egl/x11/native_ximage.c | 20 ++++++++++++++++++++ 4 files changed, 72 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 4533b3abf9..9c22ff3e43 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -49,6 +49,14 @@ enum native_attachment { NUM_NATIVE_ATTACHMENTS }; +enum native_param_type { + /* + * Return TRUE if window/pixmap surfaces use the buffers of the native + * types. + */ + NATIVE_PARAM_USE_NATIVE_BUFFER +}; + /** * Enumerations for probe results. */ @@ -145,6 +153,14 @@ struct native_display { void (*destroy)(struct native_display *ndpy); + /** + * Query the parameters of the native display. + * + * The return value is defined by the parameter. + */ + int (*get_param)(struct native_display *ndpy, + enum native_param_type param); + /** * Get the supported configs. The configs are owned by the display, but * the returned array should be free()ed. diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index 90c82eaf6c..94588bfa74 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -665,6 +665,21 @@ kms_display_get_configs(struct native_display *ndpy, int *num_configs) return configs; } +static int +kms_display_get_param(struct native_display *ndpy, + enum native_param_type param) +{ + int val; + + switch (param) { + default: + val = 0; + break; + } + + return val; +} + static void kms_display_destroy(struct native_display *ndpy) { @@ -811,6 +826,7 @@ kms_create_display(EGLNativeDisplayType dpy, } kdpy->base.destroy = kms_display_destroy; + kdpy->base.get_param = kms_display_get_param; kdpy->base.get_configs = kms_display_get_configs; kdpy->base.create_pbuffer_surface = kms_display_create_pbuffer_surface; diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c index 858033e1c1..8d2a8b1dff 100644 --- a/src/gallium/state_trackers/egl/x11/native_dri2.c +++ b/src/gallium/state_trackers/egl/x11/native_dri2.c @@ -707,6 +707,25 @@ dri2_display_is_pixmap_supported(struct native_display *ndpy, return (depth == nconf_depth || (depth == 24 && depth + 8 == nconf_depth)); } +static int +dri2_display_get_param(struct native_display *ndpy, + enum native_param_type param) +{ + int val; + + switch (param) { + case NATIVE_PARAM_USE_NATIVE_BUFFER: + /* DRI2GetBuffers use the native buffers */ + val = TRUE; + break; + default: + val = 0; + break; + } + + return val; +} + static void dri2_display_destroy(struct native_display *ndpy) { @@ -850,6 +869,7 @@ x11_create_dri2_display(EGLNativeDisplayType dpy, } dri2dpy->base.destroy = dri2_display_destroy; + dri2dpy->base.get_param = dri2_display_get_param; dri2dpy->base.get_configs = dri2_display_get_configs; dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported; dri2dpy->base.create_window_surface = dri2_display_create_window_surface; diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 5e0270c296..3421c1951a 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -699,6 +699,25 @@ ximage_display_is_pixmap_supported(struct native_display *ndpy, return (fmt == nconf->color_format); } +static int +ximage_display_get_param(struct native_display *ndpy, + enum native_param_type param) +{ + int val; + + switch (param) { + case NATIVE_PARAM_USE_NATIVE_BUFFER: + /* private buffers are allocated */ + val = FALSE; + break; + default: + val = 0; + break; + } + + return val; +} + static void ximage_display_destroy(struct native_display *ndpy) { @@ -753,6 +772,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, xdpy->base.screen = softpipe_create_screen(xdpy->winsys); xdpy->base.destroy = ximage_display_destroy; + xdpy->base.get_param = ximage_display_get_param; xdpy->base.get_configs = ximage_display_get_configs; xdpy->base.is_pixmap_supported = ximage_display_is_pixmap_supported; -- cgit v1.2.3 From 9373447a614e7b401919328b589b5f2607e456fd Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 5 Mar 2010 11:18:16 +0800 Subject: st/egl: Add support for EGL_KHR_image_base and EGL_KHR_image_pixmap. These extensions are not quite useful until the client APIs gain support for the respective EGLImage extensions. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 14 ++- src/gallium/state_trackers/egl/common/egl_g3d.h | 14 +++ .../state_trackers/egl/common/egl_g3d_image.c | 136 +++++++++++++++++++++ .../state_trackers/egl/common/egl_g3d_image.h | 41 +++++++ 4 files changed, 202 insertions(+), 3 deletions(-) create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d_image.c create mode 100644 src/gallium/state_trackers/egl/common/egl_g3d_image.h (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index ddb1ef1bf1..50774b03f3 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -36,6 +36,7 @@ #include "native.h" #include "egl_g3d.h" +#include "egl_g3d_image.h" #include "egl_st.h" /** @@ -615,6 +616,10 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, } #endif + dpy->Extensions.KHR_image_base = EGL_TRUE; + if (gdpy->native->get_param(gdpy->native, NATIVE_PARAM_USE_NATIVE_BUFFER)) + dpy->Extensions.KHR_image_pixmap = EGL_TRUE; + if (egl_g3d_add_configs(drv, dpy, 1) == 1) { _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)"); goto fail; @@ -958,8 +963,8 @@ egl_g3d_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf) /** * Find a config that supports the pixmap. */ -static _EGLConfig * -find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) +_EGLConfig * +egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix) { struct egl_g3d_display *gdpy = egl_g3d_display(dpy); struct egl_g3d_config *gconf; @@ -1011,7 +1016,7 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, if (!gsurf->render_surface) return EGL_TRUE; - gconf = egl_g3d_config(find_pixmap_config(dpy, target)); + gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, target)); if (!gconf) return _eglError(EGL_BAD_NATIVE_PIXMAP, "eglCopyBuffers"); @@ -1322,6 +1327,9 @@ _eglMain(const char *args) gdrv->base.API.BindTexImage = egl_g3d_bind_tex_image; gdrv->base.API.ReleaseTexImage = egl_g3d_release_tex_image; + gdrv->base.API.CreateImageKHR = egl_g3d_create_image; + gdrv->base.API.DestroyImageKHR = egl_g3d_destroy_image; + #ifdef EGL_MESA_screen_surface gdrv->base.API.CreateScreenSurfaceMESA = egl_g3d_create_screen_surface; gdrv->base.API.ShowScreenSurfaceMESA = egl_g3d_show_screen_surface; diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h index 5d2d9c481a..e3e55e46d3 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.h +++ b/src/gallium/state_trackers/egl/common/egl_g3d.h @@ -34,6 +34,7 @@ #include "eglcontext.h" #include "eglsurface.h" #include "eglconfig.h" +#include "eglimage.h" #include "eglscreen.h" #include "eglmode.h" @@ -81,6 +82,14 @@ struct egl_g3d_config { const struct native_config *native; }; +struct egl_g3d_image { + _EGLImage base; + struct pipe_texture *texture; + unsigned face; + unsigned level; + unsigned zslice; +}; + struct egl_g3d_screen { _EGLScreen base; const struct native_connector *native; @@ -90,5 +99,10 @@ struct egl_g3d_screen { /* standard typecasts */ _EGL_DRIVER_STANDARD_TYPECASTS(egl_g3d) _EGL_DRIVER_TYPECAST(egl_g3d_screen, _EGLScreen, obj) +_EGL_DRIVER_TYPECAST(egl_g3d_image, _EGLImage, obj) + + +_EGLConfig * +egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix); #endif /* _EGL_G3D_H_ */ diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c new file mode 100644 index 0000000000..d701f9c9a8 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c @@ -0,0 +1,136 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include "pipe/p_screen.h" +#include "util/u_memory.h" +#include "util/u_rect.h" +#include "util/u_inlines.h" +#include "eglcurrent.h" +#include "egllog.h" + +#include "native.h" +#include "egl_g3d.h" +#include "egl_g3d_image.h" + +/** + * Reference and return the front left buffer of the native pixmap. + */ +static struct pipe_texture * +egl_g3d_reference_native_pixmap(_EGLDisplay *dpy, EGLNativePixmapType pix) +{ + struct egl_g3d_display *gdpy = egl_g3d_display(dpy); + struct egl_g3d_config *gconf; + struct native_surface *nsurf; + struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS]; + enum native_attachment natt; + + gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, pix)); + if (!gconf) + return NULL; + + nsurf = gdpy->native->create_pixmap_surface(gdpy->native, + pix, gconf->native); + if (!nsurf) + return NULL; + + natt = NATIVE_ATTACHMENT_FRONT_LEFT; + if (!nsurf->validate(nsurf, 1 << natt, NULL, textures, NULL, NULL)) + textures[natt] = NULL; + + nsurf->destroy(nsurf); + + return textures[natt]; +} + +_EGLImage * +egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, + const EGLint *attribs) +{ + struct pipe_texture *ptex; + struct egl_g3d_image *gimg; + unsigned face = 0, level = 0, zslice = 0; + + gimg = CALLOC_STRUCT(egl_g3d_image); + if (!gimg) { + _eglError(EGL_BAD_ALLOC, "eglCreatePbufferSurface"); + return NULL; + } + + if (!_eglInitImage(&gimg->base, dpy, attribs)) { + free(gimg); + return NULL; + } + + switch (target) { + case EGL_NATIVE_PIXMAP_KHR: + ptex = egl_g3d_reference_native_pixmap(dpy, + (EGLNativePixmapType) buffer); + break; + default: + ptex = NULL; + break; + } + + if (!ptex) { + free(gimg); + return NULL; + } + + if (level > ptex->last_level) { + _eglError(EGL_BAD_MATCH, "eglCreateEGLImageKHR"); + pipe_texture_reference(&gimg->texture, NULL); + free(gimg); + return NULL; + } + if (zslice > ptex->depth0) { + _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); + pipe_texture_reference(&gimg->texture, NULL); + free(gimg); + return NULL; + } + + /* transfer the ownership to the image */ + gimg->texture = ptex; + gimg->face = face; + gimg->level = level; + gimg->zslice = zslice; + + return &gimg->base; +} + +EGLBoolean +egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img) +{ + struct egl_g3d_image *gimg = egl_g3d_image(img); + + pipe_texture_reference(&gimg->texture, NULL); + free(gimg); + + return EGL_TRUE; +} diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.h b/src/gallium/state_trackers/egl/common/egl_g3d_image.h new file mode 100644 index 0000000000..c199c46645 --- /dev/null +++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.h @@ -0,0 +1,41 @@ +/* + * Mesa 3-D graphics library + * Version: 7.8 + * + * Copyright (C) 2010 LunarG Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _EGL_G3D_IMAGE_H_ +#define _EGL_G3D_IMAGE_H_ + +#include "egl_g3d.h" + +_EGLImage * +egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, + EGLenum target, EGLClientBuffer buffer, + const EGLint *attribs); + +EGLBoolean +egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *image); + +#endif /* _EGL_G3D_IMAGE_H_ */ -- cgit v1.2.3 From c3b6adccc91b295772a934ba4115c7f3cced4dfe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 09:53:37 -0700 Subject: gallium/docs: updated/improve sampler state documentation --- src/gallium/docs/source/cso/sampler.rst | 98 ++++++++++++++++++++++++++------- 1 file changed, 77 insertions(+), 21 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst index 77979fc44d..44698d1250 100644 --- a/src/gallium/docs/source/cso/sampler.rst +++ b/src/gallium/docs/source/cso/sampler.rst @@ -13,38 +13,94 @@ Members ------- wrap_s - How to wrap the S coordinate. One of PIPE_TEX_WRAP. + How to wrap the S coordinate. One of PIPE_TEX_WRAP_*. wrap_t - How to wrap the T coordinate. One of PIPE_TEX_WRAP. + How to wrap the T coordinate. One of PIPE_TEX_WRAP_*. wrap_r - How to wrap the R coordinate. One of PIPE_TEX_WRAP. + How to wrap the R coordinate. One of PIPE_TEX_WRAP_*. + +The wrap modes are: + +* ``PIPE_TEX_WRAP_REPEAT``: Standard coord repeat/wrap-around mode. +* ``PIPE_TEX_WRAP_CLAMP_TO_EDGE``: Clamp coord to edge of texture, the border + color is never sampled. +* ``PIPE_TEX_WRAP_CLAMP_TO_BORDER``: Clamp coord to border of texture, the + border color is sampled when coords go outside the range [0,1]. +* ``PIPE_TEX_WRAP_CLAMP``: The coord is clamped to the range [0,1] before + scaling to the texture size. This corresponds to the legacy OpenGL GL_CLAMP + texture wrap mode. Historically, this mode hasn't acted consistantly across + all graphics hardware. It sometimes acts like CLAMP_TO_EDGE or + CLAMP_TO_BORDER. The behaviour may also vary depending on linear vs. + nearest sampling mode. +* ``PIPE_TEX_WRAP_MIRROR_REPEAT``: If the integer part of the coordinate + is odd, the coord becomes (1 - coord). Then, normal texture REPEAT is + applied to the coord. +* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE``: First, the absolute value of the + coordinate is computed. Then, regular CLAMP_TO_EDGE is applied to the coord. +* ``PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER``: First, the absolute value of the + coordinate is computed. Then, regular CLAMP_TO_BORDER is applied to the + coord. +* ``PIPE_TEX_WRAP_MIRROR_CLAMP``: First, the absolute value of the coord is + computed. Then, regular CLAMP is applied to the coord. + + min_img_filter - The filter to use when minifying texels. One of PIPE_TEX_FILTER. + The image filter to use when minifying texels. One of PIPE_TEX_FILTER_*. +mag_img_filter + The image filter to use when magnifying texels. One of PIPE_TEX_FILTER_*. + +The texture image filter modes are: + +* ``PIPE_TEX_FILTER_NEAREST``: One texel is fetched from the texture image + at the texture coordinate. +* ``PIPE_TEX_FILTER_LINEAR``: Two, four or eight texels (depending on the + texture dimensions; 1D/2D/3D) are fetched from the texture image and + linearly weighted and blended together. + min_mip_filter The filter to use when minifying mipmapped textures. One of - PIPE_TEX_FILTER. -mag_img_filter - The filter to use when magnifying texels. One of PIPE_TEX_FILTER. + PIPE_TEX_MIPFILTER_*. + +The texture mip filter modes are: + +* ``PIPE_TEX_MIPFILTER_NEAREST``: A single mipmap level/image is selected + according to the texture LOD (lambda) value. +* ``PIPE_TEX_MIPFILTER_LINEAR``: The two mipmap levels/images above/below + the texture LOD value are sampled from. The results of sampling from + those two images are blended together with linear interpolation. +* ``PIPE_TEX_MIPFILTER_NONE``: Mipmap filtering is disabled. All texels + are taken from the level 0 image. + + compare_mode - If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, texture output is computed - according to compare_func, using r coord and the texture value as operands. + If set to PIPE_TEX_COMPARE_R_TO_TEXTURE, the result of texture sampling + is not a color but a true/false value which is the result of comparing the + sampled texture value (typically a Z value from a depth texture) to the + texture coordinate's R component. If set to PIPE_TEX_COMPARE_NONE, no comparison calculation is performed. compare_func - How the comparison is computed. One of PIPE_FUNC. + The inequality operator used when compare_mode=1. One of PIPE_FUNC_x. normalized_coords - Whether the texture coordinates are normalized. If normalized, they will - always be in [0, 1]. If not, they will be in the range of each dimension - of the loaded texture. + If set, the incoming texture coordinates (nominally in the range [0,1]) + will be scaled by the texture width, height, depth to compute texel + addresses. Otherwise, the texture coords are used as-is (they are not + scaled by the texture dimensions). lod_bias - The bias to apply to the level of detail. + Bias factor which is added to the computed level of detail. + The normal level of detail is computed from the partial derivatives of + the texture coordinates and/or the fragment shader TEX/TXB/TXL + instruction. min_lod - Minimum level of detail, used to clamp LoD after bias. + Minimum level of detail, used to clamp LOD after bias. The LOD values + correspond to mipmap levels where LOD=0 is the level 0 mipmap image. max_lod - Maximum level of detail, used to clamp LoD after bias. + Maximum level of detail, used to clamp LOD after bias. border_color - RGBA color used for out-of-bounds coordinates. + RGBA color used for texel coordinates that are outside the [0,width-1], + [0, height-1] or [0, depth-1] ranges. max_anisotropy - Maximum filtering to apply anisotropically to textures. Setting this to - 0 disables anisotropic filtering. Any other setting enables anisotropic - filtering, however it's not unexpected some drivers only will change their - filtering with a setting of 2 and higher. + Maximum anistropy ratio to use when sampling from textures. For example, + if max_anistropy=4, a region of up to 1 by 4 texels will be sampled. + Set to zero to disable anisotropic filtering. Any other setting enables + anisotropic filtering, however it's not unexpected some drivers only will + change their filtering with a setting of 2 and higher. -- cgit v1.2.3 From 5024a39d111e2cef176a18e17f18917c2242ec72 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 2 Mar 2010 11:08:05 +0100 Subject: nouveau: s/TEXTURE_USAGE_PRIMARY/TEXTURE_USAGE_SCANOUT --- src/gallium/drivers/nv30/nv30_miptree.c | 4 ++-- src/gallium/drivers/nv40/nv40_miptree.c | 4 ++-- src/gallium/drivers/nv50/nv50_miptree.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index c29c36e20a..d8a9d3f093 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -18,7 +18,7 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt) PIPE_TEXTURE_USAGE_DEPTH_STENCIL | PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY); + PIPE_TEXTURE_USAGE_SCANOUT); if (pt->target == PIPE_TEXTURE_CUBE) { nr_faces = 6; @@ -78,7 +78,7 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) pt->height0 & (pt->height0 - 1)) mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; else - if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY | + if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c index ad1a9a5195..9acbef4d7d 100644 --- a/src/gallium/drivers/nv40/nv40_miptree.c +++ b/src/gallium/drivers/nv40/nv40_miptree.c @@ -20,7 +20,7 @@ nv40_miptree_layout(struct nv40_miptree *mt) PIPE_TEXTURE_USAGE_DEPTH_STENCIL | PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | - PIPE_TEXTURE_USAGE_PRIMARY); + PIPE_TEXTURE_USAGE_SCANOUT); if (pt->target == PIPE_TEXTURE_CUBE) { nr_faces = 6; @@ -80,7 +80,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt) pt->height0 & (pt->height0 - 1)) mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; else - if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY | + if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT | PIPE_TEXTURE_USAGE_DISPLAY_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR; diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index 7297c74a83..133f2204e0 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -104,7 +104,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp) tile_flags = 0x7400; break; default: - if ((pt->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) && + if ((pt->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) && util_format_get_blocksizebits(pt->format) == 32) tile_flags = 0x7a00; else -- cgit v1.2.3 From b5b128b26841e7f947edd8f0cbcc91a530d6bb8f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 12:38:05 -0700 Subject: softpipe: implement PIPE_TEX_WRAP_CLAMP_TO_EDGE for unorm texture sampling CLAMP_TO_BORDER and CLAMP_TO_EDGE were doing the same thing. --- src/gallium/drivers/softpipe/sp_tex_sample.c | 49 ++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index b3a79732b4..ef7ccf4189 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -437,8 +437,7 @@ wrap_linear_mirror_clamp_to_border(const float s[4], unsigned size, /** - * For RECT textures / unnormalized texcoords - * Only a subset of wrap modes supported. + * PIPE_TEX_WRAP_CLAMP for nearest sampling, unnormalized coords. */ static void wrap_nearest_unorm_clamp(const float s[4], unsigned size, int icoord[4]) @@ -452,11 +451,25 @@ wrap_nearest_unorm_clamp(const float s[4], unsigned size, int icoord[4]) /** - * Handles clamp_to_edge and clamp_to_border: + * PIPE_TEX_WRAP_CLAMP_TO_BORDER for nearest sampling, unnormalized coords. */ static void wrap_nearest_unorm_clamp_to_border(const float s[4], unsigned size, int icoord[4]) +{ + uint ch; + for (ch = 0; ch < 4; ch++) { + icoord[ch]= util_ifloor( CLAMP(s[ch], -0.5F, (float) size + 0.5F) ); + } +} + + +/** + * PIPE_TEX_WRAP_CLAMP_TO_EDGE for nearest sampling, unnormalized coords. + */ +static void +wrap_nearest_unorm_clamp_to_edge(const float s[4], unsigned size, + int icoord[4]) { uint ch; for (ch = 0; ch < 4; ch++) { @@ -466,8 +479,7 @@ wrap_nearest_unorm_clamp_to_border(const float s[4], unsigned size, /** - * For RECT textures / unnormalized texcoords. - * Only a subset of wrap modes supported. + * PIPE_TEX_WRAP_CLAMP for linear sampling, unnormalized coords. */ static void wrap_linear_unorm_clamp(const float s[4], unsigned size, @@ -484,13 +496,36 @@ wrap_linear_unorm_clamp(const float s[4], unsigned size, } +/** + * PIPE_TEX_WRAP_CLAMP_TO_BORDER for linear sampling, unnormalized coords. + */ static void wrap_linear_unorm_clamp_to_border(const float s[4], unsigned size, int icoord0[4], int icoord1[4], float w[4]) { uint ch; for (ch = 0; ch < 4; ch++) { - float u = CLAMP(s[ch], 0.5F, (float) size - 0.5F); + float u = CLAMP(s[ch], -0.5F, (float) size + 0.5F); + u -= 0.5F; + icoord0[ch] = util_ifloor(u); + icoord1[ch] = icoord0[ch] + 1; + if (icoord1[ch] > (int) size - 1) + icoord1[ch] = size - 1; + w[ch] = frac(u); + } +} + + +/** + * PIPE_TEX_WRAP_CLAMP_TO_EDGE for linear sampling, unnormalized coords. + */ +static void +wrap_linear_unorm_clamp_to_edge(const float s[4], unsigned size, + int icoord0[4], int icoord1[4], float w[4]) +{ + uint ch; + for (ch = 0; ch < 4; ch++) { + float u = CLAMP(s[ch], +0.5F, (float) size - 0.5F); u -= 0.5F; icoord0[ch] = util_ifloor(u); icoord1[ch] = icoord0[ch] + 1; @@ -1707,6 +1742,7 @@ get_nearest_unorm_wrap(unsigned mode) case PIPE_TEX_WRAP_CLAMP: return wrap_nearest_unorm_clamp; case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + return wrap_nearest_unorm_clamp_to_edge; case PIPE_TEX_WRAP_CLAMP_TO_BORDER: return wrap_nearest_unorm_clamp_to_border; default: @@ -1750,6 +1786,7 @@ get_linear_unorm_wrap(unsigned mode) case PIPE_TEX_WRAP_CLAMP: return wrap_linear_unorm_clamp; case PIPE_TEX_WRAP_CLAMP_TO_EDGE: + return wrap_linear_unorm_clamp_to_edge; case PIPE_TEX_WRAP_CLAMP_TO_BORDER: return wrap_linear_unorm_clamp_to_border; default: -- cgit v1.2.3 From d660e28c9cc52e55963532939ef383eac983a44b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 13:21:56 -0700 Subject: gallivm: implement non-normalized texture wrap modes Note that only the PIPE_TEX_WRAP_CLAMP,CLAMP_TO_EDGE,CLAMP_TO_BORDER modes work with non-normalized texcoords. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 107 ++++++++++++++-------- 1 file changed, 68 insertions(+), 39 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index fe41d5ee49..50dd1a57c9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -361,15 +361,10 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, LLVMValueRef two = lp_build_const_scalar(coord_bld->type, 2.0); LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5); LLVMValueRef length_f = lp_build_int_to_float(coord_bld, length); - LLVMValueRef length_minus_one; - LLVMValueRef length_f_minus_one; + LLVMValueRef length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); + LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); LLVMValueRef coord0, coord1, weight; - /* XXX check for normalized vs. unnormalized coords */ - - length_minus_one = lp_build_sub(uint_coord_bld, length, uint_coord_bld->one); - length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); - switch(wrap_mode) { case PIPE_TEX_WRAP_REPEAT: /* mul by size and subtract 0.5 */ @@ -394,7 +389,9 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, break; case PIPE_TEX_WRAP_CLAMP: - coord = lp_build_mul(coord_bld, coord, length_f); + if (bld->static_state->normalized_coords) { + coord = lp_build_mul(coord_bld, coord, length_f); + } weight = lp_build_fract(coord_bld, coord); coord0 = lp_build_clamp(coord_bld, coord, coord_bld->zero, length_f_minus_one); @@ -406,11 +403,20 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, break; case PIPE_TEX_WRAP_CLAMP_TO_EDGE: - /* clamp to [0,1] */ - coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, coord_bld->one); - /* mul by tex size and subtract 0.5 */ - coord = lp_build_mul(coord_bld, coord, length_f); - coord = lp_build_sub(coord_bld, coord, half); + if (bld->static_state->normalized_coords) { + /* clamp to [0,1] */ + coord = lp_build_clamp(coord_bld, coord, coord_bld->zero, coord_bld->one); + /* mul by tex size and subtract 0.5 */ + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); + } + else { + LLVMValueRef min, max; + /* clamp to [0.5, length - 0.5] */ + min = lp_build_const_scalar(coord_bld->type, 0.5F); + max = lp_build_sub(coord_bld, length_f, min); + coord = lp_build_clamp(coord_bld, coord, min, max); + } /* compute lerp weight */ weight = lp_build_fract(coord_bld, coord); /* coord0 = floor(coord); */ @@ -425,16 +431,25 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, case PIPE_TEX_WRAP_CLAMP_TO_BORDER: { LLVMValueRef min, max; - /* min = -1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - min = lp_build_negate(coord_bld, min); - /* max = 1.0 - min */ - max = lp_build_sub(coord_bld, coord_bld->one, min); - /* coord = clamp(coord, min, max) */ - coord = lp_build_clamp(coord_bld, coord, min, max); - /* scale coord to length (and sub 0.5?) */ - coord = lp_build_mul(coord_bld, coord, length_f); - coord = lp_build_sub(coord_bld, coord, half); + if (bld->static_state->normalized_coords) { + /* min = -1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = 1.0 - min */ + max = lp_build_sub(coord_bld, coord_bld->one, min); + /* coord = clamp(coord, min, max) */ + coord = lp_build_clamp(coord_bld, coord, min, max); + /* scale coord to length (and sub 0.5?) */ + coord = lp_build_mul(coord_bld, coord, length_f); + coord = lp_build_sub(coord_bld, coord, half); + } + else { + /* clamp to [-0.5, length + 0.5] */ + min = lp_build_const_scalar(coord_bld->type, -0.5F); + max = lp_build_sub(coord_bld, length_f, min); + coord = lp_build_clamp(coord_bld, coord, min, max); + coord = lp_build_sub(coord_bld, coord, half); + } /* compute lerp weight */ weight = lp_build_fract(coord_bld, coord); /* convert to int */ @@ -552,8 +567,6 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, LLVMValueRef length_f_minus_one = lp_build_sub(coord_bld, length_f, coord_bld->one); LLVMValueRef icoord; - /* XXX check for normalized vs. unnormalized coords */ - switch(wrap_mode) { case PIPE_TEX_WRAP_REPEAT: coord = lp_build_mul(coord_bld, coord, length_f); @@ -568,7 +581,9 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, case PIPE_TEX_WRAP_CLAMP: /* mul by size */ - coord = lp_build_mul(coord_bld, coord, length_f); + if (bld->static_state->normalized_coords) { + coord = lp_build_mul(coord_bld, coord, length_f); + } /* floor */ icoord = lp_build_ifloor(coord_bld, coord); /* clamp to [0, size-1]. Note: int coord builder type */ @@ -579,12 +594,19 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, case PIPE_TEX_WRAP_CLAMP_TO_EDGE: { LLVMValueRef min, max; - /* min = 1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - /* max = length - min */ - max = lp_build_sub(coord_bld, length_f, min); - /* scale coord to length */ - coord = lp_build_mul(coord_bld, coord, length_f); + if (bld->static_state->normalized_coords) { + /* min = 1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + } + else { + /* clamp to [0.5, length - 0.5] */ + min = lp_build_const_scalar(coord_bld->type, 0.5F); + max = lp_build_sub(coord_bld, length_f, min); + } /* coord = clamp(coord, min, max) */ coord = lp_build_clamp(coord_bld, coord, min, max); icoord = lp_build_ifloor(coord_bld, coord); @@ -595,13 +617,20 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, /* Note: this is the same as CLAMP_TO_EDGE, except min = -min */ { LLVMValueRef min, max; - /* min = -1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - min = lp_build_negate(coord_bld, min); - /* max = length - min */ - max = lp_build_sub(coord_bld, length_f, min); - /* scale coord to length */ - coord = lp_build_mul(coord_bld, coord, length_f); + if (bld->static_state->normalized_coords) { + /* min = -1.0 / (2 * length) */ + min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); + min = lp_build_negate(coord_bld, min); + /* max = length - min */ + max = lp_build_sub(coord_bld, length_f, min); + /* scale coord to length */ + coord = lp_build_mul(coord_bld, coord, length_f); + } + else { + /* clamp to [-0.5, length + 0.5] */ + min = lp_build_const_scalar(coord_bld->type, -0.5F); + max = lp_build_sub(coord_bld, length_f, min); + } /* coord = clamp(coord, min, max) */ coord = lp_build_clamp(coord_bld, coord, min, max); icoord = lp_build_ifloor(coord_bld, coord); -- cgit v1.2.3 From 88e2eae271fc76f82f3c732e32d3faa3184353ff Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 13:27:51 -0700 Subject: gallivm: minor arithmetic improvements --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 50dd1a57c9..2b04becc8c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -432,9 +432,10 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, { LLVMValueRef min, max; if (bld->static_state->normalized_coords) { - /* min = -1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - min = lp_build_negate(coord_bld, min); + /* min = -1.0 / (2 * length) = -0.5 / length */ + min = lp_build_mul(coord_bld, + lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_rcp(coord_bld, length_f)); /* max = 1.0 - min */ max = lp_build_sub(coord_bld, coord_bld->one, min); /* coord = clamp(coord, min, max) */ @@ -518,9 +519,10 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER: { LLVMValueRef min, max; - /* min = -1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - min = lp_build_negate(coord_bld, min); + /* min = -1.0 / (2 * length) = -0.5 / length */ + min = lp_build_mul(coord_bld, + lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_rcp(coord_bld, length_f)); /* max = 1.0 - min */ max = lp_build_sub(coord_bld, coord_bld->one, min); @@ -618,9 +620,10 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, { LLVMValueRef min, max; if (bld->static_state->normalized_coords) { - /* min = -1.0 / (2 * length) */ - min = lp_build_rcp(coord_bld, lp_build_mul(coord_bld, two, length_f)); - min = lp_build_negate(coord_bld, min); + /* min = -1.0 / (2 * length) = -0.5 / length */ + min = lp_build_mul(coord_bld, + lp_build_const_scalar(coord_bld->type, -0.5F), + lp_build_rcp(coord_bld, length_f)); /* max = length - min */ max = lp_build_sub(coord_bld, length_f, min); /* scale coord to length */ -- cgit v1.2.3 From 76e87786ab946b54adf7565555b0c671aa78d6bd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 13:30:24 -0700 Subject: gallium/docs: document additional wrap mode restrictions --- src/gallium/docs/source/cso/sampler.rst | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/docs/source/cso/sampler.rst b/src/gallium/docs/source/cso/sampler.rst index 44698d1250..9bbb784de8 100644 --- a/src/gallium/docs/source/cso/sampler.rst +++ b/src/gallium/docs/source/cso/sampler.rst @@ -85,6 +85,9 @@ normalized_coords will be scaled by the texture width, height, depth to compute texel addresses. Otherwise, the texture coords are used as-is (they are not scaled by the texture dimensions). + When normalized_coords=0, only a subset of the texture wrap modes are + allowed: PIPE_TEX_WRAP_CLAMP, PIPE_TEX_WRAP_CLAMP_TO_EDGE and + PIPE_TEX_WRAP_CLAMP_TO_BORDER. lod_bias Bias factor which is added to the computed level of detail. The normal level of detail is computed from the partial derivatives of -- cgit v1.2.3 From b704a4e8f332e7f9a38c21ce074cd244cf2fe89e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 14:24:02 -0700 Subject: llvmpipe: add pipe_thread_wait() calls Wait for threads to exit before cleaning up per-thread data. Fixes hang on context destruction with glean makeCurrent test. See fd.o bug 26536. --- src/gallium/drivers/llvmpipe/lp_rast.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c index 0f83eea685..dd9a8e8856 100644 --- a/src/gallium/drivers/llvmpipe/lp_rast.c +++ b/src/gallium/drivers/llvmpipe/lp_rast.c @@ -846,6 +846,12 @@ void lp_rast_destroy( struct lp_rasterizer *rast ) pipe_semaphore_signal(&rast->tasks[i].work_ready); } + /* Wait for threads to terminate before cleaning up per-thread data */ + for (i = 0; i < rast->num_threads; i++) { + pipe_thread_wait(rast->threads[i]); + } + + /* Clean up per-thread data */ for (i = 0; i < rast->num_threads; i++) { pipe_semaphore_destroy(&rast->tasks[i].work_ready); pipe_semaphore_destroy(&rast->tasks[i].work_done); -- cgit v1.2.3 From 36a0c4219deaa1509ae9746abb845f9502ca9f1b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 16:07:26 -0700 Subject: gallivm: added field for sampler lod --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 9 +++++---- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 55ac2e9436..6a026e468e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -75,14 +75,15 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, state->min_mip_filter = sampler->min_mip_filter; state->mag_img_filter = sampler->mag_img_filter; state->compare_mode = sampler->compare_mode; + state->compare_func = sampler->compare_func; + state->normalized_coords = sampler->normalized_coords; + state->lod_bias = sampler->lod_bias; + state->min_lod = sampler->min_lod; + state->max_lod = sampler->max_lod; state->border_color[0] = sampler->border_color[0]; state->border_color[1] = sampler->border_color[1]; state->border_color[2] = sampler->border_color[2]; state->border_color[3] = sampler->border_color[3]; - if(sampler->compare_mode != PIPE_TEX_COMPARE_NONE) { - state->compare_func = sampler->compare_func; - } - state->normalized_coords = sampler->normalized_coords; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index a791d88612..2120775d10 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -70,6 +70,7 @@ struct lp_sampler_static_state unsigned compare_mode:1; unsigned compare_func:3; unsigned normalized_coords:1; + float lod_bias, min_lod, max_lod; float border_color[4]; }; -- cgit v1.2.3 From 6bc644fe62adad6656be3f29c118045fc5630510 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 16:07:54 -0700 Subject: gallivm: checkpoint: texture LOD computation code gen --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 129 +++++++++++++++++++++- 1 file changed, 126 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 2b04becc8c..6b643fa85f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1040,6 +1040,127 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, } +static int +texture_dims(enum pipe_texture_target tex) +{ + switch (tex) { + case PIPE_TEXTURE_1D: + return 1; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_CUBE: + return 2; + case PIPE_TEXTURE_3D: + return 3; + default: + assert(0 && "bad texture target in texture_dims()"); + return 2; + } +} + + +/** + * Generate code to compute texture level of detail (lambda). + * \param s vector of texcoord s values + * \param t vector of texcoord t values + * \param r vector of texcoord r values + * \param width scalar int texture width + * \param height scalar int texture height + * \param depth scalar int texture depth + */ +static LLVMValueRef +lp_build_lod_selector(struct lp_build_sample_context *bld, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef width, + LLVMValueRef height, + LLVMValueRef depth) + +{ + const int dims = texture_dims(bld->static_state->target); + struct lp_build_context *coord_bld = &bld->coord_bld; + + LLVMValueRef lod_bias = lp_build_const_scalar(bld->coord_bld.type, + bld->static_state->lod_bias); + LLVMValueRef min_lod = lp_build_const_scalar(bld->coord_bld.type, + bld->static_state->min_lod); + LLVMValueRef max_lod = lp_build_const_scalar(bld->coord_bld.type, + bld->static_state->max_lod); + + LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0); + LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0); + LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0); + + LLVMValueRef s0, s1, s2; + LLVMValueRef t0, t1, t2; + LLVMValueRef r0, r1, r2; + LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; + LLVMValueRef rho, lod; + + /* + * dsdx = abs(s[1] - s[0]); + * dsdy = abs(s[2] - s[0]); + * dtdx = abs(t[1] - t[0]); + * dtdy = abs(t[2] - t[0]); + * drdx = abs(r[1] - r[0]); + * drdy = abs(r[2] - r[0]); + * XXX we're assuming a four-element quad in 2x2 layout here. + */ + s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0"); + s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1"); + s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2"); + dsdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, s1, s0)); + dsdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, s2, s0)); + if (dims > 1) { + t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0"); + t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1"); + t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2"); + dtdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, t1, t0)); + dtdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, t2, t0)); + if (dims > 2) { + r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0"); + r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1"); + r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2"); + drdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, r1, r0)); + drdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, r2, r0)); + } + } + + /* Compute rho = max of all partial derivatives scaled by texture size. + * XXX this can be vectorized somewhat + */ + rho = lp_build_mul(coord_bld, + lp_build_max(coord_bld, dsdx, dsdy), + lp_build_int_to_float(coord_bld, width)); + if (dims > 1) { + LLVMValueRef max; + max = lp_build_mul(coord_bld, + lp_build_max(coord_bld, dtdx, dtdy), + lp_build_int_to_float(coord_bld, height)); + rho = lp_build_max(coord_bld, rho, max); + if (dims > 2) { + max = lp_build_mul(coord_bld, + lp_build_max(coord_bld, drdx, drdy), + lp_build_int_to_float(coord_bld, depth)); + rho = lp_build_max(coord_bld, rho, max); + } + } + + /* compute lod = log2(rho) */ + lod = lp_build_log2(coord_bld, rho); + + /* add lod bias */ + lod = lp_build_add(coord_bld, lod, lod_bias); + + /* clamp lod */ + lod = lp_build_clamp(coord_bld, lod, min_lod, max_lod); + + return lod; +} + + + + /** * Build texture sampling code. * 'texel' will return a vector of four LLVMValueRefs corresponding to @@ -1063,7 +1184,9 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef data_ptr; LLVMValueRef s; LLVMValueRef t; - LLVMValueRef p; + LLVMValueRef r; + + (void) lp_build_lod_selector; /* temporary to silence warning */ /* Setup our build context */ memset(&bld, 0, sizeof bld); @@ -1088,7 +1211,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, s = coords[0]; t = coords[1]; - p = coords[2]; + r = coords[2]; width = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); height = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); @@ -1119,5 +1242,5 @@ lp_build_sample_soa(LLVMBuilderRef builder, /* FIXME: respect static_state->min_mip_filter */; /* FIXME: respect static_state->mag_img_filter */; - lp_build_sample_compare(&bld, p, texel); + lp_build_sample_compare(&bld, r, texel); } -- cgit v1.2.3 From 7f4b5c5387a3a8e3c5f31f0badc943c43857683a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 16:50:48 -0700 Subject: gallivm: added methods for getting texture depth, num mipmap levels --- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 2120775d10..5ba0925bb6 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -100,6 +100,18 @@ struct lp_sampler_dynamic_state LLVMBuilderRef builder, unsigned unit); + /** Obtain the base texture depth. */ + LLVMValueRef + (*depth)( struct lp_sampler_dynamic_state *state, + LLVMBuilderRef builder, + unsigned unit); + + /** Obtain the number of mipmap levels (minus one). */ + LLVMValueRef + (*last_level)( struct lp_sampler_dynamic_state *state, + LLVMBuilderRef builder, + unsigned unit); + LLVMValueRef (*stride)( struct lp_sampler_dynamic_state *state, LLVMBuilderRef builder, -- cgit v1.2.3 From b5038fdd65535012086535c6a87bc56c91a65c87 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 16:51:35 -0700 Subject: llvmpipe: added code to set texture depth, max mipmap levels info --- src/gallium/drivers/llvmpipe/lp_jit.c | 10 +++++++++- src/gallium/drivers/llvmpipe/lp_jit.h | 4 ++++ src/gallium/drivers/llvmpipe/lp_setup.c | 2 ++ src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 12 ++++++++---- 4 files changed, 23 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index b666ffc804..bacff500d6 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -51,10 +51,12 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) /* struct lp_jit_texture */ { - LLVMTypeRef elem_types[4]; + LLVMTypeRef elem_types[6]; elem_types[LP_JIT_TEXTURE_WIDTH] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_HEIGHT] = LLVMInt32Type(); + elem_types[LP_JIT_TEXTURE_DEPTH] = LLVMInt32Type(); + elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_STRIDE] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_DATA] = LLVMPointerType(LLVMInt8Type(), 0); @@ -66,6 +68,12 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, height, screen->target, texture_type, LP_JIT_TEXTURE_HEIGHT); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, depth, + screen->target, texture_type, + LP_JIT_TEXTURE_DEPTH); + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, last_level, + screen->target, texture_type, + LP_JIT_TEXTURE_LAST_LEVEL); LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, stride, screen->target, texture_type, LP_JIT_TEXTURE_STRIDE); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 8df3015d4b..0ebb2826fa 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -48,6 +48,8 @@ struct lp_jit_texture { uint32_t width; uint32_t height; + uint32_t depth; + uint32_t last_level; uint32_t stride; const void *data; }; @@ -56,6 +58,8 @@ struct lp_jit_texture enum { LP_JIT_TEXTURE_WIDTH = 0, LP_JIT_TEXTURE_HEIGHT, + LP_JIT_TEXTURE_DEPTH, + LP_JIT_TEXTURE_LAST_LEVEL, LP_JIT_TEXTURE_STRIDE, LP_JIT_TEXTURE_DATA }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index aebed85fbb..b0713c3b71 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -469,6 +469,8 @@ lp_setup_set_sampler_textures( struct setup_context *setup, jit_tex = &setup->fs.current.jit_context.textures[i]; jit_tex->width = tex->width0; jit_tex->height = tex->height0; + jit_tex->depth = tex->depth0; + jit_tex->last_level = tex->last_level; jit_tex->stride = lp_tex->stride[0]; if(!lp_tex->dt) { jit_tex->data = lp_tex->data; diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index 515c9089dd..632462460a 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -132,10 +132,12 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, } -LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH) -LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT) -LP_LLVM_TEXTURE_MEMBER(stride, LP_JIT_TEXTURE_STRIDE) -LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA) +LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH) +LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT) +LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH) +LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL) +LP_LLVM_TEXTURE_MEMBER(stride, LP_JIT_TEXTURE_STRIDE) +LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA) static void @@ -189,6 +191,8 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, sampler->base.emit_fetch_texel = lp_llvm_sampler_soa_emit_fetch_texel; sampler->dynamic_state.base.width = lp_llvm_texture_width; sampler->dynamic_state.base.height = lp_llvm_texture_height; + sampler->dynamic_state.base.depth = lp_llvm_texture_depth; + sampler->dynamic_state.base.last_level = lp_llvm_texture_last_level; sampler->dynamic_state.base.stride = lp_llvm_texture_stride; sampler->dynamic_state.base.data_ptr = lp_llvm_texture_data_ptr; sampler->dynamic_state.static_state = static_state; -- cgit v1.2.3 From 1a0a2b64ca150a97c96da2d4d97189c233dce407 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 5 Mar 2010 16:52:11 -0700 Subject: gallivm: checkpoint: code gen for mipmap selection --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 65 +++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 6b643fa85f..bc2f307c33 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1159,6 +1159,69 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, } +/** + * For PIPE_TEX_MIPFILTER_NEAREST, convert float LOD to integer + * mipmap level index. + * \param lod scalar float texture level of detail + * \param level_out returns integer + */ +static void +lp_build_nearest_mip_level(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef lod, + LLVMValueRef *level_out) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + LLVMValueRef last_level, level; + + last_level = bld->dynamic_state->last_level(bld->dynamic_state, + bld->builder, unit); + + /* convert float lod to integer */ + level = lp_build_iround(coord_bld, lod); + + /* clamp level to legal range of levels */ + *level_out = lp_build_clamp(int_coord_bld, level, + int_coord_bld->zero, + last_level); +} + + +/** + * For PIPE_TEX_MIPFILTER_LINEAR, convert float LOD to integer to + * two (adjacent) mipmap level indexes. Later, we'll sample from those + * two mipmap levels and interpolate between them. + */ +static void +lp_build_linear_mip_levels(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef lod, + LLVMValueRef *level0_out, + LLVMValueRef *level1_out, + LLVMValueRef *weight_out) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + LLVMValueRef last_level, level; + + last_level = bld->dynamic_state->last_level(bld->dynamic_state, + bld->builder, unit); + + /* convert float lod to integer */ + level = lp_build_ifloor(coord_bld, lod); + + /* compute level 0 and clamp to legal range of levels */ + *level0_out = lp_build_clamp(int_coord_bld, level, + int_coord_bld->zero, + last_level); + /* compute level 1 and clamp to legal range of levels */ + *level1_out = lp_build_add(int_coord_bld, *level0_out, int_coord_bld->one); + *level1_out = lp_build_min(int_coord_bld, *level1_out, int_coord_bld->zero); + + *weight_out = lp_build_fract(coord_bld, lod); +} + /** @@ -1187,6 +1250,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef r; (void) lp_build_lod_selector; /* temporary to silence warning */ + (void) lp_build_nearest_mip_level; + (void) lp_build_linear_mip_levels; /* Setup our build context */ memset(&bld, 0, sizeof bld); -- cgit v1.2.3 From 9af74a38c7e85069aac9bd4a266b488b68b133f5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 5 Mar 2010 15:09:08 +0000 Subject: gallivm: Generate valid IR for LLVM 2.7. The signatures for pack intrinsics were made more consistent in this version. --- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c index bc360ad77a..4c61d10749 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c @@ -256,7 +256,9 @@ lp_build_pack2(LLVMBuilderRef builder, LLVMValueRef lo, LLVMValueRef hi) { +#if !(HAVE_LLVM >= 0x0207) LLVMTypeRef src_vec_type = lp_build_vec_type(src_type); +#endif LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type); LLVMValueRef shuffle; LLVMValueRef res; @@ -272,11 +274,14 @@ lp_build_pack2(LLVMBuilderRef builder, switch(src_type.width) { case 32: if(dst_type.sign) { +#if HAVE_LLVM >= 0x0207 + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", dst_vec_type, lo, hi); +#else res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi); +#endif } else { if (util_cpu_caps.has_sse4_1) { - /* PACKUSDW is the only instrinsic with a consistent signature */ return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi); } else { @@ -288,9 +293,17 @@ lp_build_pack2(LLVMBuilderRef builder, case 16: if(dst_type.sign) +#if HAVE_LLVM >= 0x0207 + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", dst_vec_type, lo, hi); +#else res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi); +#endif else +#if HAVE_LLVM >= 0x0207 + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", dst_vec_type, lo, hi); +#else res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi); +#endif break; default: -- cgit v1.2.3 From 32631b69f503c26b010fb1bef5de5dcd012a2bcb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 5 Mar 2010 15:22:12 +0000 Subject: gallivm: Integrate udis86 on scons builds. --- src/gallium/auxiliary/SConscript | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index f365c4bbdd..c989d13359 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -7,6 +7,8 @@ env.Append(CPPPATH = [ 'util', ]) +env.Tool('udis86') + env.CodeGenerate( target = 'indices/u_indices_gen.c', script = 'indices/u_indices_gen.py', -- cgit v1.2.3 From ccf57af93f7118a044fa21e874847fa3ed555bca Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 5 Mar 2010 15:22:43 +0000 Subject: gallivm: Add a placeholder for TGSI_FILE_PREDICATE registers. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 5f2c2a54ee..84d03a145f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -384,6 +384,11 @@ emit_store( assert(0); break; + case TGSI_FILE_PREDICATE: + /* FIXME */ + assert(0); + break; + default: assert( 0 ); } -- cgit v1.2.3 From 89258652b6a1d282bed14549907892bdfda752f0 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 09:45:05 +0000 Subject: gallivm: Answer question/comment. This reverts commit 71c05689528d7987bfb99c3afe04e456887bc7b7. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 84d03a145f..28ff362cac 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -586,6 +586,17 @@ emit_instruction( if (indirect_temp_reference(inst)) return FALSE; + /* + * Stores and write masks are handled in a general fashion after the long + * instruction opcode switch statement. + * + * Although not stricitly necessary, we avoid generating instructions for + * channels which won't be stored, in cases where's that easy. For some + * complex instructions, like texture sampling, it is more convenient to + * assume a full writemask and then let LLVM optimization passes eliminate + * redundant code. + */ + assert(info->num_dst <= 1); if(info->num_dst) { FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { @@ -1131,7 +1142,6 @@ emit_instruction( break; case TGSI_OPCODE_TEX: - /* XXX what about dst0 writemask? */ emit_tex( bld, inst, FALSE, FALSE, dst0 ); break; -- cgit v1.2.3 From 69602b4dd3adc54a76f8214cb6856c004bef23a2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 10:23:07 +0000 Subject: gallivm: Add some notes about sampler static state construction. Recover some logic to make state canonical, although it is admittedly very shy compared with what could be done. We really need an helper module to make state canonical. --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 6a026e468e..29cadcc15a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -62,6 +62,18 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, if(!sampler) return; + /* + * We don't copy sampler state over unless it is actually enabled, to avoid + * spurious recompiles, as the sampler static state is part of the shader + * key. + * + * Ideally the state tracker or cso_cache module would make all state + * canonical, but until that happens it's better to be safe than sorry here. + * + * XXX: Actually there's much more than can be done here, especially + * regarding 1D/2D/3D/CUBE textures, wrap modes, etc. + */ + state->format = texture->format; state->target = texture->target; state->pot_width = util_is_pot(texture->width0); @@ -74,8 +86,12 @@ lp_sampler_static_state(struct lp_sampler_static_state *state, state->min_img_filter = sampler->min_img_filter; state->min_mip_filter = sampler->min_mip_filter; state->mag_img_filter = sampler->mag_img_filter; + state->compare_mode = sampler->compare_mode; - state->compare_func = sampler->compare_func; + if (sampler->compare_mode != PIPE_TEX_COMPARE_NONE) { + state->compare_func = sampler->compare_func; + } + state->normalized_coords = sampler->normalized_coords; state->lod_bias = sampler->lod_bias; state->min_lod = sampler->min_lod; -- cgit v1.2.3 From 4afae877e6914e311340e0b1d3490ec2fed9422f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:46:29 +0000 Subject: util: Add the shortened format name to the description. --- src/gallium/auxiliary/util/u_format.h | 6 ++++++ src/gallium/auxiliary/util/u_format_table.py | 2 ++ 2 files changed, 8 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index e8fa0022b5..ec6b077734 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -120,8 +120,14 @@ struct util_format_channel_description struct util_format_description { enum pipe_format format; + const char *name; + /** + * Short name, striped of the prefix, lower case. + */ + const char *short_name; + /** * Pixel block dimensions. */ diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index 4e29d15f3b..f9d21ed8aa 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -90,6 +90,7 @@ def write_format_table(formats): print 'util_format_none_description = {' print " PIPE_FORMAT_NONE," print " \"PIPE_FORMAT_NONE\"," + print " \"none\"," print " {0, 0, 0}," print " 0," print " 0," @@ -105,6 +106,7 @@ def write_format_table(formats): print 'util_format_%s_description = {' % (format.short_name(),) print " %s," % (format.name,) print " \"%s\"," % (format.name,) + print " \"%s\"," % (format.short_name(),) print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()) print " %s," % (layout_map(format.layout),) print " %u,\t/* nr_channels */" % (format.nr_channels(),) -- cgit v1.2.3 From cfde6c50ae6c3ce7912a3d1231c459d020d77f13 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:48:39 +0000 Subject: util: Add a new flag, for formats that can be described as a bitmask. --- src/gallium/auxiliary/util/u_format.h | 9 +++++++++ src/gallium/auxiliary/util/u_format_parse.py | 8 +------- src/gallium/auxiliary/util/u_format_table.py | 2 ++ 3 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index ec6b077734..b2aa5bfb18 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -145,6 +145,15 @@ struct util_format_description */ unsigned is_array:1; + /** + * Whether the pixel format can be described as a bitfield structure. + * + * In particular: + * - pixel depth must be 8, 16, or 32 bits; + * - all channels must be unsigned, signed, or void + */ + unsigned is_bitmask:1; + /** * Whether channels have mixed types (ignoring UTIL_FORMAT_TYPE_VOID). */ diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 250926418e..80bae6fc95 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -166,17 +166,11 @@ class Format: return True def is_bitmask(self): - if self.block_size() > 32: - return False - if not self.is_pot(): + if self.block_size() not in (8, 16, 32): return False for channel in self.channels: - if not is_pot(channel.size): - return True if channel.type not in (VOID, UNSIGNED, SIGNED): return False - if channel.size >= 32: - return False return True def inv_swizzles(self): diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py index f9d21ed8aa..fb68852a53 100755 --- a/src/gallium/auxiliary/util/u_format_table.py +++ b/src/gallium/auxiliary/util/u_format_table.py @@ -96,6 +96,7 @@ def write_format_table(formats): print " 0," print " 0," print " 0," + print " 0," print " {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}," print " {0, 0, 0, 0}," print " 0" @@ -111,6 +112,7 @@ def write_format_table(formats): print " %s," % (layout_map(format.layout),) print " %u,\t/* nr_channels */" % (format.nr_channels(),) print " %s,\t/* is_array */" % (bool_map(format.is_array()),) + print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),) print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),) print " {" for i in range(4): -- cgit v1.2.3 From f342ceca3852d5b9607d1f375be26de9304a11f6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:49:14 +0000 Subject: util: Fix the maximum value computation for SSCALED channels. --- src/gallium/auxiliary/util/u_format_parse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py index 80bae6fc95..f74dc5e88a 100755 --- a/src/gallium/auxiliary/util/u_format_parse.py +++ b/src/gallium/auxiliary/util/u_format_parse.py @@ -78,7 +78,7 @@ class Channel: if self.type == UNSIGNED: return (1 << self.size) - 1 if self.type == SIGNED: - return self.size - 1 + return (1 << (self.size - 1)) - 1 assert False def min(self): -- cgit v1.2.3 From 0869f0edf14594744f691a51cb220c13026359db Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 12:50:47 +0000 Subject: util: Several fixes to clamping and test. All tests pass here except util_format_b5g5r5a1_unorm_unpack_4ub, due to apparently a gcc 4.4.3 bug. --- src/gallium/auxiliary/util/u_format_pack.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 3f33f7cc02..1fc58cd3de 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -252,9 +252,6 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True if src_channel.type == FLOAT and dst_channel.type == FLOAT: return '(%s)%s' % (dst_native_type, value) - if not src_channel.norm and not dst_channel.norm: - return '(%s)%s' % (dst_native_type, value) - if clamp: value = clamp_expr(src_channel, dst_channel, dst_native_type, value) @@ -280,15 +277,15 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True value = '(%s * %s)' % (value, scale) return '(%s)%s' % (dst_native_type, value) - if not src_channel.norm and not dst_channel.norm: - # neither is normalized -- just cast - return '(%s)%s' % (dst_native_type, value) - if src_channel.type in (SIGNED, UNSIGNED) and dst_channel.type in (SIGNED, UNSIGNED): + if not src_channel.norm and not dst_channel.norm: + # neither is normalized -- just cast + return '(%s)%s' % (dst_native_type, value) + src_one = get_one(src_channel) dst_one = get_one(dst_channel) - if src_one > dst_one and src_channel.norm: + if src_one > dst_one and src_channel.norm and dst_channel.norm: # We can just bitshift src_shift = get_one_shift(src_channel) dst_shift = get_one_shift(dst_channel) @@ -296,7 +293,7 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True else: # We need to rescale using an intermediate type big enough to hold the multiplication of both tmp_native_type = intermediate_native_type(src_channel.size + dst_channel.size, src_channel.sign and dst_channel.sign) - value = '(%s)%s' % (tmp_native_type, value) + value = '((%s)%s)' % (tmp_native_type, value) value = '(%s * 0x%x / 0x%x)' % (value, dst_one, src_one) value = '(%s)%s' % (dst_native_type, value) return value -- cgit v1.2.3 From 212e7433db8e306a678666e9a3e82b0c9e1560ec Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 13:42:11 +0000 Subject: util: Move the format tests cases here so that they can be easily shared. --- src/gallium/auxiliary/Makefile | 1 + src/gallium/auxiliary/SConscript | 1 + src/gallium/auxiliary/util/u_format_tests.c | 544 ++++++++++++++++++++++++++++ src/gallium/auxiliary/util/u_format_tests.h | 69 ++++ 4 files changed, 615 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_format_tests.c create mode 100644 src/gallium/auxiliary/util/u_format_tests.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 1d0930e024..68b1a3e854 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -107,6 +107,7 @@ C_SOURCES = \ util/u_draw_quad.c \ util/u_format_access.c \ util/u_format_table.c \ + util/u_format_tests.c \ util/u_gen_mipmap.c \ util/u_handle_table.c \ util/u_hash_table.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index c989d13359..d6185bcb5e 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -151,6 +151,7 @@ source = [ 'util/u_draw_quad.c', 'util/u_format_access.c', 'util/u_format_table.c', + 'util/u_format_tests.c', 'util/u_gen_mipmap.c', 'util/u_handle_table.c', 'util/u_hash.c', diff --git a/src/gallium/auxiliary/util/u_format_tests.c b/src/gallium/auxiliary/util/u_format_tests.c new file mode 100644 index 0000000000..182a474044 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_tests.c @@ -0,0 +1,544 @@ +/************************************************************************** + * + * Copyright 2009-2010 VMware, Inc. + * 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 VMWARE 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 "u_memory.h" +#include "u_format_tests.h" + + +/* + * Helper macros to create the packed bytes for longer words. + */ + +#define PACKED_1x8(x) {x, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x8(x, y) {x, y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x8(x, y, z) {x, y, z, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_4x8(x, y, z, w) {x, y, z, w, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} + +#define PACKED_1x16(x) {(x) & 0xff, (x) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x16(x, y) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x16(x, y, z) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_4x16(x, y, z, w) {(x) & 0xff, (x) >> 8, (y) & 0xff, (y) >> 8, (z) & 0xff, (z) >> 8, (w) & 0xff, (w) >> 8, 0, 0, 0, 0, 0, 0, 0, 0} + +#define PACKED_1x32(x) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_2x32(x, y) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, 0, 0, 0, 0, 0, 0, 0, 0} +#define PACKED_3x32(x, y, z) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, 0, 0, 0, 0} +#define PACKED_4x32(x, y, z, w) {(x) & 0xff, ((x) >> 8) & 0xff, ((x) >> 16) & 0xff, (x) >> 24, (y) & 0xff, ((y) >> 8) & 0xff, ((y) >> 16) & 0xff, (y) >> 24, (z) & 0xff, ((z) >> 8) & 0xff, ((z) >> 16) & 0xff, (z) >> 24, (w) & 0xff, ((w) >> 8) & 0xff, ((w) >> 16) & 0xff, (w) >> 24} + + +/** + * Test cases. + * + * These were manually entered. We could generate these + * + * To keep this to a we cover only the corner cases, which should produce + * good enough coverage since that pixel format transformations are afine for + * non SRGB formats. + */ +const struct util_format_test_case +util_format_test_cases[] = +{ + + /* + * 32-bit rendertarget formats + */ + + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8A8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x000000ff), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x0000ff00), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0x00ff0000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xff000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B8G8R8X8_UNORM, PACKED_1x32(0x00ffffff), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_A8R8G8B8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_X8R8G8B8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000000ff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x0000ff00), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00ff0000), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8B8G8R8_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x000000ff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x0000ff00), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0x00ff0000), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xff000000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_X8B8G8R8_UNORM, PACKED_1x32(0xffffff00), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000003ff), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x000ffc00), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x3ff00000), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xc0000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R10G10B10A2_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + /* + * 16-bit rendertarget formats + */ + + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x03e0), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7c00), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G5R5A1_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00f0), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0f00), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B4G4R4A4_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x001f), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x07e0), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xf800), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_B5G6R5_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + + /* + * Luminance/intensity/alpha formats + */ + + {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_L8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_A8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), {0.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_I8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x00ff), {1.0, 1.0, 1.0, 0.0}}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xff00), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_L8A8_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_L16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 1.0, 1.0, 1.0}}, + + /* + * TODO: SRGB formats + */ + + /* + * Mixed-signed formats + */ + + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x81, 0x00, 0x00, 0x00), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x81, 0x00, 0x00), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8SG8SB8UX8U_NORM, PACKED_4x8(0xff, 0xff, 0xff, 0x00), PACKED_4x8(0x00, 0x00, 0xff, 0x00), { 0.0, 0.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x000f), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0011), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x01e0), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0x0220), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R5SG5SB6U_NORM, PACKED_1x16(0xffff), PACKED_1x16(0xfc00), { 0.0, 0.0, 1.0, 1.0}}, + + /* + * TODO: Depth-stencil formats + */ + + /* + * TODO: YUV formats + */ + + /* + * TODO: Compressed formats + */ + + /* + * Standard 8-bit integer formats + */ + + {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_UNORM, PACKED_1x8(0xff), PACKED_1x8(0xff), {1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_UNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), {1.0, 1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_UNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8A8_UNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_USCALED, PACKED_1x8(0xff), PACKED_1x8(0xff), {255.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0x00), {255.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0xff), { 0.0, 255.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_USCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0xff, 0xff), {255.0, 255.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0x00, 0x00), {255.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0xff, 0x00), { 0.0, 255.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0xff), { 0.0, 0.0, 255.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_USCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0xff, 0xff, 0xff), {255.0, 255.0, 255.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0x00, 0x00, 0x00), {255.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0xff, 0x00, 0x00), { 0.0, 255.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0xff, 0x00), { 0.0, 0.0, 255.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0xff), { 0.0, 0.0, 0.0, 255.0}}, + {PIPE_FORMAT_R8G8B8A8_USCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0xff, 0xff, 0xff, 0xff), {255.0, 255.0, 255.0, 255.0}}, + + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x7f), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_SNORM, PACKED_1x8(0xff), PACKED_1x8(0x81), {-1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x81, 0x00), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SNORM, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x81), { 0.0, -1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x81, 0x00, 0x00), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x81, 0x00), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), { 0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SNORM, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x81), { 0.0, 0.0, -1.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), { 1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x81, 0x00, 0x00, 0x00), {-1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), { 0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x81, 0x00, 0x00), { 0.0, -1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), { 0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x81, 0x00), { 0.0, 0.0, -1.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8A8_SNORM, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x81), { 0.0, 0.0, 0.0, -1.0}}, + + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x7f), { 127.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8_SSCALED, PACKED_1x8(0xff), PACKED_1x8(0x80), {-128.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x7f, 0x00), { 127.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x80, 0x00), {-128.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x7f), { 0.0, 127.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8_SSCALED, PACKED_2x8(0xff, 0xff), PACKED_2x8(0x00, 0x80), { 0.0, -128.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x7f, 0x00, 0x00), { 127.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x80, 0x00, 0x00), {-128.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x7f, 0x00), { 0.0, 127.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x80, 0x00), { 0.0, -128.0, 0.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x7f), { 0.0, 0.0, 127.0, 1.0}}, + {PIPE_FORMAT_R8G8B8_SSCALED, PACKED_3x8(0xff, 0xff, 0xff), PACKED_3x8(0x00, 0x00, 0x80), { 0.0, 0.0, -128.0, 1.0}}, + + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x00), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x7f, 0x00, 0x00, 0x00), { 127.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x80, 0x00, 0x00, 0x00), {-128.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x7f, 0x00, 0x00), { 0.0, 127.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x80, 0x00, 0x00), { 0.0, -128.0, 0.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x7f, 0x00), { 0.0, 0.0, 127.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x80, 0x00), { 0.0, 0.0, -128.0, 0.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x7f), { 0.0, 0.0, 0.0, 127.0}}, + {PIPE_FORMAT_R8G8B8A8_SSCALED, PACKED_4x8(0xff, 0xff, 0xff, 0xff), PACKED_4x8(0x00, 0x00, 0x00, 0x80), { 0.0, 0.0, 0.0, -128.0}}, + + /* + * Standard 16-bit integer formats + */ + + {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_UNORM, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_UNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), {1.0, 1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_UNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16A16_UNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_USCALED, PACKED_1x16(0xffff), PACKED_1x16(0xffff), {65535.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0x0000), {65535.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0xffff), { 0.0, 65535.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_USCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0xffff, 0xffff), {65535.0, 65535.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0x0000, 0x0000), {65535.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0xffff, 0x0000), { 0.0, 65535.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0xffff), { 0.0, 0.0, 65535.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_USCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0xffff, 0xffff, 0xffff), {65535.0, 65535.0, 65535.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0x0000, 0x0000, 0x0000), {65535.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0xffff, 0x0000, 0x0000), { 0.0, 65535.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0xffff, 0x0000), { 0.0, 0.0, 65535.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0xffff), { 0.0, 0.0, 0.0, 65535.0}}, + {PIPE_FORMAT_R16G16B16A16_USCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), {65535.0, 65535.0, 65535.0, 65535.0}}, + + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_SNORM, PACKED_1x16(0xffff), PACKED_1x16(0x8001), { -1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8001, 0x0000), { -1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SNORM, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8001), { 0.0, -1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8001, 0x0000, 0x0000), { -1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8001, 0x0000), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), { 0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SNORM, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8001), { 0.0, 0.0, -1.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), { 1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8001, 0x0000, 0x0000, 0x0000), { -1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), { 0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8001, 0x0000, 0x0000), { 0.0, -1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), { 0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8001, 0x0000), { 0.0, 0.0, -1.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16A16_SNORM, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8001), { 0.0, 0.0, 0.0, -1.0}}, + + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x7fff), { 32767.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16_SSCALED, PACKED_1x16(0xffff), PACKED_1x16(0x8000), {-32768.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x7fff, 0x0000), { 32767.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x8000, 0x0000), {-32768.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x7fff), { 0.0, 32767.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16_SSCALED, PACKED_2x16(0xffff, 0xffff), PACKED_2x16(0x0000, 0x8000), { 0.0, -32768.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x7fff, 0x0000, 0x0000), { 32767.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x8000, 0x0000, 0x0000), {-32768.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x7fff, 0x0000), { 0.0, 32767.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x8000, 0x0000), { 0.0, -32768.0, 0.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x7fff), { 0.0, 0.0, 32767.0, 1.0}}, + {PIPE_FORMAT_R16G16B16_SSCALED, PACKED_3x16(0xffff, 0xffff, 0xffff), PACKED_3x16(0x0000, 0x0000, 0x8000), { 0.0, 0.0, -32768.0, 1.0}}, + + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x0000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x7fff, 0x0000, 0x0000, 0x0000), { 32767.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x8000, 0x0000, 0x0000, 0x0000), {-32768.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x7fff, 0x0000, 0x0000), { 0.0, 32767.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x8000, 0x0000, 0x0000), { 0.0, -32768.0, 0.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x7fff, 0x0000), { 0.0, 0.0, 32767.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x8000, 0x0000), { 0.0, 0.0, -32768.0, 0.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x7fff), { 0.0, 0.0, 0.0, 32767.0}}, + {PIPE_FORMAT_R16G16B16A16_SSCALED, PACKED_4x16(0xffff, 0xffff, 0xffff, 0xffff), PACKED_4x16(0x0000, 0x0000, 0x0000, 0x8000), { 0.0, 0.0, 0.0, -32768.0}}, + + /* + * Standard 32-bit integer formats + * + * NOTE: We can't accurately represent integers larger than +/-0x1000000 + * with single precision floats, so that's as far as we test. + */ + + {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_UNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0xffffffff), {1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0x00000000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xffffffff), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_UNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xffffffff, 0xffffffff), {1.0, 1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0x00000000, 0x00000000), {1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xffffffff, 0x00000000), {0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xffffffff), {0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_UNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), {0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0x00000000, 0x00000000, 0x00000000), {1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xffffffff, 0x00000000, 0x00000000), {0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xffffffff, 0x00000000), {0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xffffffff), {0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32A32_UNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), {1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_USCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), {16777216.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), {16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), { 0.0, 16777216.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_USCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x01000000), {16777216.0, 16777216.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), {16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), { 0.0, 16777216.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), { 0.0, 0.0, 16777216.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_USCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x01000000, 0x01000000), {16777216.0, 16777216.0, 16777216.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), {16777216.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), { 0.0, 16777216.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), { 0.0, 0.0, 16777216.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), { 0.0, 0.0, 0.0, 16777216.0}}, + {PIPE_FORMAT_R32G32B32A32_USCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x01000000, 0x01000000, 0x01000000), {16777216.0, 16777216.0, 16777216.0, 16777216.0}}, + + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x7fffffff), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_SNORM, PACKED_1x32(0xffffffff), PACKED_1x32(0x80000001), { -1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x7fffffff, 0x00000000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x80000001, 0x00000000), { -1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x7fffffff), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SNORM, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x80000001), { 0.0, -1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x7fffffff, 0x00000000, 0x00000000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x80000001, 0x00000000, 0x00000000), { -1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x7fffffff, 0x00000000), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x80000001, 0x00000000), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x7fffffff), { 0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SNORM, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x80000001), { 0.0, 0.0, -1.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x7fffffff, 0x00000000, 0x00000000, 0x00000000), { 1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x80000001, 0x00000000, 0x00000000, 0x00000000), { -1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x7fffffff, 0x00000000, 0x00000000), { 0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x80000001, 0x00000000, 0x00000000), { 0.0, -1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x7fffffff, 0x00000000), { 0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x80000001, 0x00000000), { 0.0, 0.0, -1.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x7fffffff), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32A32_SNORM, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x80000001), { 0.0, 0.0, 0.0, -1.0}}, + + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0x01000000), { 16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_SSCALED, PACKED_1x32(0xffffffff), PACKED_1x32(0xff000000), {-16777216.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x01000000, 0x00000000), { 16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xff000000, 0x00000000), {-16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x01000000), { 0.0, 16777216.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_SSCALED, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xff000000), { 0.0, -16777216.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x01000000, 0x00000000, 0x00000000), { 16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xff000000, 0x00000000, 0x00000000), {-16777216.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x01000000, 0x00000000), { 0.0, 16777216.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xff000000, 0x00000000), { 0.0, -16777216.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x01000000), { 0.0, 0.0, 16777216.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_SSCALED, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xff000000), { 0.0, 0.0, -16777216.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x01000000, 0x00000000, 0x00000000, 0x00000000), { 16777216.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xff000000, 0x00000000, 0x00000000, 0x00000000), {-16777216.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x01000000, 0x00000000, 0x00000000), { 0.0, 16777216.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xff000000, 0x00000000, 0x00000000), { 0.0, -16777216.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x01000000, 0x00000000), { 0.0, 0.0, 16777216.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xff000000, 0x00000000), { 0.0, 0.0, -16777216.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x01000000), { 0.0, 0.0, 0.0, 16777216.0}}, + {PIPE_FORMAT_R32G32B32A32_SSCALED, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xff000000), { 0.0, 0.0, 0.0, -16777216.0}}, + + /* + * Standard 32-bit float formats + */ + + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0x3f800000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32_FLOAT, PACKED_1x32(0xffffffff), PACKED_1x32(0xbf800000), { -1.0, 0.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x00000000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0xbf800000, 0x00000000), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0x3f800000), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x00000000, 0xbf800000), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32_FLOAT, PACKED_2x32(0xffffffff, 0xffffffff), PACKED_2x32(0x3f800000, 0x3f800000), { 1.0, 1.0, 0.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x00000000, 0x00000000), { 1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0xbf800000, 0x00000000, 0x00000000), {-1.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x3f800000, 0x00000000), { 0.0, 1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0xbf800000, 0x00000000), { 0.0, -1.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0x3f800000), { 0.0, 0.0, 1.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x00000000, 0x00000000, 0xbf800000), { 0.0, 0.0, -1.0, 1.0}}, + {PIPE_FORMAT_R32G32B32_FLOAT, PACKED_3x32(0xffffffff, 0xffffffff, 0xffffffff), PACKED_3x32(0x3f800000, 0x3f800000, 0x3f800000), { 1.0, 1.0, 1.0, 1.0}}, + + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x00000000), { 0.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x00000000, 0x00000000, 0x00000000), { 1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0xbf800000, 0x00000000, 0x00000000, 0x00000000), {-1.0, 0.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x3f800000, 0x00000000, 0x00000000), { 0.0, 1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0xbf800000, 0x00000000, 0x00000000), { 0.0, -1.0, 0.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x3f800000, 0x00000000), { 0.0, 0.0, 1.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0xbf800000, 0x00000000), { 0.0, 0.0, -1.0, 0.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0x3f800000), { 0.0, 0.0, 0.0, 1.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x00000000, 0x00000000, 0x00000000, 0xbf800000), { 0.0, 0.0, 0.0, -1.0}}, + {PIPE_FORMAT_R32G32B32A32_FLOAT, PACKED_4x32(0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff), PACKED_4x32(0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000), { 1.0, 1.0, 1.0, 1.0}}, +}; + + +const unsigned util_format_nr_test_cases = Elements(util_format_test_cases); diff --git a/src/gallium/auxiliary/util/u_format_tests.h b/src/gallium/auxiliary/util/u_format_tests.h new file mode 100644 index 0000000000..2d4d9d5fa9 --- /dev/null +++ b/src/gallium/auxiliary/util/u_format_tests.h @@ -0,0 +1,69 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef U_FORMAT_TESTS_H_ +#define U_FORMAT_TESTS_H_ + + +#include "pipe/p_compiler.h" +#include "pipe/p_format.h" + + +#define UTIL_FORMAT_MAX_PACKED_BYTES 16 + + +/** + * A (packed, unpacked) color pair. + */ +struct util_format_test_case +{ + enum pipe_format format; + + /** + * Mask of the bits that actually meaningful data. Used to mask out the + * "X" channels. + */ + uint8_t mask[UTIL_FORMAT_MAX_PACKED_BYTES]; + + uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; + + /** + * RGBA. + */ + double unpacked[4]; +}; + + +extern const struct util_format_test_case +util_format_test_cases[]; + + +extern const unsigned util_format_nr_test_cases; + + +#endif /* U_FORMAT_TESTS_H_ */ -- cgit v1.2.3 From 45ae4434b5bd779e74d12e5b63fcf91d88f4cb28 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 6 Mar 2010 14:22:56 +0000 Subject: util: Use bitshift arithmetic to unpack pixels. All test cases pass now. --- src/gallium/auxiliary/util/u_format_pack.py | 115 ++++++++++++++++++++++------ 1 file changed, 92 insertions(+), 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index 1fc58cd3de..b49039db39 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -304,6 +304,8 @@ def conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=True def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): '''Generate the function to unpack pixels from a particular format''' + assert format.layout == PLAIN + name = format.short_name() src_native_type = native_type(format) @@ -311,32 +313,99 @@ def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix): print 'static INLINE void' print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type) print '{' - print ' union util_format_%s pixel;' % format.short_name() - print ' memcpy(&pixel, src, sizeof pixel);' - bswap_format(format) + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = *(uint%u_t *)src;' % (depth, depth) - assert format.layout == PLAIN + # Declare the intermediate variables + for i in range(format.nr_channels()): + src_channel = format.channels[i] + if src_channel.type == UNSIGNED: + print ' uint%u_t %s;' % (depth, src_channel.name) + elif src_channel.type == SIGNED: + print ' int%u_t %s;' % (depth, src_channel.name) - for i in range(4): - swizzle = format.swizzles[i] - if swizzle < 4: - src_channel = format.channels[swizzle] - value = 'pixel.chan.%s' % src_channel.name - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - elif swizzle == SWIZZLE_0: - value = '0' - elif swizzle == SWIZZLE_1: - value = get_one(dst_channel) - elif swizzle == SWIZZLE_NONE: - value = '0' - else: - assert False - if format.colorspace == ZS: - if i == 3: + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' + + # Compute the intermediate unshifted values + shift = 0 + for i in range(format.nr_channels()): + src_channel = format.channels[i] + value = 'value' + if src_channel.type == UNSIGNED: + if shift: + value = '%s >> %u' % (value, shift) + if shift + src_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << src_channel.size) - 1) + elif src_channel.type == SIGNED: + if shift + src_channel.size < depth: + # Align the sign bit + lshift = depth - (shift + src_channel.size) + value = '%s << %u' % (value, lshift) + # Cast to signed + value = '(int%u_t)(%s) ' % (depth, value) + if src_channel.size < depth: + # Align the LSB bit + rshift = depth - src_channel.size + value = '(%s) >> %u' % (value, rshift) + else: + value = None + + if value is not None: + print ' %s = %s;' % (src_channel.name, value) + + shift += src_channel.size + + # Convert, swizzle, and store final values + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: value = get_one(dst_channel) - elif i >= 1: - value = 'dst[0]' - print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) + + else: + print ' union util_format_%s pixel;' % format.short_name() + print ' memcpy(&pixel, src, sizeof pixel);' + bswap_format(format) + + for i in range(4): + swizzle = format.swizzles[i] + if swizzle < 4: + src_channel = format.channels[swizzle] + value = 'pixel.chan.%s' % src_channel.name + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + elif swizzle == SWIZZLE_0: + value = '0' + elif swizzle == SWIZZLE_1: + value = get_one(dst_channel) + elif swizzle == SWIZZLE_NONE: + value = '0' + else: + assert False + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = 'dst[0]' + print ' dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]) print '}' print -- cgit v1.2.3 From c37a20416d681a3fea42a1a2ce907eb8e11ba795 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 6 Mar 2010 19:35:10 +0100 Subject: r300g: clamp vertex max index according to currently bound buffers --- src/gallium/drivers/r300/r300_render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 6c891029a5..073664fa45 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -278,7 +278,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); - maxIndex = MIN2(maxIndex, ((1 << 24) - 1)); + maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); if (alt_num_verts) { BEGIN_CS(16); -- cgit v1.2.3 From 09653d65e9650c3c04b3e8160b8f2ad7198fc122 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 6 Mar 2010 23:29:17 +0100 Subject: r300g: minor cleanups after the no-rhw merge --- src/gallium/drivers/r300/r300_state.c | 4 +--- src/gallium/drivers/r300/r300_state_derived.c | 10 ++++------ 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 1f6f99d3e5..4349bc1d50 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -716,8 +716,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, rs->vap_control_status = R300_VC_32BIT_SWAP; #endif - /* If bypassing TCL, or if no TCL engine is present, turn off the HW TCL. - * Else, enable HW TCL and force Draw's TCL off. */ + /* If no TCL engine is present, turn off the HW TCL. */ if (!r300screen->caps->has_tcl) { rs->vap_control_status |= R300_VAP_TCL_BYPASS; } @@ -1121,7 +1120,6 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ r300->vap_output_state.dirty = TRUE; - r300->vertex_stream_state.dirty = TRUE; /* XXX needed for TCL bypass */ r300->pvs_flush.dirty = TRUE; if (r300->fs) { diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 9c8e907fdf..fc24cd5817 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -436,15 +436,14 @@ static void r300_update_derived_shader_state(struct r300_context* r300) struct r300_vap_output_state *vap_out = (struct r300_vap_output_state*)r300->vap_output_state.state; - /* XXX Mmm, delicious hax */ - memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); - memcpy(vap_out, vs->hwfmt, sizeof(uint)*4); - r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs); if (r300screen->caps->has_tcl) { + memcpy(vap_out, vs->hwfmt, sizeof(uint)*4); r300_vertex_psc(r300); } else { + /* XXX set vap_out */ + memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); r300_draw_emit_all_attribs(r300); draw_compute_vertex_size(&r300->vertex_info); r300_swtcl_vertex_psc(r300); @@ -582,8 +581,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { if (r300->rs_block_state.dirty || - r300->vertex_stream_state.dirty || /* XXX put updating this state out of this file */ - r300->rs_state.dirty) { /* XXX and remove this one (tcl_bypass dependency) */ + r300->vertex_stream_state.dirty) { /* XXX put updating PSC out of this file */ r300_update_derived_shader_state(r300); } -- cgit v1.2.3 From 6f4a19ca562ccd7e4bc2f7ea32263391abaa16bd Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 01:12:57 +0100 Subject: r300g: abort if FS compilation fails on non-debug builds --- src/gallium/drivers/r300/r300_fs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 3c2625269b..9e71e61c30 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -207,6 +207,7 @@ static void r300_translate_fragment_shader( DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n", compiler.Base.ErrorMsg); assert(0); + abort(); } /* And, finally... */ -- cgit v1.2.3 From 4f541db80c5ffff8932679a389a6043105f0b1be Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 02:32:09 +0100 Subject: r300g: share the VS-output-mapping state with SWTCL And associated cleanups. --- src/gallium/drivers/r300/r300_state.c | 64 +++++----- src/gallium/drivers/r300/r300_state_derived.c | 4 - src/gallium/drivers/r300/r300_vs.c | 163 +++++++++----------------- src/gallium/drivers/r300/r300_vs.h | 13 +- 4 files changed, 96 insertions(+), 148 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 4349bc1d50..381676e09a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1087,67 +1087,71 @@ static void* r300_create_vs_state(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); - if (r300_screen(pipe->screen)->caps->has_tcl) { - struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader); - /* Copy state directly into shader. */ - vs->state = *shader; - vs->state.tokens = tgsi_dup_tokens(shader->tokens); - - tgsi_scan_shader(shader->tokens, &vs->info); + struct r300_vertex_shader* vs = CALLOC_STRUCT(r300_vertex_shader); + r300_vertex_shader_common_init(vs, shader); - return (void*)vs; + if (r300_screen(pipe->screen)->caps->has_tcl) { + r300_translate_vertex_shader(r300, vs); } else { - return draw_create_vertex_shader(r300->draw, shader); + vs->draw_vs = draw_create_vertex_shader(r300->draw, shader); } + + return vs; } static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) { struct r300_context* r300 = r300_context(pipe); + struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; - if (r300_screen(pipe->screen)->caps->has_tcl) { - struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; + if (vs == NULL) { + r300->vs_state.state = NULL; + return; + } + if (vs == r300->vs_state.state) { + return; + } + r300->vs_state.state = vs; - if (vs == NULL) { - r300->vs_state.state = NULL; - return; - } else if (!vs->translated) { - r300_translate_vertex_shader(r300, vs); - } + // VS output mapping for HWTCL or stream mapping for SWTCL to the RS block + if (r300->fs) { + r300_vertex_shader_setup_wpos(r300); + } + memcpy(r300->vap_output_state.state, &vs->vap_out, + sizeof(struct r300_vap_output_state)); + r300->vap_output_state.dirty = TRUE; + + /* The majority of the RS block bits is dependent on the vertex shader. */ + r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ - UPDATE_STATE(shader, r300->vs_state); + if (r300_screen(pipe->screen)->caps->has_tcl) { + r300->vs_state.dirty = TRUE; r300->vs_state.size = vs->code.length + 9; - r300->rs_block_state.dirty = TRUE; /* Will be updated before the emission. */ - r300->vap_output_state.dirty = TRUE; r300->pvs_flush.dirty = TRUE; - if (r300->fs) { - r300_vertex_shader_setup_wpos(r300); - } - r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; } else { draw_flush(r300->draw); draw_bind_vertex_shader(r300->draw, - (struct draw_vertex_shader*)shader); + (struct draw_vertex_shader*)vs->draw_vs); } } static void r300_delete_vs_state(struct pipe_context* pipe, void* shader) { struct r300_context* r300 = r300_context(pipe); + struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; if (r300_screen(pipe->screen)->caps->has_tcl) { - struct r300_vertex_shader* vs = (struct r300_vertex_shader*)shader; - rc_constants_destroy(&vs->code.constants); - FREE((void*)vs->state.tokens); - FREE(shader); } else { draw_delete_vertex_shader(r300->draw, - (struct draw_vertex_shader*)shader); + (struct draw_vertex_shader*)vs->draw_vs); } + + FREE((void*)vs->state.tokens); + FREE(shader); } static void r300_set_constant_buffer(struct pipe_context *pipe, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index fc24cd5817..e9e40747ef 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -433,16 +433,12 @@ static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; struct r300_screen* r300screen = r300_screen(r300->context.screen); - struct r300_vap_output_state *vap_out = - (struct r300_vap_output_state*)r300->vap_output_state.state; r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs); if (r300screen->caps->has_tcl) { - memcpy(vap_out, vs->hwfmt, sizeof(uint)*4); r300_vertex_psc(r300); } else { - /* XXX set vap_out */ memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); r300_draw_emit_all_attribs(r300); draw_compute_vertex_size(&r300->vertex_info); diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index 60a04bbfed..379939ac75 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -89,95 +89,41 @@ static void r300_shader_read_vs_outputs( assert(0); } } + + /* WPOS is a straight copy of POSITION and it's always emitted. */ + vs_outputs->wpos = i; } -static void r300_shader_vap_output_fmt(struct r300_vertex_shader* vs) +/* This function sets up: + * - VAP mapping, which maps VS registers to output semantics and + * at the same time it indicates which attributes are enabled and should + * be rasterized. + * - Stream mapping to VS outputs if TCL is not present. */ +static void r300_init_vs_output_mapping(struct r300_vertex_shader* vs) { struct r300_shader_semantics* vs_outputs = &vs->outputs; - uint32_t* hwfmt = vs->hwfmt; - int i, gen_count; + struct r300_vap_output_state *vap_out = &vs->vap_out; + int *stream_loc = vs->stream_loc_notcl; + int i, gen_count, tabi = 0; boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED || vs_outputs->bcolor[1] != ATTR_UNUSED; - /* Do the actual vertex_info setup. - * - * vertex_info has four uints of hardware-specific data in it. - * vinfo.hwfmt[0] is R300_VAP_VTX_STATE_CNTL - * vinfo.hwfmt[1] is R300_VAP_VSM_VTX_ASSM - * vinfo.hwfmt[2] is R300_VAP_OUTPUT_VTX_FMT_0 - * vinfo.hwfmt[3] is R300_VAP_OUTPUT_VTX_FMT_1 */ - - hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */ + vap_out->vap_vtx_state_cntl = 0x5555; /* XXX this is classic Mesa bonghits */ /* Position. */ if (vs_outputs->pos != ATTR_UNUSED) { - hwfmt[1] |= R300_INPUT_CNTL_POS; - hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_POS; + vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT; + + stream_loc[tabi++] = 0; } else { assert(0); } /* Point size. */ if (vs_outputs->psize != ATTR_UNUSED) { - hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - } - - /* Colors. */ - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || - vs_outputs->color[1] != ATTR_UNUSED) { - hwfmt[1] |= R300_INPUT_CNTL_COLOR; - hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i; - } - } - - /* Back-face colors. */ - if (any_bcolor_used) { - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - hwfmt[1] |= R300_INPUT_CNTL_COLOR; - hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); - } - } + vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT; - /* Texture coordinates. */ - gen_count = 0; - for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED) { - hwfmt[1] |= (R300_INPUT_CNTL_TC0 << gen_count); - hwfmt[3] |= (4 << (3 * gen_count)); - gen_count++; - } - } - - /* Fog coordinates. */ - if (vs_outputs->fog != ATTR_UNUSED) { - hwfmt[1] |= (R300_INPUT_CNTL_TC0 << gen_count); - hwfmt[3] |= (4 << (3 * gen_count)); - gen_count++; - } - - /* XXX magic */ - assert(gen_count <= 8); - - /* WPOS. */ - vs->wpos_tex_output = gen_count; -} - -/* Sets up stream mapping to equivalent VS outputs if TCL is bypassed - * or isn't present. */ -static void r300_stream_locations_notcl( - struct r300_shader_semantics* vs_outputs, - int* stream_loc) -{ - int i, tabi = 0, gen_count; - boolean any_bcolor_used = vs_outputs->bcolor[0] != ATTR_UNUSED || - vs_outputs->bcolor[1] != ATTR_UNUSED; - - /* Position. */ - stream_loc[tabi++] = 0; - - /* Point size. */ - if (vs_outputs->psize != ATTR_UNUSED) { stream_loc[tabi++] = 1; } @@ -185,6 +131,9 @@ static void r300_stream_locations_notcl( for (i = 0; i < ATTR_COLOR_COUNT; i++) { if (vs_outputs->color[i] != ATTR_UNUSED || any_bcolor_used || vs_outputs->color[1] != ATTR_UNUSED) { + vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; + vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i; + stream_loc[tabi++] = 2 + i; } } @@ -192,6 +141,9 @@ static void r300_stream_locations_notcl( /* Back-face colors. */ if (any_bcolor_used) { for (i = 0; i < ATTR_COLOR_COUNT; i++) { + vap_out->vap_vsm_vtx_assm |= R300_INPUT_CNTL_COLOR; + vap_out->vap_out_vtx_fmt[0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << (2+i); + stream_loc[tabi++] = 4 + i; } } @@ -200,6 +152,9 @@ static void r300_stream_locations_notcl( gen_count = 0; for (i = 0; i < ATTR_GENERIC_COUNT; i++) { if (vs_outputs->generic[i] != ATTR_UNUSED) { + vap_out->vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << gen_count); + vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * gen_count)); + assert(tabi < 16); stream_loc[tabi++] = 6 + gen_count; gen_count++; @@ -208,17 +163,22 @@ static void r300_stream_locations_notcl( /* Fog coordinates. */ if (vs_outputs->fog != ATTR_UNUSED) { + vap_out->vap_vsm_vtx_assm |= (R300_INPUT_CNTL_TC0 << gen_count); + vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * gen_count)); + assert(tabi < 16); stream_loc[tabi++] = 6 + gen_count; gen_count++; } + /* XXX magic */ + assert(gen_count <= 8); + /* WPOS. */ - if (vs_outputs->wpos != ATTR_UNUSED) { - assert(tabi < 16); - stream_loc[tabi++] = 6 + gen_count; - gen_count++; - } + vs->wpos_tex_output = gen_count; + + assert(tabi < 16); + stream_loc[tabi++] = 6 + gen_count; for (; tabi < 16;) { stream_loc[tabi++] = -1; @@ -294,26 +254,16 @@ static void set_vertex_inputs_outputs(struct r300_vertex_program_compiler * c) } } -static void r300_insert_wpos(struct r300_vertex_program_compiler* c, - struct r300_shader_semantics* outputs) +void r300_vertex_shader_common_init(struct r300_vertex_shader *vs, + const struct pipe_shader_state *shader) { - int i, lastOutput = 0; - - /* Find the max output index. */ - lastOutput = MAX2(lastOutput, outputs->psize); - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - lastOutput = MAX2(lastOutput, outputs->color[i]); - lastOutput = MAX2(lastOutput, outputs->bcolor[i]); - } - for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - lastOutput = MAX2(lastOutput, outputs->generic[i]); - } - lastOutput = MAX2(lastOutput, outputs->fog); + /* Copy state directly into shader. */ + vs->state = *shader; + vs->state.tokens = tgsi_dup_tokens(shader->tokens); + tgsi_scan_shader(shader->tokens, &vs->info); - /* Set WPOS after the last output. */ - lastOutput++; - rc_copy_output(&c->Base, 0, lastOutput); /* out[lastOutput] = out[0]; */ - outputs->wpos = lastOutput; + r300_shader_read_vs_outputs(&vs->info, &vs->outputs); + r300_init_vs_output_mapping(vs); } void r300_translate_vertex_shader(struct r300_context* r300, @@ -322,9 +272,6 @@ void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_program_compiler compiler; struct tgsi_to_rc ttr; - /* Initialize. */ - r300_shader_read_vs_outputs(&vs->info, &vs->outputs); - /* Setup the compiler */ rc_init(&compiler.Base); @@ -348,10 +295,7 @@ void r300_translate_vertex_shader(struct r300_context* r300, compiler.SetHwInputOutput = &set_vertex_inputs_outputs; /* Insert the WPOS output. */ - r300_insert_wpos(&compiler, &vs->outputs); - - r300_shader_vap_output_fmt(vs); - r300_stream_locations_notcl(&vs->outputs, vs->stream_loc_notcl); + rc_copy_output(&compiler.Base, 0, vs->outputs.wpos); /* Invoke the compiler */ r3xx_compile_vertex_program(&compiler); @@ -363,30 +307,29 @@ void r300_translate_vertex_shader(struct r300_context* r300, /* And, finally... */ rc_destroy(&compiler.Base); - vs->translated = TRUE; } boolean r300_vertex_shader_setup_wpos(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; + struct r300_vap_output_state *vap_out = &vs->vap_out; int tex_output = vs->wpos_tex_output; uint32_t tex_fmt = R300_INPUT_CNTL_TC0 << tex_output; - uint32_t* hwfmt = vs->hwfmt; if (r300->fs->inputs.wpos != ATTR_UNUSED) { /* Enable WPOS in VAP. */ - if (!(hwfmt[1] & tex_fmt)) { - hwfmt[1] |= tex_fmt; - hwfmt[3] |= (4 << (3 * tex_output)); + if (!(vap_out->vap_vsm_vtx_assm & tex_fmt)) { + vap_out->vap_vsm_vtx_assm |= tex_fmt; + vap_out->vap_out_vtx_fmt[1] |= (4 << (3 * tex_output)); assert(tex_output < 8); return TRUE; } } else { /* Disable WPOS in VAP. */ - if (hwfmt[1] & tex_fmt) { - hwfmt[1] &= ~tex_fmt; - hwfmt[3] &= ~(4 << (3 * tex_output)); + if (vap_out->vap_vsm_vtx_assm & tex_fmt) { + vap_out->vap_vsm_vtx_assm &= ~tex_fmt; + vap_out->vap_out_vtx_fmt[1] &= ~(4 << (3 * tex_output)); return TRUE; } } diff --git a/src/gallium/drivers/r300/r300_vs.h b/src/gallium/drivers/r300/r300_vs.h index 18cfeee3cd..f6f0b86b68 100644 --- a/src/gallium/drivers/r300/r300_vs.h +++ b/src/gallium/drivers/r300/r300_vs.h @@ -28,6 +28,7 @@ #include "tgsi/tgsi_scan.h" #include "radeon_code.h" +#include "r300_context.h" #include "r300_shader_semantics.h" struct r300_context; @@ -38,7 +39,7 @@ struct r300_vertex_shader { struct tgsi_shader_info info; struct r300_shader_semantics outputs; - uint hwfmt[4]; + struct r300_vap_output_state vap_out; /* Stream locations for SWTCL or if TCL is bypassed. */ int stream_loc_notcl[16]; @@ -46,13 +47,17 @@ struct r300_vertex_shader { /* Output stream location for WPOS. */ int wpos_tex_output; - /* Has this shader been translated yet? */ - boolean translated; - + /* HWTCL-specific. */ /* Machine code (if translated) */ struct r300_vertex_program_code code; + + /* SWTCL-specific. */ + void *draw_vs; }; +void r300_vertex_shader_common_init(struct r300_vertex_shader *vs, + const struct pipe_shader_state *shader); + void r300_translate_vertex_shader(struct r300_context* r300, struct r300_vertex_shader* vs); -- cgit v1.2.3 From b03b70f6586baf3ff419be28817f61e6c4bacfb5 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 02:40:57 +0100 Subject: r300g: validate buffers when using SWTCL --- src/gallium/drivers/r300/r300_render.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 073664fa45..c8420bcdd5 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -186,7 +186,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, dwords = 10 + count * vertex_size; r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); - r300_emit_buffer_validate(r300, FALSE, 0); + r300_emit_buffer_validate(r300, FALSE, NULL); r300_emit_dirty_state(r300); BEGIN_CS(dwords); @@ -450,7 +450,7 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, /* Make sure there are at least 128 spare dwords in the command buffer. * (most of it being consumed by emit_aos) */ r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128); - r300_emit_buffer_validate(r300, TRUE, 0); + r300_emit_buffer_validate(r300, TRUE, NULL); r300_emit_dirty_state(r300); if (alt_num_verts || count <= 65535) { @@ -468,7 +468,7 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode, /* Again, we emit both AOS and draw_arrays so there should be * at least 128 spare dwords. */ if (count && r300_reserve_cs_space(r300, 128)) { - r300_emit_buffer_validate(r300, TRUE, 0); + r300_emit_buffer_validate(r300, TRUE, NULL); r300_emit_dirty_state(r300); } } while (count); @@ -688,6 +688,7 @@ static void r300_render_draw_arrays(struct vbuf_render* render, CS_LOCALS(r300); r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 2); + r300_emit_buffer_validate(r300, FALSE, NULL); r300_emit_dirty_state(r300); DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); @@ -711,6 +712,7 @@ static void r300_render_draw(struct vbuf_render* render, CS_LOCALS(r300); r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); + r300_emit_buffer_validate(r300, FALSE, NULL); r300_emit_dirty_state(r300); BEGIN_CS(dwords); -- cgit v1.2.3 From 81992f37da64c2c89ce108e6b17159eee6085e5d Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 03:00:07 +0100 Subject: r300g: resurrect r300_emit_vertex_buffer for SWTCL Taken over from c9928ac3ee5dc0d10127388f9312779a6c59da7c. --- src/gallium/drivers/r300/r300_emit.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index addb28bded..03da4754b7 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -794,6 +794,30 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset) END_CS; } +void r300_emit_vertex_buffer(struct r300_context* r300) +{ + CS_LOCALS(r300); + + DBG(r300, DBG_DRAW, "r300: Preparing vertex buffer %p for render, " + "vertex size %d\n", r300->vbo, + r300->vertex_info.size); + /* Set the pointer to our vertex buffer. The emitted values are this: + * PACKET3 [3D_LOAD_VBPNTR] + * COUNT [1] + * FORMAT [size | stride << 8] + * OFFSET [offset into BO] + * VBPNTR [relocated BO] + */ + BEGIN_CS(7); + OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); + OUT_CS(1); + OUT_CS(r300->vertex_info.size | + (r300->vertex_info.size << 8)); + OUT_CS(r300->vbo_offset); + OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + END_CS; +} + void r300_emit_vertex_stream_state(struct r300_context* r300, unsigned size, void* state) { @@ -1135,8 +1159,10 @@ void r300_emit_dirty_state(struct r300_context* r300) assert(r300->dirty_state == 0); */ - /* Finally, emit the VBO. */ - /* r300_emit_vertex_buffer(r300); */ + /* Emit the VBO for SWTCL. */ + if (!r300screen->caps->has_tcl) { + r300_emit_vertex_buffer(r300); + } r300->dirty_hw++; } -- cgit v1.2.3 From 690ded32cdda4363c30aca32ef94383ba356a3c5 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 03:17:58 +0100 Subject: r300g: disable emitting the HWTCL-related state when SWTCL is in use Now SWTCL renders at least "something", we're close... --- src/gallium/drivers/r300/r300_context.c | 1 - src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/drivers/r300/r300_flush.c | 6 ++++++ src/gallium/drivers/r300/r300_state.c | 6 ++++-- 4 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 86b98a4ba5..ec1c586522 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -212,7 +212,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->invariant_state.dirty = TRUE; r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300); - r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw++; r300->blitter = util_blitter_create(&r300->context); diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 03da4754b7..a1d31d57b8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -892,7 +892,7 @@ void r300_emit_vs_state(struct r300_context* r300, unsigned size, void* state) CS_LOCALS(r300); if (!r300screen->caps->has_tcl) { - debug_printf("r300: Implementation error: emit_vertex_shader called," + debug_printf("r300: Implementation error: emit_vs_state called," " but has_tcl is FALSE!\n"); return; } @@ -931,7 +931,7 @@ void r300_emit_vs_constant_buffer(struct r300_context* r300, CS_LOCALS(r300); if (!r300screen->caps->has_tcl) { - debug_printf("r300: Implementation error: emit_vertex_shader called," + debug_printf("r300: Implementation error: emit_vs_constant_buffer called," " but has_tcl is FALSE!\n"); return; } diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index e37d309270..70de152713 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -61,6 +61,12 @@ static void r300_flush(struct pipe_context* pipe, atom->dirty = TRUE; } } + + /* Unmark HWTCL state for SWTCL. */ + if (!r300_screen(pipe->screen)->caps->has_tcl) { + r300->vs_state.dirty = FALSE; + r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS; + } } /* reset flushed query */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 381676e09a..de3ee0eefb 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1203,8 +1203,10 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, pipe_buffer_unmap(pipe->screen, buf); if (shader == PIPE_SHADER_VERTEX) { - r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; - r300->pvs_flush.dirty = TRUE; + if (r300screen->caps->has_tcl) { + r300->dirty_state |= R300_NEW_VERTEX_SHADER_CONSTANTS; + r300->pvs_flush.dirty = TRUE; + } } else if (shader == PIPE_SHADER_FRAGMENT) r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; -- cgit v1.2.3 From 661b416e07004655af3f372114119e4f8166496e Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Sat, 6 Mar 2010 20:30:28 -0800 Subject: gallivm: Initialize variables for default cases. Fixes use of uninitialized variables in non-debug builds. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index bc2f307c33..9058f76c1d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -538,6 +538,9 @@ lp_build_sample_wrap_linear(struct lp_build_sample_context *bld, default: assert(0); + coord0 = NULL; + coord1 = NULL; + weight = NULL; } *x0_out = coord0; @@ -700,6 +703,7 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, default: assert(0); + icoord = NULL; } return icoord; -- cgit v1.2.3 From 4012219f1f215cec9406be644b6b9d421bb5d8e4 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 6 Feb 2010 03:11:50 +0100 Subject: r300g: move r300_transfer to separate files --- src/gallium/drivers/r300/Makefile | 3 +- src/gallium/drivers/r300/SConscript | 1 + src/gallium/drivers/r300/r300_screen.c | 74 ++-------------------- src/gallium/drivers/r300/r300_screen.h | 16 +---- src/gallium/drivers/r300/r300_transfer.c | 101 +++++++++++++++++++++++++++++++ src/gallium/drivers/r300/r300_transfer.h | 60 ++++++++++++++++++ 6 files changed, 171 insertions(+), 84 deletions(-) create mode 100644 src/gallium/drivers/r300/r300_transfer.c create mode 100644 src/gallium/drivers/r300/r300_transfer.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 1f69daec81..61b54af4dd 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -19,7 +19,8 @@ C_SOURCES = \ r300_state_invariant.c \ r300_vs.c \ r300_texture.c \ - r300_tgsi_to_rc.c + r300_tgsi_to_rc.c \ + r300_transfer.c LIBRARY_INCLUDES = \ -I$(TOP)/src/mesa/drivers/dri/r300/compiler \ diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript index 183aa17f9b..27b2e30993 100644 --- a/src/gallium/drivers/r300/SConscript +++ b/src/gallium/drivers/r300/SConscript @@ -30,6 +30,7 @@ r300 = env.ConvenienceLibrary( 'r300_vs.c', 'r300_texture.c', 'r300_tgsi_to_rc.c', + 'r300_transfer.c', ] + r300compiler) + r300compiler Export('r300') diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index d397a8eb2b..a35be05940 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -1,5 +1,6 @@ /* * Copyright 2008 Corbin Simpson + * Copyright 2010 Marek Olšák * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -20,14 +21,13 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "util/u_inlines.h" #include "util/u_format.h" #include "util/u_memory.h" #include "util/u_simple_screen.h" #include "r300_context.h" -#include "r300_screen.h" #include "r300_texture.h" +#include "r300_transfer.h" #include "radeon_winsys.h" #include "r300_winsys.h" @@ -250,70 +250,6 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, return retval == usage; } -static struct pipe_transfer* -r300_get_tex_transfer(struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, unsigned x, unsigned y, - unsigned w, unsigned h) -{ - struct r300_texture *tex = (struct r300_texture *)texture; - struct r300_transfer *trans; - struct r300_screen *rscreen = r300_screen(screen); - unsigned offset; - - offset = r300_texture_get_offset(tex, level, zslice, face); /* in bytes */ - - trans = CALLOC_STRUCT(r300_transfer); - if (trans) { - pipe_texture_reference(&trans->transfer.texture, texture); - trans->transfer.x = x; - trans->transfer.y = y; - trans->transfer.width = w; - trans->transfer.height = h; - trans->transfer.stride = r300_texture_get_stride(rscreen, tex, level); - trans->transfer.usage = usage; - trans->transfer.zslice = zslice; - trans->transfer.face = face; - - trans->offset = offset; - } - return &trans->transfer; -} - -static void -r300_tex_transfer_destroy(struct pipe_transfer *trans) -{ - pipe_texture_reference(&trans->texture, NULL); - FREE(trans); -} - -static void* r300_transfer_map(struct pipe_screen* screen, - struct pipe_transfer* transfer) -{ - struct r300_texture* tex = (struct r300_texture*)transfer->texture; - char* map; - enum pipe_format format = tex->tex.format; - - map = pipe_buffer_map(screen, tex->buffer, - pipe_transfer_buffer_flags(transfer)); - - if (!map) { - return NULL; - } - - return map + r300_transfer(transfer)->offset + - transfer->y / util_format_get_blockheight(format) * transfer->stride + - transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); -} - -static void r300_transfer_unmap(struct pipe_screen* screen, - struct pipe_transfer* transfer) -{ - struct r300_texture* tex = (struct r300_texture*)transfer->texture; - pipe_buffer_unmap(screen, tex->buffer); -} - static void r300_destroy_screen(struct pipe_screen* pscreen) { struct r300_screen* r300screen = r300_screen(pscreen); @@ -350,13 +286,11 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys) r300screen->screen.get_paramf = r300_get_paramf; r300screen->screen.is_format_supported = r300_is_format_supported; r300screen->screen.context_create = r300_create_context; - r300screen->screen.get_tex_transfer = r300_get_tex_transfer; - r300screen->screen.tex_transfer_destroy = r300_tex_transfer_destroy; - r300screen->screen.transfer_map = r300_transfer_map; - r300screen->screen.transfer_unmap = r300_transfer_unmap; r300_init_screen_texture_functions(&r300screen->screen); + r300_init_screen_transfer_functions(&r300screen->screen); u_simple_screen_init(&r300screen->screen); return &r300screen->screen; } + diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 502fbfa5a2..6d72fec778 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -1,5 +1,6 @@ /* * Copyright 2008 Corbin Simpson + * Copyright 2010 Marek Olšák * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -42,25 +43,14 @@ struct r300_screen { unsigned debug; }; -struct r300_transfer { - /* Parent class */ - struct pipe_transfer transfer; - - /* Offset from start of buffer. */ - unsigned offset; -}; /* Convenience cast wrapper. */ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) { return (struct r300_screen*)screen; } -/* Convenience cast wrapper. */ -static INLINE struct r300_transfer* -r300_transfer(struct pipe_transfer* transfer) -{ - return (struct r300_transfer*)transfer; -} +/* Creates a new r300 screen. */ +struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys); /* Debug functionality. */ diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c new file mode 100644 index 0000000000..fa48688db2 --- /dev/null +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -0,0 +1,101 @@ +/* + * Copyright 2008 Corbin Simpson + * Copyright 2010 Marek Olšák + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#include "r300_context.h" +#include "r300_transfer.h" +#include "r300_texture.h" +#include "r300_screen.h" + +#include "util/u_memory.h" +#include "util/u_format.h" + +static struct pipe_transfer* +r300_get_tex_transfer(struct pipe_screen *screen, + struct pipe_texture *texture, + unsigned face, unsigned level, unsigned zslice, + enum pipe_transfer_usage usage, unsigned x, unsigned y, + unsigned w, unsigned h) +{ + struct r300_texture *tex = (struct r300_texture *)texture; + struct r300_transfer *trans; + struct r300_screen *rscreen = r300_screen(screen); + unsigned offset; + + offset = r300_texture_get_offset(tex, level, zslice, face); /* in bytes */ + + trans = CALLOC_STRUCT(r300_transfer); + if (trans) { + pipe_texture_reference(&trans->transfer.texture, texture); + trans->transfer.x = x; + trans->transfer.y = y; + trans->transfer.width = w; + trans->transfer.height = h; + trans->transfer.stride = r300_texture_get_stride(rscreen, tex, level); + trans->transfer.usage = usage; + trans->transfer.zslice = zslice; + trans->transfer.face = face; + + trans->offset = offset; + } + return &trans->transfer; +} + +static void r300_tex_transfer_destroy(struct pipe_transfer *trans) +{ + pipe_texture_reference(&trans->texture, NULL); + FREE(trans); +} + +static void* r300_transfer_map(struct pipe_screen *screen, + struct pipe_transfer *transfer) +{ + struct r300_texture *tex = (struct r300_texture*)transfer->texture; + char *map; + enum pipe_format format = tex->tex.format; + + map = pipe_buffer_map(screen, tex->buffer, + pipe_transfer_buffer_flags(transfer)); + + if (!map) { + return NULL; + } + + return map + r300_transfer(transfer)->offset + + transfer->y / util_format_get_blockheight(format) * transfer->stride + + transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); +} + +static void r300_transfer_unmap(struct pipe_screen *screen, + struct pipe_transfer *transfer) +{ + struct r300_texture *tex = (struct r300_texture*)transfer->texture; + pipe_buffer_unmap(screen, tex->buffer); +} + +void r300_init_screen_transfer_functions(struct pipe_screen *screen) +{ + screen->get_tex_transfer = r300_get_tex_transfer; + screen->tex_transfer_destroy = r300_tex_transfer_destroy; + screen->transfer_map = r300_transfer_map; + screen->transfer_unmap = r300_transfer_unmap; +} diff --git a/src/gallium/drivers/r300/r300_transfer.h b/src/gallium/drivers/r300/r300_transfer.h new file mode 100644 index 0000000000..faf62338ef --- /dev/null +++ b/src/gallium/drivers/r300/r300_transfer.h @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Corbin Simpson + * Copyright 2010 Marek Olšák + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. */ + +#ifndef R300_TRANSFER +#define R300_TRANSFER + +#include "pipe/p_screen.h" +#include "pipe/p_state.h" + +struct r300_texture; +struct r300_screen; + +struct r300_transfer { + /* Parent class */ + struct pipe_transfer transfer; + + /* Parameters of get_tex_transfer. */ + unsigned x, y, level, zslice, face; + + /* Offset from start of buffer. */ + unsigned offset; + + /* Untiled texture. */ + struct r300_texture *untiled_texture; + + /* Transfer and format flags. */ + unsigned buffer_usage, render_target_usage; +}; + +/* Convenience cast wrapper. */ +static INLINE struct r300_transfer* +r300_transfer(struct pipe_transfer* transfer) +{ + return (struct r300_transfer*)transfer; +} + +void r300_init_screen_transfer_functions(struct pipe_screen *screen); + +#endif + -- cgit v1.2.3 From 6c7fac846ef99cde5305cf1011b4570bd1901625 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 14 Feb 2010 03:19:01 +0100 Subject: r300g: add ability to tile/detile textures using blit during transfers --- src/gallium/drivers/r300/r300_context.c | 2 + src/gallium/drivers/r300/r300_screen.h | 6 + src/gallium/drivers/r300/r300_texture.c | 5 +- src/gallium/drivers/r300/r300_transfer.c | 210 +++++++++++++++++++++++++++---- src/gallium/drivers/r300/r300_transfer.h | 29 ----- 5 files changed, 197 insertions(+), 55 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index ec1c586522..e43e088b36 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -159,6 +159,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, if (!r300) return NULL; + r300screen->ctx = (struct pipe_context*)r300; + r300->winsys = radeon_winsys; r300->context.winsys = (struct pipe_winsys*)radeon_winsys; diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h index 6d72fec778..484bde6a6b 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -28,6 +28,8 @@ #include "r300_chipset.h" +#define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM + struct radeon_winsys; struct r300_screen { @@ -36,6 +38,10 @@ struct r300_screen { struct radeon_winsys* radeon_winsys; + /* XXX This hack will be removed once texture transfers become part of + * pipe_context. */ + struct pipe_context* ctx; + /* Chipset capabilities */ struct r300_capabilities* caps; diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index c0144f64b4..04e326eb78 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -725,9 +725,8 @@ static void r300_setup_flags(struct r300_texture* tex) } /* Create a new texture. */ -static struct pipe_texture* - r300_texture_create(struct pipe_screen* screen, - const struct pipe_texture* template) +static struct pipe_texture* r300_texture_create(struct pipe_screen* screen, + const struct pipe_texture* template) { struct r300_texture* tex = CALLOC_STRUCT(r300_texture); struct r300_screen* rscreen = r300_screen(screen); diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index fa48688db2..56a6976e8b 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -29,6 +29,89 @@ #include "util/u_memory.h" #include "util/u_format.h" +struct r300_transfer { + /* Parent class */ + struct pipe_transfer transfer; + + /* Pipe context. */ + struct pipe_context *ctx; + + /* Parameters of get_tex_transfer. */ + unsigned x, y, level, zslice, face; + + /* Offset from start of buffer. */ + unsigned offset; + + /* Detiled texture. */ + struct r300_texture *detiled_texture; + + /* Transfer and format flags. */ + unsigned buffer_usage, render_target_usage; +}; + +/* Convenience cast wrapper. */ +static INLINE struct r300_transfer* +r300_transfer(struct pipe_transfer* transfer) +{ + return (struct r300_transfer*)transfer; +} + +/* Copy from a tiled texture to a detiled one. */ +static void r300_copy_from_tiled_texture(struct pipe_context *ctx, + struct r300_transfer *r300transfer) +{ + struct pipe_screen *screen = ctx->screen; + struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer; + struct pipe_texture *tex = transfer->texture; + struct pipe_surface *src, *dst; + + src = screen->get_tex_surface(screen, tex, r300transfer->face, + r300transfer->level, r300transfer->zslice, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_PIXEL); + + dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->tex, + 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_WRITE | + PIPE_BUFFER_USAGE_PIXEL | + r300transfer->buffer_usage); + + ctx->surface_copy(ctx, dst, 0, 0, src, r300transfer->x, r300transfer->y, + transfer->width, transfer->height); + + pipe_surface_reference(&src, NULL); + pipe_surface_reference(&dst, NULL); +} + +/* Copy a detiled texture to a tiled one. */ +static void r300_copy_into_tiled_texture(struct pipe_context *ctx, + struct r300_transfer *r300transfer) +{ + struct pipe_screen *screen = ctx->screen; + struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer; + struct pipe_texture *tex = transfer->texture; + struct pipe_surface *src, *dst; + + src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->tex, + 0, 0, 0, + PIPE_BUFFER_USAGE_GPU_READ | + PIPE_BUFFER_USAGE_PIXEL); + + dst = screen->get_tex_surface(screen, tex, r300transfer->face, + r300transfer->level, r300transfer->zslice, + PIPE_BUFFER_USAGE_GPU_WRITE | + PIPE_BUFFER_USAGE_PIXEL); + + ctx->surface_copy(ctx, dst, r300transfer->x, r300transfer->y, src, 0, 0, + transfer->width, transfer->height); + + /* XXX this flush fixes lots of regressions, not sure why */ + ctx->flush(ctx, 0, NULL); + + pipe_surface_reference(&src, NULL); + pipe_surface_reference(&dst, NULL); +} + static struct pipe_transfer* r300_get_tex_transfer(struct pipe_screen *screen, struct pipe_texture *texture, @@ -38,58 +121,139 @@ r300_get_tex_transfer(struct pipe_screen *screen, { struct r300_texture *tex = (struct r300_texture *)texture; struct r300_transfer *trans; - struct r300_screen *rscreen = r300_screen(screen); - unsigned offset; - - offset = r300_texture_get_offset(tex, level, zslice, face); /* in bytes */ + struct r300_screen *r300screen = r300_screen(screen); + struct pipe_texture template; trans = CALLOC_STRUCT(r300_transfer); if (trans) { + /* Initialize the transfer object. */ pipe_texture_reference(&trans->transfer.texture, texture); - trans->transfer.x = x; - trans->transfer.y = y; + trans->transfer.usage = usage; trans->transfer.width = w; trans->transfer.height = h; - trans->transfer.stride = r300_texture_get_stride(rscreen, tex, level); - trans->transfer.usage = usage; - trans->transfer.zslice = zslice; - trans->transfer.face = face; + trans->ctx = r300screen->ctx; + trans->x = x; + trans->y = y; + trans->level = level; + trans->zslice = zslice; + trans->face = face; + + /* If the texture is tiled, we must create a temporary detiled texture + * for this transfer. */ + if (tex->microtile || tex->macrotile) { + trans->buffer_usage = pipe_transfer_buffer_flags(&trans->transfer); + trans->render_target_usage = + util_format_is_depth_or_stencil(texture->format) ? + PIPE_TEXTURE_USAGE_DEPTH_STENCIL : + PIPE_TEXTURE_USAGE_RENDER_TARGET; + + template.target = PIPE_TEXTURE_2D; + template.format = texture->format; + template.width0 = w; + template.height0 = h; + template.depth0 = 0; + template.last_level = 0; + template.nr_samples = 0; + template.tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC | + R300_TEXTURE_USAGE_TRANSFER; - trans->offset = offset; + /* For texture reading, the temporary (detiled) texture is used as + * a render target when blitting from a tiled texture. */ + if (usage & PIPE_TRANSFER_READ) { + template.tex_usage |= trans->render_target_usage; + } + /* For texture writing, the temporary texture is used as a sampler + * when blitting into a tiled texture. */ + if (usage & PIPE_TRANSFER_WRITE) { + template.tex_usage |= PIPE_TEXTURE_USAGE_SAMPLER; + } + + /* Create the temporary texture. */ + trans->detiled_texture = + (struct r300_texture*)screen->texture_create(screen, &template); + assert(!trans->detiled_texture->microtile && + !trans->detiled_texture->macrotile); + + /* Set the stride. + * Parameters x, y, level, zslice, and face remain zero. */ + trans->transfer.stride = + r300_texture_get_stride(r300screen, trans->detiled_texture, 0); + + if (usage & PIPE_TRANSFER_READ) { + /* We cannot map a tiled texture directly because the data is + * in a different order, therefore we do detiling using a blit. */ + r300_copy_from_tiled_texture(r300screen->ctx, trans); + } + } else { + trans->transfer.x = x; + trans->transfer.y = y; + trans->transfer.stride = + r300_texture_get_stride(r300screen, tex, level); + trans->transfer.level = level; + trans->transfer.zslice = zslice; + trans->transfer.face = face; + trans->offset = r300_texture_get_offset(tex, level, zslice, face); + } } return &trans->transfer; } static void r300_tex_transfer_destroy(struct pipe_transfer *trans) { - pipe_texture_reference(&trans->texture, NULL); - FREE(trans); + struct r300_transfer *r300transfer = r300_transfer(trans); + + if (r300transfer->detiled_texture) { + if (trans->usage & PIPE_TRANSFER_WRITE) { + r300_copy_into_tiled_texture(r300transfer->ctx, r300transfer); + } + + pipe_texture_reference( + (struct pipe_texture**)&r300transfer->detiled_texture, NULL); + } + pipe_texture_reference(&trans->texture, NULL); + FREE(trans); } static void* r300_transfer_map(struct pipe_screen *screen, - struct pipe_transfer *transfer) + struct pipe_transfer *transfer) { + struct r300_transfer *r300transfer = r300_transfer(transfer); struct r300_texture *tex = (struct r300_texture*)transfer->texture; char *map; enum pipe_format format = tex->tex.format; - map = pipe_buffer_map(screen, tex->buffer, - pipe_transfer_buffer_flags(transfer)); + if (r300transfer->detiled_texture) { + /* The detiled texture is of the same size as the region being mapped + * (no offset needed). */ + return pipe_buffer_map(screen, + r300transfer->detiled_texture->buffer, + pipe_transfer_buffer_flags(transfer)); + } else { + /* Tiling is disabled. */ + map = pipe_buffer_map(screen, tex->buffer, + pipe_transfer_buffer_flags(transfer)); - if (!map) { - return NULL; - } + if (!map) { + return NULL; + } - return map + r300_transfer(transfer)->offset + - transfer->y / util_format_get_blockheight(format) * transfer->stride + - transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); + return map + r300_transfer(transfer)->offset + + transfer->y / util_format_get_blockheight(format) * transfer->stride + + transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); + } } static void r300_transfer_unmap(struct pipe_screen *screen, struct pipe_transfer *transfer) { + struct r300_transfer *r300transfer = r300_transfer(transfer); struct r300_texture *tex = (struct r300_texture*)transfer->texture; - pipe_buffer_unmap(screen, tex->buffer); + + if (r300transfer->detiled_texture) { + pipe_buffer_unmap(screen, r300transfer->detiled_texture->buffer); + } else { + pipe_buffer_unmap(screen, tex->buffer); + } } void r300_init_screen_transfer_functions(struct pipe_screen *screen) diff --git a/src/gallium/drivers/r300/r300_transfer.h b/src/gallium/drivers/r300/r300_transfer.h index faf62338ef..60d1d3dc85 100644 --- a/src/gallium/drivers/r300/r300_transfer.h +++ b/src/gallium/drivers/r300/r300_transfer.h @@ -25,36 +25,7 @@ #define R300_TRANSFER #include "pipe/p_screen.h" -#include "pipe/p_state.h" - -struct r300_texture; -struct r300_screen; - -struct r300_transfer { - /* Parent class */ - struct pipe_transfer transfer; - - /* Parameters of get_tex_transfer. */ - unsigned x, y, level, zslice, face; - - /* Offset from start of buffer. */ - unsigned offset; - - /* Untiled texture. */ - struct r300_texture *untiled_texture; - - /* Transfer and format flags. */ - unsigned buffer_usage, render_target_usage; -}; - -/* Convenience cast wrapper. */ -static INLINE struct r300_transfer* -r300_transfer(struct pipe_transfer* transfer) -{ - return (struct r300_transfer*)transfer; -} void r300_init_screen_transfer_functions(struct pipe_screen *screen); #endif - -- cgit v1.2.3 From b37d63337596aabc543ea7ecfa82f0f9fdbade69 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 14 Feb 2010 04:57:09 +0100 Subject: r300g: enable micro- and macrotiling for all textures and renderbuffers --- src/gallium/drivers/r300/r300_texture.c | 39 +++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 04e326eb78..0736155d52 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -724,6 +724,42 @@ static void r300_setup_flags(struct r300_texture* tex) !util_is_power_of_two(tex->tex.height0); } +static void r300_setup_tiling(struct pipe_screen *screen, + struct r300_texture *tex) +{ + enum pipe_format format = tex->tex.format; + boolean rv350_mode = r300_screen(screen)->caps->family >= CHIP_FAMILY_RV350; + + if (util_format_is_compressed(format)) { + return; + } + + if (tex->tex.width0 == 1 || + tex->tex.height0 == 1) { + return; + } + + /* Set microtiling. */ + switch (util_format_get_blocksize(format)) { + case 1: + case 4: + tex->microtile = R300_BUFFER_TILED; + break; + + /* XXX Square-tiling doesn't work with kernel older than 2.6.34, + * XXX need to check the DRM version */ + /*case 2: + case 8: + tex->microtile = R300_BUFFER_SQUARETILED; + break;*/ + } + + /* Set macrotiling. */ + if (r300_texture_macro_switch(tex, 0, rv350_mode)) { + tex->macrotile = R300_BUFFER_TILED; + } +} + /* Create a new texture. */ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen, const struct pipe_texture* template) @@ -741,6 +777,9 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen, tex->tex.screen = screen; r300_setup_flags(tex); + if (!(template->tex_usage & R300_TEXTURE_USAGE_TRANSFER)) { + r300_setup_tiling(screen, tex); + } r300_setup_miptree(rscreen, tex); r300_setup_texture_state(rscreen, tex); -- cgit v1.2.3 From 57a1395ec3f8eb01af6cfea3fd6b5903dcc61720 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Fri, 19 Feb 2010 03:02:34 +0100 Subject: r300g: disable macrotiling when the texture height is smaller than a macrotile Otherwise incorrect rendering occurs (no idea why). --- src/gallium/drivers/r300/r300_texture.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 0736155d52..c0da339916 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -617,18 +617,23 @@ static unsigned r300_texture_get_tile_size(struct r300_texture* tex, /* Return true if macrotiling should be enabled on the miplevel. */ static boolean r300_texture_macro_switch(struct r300_texture *tex, unsigned level, - boolean rv350_mode) + boolean rv350_mode, + int dim) { - unsigned tile_width, width; + unsigned tile, texdim; - tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH, TRUE); - width = u_minify(tex->tex.width0, level); + tile = r300_texture_get_tile_size(tex, dim, TRUE); + if (dim == TILE_WIDTH) { + texdim = u_minify(tex->tex.width0, level); + } else { + texdim = u_minify(tex->tex.height0, level); + } /* See TX_FILTER1_n.MACRO_SWITCH. */ if (rv350_mode) { - return width >= tile_width; + return texdim >= tile; } else { - return width > tile_width; + return texdim > tile; } } @@ -692,9 +697,10 @@ static void r300_setup_miptree(struct r300_screen* screen, for (i = 0; i <= base->last_level; i++) { /* Let's see if this miplevel can be macrotiled. */ - tex->mip_macrotile[i] = (tex->macrotile == R300_BUFFER_TILED && - r300_texture_macro_switch(tex, i, rv350_mode)) ? - R300_BUFFER_TILED : R300_BUFFER_LINEAR; + tex->mip_macrotile[i] = + (tex->macrotile == R300_BUFFER_TILED && + r300_texture_macro_switch(tex, i, rv350_mode, TILE_WIDTH)) ? + R300_BUFFER_TILED : R300_BUFFER_LINEAR; stride = r300_texture_get_stride(screen, tex, i); nblocksy = r300_texture_get_nblocksy(tex, i); @@ -755,7 +761,8 @@ static void r300_setup_tiling(struct pipe_screen *screen, } /* Set macrotiling. */ - if (r300_texture_macro_switch(tex, 0, rv350_mode)) { + if (r300_texture_macro_switch(tex, 0, rv350_mode, TILE_WIDTH) && + r300_texture_macro_switch(tex, 0, rv350_mode, TILE_HEIGHT)) { tex->macrotile = R300_BUFFER_TILED; } } -- cgit v1.2.3 From 6b39abb63acba34f0f4f017f06b0c90da79e6e70 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 23 Feb 2010 01:14:44 +0100 Subject: r300g: fix DRM errors --- src/gallium/drivers/r300/r300_transfer.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index 56a6976e8b..ec89681a3c 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -102,10 +102,15 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx, PIPE_BUFFER_USAGE_GPU_WRITE | PIPE_BUFFER_USAGE_PIXEL); + /* XXX this flush prevents the following DRM error from occuring: + * [drm:radeon_cs_ioctl] *ERROR* Failed to parse relocation ! + * Reproducible with perf/copytex. */ + ctx->flush(ctx, 0, NULL); + ctx->surface_copy(ctx, dst, r300transfer->x, r300transfer->y, src, 0, 0, transfer->width, transfer->height); - /* XXX this flush fixes lots of regressions, not sure why */ + /* XXX this flush fixes a few piglit tests (e.g. glean/pixelFormats). */ ctx->flush(ctx, 0, NULL); pipe_surface_reference(&src, NULL); -- cgit v1.2.3 From ee6fbf8d2f4718452c36366a08aa798cdda45ace Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 3 Mar 2010 23:51:13 +0800 Subject: st/vega: Fix OpenVG demo segfaults. When the paint is color, paint_bind_samplers binds a dummy sampler without a texture. It causes demos requiring a sampler (those use a mask or an image) to crash. --- src/gallium/state_trackers/vega/paint.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index caf0c14b74..cdb87d3bf6 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -639,9 +639,6 @@ VGint paint_bind_samplers(struct vg_paint *paint, struct pipe_sampler_state **sa } break; default: - samplers[0] = &paint->pattern.sampler; /* dummy */ - textures[0] = 0; - return 0; break; } return 0; -- cgit v1.2.3 From 6abe6145fb3b642fc2ae1d6ad2cc9de045efe0cb Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 8 Mar 2010 04:31:03 +0100 Subject: r300g: remove unnecessary state emissions and clean up --- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 2 +- src/gallium/drivers/r300/r300_state.c | 37 ++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 15 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 0d1518a05b..8c52d880a3 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -368,6 +368,8 @@ struct r300_context { boolean polygon_offset_enabled; /* Z buffer bit depth. */ uint32_t zbuffer_bpp; + /* Whether scissor is enabled. */ + boolean scissor_enabled; }; /* Convenience cast wrapper. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index a1d31d57b8..51fc590e5d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -675,7 +675,7 @@ void r300_emit_scissor_state(struct r300_context* r300, maxx = fb->width; maxy = fb->height; - if (((struct r300_rs_state*)r300->rs_state.state)->rs.scissor) { + if (r300->scissor_enabled) { minx = MAX2(minx, scissor->minx); miny = MAX2(miny, scissor->miny); maxx = MIN2(maxx, scissor->maxx); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index de3ee0eefb..31259b557f 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -571,6 +571,7 @@ static void { struct r300_context* r300 = r300_context(pipe); struct r300_screen* r300screen = r300_screen(pipe->screen); + struct pipe_framebuffer_state *old_state = r300->fb_state.state; unsigned max_width, max_height; uint32_t zbuffer_bpp = 0; @@ -595,11 +596,24 @@ static void return; } - if (r300->draw) { draw_flush(r300->draw); } + r300->fb_state.dirty = TRUE; + + /* If nr_cbufs is changed from zero to non-zero or vice versa... */ + if (!!old_state->nr_cbufs != !!state->nr_cbufs) { + r300->blend_state.dirty = TRUE; + } + /* If zsbuf is set from NULL to non-NULL or vice versa.. */ + if (!!old_state->zsbuf != !!state->zsbuf) { + r300->dsa_state.dirty = TRUE; + } + if (!r300->scissor_enabled) { + r300->scissor_state.dirty = TRUE; + } + memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) + @@ -607,11 +621,6 @@ static void r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); - /* XXX wait what */ - r300->blend_state.dirty = TRUE; - r300->dsa_state.dirty = TRUE; - r300->fb_state.dirty = TRUE; - r300->scissor_state.dirty = TRUE; /* Polygon offset depends on the zbuffer bit depth. */ if (state->zsbuf && r300->polygon_offset_enabled) { @@ -806,6 +815,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) { struct r300_context* r300 = r300_context(pipe); struct r300_rs_state* rs = (struct r300_rs_state*)state; + boolean scissor_was_enabled = r300->scissor_enabled; if (r300->draw) { draw_flush(r300->draw); @@ -814,20 +824,17 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state) if (rs) { r300->polygon_offset_enabled = rs->rs.offset_cw || rs->rs.offset_ccw; + r300->scissor_enabled = rs->rs.scissor; } else { r300->polygon_offset_enabled = FALSE; + r300->scissor_enabled = FALSE; } UPDATE_STATE(state, r300->rs_state); r300->rs_state.size = 17 + (r300->polygon_offset_enabled ? 5 : 0); - /* XXX Why is this still needed, dammit!? */ - r300->scissor_state.dirty = TRUE; - r300->viewport_state.dirty = TRUE; - - /* XXX Clean these up when we move to atom emits */ - if (r300->fs && r300->fs->inputs.wpos != ATTR_UNUSED) { - r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS; + if (scissor_was_enabled != r300->scissor_enabled) { + r300->scissor_state.dirty = TRUE; } } @@ -972,7 +979,9 @@ static void r300_set_scissor_state(struct pipe_context* pipe, memcpy(r300->scissor_state.state, state, sizeof(struct pipe_scissor_state)); - r300->scissor_state.dirty = TRUE; + if (r300->scissor_enabled) { + r300->scissor_state.dirty = TRUE; + } } static void r300_set_viewport_state(struct pipe_context* pipe, -- cgit v1.2.3 From 9860f652e271d03672ec3e5f0e379170953a1e56 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Mon, 8 Mar 2010 04:38:16 +0100 Subject: r300g: fix updating the tiling flags for the framebuffer state --- src/gallium/drivers/r300/r300_state.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 31259b557f..8c9f604622 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -614,14 +614,13 @@ static void r300->scissor_state.dirty = TRUE; } + r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); + memcpy(r300->fb_state.state, state, sizeof(struct pipe_framebuffer_state)); r300->fb_state.size = (10 * state->nr_cbufs) + (2 * (4 - state->nr_cbufs)) + (state->zsbuf ? 10 : 0) + 8; - r300_fb_update_tiling_flags(r300, r300->fb_state.state, state); - - /* Polygon offset depends on the zbuffer bit depth. */ if (state->zsbuf && r300->polygon_offset_enabled) { switch (util_format_get_blocksize(state->zsbuf->texture->format)) { -- cgit v1.2.3 From 9b7c332d5f099fcf090bee9dbda9c73d7912b211 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 13:35:23 +0000 Subject: winsys/xlib: sketch of cell support --- src/gallium/winsys/xlib/xlib_cell.c | 268 +++--------------------------------- 1 file changed, 20 insertions(+), 248 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c index 1dc9e8fa11..ce4efe8851 100644 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ b/src/gallium/winsys/xlib/xlib_cell.c @@ -32,98 +32,19 @@ * Brian Paul */ -#include "xlib.h" - -#ifdef GALLIUM_CELL - -#include "xm_api.h" - -#undef ASSERT -#undef Elements - -#include "util/u_simple_screen.h" -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "cell/ppu/cell_context.h" -#include "cell/ppu/cell_screen.h" -#include "cell/ppu/cell_winsys.h" -#include "cell/ppu/cell_texture.h" - - -/** - * Subclass of pipe_buffer for Xlib winsys. - * Low-level OS/window system memory buffer - */ -struct xm_buffer -{ - struct pipe_buffer base; - boolean userBuffer; /** Is this a user-space buffer? */ - void *data; - void *mapped; - - XImage *tempImage; - int shm; -}; -/** - * Subclass of pipe_winsys for Xlib winsys - */ -struct xmesa_pipe_winsys -{ - struct pipe_winsys base; -}; - - - -/** Cast wrapper */ -static INLINE struct xm_buffer * -xm_buffer( struct pipe_buffer *buf ) -{ - return (struct xm_buffer *)buf; -} +#include "xlib.h" -/* Most callbacks map direcly onto dri_bufmgr operations: - */ -static void * -xm_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, - unsigned flags) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = xm_buf->data; - return xm_buf->mapped; -} - -static void -xm_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct xm_buffer *xm_buf = xm_buffer(buf); - xm_buf->mapped = NULL; -} -static void -xm_buffer_destroy(/*struct pipe_winsys *pws,*/ - struct pipe_buffer *buf) -{ - struct xm_buffer *oldBuf = xm_buffer(buf); +#if defined(GALLIUM_CELL) - if (oldBuf) { - if (oldBuf->data) { - if (!oldBuf->userBuffer) { - align_free(oldBuf->data); - } +#include "cell/ppu/cell_texture.h" +#include "cell/ppu/cell_screen.h" +#include "state_tracker/sw_winsys.h" +#include "util/u_debug.h" - oldBuf->data = NULL; - } - free(oldBuf); - } -} /** @@ -155,15 +76,16 @@ twiddle_tile(const uint *tileIn, uint *tileOut) } } - - /** * Display a surface that's in a tiled configuration. That is, all the * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory. */ static void -xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) +xm_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *winsys_drawable) { + struct xmesa_buffer *xm_buffer = (struct xm_drawable *)winsys_drawable; XImage *ximage; struct xm_buffer *xm_buf = xm_buffer( cell_texture(surf->texture)->buffer); @@ -210,165 +132,21 @@ xlib_cell_display_surface(struct xmesa_buffer *b, struct pipe_surface *surf) - - -static void -xm_flush_frontbuffer(struct pipe_winsys *pws, - struct pipe_surface *surf, - void *context_private) -{ - /* - * The front color buffer is actually just another XImage buffer. - * This function copies that XImage to the actual X Window. - */ - XMesaContext xmctx = (XMesaContext) context_private; - if (xmctx) - xlib_cell_display_surface(xmctx->xm_buffer, surf); -} - - - -static const char * -xm_get_name(struct pipe_winsys *pws) -{ - return "Xlib/Cell"; -} - - -static struct pipe_buffer * -xm_buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.alignment = alignment; - buffer->base.usage = usage; - buffer->base.size = size; - - - if (buffer->data == NULL) { - buffer->shm = 0; - - /* align to 16-byte multiple for Cell */ - buffer->data = align_malloc(size, max(alignment, 16)); - } - - return &buffer->base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -xm_user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct xm_buffer *buffer = CALLOC_STRUCT(xm_buffer); - pipe_reference_init(&buffer->base.reference, 1); - buffer->base.size = bytes; - buffer->userBuffer = TRUE; - buffer->data = ptr; - buffer->shm = 0; - - return &buffer->base; -} - - - -static struct pipe_buffer * -xm_surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - /* XXX a bit of a hack */ - *stride * align(nblocksy, TILE_SIZE)); -} - - -/* - * Fence functions - basically nothing to do, as we don't create any actual - * fence objects. - */ - -static void -xm_fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ -} - - -static int -xm_fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - -static int -xm_fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - return 0; -} - - - -static struct pipe_winsys * -xlib_create_cell_winsys( void ) -{ - static struct xmesa_pipe_winsys *ws = NULL; - - if (!ws) { - ws = CALLOC_STRUCT(xmesa_pipe_winsys); - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->base.buffer_create = xm_buffer_create; - ws->base.user_buffer_create = xm_user_buffer_create; - ws->base.buffer_map = xm_buffer_map; - ws->base.buffer_unmap = xm_buffer_unmap; - ws->base.buffer_destroy = xm_buffer_destroy; - - ws->base.surface_buffer_create = xm_surface_buffer_create; - - ws->base.fence_reference = xm_fence_reference; - ws->base.fence_signalled = xm_fence_signalled; - ws->base.fence_finish = xm_fence_finish; - - ws->base.flush_frontbuffer = xm_flush_frontbuffer; - ws->base.get_name = xm_get_name; - } - - return &ws->base; -} - - static struct pipe_screen * -xlib_create_cell_screen( void ) +xlib_create_cell_screen( Display *dpy ) { - struct pipe_winsys *winsys; + struct sw_winsys *winsys; struct pipe_screen *screen; - winsys = xlib_create_cell_winsys(); + winsys = xlib_create_sw_winsys( dpy ); if (winsys == NULL) return NULL; + /* Plug in a little cell-specific code: + */ + + ws->base.displaytarget_display = xm_cell_displaytarget_display; + screen = cell_create_screen(winsys); if (screen == NULL) goto fail; @@ -384,18 +162,12 @@ fail: + struct xm_driver xlib_cell_driver = { .create_pipe_screen = xlib_create_cell_screen, - .display_surface = xlib_cell_display_surface, }; -#else -struct xm_driver xlib_cell_driver = -{ - .create_pipe_screen = NULL, - .display_surface = NULL, -}; -#endif +#endif /* GALLIUM_CELL */ -- cgit v1.2.3 From 7f9a3959b0a69f6f4b520a87e3ea87918cf89f11 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 15:35:51 +0000 Subject: ws/xlib: remove redundant declarations --- src/gallium/winsys/xlib/xlib.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h index 7f9f910b88..8e091d0c08 100644 --- a/src/gallium/winsys/xlib/xlib.h +++ b/src/gallium/winsys/xlib/xlib.h @@ -9,12 +9,5 @@ extern struct xm_driver xlib_softpipe_driver; extern struct xm_driver xlib_llvmpipe_driver; extern struct xm_driver xlib_cell_driver; -/* Internal: - */ -struct sw_winsys; -struct sw_displaytarget; -struct sw_winsys *xlib_create_sw_winsys( void ); -void xlib_sw_display(struct xmesa_buffer *xm_buffer, - struct sw_displaytarget *dt); #endif -- cgit v1.2.3 From 1675d05f911fbd569efb5248674aa71cb755c75b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 16:20:09 +0000 Subject: winsys/xlib: remove dependency on glx/x11 state tracker Introduce xlib_drawable struct, pass this down to winsys instead of having it use the internal data structures from glx/x11 --- src/gallium/include/state_tracker/xlib_sw_winsys.h | 25 ++++++ src/gallium/state_trackers/glx/xlib/glx_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 91 ++++------------------ src/gallium/state_trackers/glx/xlib/xm_api.h | 18 +---- src/gallium/state_trackers/glx/xlib/xm_winsys.h | 7 +- src/gallium/winsys/xlib/xlib_llvmpipe.c | 8 +- src/gallium/winsys/xlib/xlib_softpipe.c | 4 +- src/gallium/winsys/xlib/xlib_sw_winsys.c | 81 +++++++++++-------- 8 files changed, 103 insertions(+), 133 deletions(-) create mode 100644 src/gallium/include/state_tracker/xlib_sw_winsys.h (limited to 'src/gallium') diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h new file mode 100644 index 0000000000..71d39b9cdb --- /dev/null +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -0,0 +1,25 @@ +#ifndef XLIB_SW_WINSYS_H +#define XLIB_SW_WINSYS_H + +#include "state_tracker/sw_winsys.h" +#include + +struct sw_winsys *xlib_create_sw_winsys( Display *display ); + +/* This is what the xlib software winsys expects to find in the + * "private" field of flush_frontbuffers(). Xlib-based state trackers + * somehow need to know this. + */ +struct xlib_drawable { + Visual *visual; + int depth; + Drawable drawable; + GC gc; /* temporary? */ +}; + +void +xlib_sw_display(struct xlib_drawable *xm_buffer, + struct sw_displaytarget *dt); + + +#endif diff --git a/src/gallium/state_trackers/glx/xlib/glx_api.c b/src/gallium/state_trackers/glx/xlib/glx_api.c index 08bf624b5c..2454585850 100644 --- a/src/gallium/state_trackers/glx/xlib/glx_api.c +++ b/src/gallium/state_trackers/glx/xlib/glx_api.c @@ -689,7 +689,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) int desiredVisualID = -1; int numAux = 0; - xmesa_init(); + xmesa_init( dpy ); parselist = list; diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 217bdeff75..d878740ab1 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -35,10 +35,6 @@ * corner of the window. Therefore, most drawing functions in this * file have to flip Y coordinates. * - * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile - * in support for the MIT Shared Memory extension. If enabled, when you - * use an Ximage for the back buffer in double buffered mode, the "swap" - * operation will be faster. You must also link with -lXext. * * Byte swapping: If the Mesa host and the X display use a different * byte order then there's some trickiness to be aware of when using @@ -111,41 +107,6 @@ static int host_byte_order( void ) } -/** - * Check if the X Shared Memory extension is available. - * Return: 0 = not available - * 1 = shared XImage support available - * 2 = shared Pixmap support available also - */ -int xmesa_check_for_xshm( Display *display ) -{ -#if defined(USE_XSHM) - int major, minor, ignore; - Bool pixmaps; - - if (getenv("SP_NO_RAST")) - return 0; - - if (getenv("MESA_NOSHM")) { - return 0; - } - - if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) { - if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) { - return (pixmaps==True) ? 2 : 1; - } - else { - return 0; - } - } - else { - return 0; - } -#else - /* No XSHM support */ - return 0; -#endif -} /** @@ -242,7 +203,7 @@ xmesa_get_window_size(Display *dpy, XMesaBuffer b, pipe_mutex_lock(_xmesa_lock); XSync(b->xm_visual->display, 0); /* added for Chromium */ - stat = get_drawable_size(dpy, b->drawable, width, height); + stat = get_drawable_size(dpy, b->ws.drawable, width, height); pipe_mutex_unlock(_xmesa_lock); if (!stat) { @@ -397,7 +358,9 @@ create_xmesa_buffer(Drawable d, BufferType type, if (!b) return NULL; - b->drawable = d; + b->ws.drawable = d; + b->ws.visual = vis->visinfo->visual; + b->ws.depth = vis->visinfo->depth; b->xm_visual = vis; b->type = type; @@ -422,18 +385,6 @@ create_xmesa_buffer(Drawable d, BufferType type, (void *) b); fb = &b->stfb->Base; - /* - * Create scratch XImage for xmesa_display_surface() - */ - b->tempImage = XCreateImage(vis->display, - vis->visinfo->visual, - vis->visinfo->depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ - 0); /* bytes_per_line */ - /* GLX_EXT_texture_from_pixmap */ b->TextureTarget = 0; b->TextureFormat = GLX_TEXTURE_FORMAT_NONE_EXT; @@ -490,15 +441,12 @@ xmesa_free_buffer(XMesaBuffer buffer) /* Since the X window for the XMesaBuffer is going away, we don't * want to dereference this pointer in the future. */ - b->drawable = 0; - - buffer->tempImage->data = NULL; - XDestroyImage(buffer->tempImage); + b->ws.drawable = 0; /* Unreference. If count = zero we'll really delete the buffer */ _mesa_reference_framebuffer(&fb, NULL); - XFreeGC(b->xm_visual->display, b->gc); + XFreeGC(b->xm_visual->display, b->ws.gc); free(buffer); @@ -578,17 +526,12 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, if (b && window) { /* these should have been set in create_xmesa_buffer */ - ASSERT(b->drawable == window); + ASSERT(b->ws.drawable == window); - /* Setup for single/double buffering */ - if (v->mesa_visual.doubleBufferMode) { - /* Double buffered */ - b->shm = xmesa_check_for_xshm( v->display ); - } /* X11 graphics context */ - b->gc = XCreateGC( v->display, window, 0, NULL ); - XSetFunction( v->display, b->gc, GXcopy ); + b->ws.gc = XCreateGC( v->display, window, 0, NULL ); + XSetFunction( v->display, b->ws.gc, GXcopy ); } return GL_TRUE; @@ -673,7 +616,7 @@ XMesaVisual XMesaCreateVisual( Display *display, XMesaVisual v; GLint red_bits, green_bits, blue_bits, alpha_bits; - xmesa_init(); + xmesa_init( display ); /* For debugging only */ if (_mesa_getenv("MESA_XSYNC")) { @@ -773,12 +716,12 @@ void XMesaDestroyVisual( XMesaVisual v ) * Do one-time initializations. */ void -xmesa_init(void) +xmesa_init( Display *display ) { static GLboolean firstTime = GL_TRUE; if (firstTime) { pipe_mutex_init(_xmesa_lock); - _screen = driver.create_pipe_screen(); + _screen = driver.create_pipe_screen( display ); screen = trace_screen_create( _screen ); firstTime = GL_FALSE; } @@ -800,7 +743,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) GLcontext *mesaCtx; uint pf; - xmesa_init(); + xmesa_init( v->display ); /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */ c = (XMesaContext) CALLOC_STRUCT(xmesa_context); @@ -1155,7 +1098,7 @@ void XMesaSwapBuffers( XMesaBuffer b ) frontLeftSurf = surf; } - driver.display_surface(b, frontLeftSurf); + driver.display_surface(&b->ws, frontLeftSurf); } xmesa_check_and_update_buffer_size(NULL, b); @@ -1203,7 +1146,7 @@ XMesaBuffer XMesaFindBuffer( Display *dpy, Drawable d ) { XMesaBuffer b; for (b = XMesaBufferList; b; b = b->Next) { - if (b->drawable == d && b->xm_visual->display == dpy) { + if (b->ws.drawable == d && b->xm_visual->display == dpy) { return b; } } @@ -1237,10 +1180,10 @@ void XMesaGarbageCollect( void ) next = b->Next; if (b->xm_visual && b->xm_visual->display && - b->drawable && + b->ws.drawable && b->type == WINDOW) { XSync(b->xm_visual->display, False); - if (!window_exists( b->xm_visual->display, b->drawable )) { + if (!window_exists( b->xm_visual->display, b->ws.drawable )) { /* found a dead window, free the ancillary info */ XMesaDestroyBuffer( b ); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.h b/src/gallium/state_trackers/glx/xlib/xm_api.h index 004cb260dc..de47064b41 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.h +++ b/src/gallium/state_trackers/glx/xlib/xm_api.h @@ -62,15 +62,11 @@ and create a window, you must do the following to use the X/Mesa interface: #include "state_tracker/st_public.h" #include "os/os_thread.h" +#include "state_tracker/xlib_sw_winsys.h" # include # include # include -# ifdef USE_XSHM /* was SHM */ -# include -# include -# include -# endif typedef struct xmesa_buffer *XMesaBuffer; typedef struct xmesa_context *XMesaContext; @@ -316,6 +312,7 @@ typedef enum { */ struct xmesa_buffer { struct st_framebuffer *stfb; + struct xlib_drawable ws; GLboolean wasCurrent; /* was ever the current buffer? */ XMesaVisual xm_visual; /* the X/Mesa visual */ @@ -329,13 +326,6 @@ struct xmesa_buffer { XImage *tempImage; unsigned long selectedEvents;/* for pbuffers only */ - GLuint shm; /* X Shared Memory extension status: */ - /* 0 = not available */ - /* 1 = XImage support available */ - /* 2 = Pixmap support available too */ -#if defined(USE_XSHM) - XShmSegmentInfo shminfo; -#endif GC gc; /* scratch GC for span, line, tri drawing */ @@ -367,7 +357,7 @@ xmesa_buffer(GLframebuffer *fb) extern void -xmesa_init(void); +xmesa_init(Display *dpy); extern void xmesa_delete_framebuffer(struct gl_framebuffer *fb); @@ -397,8 +387,6 @@ xmesa_buffer_height(XMesaBuffer b) return b->stfb->Base.Height; } -extern int -xmesa_check_for_xshm(Display *display); #endif diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h index 4bd5b5c8d3..fc4444bee0 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h +++ b/src/gallium/state_trackers/glx/xlib/xm_winsys.h @@ -32,14 +32,15 @@ struct pipe_context; struct pipe_screen; struct pipe_surface; -struct xmesa_buffer; +struct xlib_drawable; +#include struct xm_driver { - struct pipe_screen *(*create_pipe_screen)( void ); + struct pipe_screen *(*create_pipe_screen)( Display *display ); - void (*display_surface)( struct xmesa_buffer *, + void (*display_surface)( struct xlib_drawable *, struct pipe_surface * ); }; diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c index cb559f9080..ceefc1624c 100644 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c @@ -42,16 +42,16 @@ #include "llvmpipe/lp_texture.h" #include "llvmpipe/lp_screen.h" -#include "state_tracker/sw_winsys.h" +#include "state_tracker/xlib_sw_winsys.h" #include "util/u_debug.h" static struct pipe_screen * -xlib_create_llvmpipe_screen( void ) +xlib_create_llvmpipe_screen( Display *display ) { struct sw_winsys *winsys; struct pipe_screen *screen; - winsys = xlib_create_sw_winsys(); + winsys = xlib_create_sw_winsys( display ); if (winsys == NULL) return NULL; @@ -70,7 +70,7 @@ fail: static void -xlib_llvmpipe_display_surface(struct xmesa_buffer *xm_buffer, +xlib_llvmpipe_display_surface(struct xlib_drawable *xm_buffer, struct pipe_surface *surf) { struct llvmpipe_texture *texture = llvmpipe_texture(surf->texture); diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 47fec4313b..9d665c3d83 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -34,12 +34,12 @@ #include "util/u_debug.h" static struct pipe_screen * -xlib_create_softpipe_screen( void ) +xlib_create_softpipe_screen( Display *display ) { struct sw_winsys *winsys; struct pipe_screen *screen; - winsys = xlib_create_sw_winsys(); + winsys = xlib_create_sw_winsys( display ); if (winsys == NULL) return NULL; diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index e4b02ba093..21649a0b1f 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -46,10 +46,17 @@ #include "util/u_math.h" #include "util/u_memory.h" -#include "state_tracker/sw_winsys.h" +#include "state_tracker/xlib_sw_winsys.h" #include "xlib.h" +#include +#include +#include +#include +#include +#include + /** * Subclass of pipe_buffer for Xlib winsys. * Low-level OS/window system memory buffer @@ -64,21 +71,25 @@ struct xm_displaytarget void *data; void *mapped; + Display *display; + Visual *visual; XImage *tempImage; -#ifdef USE_XSHM - int shm; + XShmSegmentInfo shminfo; -#endif + int shm; }; /** * Subclass of sw_winsys for Xlib winsys */ -struct xmesa_sw_winsys +struct xlib_sw_winsys { struct sw_winsys base; -/* struct xmesa_visual *xm_visual; */ + + + + Display *display; }; @@ -136,8 +147,8 @@ static char *alloc_shm(struct xm_displaytarget *buf, unsigned size) * Allocate a shared memory XImage back buffer for the given XMesaBuffer. */ static void -alloc_shm_ximage(struct xm_displaytarget *xm_buffer, - struct xmesa_buffer *xmb, +alloc_shm_ximage(struct xm_displaytarget *xm_dt, + struct xlib_drawable *xmb, unsigned width, unsigned height) { /* @@ -148,15 +159,15 @@ alloc_shm_ximage(struct xm_displaytarget *xm_buffer, */ int (*old_handler)(Display *, XErrorEvent *); - xm_buffer->tempImage = XShmCreateImage(xmb->xm_visual->display, - xmb->xm_visual->visinfo->visual, - xmb->xm_visual->visinfo->depth, - ZPixmap, - NULL, - &xm_buffer->shminfo, - width, height); - if (xm_buffer->tempImage == NULL) { - xm_buffer->shm = 0; + xm_dt->tempImage = XShmCreateImage(xm_dt->display, + xmb->visual, + xmb->depth, + ZPixmap, + NULL, + &xm_dt->shminfo, + width, height); + if (xm_dt->tempImage == NULL) { + xm_dt->shm = 0; return; } @@ -164,21 +175,21 @@ alloc_shm_ximage(struct xm_displaytarget *xm_buffer, mesaXErrorFlag = 0; old_handler = XSetErrorHandler(mesaHandleXError); /* This may trigger the X protocol error we're ready to catch: */ - XShmAttach(xmb->xm_visual->display, &xm_buffer->shminfo); - XSync(xmb->xm_visual->display, False); + XShmAttach(xm_dt->display, &xm_dt->shminfo); + XSync(xm_dt->display, False); if (mesaXErrorFlag) { /* we are on a remote display, this error is normal, don't print it */ - XFlush(xmb->xm_visual->display); + XFlush(xm_dt->display); mesaXErrorFlag = 0; - XDestroyImage(xm_buffer->tempImage); - xm_buffer->tempImage = NULL; - xm_buffer->shm = 0; + XDestroyImage(xm_dt->tempImage); + xm_dt->tempImage = NULL; + xm_dt->shm = 0; (void) XSetErrorHandler(old_handler); return; } - xm_buffer->shm = 1; + xm_dt->shm = 1; } #endif /* USE_XSHM */ @@ -239,7 +250,7 @@ xm_displaytarget_destroy(struct sw_winsys *ws, * by the XMesaBuffer. */ void -xlib_sw_display(struct xmesa_buffer *xm_buffer, +xlib_sw_display(struct xlib_drawable *xlib_drawable, struct sw_displaytarget *dt) { XImage *ximage; @@ -262,7 +273,8 @@ xlib_sw_display(struct xmesa_buffer *xm_buffer, { assert(util_format_get_blockwidth(xm_dt->format) == 1); assert(util_format_get_blockheight(xm_dt->format) == 1); - alloc_shm_ximage(xm_dt, xm_buffer, + alloc_shm_ximage(xm_dt, + xlib_drawable, xm_dt->stride / util_format_get_blocksize(xm_dt->format), xm_dt->height); } @@ -271,7 +283,7 @@ xlib_sw_display(struct xmesa_buffer *xm_buffer, ximage->data = xm_dt->data; /* _debug_printf("XSHM\n"); */ - XShmPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + XShmPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); } else @@ -291,7 +303,7 @@ xlib_sw_display(struct xmesa_buffer *xm_buffer, ximage->bytes_per_line = xm_dt->stride; /* _debug_printf("XPUT\n"); */ - XPutImage(xm_buffer->xm_visual->display, xm_buffer->drawable, xm_buffer->gc, + XPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); } } @@ -305,9 +317,8 @@ xm_displaytarget_display(struct sw_winsys *ws, struct sw_displaytarget *dt, void *context_private) { - XMesaContext xmctx = (XMesaContext) context_private; - struct xmesa_buffer *xm_buffer = xmctx->xm_buffer; - xm_sw_display(xm_buffer, dt); + struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private; + xlib_sw_display(xlib_drawable, dt); } @@ -325,6 +336,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, if(!xm_dt) goto no_xm_dt; + xm_dt->display = ((struct xlib_sw_winsys *)winsys)->display; xm_dt->format = format; xm_dt->width = width; xm_dt->height = height; @@ -370,14 +382,15 @@ xm_destroy( struct sw_winsys *ws ) struct sw_winsys * -xlib_create_sw_winsys( void ) +xlib_create_sw_winsys( Display *display ) { - struct xmesa_sw_winsys *ws; + struct xlib_sw_winsys *ws; - ws = CALLOC_STRUCT(xmesa_sw_winsys); + ws = CALLOC_STRUCT(xlib_sw_winsys); if (!ws) return NULL; + ws->display = display; ws->base.destroy = xm_destroy; ws->base.is_displaytarget_format_supported = xm_is_displaytarget_format_supported; -- cgit v1.2.3 From 4350e025cf18ee3b570340ca8cacc8fd857eb59a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 16:48:39 +0000 Subject: ws/xlib: fixup softpipe build --- src/gallium/winsys/xlib/xlib_softpipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 9d665c3d83..3b51d7c17c 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -30,7 +30,7 @@ #include "xlib.h" #include "softpipe/sp_texture.h" #include "softpipe/sp_screen.h" -#include "state_tracker/sw_winsys.h" +#include "state_tracker/xlib_sw_winsys.h" #include "util/u_debug.h" static struct pipe_screen * @@ -58,7 +58,7 @@ fail: static void -xlib_softpipe_display_surface(struct xmesa_buffer *xm_buffer, +xlib_softpipe_display_surface(struct xlib_drawable *xm_buffer, struct pipe_surface *surf) { struct softpipe_texture *texture = softpipe_texture(surf->texture); -- cgit v1.2.3 From 90b3baf9b3d0236cbecb171f2e742c9157dd312d Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 16:48:45 +0000 Subject: ws/xlib: remove dead files --- src/gallium/winsys/xlib/xmesa.h | 424 -------------------------------------- src/gallium/winsys/xlib/xmesa_x.h | 86 -------- 2 files changed, 510 deletions(-) delete mode 100644 src/gallium/winsys/xlib/xmesa.h delete mode 100644 src/gallium/winsys/xlib/xmesa_x.h (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xmesa.h b/src/gallium/winsys/xlib/xmesa.h deleted file mode 100644 index 98139af833..0000000000 --- a/src/gallium/winsys/xlib/xmesa.h +++ /dev/null @@ -1,424 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2007 Brian Paul 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, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL 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. - */ - - -/* - * Mesa/X11 interface. This header file serves as the documentation for - * the Mesa/X11 interface functions. - * - * Note: this interface isn't intended for user programs. It's primarily - * just for implementing the pseudo-GLX interface. - */ - - -/* Sample Usage: - -In addition to the usual X calls to select a visual, create a colormap -and create a window, you must do the following to use the X/Mesa interface: - -1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo. - -2. Call XMesaCreateContext() to create an X/Mesa rendering context, given - the XMesaVisual. - -3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window - and XMesaVisual. - -4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and - to make the context the current one. - -5. Make gl* calls to render your graphics. - -6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers. - -7. Before the X window is destroyed, call XMesaDestroyBuffer(). - -8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext. - -*/ - - - - -#ifndef XMESA_H -#define XMESA_H - -#ifdef __VMS -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef XFree86Server -#include "xmesa_xf86.h" -#else -#include -#include -#include "xmesa_x.h" -#endif -#include "GL/gl.h" - -#ifdef AMIWIN -#include -extern struct Library *XLibBase; -#endif - - -#define XMESA_MAJOR_VERSION 6 -#define XMESA_MINOR_VERSION 3 - - - -/* - * Values passed to XMesaGetString: - */ -#define XMESA_VERSION 1 -#define XMESA_EXTENSIONS 2 - - -/* - * Values passed to XMesaSetFXmode: - */ -#define XMESA_FX_WINDOW 1 -#define XMESA_FX_FULLSCREEN 2 - - - -typedef struct xmesa_context *XMesaContext; - -typedef struct xmesa_visual *XMesaVisual; - -typedef struct xmesa_buffer *XMesaBuffer; - - - -/* - * Create a new X/Mesa visual. - * Input: display - X11 display - * visinfo - an XVisualInfo pointer - * rgb_flag - GL_TRUE = RGB mode, - * GL_FALSE = color index mode - * alpha_flag - alpha buffer requested? - * db_flag - GL_TRUE = double-buffered, - * GL_FALSE = single buffered - * stereo_flag - stereo visual? - * ximage_flag - GL_TRUE = use an XImage for back buffer, - * GL_FALSE = use an off-screen pixmap for back buffer - * depth_size - requested bits/depth values, or zero - * stencil_size - requested bits/stencil values, or zero - * accum_red_size - requested bits/red accum values, or zero - * accum_green_size - requested bits/green accum values, or zero - * accum_blue_size - requested bits/blue accum values, or zero - * accum_alpha_size - requested bits/alpha accum values, or zero - * num_samples - number of samples/pixel if multisampling, or zero - * level - visual level, usually 0 - * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT - * Return; a new XMesaVisual or 0 if error. - */ -extern XMesaVisual XMesaCreateVisual( XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_red_size, - GLint accum_green_size, - GLint accum_blue_size, - GLint accum_alpha_size, - GLint num_samples, - GLint level, - GLint visualCaveat ); - -/* - * Destroy an XMesaVisual, but not the associated XVisualInfo. - */ -extern void XMesaDestroyVisual( XMesaVisual v ); - - - -/* - * Create a new XMesaContext for rendering into an X11 window. - * - * Input: visual - an XMesaVisual - * share_list - another XMesaContext with which to share display - * lists or NULL if no sharing is wanted. - * Return: an XMesaContext or NULL if error. - */ -extern XMesaContext XMesaCreateContext( XMesaVisual v, - XMesaContext share_list ); - - -/* - * Destroy a rendering context as returned by XMesaCreateContext() - */ -extern void XMesaDestroyContext( XMesaContext c ); - - -#ifdef XFree86Server -/* - * These are the extra routines required for integration with XFree86. - * None of these routines should be user visible. -KEM - */ -extern GLboolean XMesaForceCurrent( XMesaContext c ); - -extern GLboolean XMesaLoseCurrent( XMesaContext c ); - -extern GLboolean XMesaCopyContext( XMesaContext src, - XMesaContext dst, - GLuint mask ); -#endif /* XFree86Server */ - - -/* - * Create an XMesaBuffer from an X window. - */ -extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w ); - - -/* - * Create an XMesaBuffer from an X pixmap. - */ -extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, - XMesaPixmap p, - XMesaColormap cmap ); - - -/* - * Destroy an XMesaBuffer, but not the corresponding window or pixmap. - */ -extern void XMesaDestroyBuffer( XMesaBuffer b ); - - -/* - * Return the XMesaBuffer handle which corresponds to an X drawable, if any. - * - * New in Mesa 2.3. - */ -extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, - XMesaDrawable d ); - - - -/* - * Bind a buffer to a context and make the context the current one. - */ -extern GLboolean XMesaMakeCurrent( XMesaContext c, - XMesaBuffer b ); - - -/* - * Bind two buffers (read and draw) to a context and make the - * context the current one. - * New in Mesa 3.3 - */ -extern GLboolean XMesaMakeCurrent2( XMesaContext c, - XMesaBuffer drawBuffer, - XMesaBuffer readBuffer ); - - -/* - * Unbind the current context from its buffer. - */ -extern GLboolean XMesaUnbindContext( XMesaContext c ); - - -/* - * Return a handle to the current context. - */ -extern XMesaContext XMesaGetCurrentContext( void ); - - -/* - * Return handle to the current (draw) buffer. - */ -extern XMesaBuffer XMesaGetCurrentBuffer( void ); - - -/* - * Return handle to the current read buffer. - * New in Mesa 3.3 - */ -extern XMesaBuffer XMesaGetCurrentReadBuffer( void ); - - -/* - * Swap the front and back buffers for the given buffer. No action is - * taken if the buffer is not double buffered. - */ -extern void XMesaSwapBuffers( XMesaBuffer b ); - - -/* - * Copy a sub-region of the back buffer to the front buffer. - * - * New in Mesa 2.6 - */ -extern void XMesaCopySubBuffer( XMesaBuffer b, - int x, - int y, - int width, - int height ); - - -/* - * Return a pointer to the the Pixmap or XImage being used as the back - * color buffer of an XMesaBuffer. This function is a way to get "under - * the hood" of X/Mesa so one can manipulate the back buffer directly. - * Input: b - the XMesaBuffer - * Output: pixmap - pointer to back buffer's Pixmap, or 0 - * ximage - pointer to back buffer's XImage, or NULL - * Return: GL_TRUE = context is double buffered - * GL_FALSE = context is single buffered - */ -extern GLboolean XMesaGetBackBuffer( XMesaBuffer b, - XMesaPixmap *pixmap, - XMesaImage **ximage ); - - - -/* - * Return the depth buffer associated with an XMesaBuffer. - * Input: b - the XMesa buffer handle - * Output: width, height - size of buffer in pixels - * bytesPerValue - bytes per depth value (2 or 4) - * buffer - pointer to depth buffer values - * Return: GL_TRUE or GL_FALSE to indicate success or failure. - * - * New in Mesa 2.4. - */ -extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b, - GLint *width, - GLint *height, - GLint *bytesPerValue, - void **buffer ); - - - -/* - * Flush/sync a context - */ -extern void XMesaFlush( XMesaContext c ); - - - -/* - * Get an X/Mesa-specific string. - * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS - */ -extern const char *XMesaGetString( XMesaContext c, int name ); - - - -/* - * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free - * any memory used by that buffer. - * - * New in Mesa 2.3. - */ -extern void XMesaGarbageCollect( void ); - - - -/* - * Return a dithered pixel value. - * Input: c - XMesaContext - * x, y - window coordinate - * red, green, blue, alpha - color components in [0,1] - * Return: pixel value - * - * New in Mesa 2.3. - */ -extern unsigned long XMesaDitherColor( XMesaContext xmesa, - GLint x, - GLint y, - GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha ); - - - -/* - * 3Dfx Glide driver only! - * Set 3Dfx/Glide full-screen or window rendering mode. - * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or - * XMESA_FX_FULLSCREEN (full-screen rendering mode) - * Return: GL_TRUE if success - * GL_FALSE if invalid mode or if not using 3Dfx driver - * - * New in Mesa 2.6. - */ -extern GLboolean XMesaSetFXmode( GLint mode ); - - - -/* - * Reallocate the back/depth/stencil/accum/etc/ buffers associated with - * buffer if its size has changed. - * - * New in Mesa 4.0.2 - */ -extern void XMesaResizeBuffers( XMesaBuffer b ); - - - -/* - * Create a pbuffer. - * New in Mesa 4.1 - */ -extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, - unsigned int width, unsigned int height); - - - -/* - * Texture from Pixmap - * New in Mesa 7.1 - */ -extern void -XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer, - const int *attrib_list); - -extern void -XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer); - - -extern XMesaBuffer -XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap cmap, - int format, int target, int mipmap); - - - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/src/gallium/winsys/xlib/xmesa_x.h b/src/gallium/winsys/xlib/xmesa_x.h deleted file mode 100644 index 865bab4313..0000000000 --- a/src/gallium/winsys/xlib/xmesa_x.h +++ /dev/null @@ -1,86 +0,0 @@ - -/************************************************************************** - -Copyright 1998-1999 Precision Insight, 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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * - * When we're building the XMesa driver for stand-alone Mesa we - * include this file when building the xm_*.c files. - * We need to define some types and macros differently when building - * in the Xserver vs. stand-alone Mesa. - */ - -#ifndef _XMESA_X_H_ -#define _XMESA_X_H_ - -typedef Display XMesaDisplay; -typedef Pixmap XMesaPixmap; -typedef Colormap XMesaColormap; -typedef Drawable XMesaDrawable; -typedef Window XMesaWindow; -typedef GC XMesaGC; -typedef XVisualInfo *XMesaVisualInfo; -typedef XImage XMesaImage; -typedef XPoint XMesaPoint; -typedef XColor XMesaColor; - -#define XMesaDestroyImage XDestroyImage - -#define XMesaPutPixel XPutPixel -#define XMesaGetPixel XGetPixel - -#define XMesaSetForeground XSetForeground -#define XMesaSetBackground XSetBackground -#define XMesaSetPlaneMask XSetPlaneMask -#define XMesaSetFunction XSetFunction -#define XMesaSetFillStyle XSetFillStyle -#define XMesaSetTile XSetTile - -#define XMesaDrawPoint XDrawPoint -#define XMesaDrawPoints XDrawPoints -#define XMesaDrawLine XDrawLine -#define XMesaFillRectangle XFillRectangle -#define XMesaGetImage XGetImage -#define XMesaPutImage XPutImage -#define XMesaCopyArea XCopyArea - -#define XMesaCreatePixmap XCreatePixmap -#define XMesaFreePixmap XFreePixmap -#define XMesaFreeGC XFreeGC - -#define GET_COLORMAP_SIZE(__v) __v->visinfo->colormap_size -#define GET_REDMASK(__v) __v->mesa_visual.redMask -#define GET_GREENMASK(__v) __v->mesa_visual.greenMask -#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask -#define GET_VISUAL_DEPTH(__v) __v->visinfo->depth -#define GET_BLACK_PIXEL(__v) BlackPixel(__v->display, __v->mesa_visual.screen) -#define CHECK_BYTE_ORDER(__v) host_byte_order()==ImageByteOrder(__v->display) -#define CHECK_FOR_HPCR(__v) XInternAtom(__v->display, "_HP_RGB_SMOOTH_MAP_LIST", True) - -#endif -- cgit v1.2.3 From e1762fb870f86afc4f6bd000b4a1c059d161f10d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 11:34:55 -0700 Subject: softpipe: zero-out entire clear_flags array in sp_tile_cache_flush_clear() Before, we only cleared the flags for the active tiles (the ones inside the framebuffer bound). The problem is if we later bound a different, larger surface to the tile cache we'd have some stale clear-flags still set (and mistakenly clear some tiles in the new surface). Fixes fd.o bug 26932. --- src/gallium/drivers/softpipe/sp_tile_cache.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 3b30954ac8..aedfdf1b46 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -299,13 +299,14 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) x, y, TILE_SIZE, TILE_SIZE, tc->tile.data.color32, 0/*STRIDE*/); - /* do this? */ - clear_clear_flag(tc->clear_flags, addr); - numCleared++; } } } + + /* reset all clear flags to zero */ + memset(tc->clear_flags, 0, sizeof(tc->clear_flags)); + #if 0 debug_printf("num cleared: %u\n", numCleared); #endif -- cgit v1.2.3 From 99f11d0e18e1ff5a433c84d52ffc13b9684c2650 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 19:11:35 +0000 Subject: gallium: introduce target directory Currently there are still at least two functions bundled up inside the winsys concept: a) that of a backend resource manager, sometimes capable of performing present() operations, b) the initialization code/routine for the whole driver stack. The inclusion of (b) makes it difficult to share implementations of (a) between different drivers. For instance, a clean xlib winsys could be of use for software-rasterized VG, GLES, EGL, etc, stacks. But that is only true as long as there is no dependency from the winsys to higher level code, as would be the case when we include (b) in this component. This change creates a new gallium/targets subtree, specifically for implementing the glue needed to build individual driver stacks, and moves that code out of a single example winsys, namely xlib. Other drivers continue to build unchanged, but hopefully can migrate to this structure over time. --- configs/autoconf.in | 1 + configs/default | 3 +- configs/linux-cell | 2 +- configs/linux-dri | 1 + configs/linux-egl | 3 +- configs/linux-i965 | 1 + configs/linux-opengl-es | 2 +- src/gallium/include/state_tracker/xlib_sw_winsys.h | 17 +- src/gallium/state_trackers/glx/xlib/SConscript | 2 - src/gallium/state_trackers/glx/xlib/xm_winsys.h | 11 -- src/gallium/targets/Makefile | 12 ++ src/gallium/targets/SConscript | 16 ++ src/gallium/targets/libgl-xlib/Makefile | 98 ++++++++++ src/gallium/targets/libgl-xlib/SConscript | 64 +++++++ src/gallium/targets/libgl-xlib/xlib.c | 104 ++++++++++ src/gallium/winsys/xlib/Makefile | 90 +-------- src/gallium/winsys/xlib/SConscript | 83 +++----- src/gallium/winsys/xlib/xlib.c | 136 -------------- src/gallium/winsys/xlib/xlib.h | 7 +- src/gallium/winsys/xlib/xlib_brw_context.c | 209 --------------------- src/gallium/winsys/xlib/xlib_sw_winsys.c | 1 - 21 files changed, 350 insertions(+), 513 deletions(-) create mode 100644 src/gallium/targets/Makefile create mode 100644 src/gallium/targets/SConscript create mode 100644 src/gallium/targets/libgl-xlib/Makefile create mode 100644 src/gallium/targets/libgl-xlib/SConscript create mode 100644 src/gallium/targets/libgl-xlib/xlib.c delete mode 100644 src/gallium/winsys/xlib/xlib.c delete mode 100644 src/gallium/winsys/xlib/xlib_brw_context.c (limited to 'src/gallium') diff --git a/configs/autoconf.in b/configs/autoconf.in index 30637877f3..023b86eed6 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -73,6 +73,7 @@ EGL_DRIVERS_DIRS = @EGL_DRIVERS_DIRS@ GALLIUM_DIRS = @GALLIUM_DIRS@ GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@ GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@ +GALLIUM_TARGET_DIRS = @GALLIUM_TARGET_DIRS@ GALLIUM_WINSYS_DRM_DIRS = @GALLIUM_WINSYS_DRM_DIRS@ GALLIUM_STATE_TRACKERS_DIRS = @GALLIUM_STATE_TRACKERS_DIRS@ GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a diff --git a/configs/default b/configs/default index ad6d93c92f..45eaf8752e 100644 --- a/configs/default +++ b/configs/default @@ -86,7 +86,7 @@ MOTIF_CFLAGS = -I/usr/include/Motif1.2 # Directories to build LIB_DIR = lib -SRC_DIRS = glsl mesa gallium egl gallium/winsys glu glut/glx glew glw +SRC_DIRS = glsl mesa gallium egl gallium/winsys gallium/targets glu glut/glx glew glw GLU_DIRS = sgi DRIVER_DIRS = x11 osmesa # Which subdirs under $(TOP)/progs/ to enter: @@ -101,6 +101,7 @@ GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) GALLIUM_WINSYS_DIRS = drm xlib +GALLIUM_TARGET_DIRS = libgl-xlib GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx vega diff --git a/configs/linux-cell b/configs/linux-cell index e89a08cd93..306b9e01f4 100644 --- a/configs/linux-cell +++ b/configs/linux-cell @@ -37,7 +37,7 @@ CXXFLAGS = $(COMMON_C_CPP_FLAGS) # Omitting glw here: -SRC_DIRS = glsl mesa gallium gallium/winsys glu glut/glx glew +SRC_DIRS = glsl mesa gallium gallium/winsys gallium/targets glu glut/glx glew # Build no traditional Mesa drivers: DRIVER_DIRS = diff --git a/configs/linux-dri b/configs/linux-dri index e8e8ccfcf9..ae33973000 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -60,6 +60,7 @@ EGL_DRIVERS_DIRS = glx DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = drm +GALLIUM_TARGET_DIRS = GALLIUM_WINSYS_DRM_DIRS = vmware intel i965 GALLIUM_STATE_TRACKERS_DIRS = egl diff --git a/configs/linux-egl b/configs/linux-egl index 2c2834b81d..9d898182fc 100644 --- a/configs/linux-egl +++ b/configs/linux-egl @@ -47,11 +47,12 @@ GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \ # Directories -SRC_DIRS = gallium mesa gallium/winsys glu egl +SRC_DIRS = gallium mesa gallium/winsys gallium/targets glu egl PROGRAM_DIRS = egl DRIVER_DIRS = dri WINDOW_SYSTEM = dri GALLIUM_WINSYS_DIRS = egl_drm +GALLIUM_TARGET_DIRS = DRI_DIRS = intel diff --git a/configs/linux-i965 b/configs/linux-i965 index e66abc347b..7656a2adc5 100644 --- a/configs/linux-i965 +++ b/configs/linux-i965 @@ -6,3 +6,4 @@ CONFIG_NAME = linux-i965 GALLIUM_DRIVER_DIRS = i965 GALLIUM_WINSYS_DIRS = drm/i965/xlib +GALLIUM_TARGET_DIRS = diff --git a/configs/linux-opengl-es b/configs/linux-opengl-es index 259c26a931..76054aad14 100644 --- a/configs/linux-opengl-es +++ b/configs/linux-opengl-es @@ -6,7 +6,7 @@ CONFIG_NAME = linux-opengl-es # Directories to build LIB_DIR = lib -SRC_DIRS = egl glsl mesa/es gallium gallium/winsys +SRC_DIRS = egl glsl mesa/es gallium gallium/winsys gallium/targets PROGRAM_DIRS = es1/screen es1/xegl es2/xegl # egl st needs this diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index 71d39b9cdb..c703d3b66c 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -4,7 +4,9 @@ #include "state_tracker/sw_winsys.h" #include -struct sw_winsys *xlib_create_sw_winsys( Display *display ); + +struct pipe_screen; +struct pipe_surface; /* This is what the xlib software winsys expects to find in the * "private" field of flush_frontbuffers(). Xlib-based state trackers @@ -17,9 +19,16 @@ struct xlib_drawable { GC gc; /* temporary? */ }; -void -xlib_sw_display(struct xlib_drawable *xm_buffer, - struct sw_displaytarget *dt); +struct xm_driver { + struct pipe_screen *(*create_pipe_screen)( Display *display ); + + void (*display_surface)( struct xlib_drawable *, + struct pipe_surface * ); +}; + +/* Called by the libgl-xlib target code to build the rendering stack. + */ +struct xm_driver *xlib_sw_winsys_init( void ); #endif diff --git a/src/gallium/state_trackers/glx/xlib/SConscript b/src/gallium/state_trackers/glx/xlib/SConscript index fa96df357d..bb20235150 100644 --- a/src/gallium/state_trackers/glx/xlib/SConscript +++ b/src/gallium/state_trackers/glx/xlib/SConscript @@ -13,8 +13,6 @@ if env['platform'] == 'linux' \ '#/src/mesa/main', ]) - env.Append(CPPDEFINES = ['USE_XSHM']) - st_xlib = env.ConvenienceLibrary( target = 'st_xlib', source = [ diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h index fc4444bee0..648f1c90ef 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h +++ b/src/gallium/state_trackers/glx/xlib/xm_winsys.h @@ -34,17 +34,6 @@ struct pipe_screen; struct pipe_surface; struct xlib_drawable; -#include - -struct xm_driver { - - struct pipe_screen *(*create_pipe_screen)( Display *display ); - - void (*display_surface)( struct xlib_drawable *, - struct pipe_surface * ); - -}; - extern void xmesa_set_driver( const struct xm_driver *driver ); diff --git a/src/gallium/targets/Makefile b/src/gallium/targets/Makefile new file mode 100644 index 0000000000..a0bc5eb14f --- /dev/null +++ b/src/gallium/targets/Makefile @@ -0,0 +1,12 @@ +# src/gallium/winsys/Makefile +TOP = ../../.. +include $(TOP)/configs/current + +SUBDIRS = $(GALLIUM_TARGET_DIRS) + +default install clean: + @for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) $@) || exit 1; \ + fi \ + done diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript new file mode 100644 index 0000000000..46cbe656f4 --- /dev/null +++ b/src/gallium/targets/SConscript @@ -0,0 +1,16 @@ +Import('*') + +#if env['dri']: +# SConscript([ +# 'drm/SConscript', +# ]) + +if 'xlib' in env['winsys']: + SConscript([ + 'libgl-xlib/SConscript', + ]) + +#if 'gdi' in env['winsys']: +# SConscript([ +# 'gdi/SConscript', +# ]) diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile new file mode 100644 index 0000000000..8ffe4dbf24 --- /dev/null +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -0,0 +1,98 @@ +# src/gallium/targets/libgl-xlib/Makefile + +# This makefile produces a "stand-alone" libGL.so which is based on +# Xlib (no DRI HW acceleration) + + +TOP = ../../../.. +include $(TOP)/configs/current + + +GL_MAJOR = 1 +GL_MINOR = 5 +GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) + + +INCLUDE_DIRS = \ + -I$(TOP)/include \ + -I$(TOP)/src/mesa \ + -I$(TOP)/src/mesa/main \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/state_trackers/glx/xlib \ + -I$(TOP)/src/gallium/auxiliary + +DEFINES += \ + -DGALLIUM_SOFTPIPE +#-DGALLIUM_CELL will be defined by the config */ + +XLIB_TARGET_SOURCES = \ + xlib.c + + +XLIB_TARGET_OBJECTS = $(XLIB_TARGET_SOURCES:.c=.o) + + +# Note: CELL_SPU_LIB is only defined for cell configs + +LIBS = \ + $(GALLIUM_DRIVERS) \ + $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ + $(TOP)/src/gallium/winsys/xlib/libws_xlib.a \ + $(TOP)/src/mesa/libglapi.a \ + $(TOP)/src/mesa/libmesagallium.a \ + $(GALLIUM_AUXILIARIES) \ + $(CELL_SPU_LIB) \ + + +.SUFFIXES : .cpp + +.c.o: + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ + +.cpp.o: + $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ + + + +default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME) + +$(TOP)/$(LIB_DIR)/gallium: + @ mkdir -p $(TOP)/$(LIB_DIR)/gallium + +# Make the libGL.so library +$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_TARGET_OBJECTS) $(LIBS) Makefile + $(TOP)/bin/mklib -o $(GL_LIB) \ + -linker "$(CC)" \ + -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ + -install $(TOP)/$(LIB_DIR)/gallium \ + $(MKLIB_OPTIONS) $(XLIB_TARGET_OBJECTS) \ + -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS) + + +depend: $(XLIB_TARGET_SOURCES) + @ echo "running $(MKDEP)" + @ rm -f depend # workaround oops on gutsy?!? + @ touch depend + $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_TARGET_SOURCES) \ + > /dev/null 2>/dev/null + + +install: default + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL + $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) + $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL + @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ + fi + + +# Emacs tags +tags: + etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h + +clean: + -rm -f *.o + + +include depend diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript new file mode 100644 index 0000000000..92e508ee50 --- /dev/null +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -0,0 +1,64 @@ +####################################################################### +# SConscript for xlib winsys + +Import('*') + +if env['platform'] != 'linux': + Return() + +if 'mesa' not in env['statetrackers']: + print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so' + Return() + +if env['dri']: + print 'warning: DRI enabled: skipping build of xlib libGL.so' + Return() + +if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']): + print 'warning: no supported pipe driver: skipping build of xlib libGL.so' + Return() + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/mesa', + '#/src/mesa/main', + '#src/gallium/state_trackers/glx/xlib', +]) + +env.Append(CPPDEFINES = ['USE_XSHM']) + +sources = [ + 'xlib.c', +] + +drivers = [trace] + +if 'softpipe' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') + sources += ['xlib_softpipe.c', 'xlib_sw_winsys.c'] + drivers += [softpipe] + +if 'llvmpipe' in env['drivers']: + env.Tool('llvm') + if 'LLVM_VERSION' in env: + env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') + env.Tool('udis86') + sources += ['xlib_llvmpipe.c', 'xlib_sw_winsys.c'] + drivers += [llvmpipe] + +if 'cell' in env['drivers']: + env.Append(CPPDEFINES = 'GALLIUM_CELL') + sources += ['xlib_cell.c'] + drivers += [cell] + +# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions +libgl = env.SharedLibrary( + target ='GL', + source = sources, + LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'], +) + +if not env['dri']: + # Only install this libGL.so if DRI not enabled + env.InstallSharedLibrary(libgl, version=(1, 5)) diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c new file mode 100644 index 0000000000..7cae0884e8 --- /dev/null +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -0,0 +1,104 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/* + * Authors: + * Keith Whitwell + */ + +#include "state_tracker/xlib_sw_winsys.h" +#include "xm_winsys.h" +#include "util/u_debug.h" + + +/* advertise OpenGL support */ +PUBLIC const int st_api_OpenGL = 1; + +static void _init( void ) __attribute__((constructor)); + +/* Build the rendering stack. + */ +static void _init( void ) +{ + struct xm_driver *driver; + + /* Initialize the xlib software winsys. Later on, once Display and + * other parameters are known, this will be used to create the + * gallium driver (such as softpipe), etc. + */ + driver = xlib_sw_winsys_init(); + + /* Initialize the xlib libgl code, pass in the winsys: + */ + xmesa_set_driver( driver ); +} + + +/*********************************************************************** + * + * Butt-ugly hack to convince the linker not to throw away public GL + * symbols (they are all referenced from getprocaddress, I guess). + */ +extern void (*linker_foo(const unsigned char *procName))(); +extern void (*glXGetProcAddress(const unsigned char *procName))(); + +extern void (*linker_foo(const unsigned char *procName))() +{ + return glXGetProcAddress(procName); +} + + +/** + * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in + * libglapi.a. We need to define them here. + */ +#ifdef GLX_INDIRECT_RENDERING + +#define GL_GLEXT_PROTOTYPES +#include "GL/gl.h" +#include "glapi/glapi.h" +#include "glapi/glapitable.h" +#include "glapi/glapidispatch.h" + +#if defined(USE_MGL_NAMESPACE) +#define NAME(func) mgl##func +#else +#define NAME(func) gl##func +#endif + +#define DISPATCH(FUNC, ARGS, MESSAGE) \ + CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ + return CALL_ ## FUNC(GET_DISPATCH(), ARGS); + +/* skip normal ones */ +#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS +#include "glapi/glapitemp.h" + +#endif /* GLX_INDIRECT_RENDERING */ diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 129300423a..056b6a308f 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -1,101 +1,19 @@ -# src/gallium/winsys/xlib/Makefile - -# This makefile produces a "stand-alone" libGL.so which is based on -# Xlib (no DRI HW acceleration) - - TOP = ../../../.. include $(TOP)/configs/current +LIBNAME = ws_xlib -GL_MAJOR = 1 -GL_MINOR = 5 -GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY) - - -INCLUDE_DIRS = \ - -I$(TOP)/include \ - -I$(TOP)/src/mesa \ - -I$(TOP)/src/mesa/main \ +LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/drivers \ - -I$(TOP)/src/gallium/state_trackers/glx/xlib \ -I$(TOP)/src/gallium/auxiliary -DEFINES += \ - -DGALLIUM_SOFTPIPE -#-DGALLIUM_CELL will be defined by the config */ - -XLIB_WINSYS_SOURCES = \ - xlib.c \ +C_SOURCES = \ xlib_cell.c \ xlib_sw_winsys.c \ xlib_llvmpipe.c \ xlib_softpipe.c - -XLIB_WINSYS_OBJECTS = $(XLIB_WINSYS_SOURCES:.c=.o) - - -# Note: CELL_SPU_LIB is only defined for cell configs - -LIBS = \ - $(GALLIUM_DRIVERS) \ - $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ - $(TOP)/src/mesa/libglapi.a \ - $(TOP)/src/mesa/libmesagallium.a \ - $(GALLIUM_AUXILIARIES) \ - $(CELL_SPU_LIB) \ - - -.SUFFIXES : .cpp - -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ - -.cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ - - - -default: $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME) - -$(TOP)/$(LIB_DIR)/gallium: - @ mkdir -p $(TOP)/$(LIB_DIR)/gallium - -# Make the libGL.so library -$(TOP)/$(LIB_DIR)/gallium/$(GL_LIB_NAME): $(XLIB_WINSYS_OBJECTS) $(LIBS) Makefile - $(TOP)/bin/mklib -o $(GL_LIB) \ - -linker "$(CC)" \ - -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \ - -install $(TOP)/$(LIB_DIR)/gallium \ - $(MKLIB_OPTIONS) $(XLIB_WINSYS_OBJECTS) \ - -Wl,--start-group $(LIBS) -Wl,--end-group $(GL_LIB_DEPS) - - -depend: $(XLIB_WINSYS_SOURCES) - @ echo "running $(MKDEP)" - @ rm -f depend # workaround oops on gutsy?!? - @ touch depend - $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(XLIB_WINSYS_SOURCES) \ - > /dev/null 2>/dev/null - - -install: default - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/include/GL - $(INSTALL) -d $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR) - $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(DESTDIR)$(INSTALL_DIR)/include/GL - @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(DESTDIR)$(INSTALL_DIR)/$(LIB_DIR); \ - fi - - -# Emacs tags -tags: - etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h - -clean: - -rm -f *.o +include ../../Makefile.template -include depend diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 92e508ee50..26a13e42b5 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -1,64 +1,29 @@ ####################################################################### # SConscript for xlib winsys -Import('*') - -if env['platform'] != 'linux': - Return() - -if 'mesa' not in env['statetrackers']: - print 'warning: Mesa state tracker disabled: skipping build of xlib libGL.so' - Return() - -if env['dri']: - print 'warning: DRI enabled: skipping build of xlib libGL.so' - Return() - -if not set(('softpipe', 'llvmpipe', 'cell')).intersection(env['drivers']): - print 'warning: no supported pipe driver: skipping build of xlib libGL.so' - Return() - -env = env.Clone() -env.Append(CPPPATH = [ - '#/src/mesa', - '#/src/mesa/main', - '#src/gallium/state_trackers/glx/xlib', -]) - -env.Append(CPPDEFINES = ['USE_XSHM']) - -sources = [ - 'xlib.c', -] - -drivers = [trace] - -if 'softpipe' in env['drivers']: - env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') - sources += ['xlib_softpipe.c', 'xlib_sw_winsys.c'] - drivers += [softpipe] - -if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') - env.Tool('udis86') - sources += ['xlib_llvmpipe.c', 'xlib_sw_winsys.c'] - drivers += [llvmpipe] - -if 'cell' in env['drivers']: - env.Append(CPPDEFINES = 'GALLIUM_CELL') - sources += ['xlib_cell.c'] - drivers += [cell] - -# TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions -libgl = env.SharedLibrary( - target ='GL', - source = sources, - LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'], -) +Import('*') -if not env['dri']: - # Only install this libGL.so if DRI not enabled - env.InstallSharedLibrary(libgl, version=(1, 5)) +if env['platform'] == 'linux' \ + and 'mesa' in env['statetrackers']: + + env = env.Clone() + + env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', + ]) + + env.Append(CPPDEFINES = ['USE_XSHM']) + + st_xlib = env.ConvenienceLibrary( + target = 'ws_xlib', + source = [ + 'xlib_cell.c', + 'xlib_llvmpipe.c', + 'xlib_softpipe.c', + 'xlib_sw_winsys.c', + ] + ) + Export('ws_xlib') diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c deleted file mode 100644 index 9b91c980d1..0000000000 --- a/src/gallium/winsys/xlib/xlib.c +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - -#include "xlib.h" -#include "xm_winsys.h" -#include "util/u_debug.h" - -/* Todo, replace all this with callback-structs provided by the - * individual implementations. - */ - -enum mode { - MODE_CELL, - MODE_LLVMPIPE, - MODE_SOFTPIPE -}; - -/* advertise OpenGL support */ -PUBLIC const int st_api_OpenGL = 1; - -static enum mode get_mode() -{ -#ifdef GALLIUM_CELL - if (!getenv("GALLIUM_NOCELL")) - return MODE_CELL; -#endif - -#if defined(GALLIUM_LLVMPIPE) - return MODE_LLVMPIPE; -#else - return MODE_SOFTPIPE; -#endif -} - -static void _init( void ) __attribute__((constructor)); - -static void _init( void ) -{ - enum mode xlib_mode = get_mode(); - - switch (xlib_mode) { - case MODE_CELL: -#if defined(GALLIUM_CELL) - xmesa_set_driver( &xlib_cell_driver ); -#endif - break; - case MODE_LLVMPIPE: -#if defined(GALLIUM_LLVMPIPE) - xmesa_set_driver( &xlib_llvmpipe_driver ); -#endif - break; - case MODE_SOFTPIPE: -#if defined(GALLIUM_SOFTPIPE) - xmesa_set_driver( &xlib_softpipe_driver ); -#endif - break; - default: - assert(0); - break; - } -} - - -/*********************************************************************** - * - * Butt-ugly hack to convince the linker not to throw away public GL - * symbols (they are all referenced from getprocaddress, I guess). - */ -extern void (*linker_foo(const unsigned char *procName))(); -extern void (*glXGetProcAddress(const unsigned char *procName))(); - -extern void (*linker_foo(const unsigned char *procName))() -{ - return glXGetProcAddress(procName); -} - - -/** - * When GLX_INDIRECT_RENDERING is defined, some symbols are missing in - * libglapi.a. We need to define them here. - */ -#ifdef GLX_INDIRECT_RENDERING - -#define GL_GLEXT_PROTOTYPES -#include "GL/gl.h" -#include "glapi/glapi.h" -#include "glapi/glapitable.h" -#include "glapi/glapidispatch.h" - -#if defined(USE_MGL_NAMESPACE) -#define NAME(func) mgl##func -#else -#define NAME(func) gl##func -#endif - -#define DISPATCH(FUNC, ARGS, MESSAGE) \ - CALL_ ## FUNC(GET_DISPATCH(), ARGS); - -#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \ - return CALL_ ## FUNC(GET_DISPATCH(), ARGS); - -/* skip normal ones */ -#define _GLAPI_SKIP_NORMAL_ENTRY_POINTS -#include "glapi/glapitemp.h" - -#endif /* GLX_INDIRECT_RENDERING */ diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h index 8e091d0c08..3c20048616 100644 --- a/src/gallium/winsys/xlib/xlib.h +++ b/src/gallium/winsys/xlib/xlib.h @@ -3,11 +3,16 @@ #define XLIB_H #include "pipe/p_compiler.h" -#include "xm_winsys.h" +#include "state_tracker/xlib_sw_winsys.h" extern struct xm_driver xlib_softpipe_driver; extern struct xm_driver xlib_llvmpipe_driver; extern struct xm_driver xlib_cell_driver; +struct sw_winsys *xlib_create_sw_winsys( Display *display ); + +void xlib_sw_display(struct xlib_drawable *xm_buffer, + struct sw_displaytarget *dt); + #endif diff --git a/src/gallium/winsys/xlib/xlib_brw_context.c b/src/gallium/winsys/xlib/xlib_brw_context.c deleted file mode 100644 index 22bf41a46f..0000000000 --- a/src/gallium/winsys/xlib/xlib_brw_context.c +++ /dev/null @@ -1,209 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -/* #include "glxheader.h" */ -/* #include "xmesaP.h" */ - -#include "util/u_simple_screen.h" -#include "util/u_inlines.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "i965simple/brw_winsys.h" -#include "xlib_brw_aub.h" -#include "xlib_brw.h" - - - - -#define XBCWS_BATCHBUFFER_SIZE 1024 - - -/* The backend to the brw driver (ie struct brw_winsys) is actually a - * per-context entity. - */ -struct xlib_brw_context_winsys { - struct brw_winsys brw_context_winsys; /**< batch buffer funcs */ - struct aub_context *aub; - - struct pipe_winsys *pipe_winsys; - - unsigned batch_data[XBCWS_BATCHBUFFER_SIZE]; - unsigned batch_nr; - unsigned batch_size; - unsigned batch_alloc; -}; - - -/* Turn a brw_winsys into an xlib_brw_context_winsys: - */ -static inline struct xlib_brw_context_winsys * -xlib_brw_context_winsys( struct brw_winsys *sws ) -{ - return (struct xlib_brw_context_winsys *)sws; -} - - -/* Simple batchbuffer interface: - */ - -static unsigned *xbcws_batch_start( struct brw_winsys *sws, - unsigned dwords, - unsigned relocs ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - if (xbcws->batch_size < xbcws->batch_nr + dwords) - return NULL; - - xbcws->batch_alloc = xbcws->batch_nr + dwords; - return (void *)1; /* not a valid pointer! */ -} - -static void xbcws_batch_dword( struct brw_winsys *sws, - unsigned dword ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr < xbcws->batch_alloc); - xbcws->batch_data[xbcws->batch_nr++] = dword; -} - -static void xbcws_batch_reloc( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned access_flags, - unsigned delta ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr < xbcws->batch_alloc); - xbcws->batch_data[xbcws->batch_nr++] = - ( xlib_brw_get_buffer_offset( NULL, buf, access_flags ) + - delta ); -} - -static void xbcws_batch_end( struct brw_winsys *sws ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - assert(xbcws->batch_nr <= xbcws->batch_alloc); - xbcws->batch_alloc = 0; -} - -static void xbcws_batch_flush( struct brw_winsys *sws, - struct pipe_fence_handle **fence ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - assert(xbcws->batch_nr <= xbcws->batch_size); - - if (xbcws->batch_nr) { - xlib_brw_commands_aub( xbcws->pipe_winsys, - xbcws->batch_data, - xbcws->batch_nr ); - } - - xbcws->batch_nr = 0; -} - - - -/* Really a per-device function, just pass through: - */ -static unsigned xbcws_get_buffer_offset( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned access_flags ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - return xlib_brw_get_buffer_offset( xbcws->pipe_winsys, - buf, - access_flags ); -} - - -/* Really a per-device function, just pass through: - */ -static void xbcws_buffer_subdata_typed( struct brw_winsys *sws, - struct pipe_buffer *buf, - unsigned long offset, - unsigned long size, - const void *data, - unsigned data_type ) -{ - struct xlib_brw_context_winsys *xbcws = xlib_brw_context_winsys(sws); - - xlib_brw_buffer_subdata_typed( xbcws->pipe_winsys, - buf, - offset, - size, - data, - data_type ); -} - - -/** - * Create i965 hardware rendering context, but plugged into a - * dump-to-aubfile backend. - */ -struct pipe_context * -xlib_create_brw_context( struct pipe_screen *screen, - void *unused ) -{ - struct xlib_brw_context_winsys *xbcws = CALLOC_STRUCT( xlib_brw_context_winsys ); - - /* Fill in this struct with callbacks that i965simple will need to - * communicate with the window system, buffer manager, etc. - */ - xbcws->brw_context_winsys.batch_start = xbcws_batch_start; - xbcws->brw_context_winsys.batch_dword = xbcws_batch_dword; - xbcws->brw_context_winsys.batch_reloc = xbcws_batch_reloc; - xbcws->brw_context_winsys.batch_end = xbcws_batch_end; - xbcws->brw_context_winsys.batch_flush = xbcws_batch_flush; - xbcws->brw_context_winsys.buffer_subdata_typed = xbcws_buffer_subdata_typed; - xbcws->brw_context_winsys.get_buffer_offset = xbcws_get_buffer_offset; - - xbcws->pipe_winsys = screen->winsys; /* redundant */ - - xbcws->batch_size = XBCWS_BATCHBUFFER_SIZE; - - /* Create the i965simple context: - */ -#ifdef GALLIUM_CELL - return NULL; -#else - return brw_create( screen, - &xbcws->brw_context_winsys, - 0 ); -#endif -} diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 21649a0b1f..3e8fefb582 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -34,7 +34,6 @@ -#include "xm_api.h" #undef ASSERT #undef Elements -- cgit v1.2.3 From c867c58c7340eb5d56f7cc3edf95cce94600f858 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 19:21:27 +0000 Subject: gallium: make it work --- src/gallium/winsys/xlib/Makefile | 1 + src/gallium/winsys/xlib/xlib.c | 49 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/gallium/winsys/xlib/xlib.c (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 056b6a308f..bb631b16ce 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -9,6 +9,7 @@ LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/auxiliary C_SOURCES = \ + xlib.c \ xlib_cell.c \ xlib_sw_winsys.c \ xlib_llvmpipe.c \ diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c new file mode 100644 index 0000000000..6ca9e362e7 --- /dev/null +++ b/src/gallium/winsys/xlib/xlib.c @@ -0,0 +1,49 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/* + * Authors: + * Keith Whitwell + */ + +#include "xlib.h" +#include "util/u_debug.h" + +struct xm_driver *xlib_sw_winsys_init( void ) +{ +#if defined(GALLIUM_CELL) + if (!getenv("GALLIUM_NOCELL")) + return &xlib_cell_driver; +#endif + +#if defined(GALLIUM_LLVMPIPE) + return &xlib_llvmpipe_driver; +#endif + + return &xlib_softpipe_driver; +} -- cgit v1.2.3 From 3ab8211be40e3cd835bd1f6947b2c56f9a0c7a59 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Mar 2010 19:23:10 +0000 Subject: gallium: remove xlib_driver::display_surface Just use flush_frontbuffer directly. The flush_frontbuffer routine has been somewhat devalued recently, but it is actually just the right interface for our needs. It is in pipe_screen, meaning that any wrapping (eg trace module) will get properly unwrapped before we try and use the pipe_surface argument for real. If a particular co-state-tracker needs to implement this itself, it should organize a way to allow the winsys to call back up to its level, rather than hijacking the driver-supplied implementation. --- src/gallium/include/state_tracker/xlib_sw_winsys.h | 3 --- src/gallium/state_trackers/glx/xlib/xm_api.c | 10 +++------- src/gallium/winsys/xlib/xlib_llvmpipe.c | 13 ------------- src/gallium/winsys/xlib/xlib_softpipe.c | 11 ----------- 4 files changed, 3 insertions(+), 34 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index c703d3b66c..915a7b37fb 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -22,9 +22,6 @@ struct xlib_drawable { struct xm_driver { struct pipe_screen *(*create_pipe_screen)( Display *display ); - - void (*display_surface)( struct xlib_drawable *, - struct pipe_surface * ); }; /* Called by the libgl-xlib target code to build the rendering stack. diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index d878740ab1..d8aa59b3b7 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1092,13 +1092,9 @@ void XMesaSwapBuffers( XMesaBuffer b ) st_swapbuffers(b->stfb, &frontLeftSurf, NULL); if (frontLeftSurf) { - if (_screen != screen) { - struct trace_surface *tr_surf = trace_surface( frontLeftSurf ); - struct pipe_surface *surf = tr_surf->surface; - frontLeftSurf = surf; - } - - driver.display_surface(&b->ws, frontLeftSurf); + screen->flush_frontbuffer( screen, + frontLeftSurf, + &b->ws ); } xmesa_check_and_update_buffer_size(NULL, b); diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c index ceefc1624c..8b66b7459d 100644 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ b/src/gallium/winsys/xlib/xlib_llvmpipe.c @@ -69,22 +69,9 @@ fail: } -static void -xlib_llvmpipe_display_surface(struct xlib_drawable *xm_buffer, - struct pipe_surface *surf) -{ - struct llvmpipe_texture *texture = llvmpipe_texture(surf->texture); - - assert(texture->dt); - if (texture->dt) - xlib_sw_display(xm_buffer, texture->dt); -} - - struct xm_driver xlib_llvmpipe_driver = { .create_pipe_screen = xlib_create_llvmpipe_screen, - .display_surface = xlib_llvmpipe_display_surface }; diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c index 3b51d7c17c..08b7f08837 100644 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ b/src/gallium/winsys/xlib/xlib_softpipe.c @@ -57,22 +57,11 @@ fail: } -static void -xlib_softpipe_display_surface(struct xlib_drawable *xm_buffer, - struct pipe_surface *surf) -{ - struct softpipe_texture *texture = softpipe_texture(surf->texture); - - assert(texture->dt); - if (texture->dt) - xlib_sw_display(xm_buffer, texture->dt); -} struct xm_driver xlib_softpipe_driver = { .create_pipe_screen = xlib_create_softpipe_screen, - .display_surface = xlib_softpipe_display_surface }; -- cgit v1.2.3 From 1d84808dc045d7fcf2fade8d1504bc25e7c5041a Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 8 Mar 2010 15:04:04 -0500 Subject: gallivm: fix a crash by making sure we set the has_mask flag correctly --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 28ff362cac..fbb664d43a 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -152,8 +152,7 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context static void lp_exec_mask_update(struct lp_exec_mask *mask) { mask->exec_mask = mask->cond_mask; - if (mask->cond_stack_size > 0) - mask->has_mask = TRUE; + mask->has_mask = (mask->cond_stack_size > 0); } static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, -- cgit v1.2.3 From e3b6f7b8003a8838da2a219f62d6c025a87e9396 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 13:25:28 -0700 Subject: llvmpipe: rewrap for 80 columns --- src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index 632462460a..fde2d653eb 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -51,10 +51,11 @@ /** - * This provides the bridge between the sampler state store in lp_jit_context - * and lp_jit_texture and the sampler code generator. It provides the - * texture layout information required by the texture sampler code generator - * in terms of the state stored in lp_jit_context and lp_jit_texture in runtime. + * This provides the bridge between the sampler state store in + * lp_jit_context and lp_jit_texture and the sampler code + * generator. It provides the texture layout information required by + * the texture sampler code generator in terms of the state stored in + * lp_jit_context and lp_jit_texture in runtime. */ struct llvmpipe_sampler_dynamic_state { @@ -89,7 +90,8 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, unsigned member_index, const char *member_name) { - struct llvmpipe_sampler_dynamic_state *state = (struct llvmpipe_sampler_dynamic_state *)base; + struct llvmpipe_sampler_dynamic_state *state = + (struct llvmpipe_sampler_dynamic_state *)base; LLVMValueRef indices[4]; LLVMValueRef ptr; LLVMValueRef res; @@ -116,11 +118,13 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, /** - * Helper macro to instantiate the functions that generate the code to fetch - * the members of lp_jit_texture to fulfill the sampler code generator requests. + * Helper macro to instantiate the functions that generate the code to + * fetch the members of lp_jit_texture to fulfill the sampler code + * generator requests. * - * This complexity is the price we have to pay to keep the texture sampler code - * generator a reusable module without dependencies to llvmpipe internals. + * This complexity is the price we have to pay to keep the texture + * sampler code generator a reusable module without dependencies to + * llvmpipe internals. */ #define LP_LLVM_TEXTURE_MEMBER(_name, _index) \ static LLVMValueRef \ -- cgit v1.2.3 From d73fadf2116f5459f18bd84f48e7ed86773797b0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 13:36:34 -0700 Subject: llvmpipe: define max texture levels --- src/gallium/drivers/llvmpipe/lp_screen.c | 6 +++--- src/gallium/drivers/llvmpipe/lp_texture.h | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index f84ede675b..2c6fd67eae 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -107,11 +107,11 @@ llvmpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 13; /* max 4Kx4K */ + return LP_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 9; /* max 256x256x256 */ + return LP_MAX_TEXTURE_3D_LEVELS; case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 13; /* max 4Kx4K */ + return LP_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_TGSI_CONT_SUPPORTED: return 1; case PIPE_CAP_BLEND_EQUATION_SEPARATE: diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index 87c905bc02..c511a01298 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -32,6 +32,10 @@ #include "pipe/p_state.h" +#define LP_MAX_TEXTURE_2D_LEVELS 13 /* 4K x 4K for now */ +#define LP_MAX_TEXTURE_3D_LEVELS 10 /* 512 x 512 x 512 for now */ + + struct pipe_context; struct pipe_screen; struct llvmpipe_context; @@ -42,8 +46,8 @@ struct llvmpipe_texture { struct pipe_texture base; - unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS]; - unsigned stride[PIPE_MAX_TEXTURE_LEVELS]; + unsigned long level_offset[LP_MAX_TEXTURE_2D_LEVELS]; + unsigned stride[LP_MAX_TEXTURE_2D_LEVELS]; /** * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET -- cgit v1.2.3 From 44eec2802323b1e6cb47dfcf0aeab6b4cfd1c110 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 13:56:44 -0700 Subject: softpipe: define SP_MAX_TEXTURE_2D/3D_LEVELS --- src/gallium/drivers/softpipe/sp_screen.c | 6 +++--- src/gallium/drivers/softpipe/sp_texture.h | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 6ec63fe698..3405a043c6 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -83,11 +83,11 @@ softpipe_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 13; /* max 4Kx4K */ + return SP_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 9; /* max 256x256x256 */ + return SP_MAX_TEXTURE_3D_LEVELS; case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 13; /* max 4Kx4K */ + return SP_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_TGSI_CONT_SUPPORTED: return 1; case PIPE_CAP_BLEND_EQUATION_SEPARATE: diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h index 2ef64e1e7c..b54cf33ef5 100644 --- a/src/gallium/drivers/softpipe/sp_texture.h +++ b/src/gallium/drivers/softpipe/sp_texture.h @@ -33,6 +33,10 @@ #include "pipe/p_video_state.h" +#define SP_MAX_TEXTURE_2D_LEVELS 13 /* 4K x 4K */ +#define SP_MAX_TEXTURE_3D_LEVELS 9 /* 512 x 512 x 512 */ + + struct pipe_context; struct pipe_screen; struct softpipe_context; @@ -42,8 +46,8 @@ struct softpipe_texture { struct pipe_texture base; - unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS]; - unsigned stride[PIPE_MAX_TEXTURE_LEVELS]; + unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS]; + unsigned stride[SP_MAX_TEXTURE_2D_LEVELS]; /* The data is held here: */ -- cgit v1.2.3 From e836f35369784fd90657252dcaf75e66f2369068 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 13:57:14 -0700 Subject: i965g: define BRW_MAX_TEXTURE_2D/3D_LEVELS --- src/gallium/drivers/i965/brw_screen.c | 6 +++--- src/gallium/drivers/i965/brw_screen.h | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c index 66f3aad8b2..cef83ffea8 100644 --- a/src/gallium/drivers/i965/brw_screen.c +++ b/src/gallium/drivers/i965/brw_screen.c @@ -174,11 +174,11 @@ brw_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 11; /* max 1024x1024 */ + return BRW_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 8; /* max 128x128x128 */ + return BRW_MAX_TEXTURE_3D_LEVELS; case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 11; /* max 1024x1024 */ + return BRW_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: return 1; diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h index 7226d9228b..e0f3cd2a9f 100644 --- a/src/gallium/drivers/i965/brw_screen.h +++ b/src/gallium/drivers/i965/brw_screen.h @@ -100,6 +100,9 @@ struct brw_surface }; +#define BRW_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */ +#define BRW_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */ + struct brw_texture { @@ -107,9 +110,9 @@ struct brw_texture struct brw_winsys_buffer *bo; struct brw_surface_state ss; - unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; - unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS]; - unsigned level_offset[PIPE_MAX_TEXTURE_LEVELS]; + unsigned *image_offset[BRW_MAX_TEXTURE_2D_LEVELS]; + unsigned nr_images[BRW_MAX_TEXTURE_2D_LEVELS]; + unsigned level_offset[BRW_MAX_TEXTURE_2D_LEVELS]; boolean compressed; unsigned brw_target; -- cgit v1.2.3 From e0d4f3202e213ae790a272eba7e96a40f68a6822 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 13:59:39 -0700 Subject: i915g: define I915_MAX_TEXTURE_2D/3D_LEVELS --- src/gallium/drivers/i915/i915_context.h | 7 +++++-- src/gallium/drivers/i915/i915_screen.c | 6 +++--- src/gallium/drivers/i915/i915_texture.c | 4 ++-- 3 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index da769e7b29..499a727314 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -187,6 +187,9 @@ struct i915_sampler_state { unsigned maxlod; }; +#define I915_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */ +#define I915_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */ + struct i915_texture { struct pipe_texture base; @@ -199,7 +202,7 @@ struct i915_texture { unsigned sw_tiled; /**< tiled with software flags */ unsigned hw_tiled; /**< tiled with hardware fences */ - unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS]; + unsigned nr_images[I915_MAX_TEXTURE_2D_LEVELS]; /* Explicitly store the offset of each image for each cube face or * depth value. Pretty much have to accept that hardware formats @@ -207,7 +210,7 @@ struct i915_texture { * compute the offsets of depth/cube images within a mipmap level, * so have to store them as a lookup table: */ - unsigned *image_offset[PIPE_MAX_TEXTURE_LEVELS]; /**< array [depth] of offsets */ + unsigned *image_offset[I915_MAX_TEXTURE_2D_LEVELS]; /**< array [depth] of offsets */ /* The data is held here: */ diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 72bd263550..e5bf4a20bd 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -116,11 +116,11 @@ i915_get_param(struct pipe_screen *screen, int param) case PIPE_CAP_TEXTURE_SHADOW_MAP: return 1; case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: - return 11; /* max 1024x1024 */ + return I915_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: - return 8; /* max 128x128x128 */ + return I915_MAX_TEXTURE_3D_LEVELS; case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: - return 11; /* max 1024x1024 */ + return I915_MAX_TEXTURE_2D_LEVELS; case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT: case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER: return 1; diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 334959c46d..5b1f42313e 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -96,7 +96,7 @@ i915_miptree_set_level_info(struct i915_texture *tex, unsigned nr_images, unsigned w, unsigned h, unsigned d) { - assert(level < PIPE_MAX_TEXTURE_LEVELS); + assert(level < Elements(tex->nr_images)); tex->nr_images[level] = nr_images; @@ -775,7 +775,7 @@ i915_texture_destroy(struct pipe_texture *pt) iws->buffer_destroy(iws, tex->buffer); - for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) + for (i = 0; i < Elements(tex->image_offset); i++) if (tex->image_offset[i]) FREE(tex->image_offset[i]); -- cgit v1.2.3 From 156585c12ea4ffc6ada703d68c80ed49137da59c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 14:00:20 -0700 Subject: svga: s/PIPE_MAX_TEXTURE_LEVELS/SVGA_MAX_TEXTURE_LEVELS/ --- src/gallium/drivers/svga/svga_screen_texture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_screen_texture.h index 24c1f78ca5..ca6602b436 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.h +++ b/src/gallium/drivers/svga/svga_screen_texture.h @@ -78,7 +78,7 @@ struct svga_texture { struct pipe_texture base; - boolean defined[6][PIPE_MAX_TEXTURE_LEVELS]; + boolean defined[6][SVGA_MAX_TEXTURE_LEVELS]; struct svga_sampler_view *cached_view; -- cgit v1.2.3 From ac2e8491117dcf4a608eff4f52a9e34c1bea2a03 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 14:01:30 -0700 Subject: r300g: define R300_MAX_TEXTURE_LEVELS --- src/gallium/drivers/r300/r300_context.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 8c52d880a3..c2825d5f26 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -124,13 +124,15 @@ struct r300_texture_format_state { uint32_t format2; /* R300_TX_FORMAT2: 0x4500 */ }; +#define R300_MAX_TEXTURE_LEVELS 13 + struct r300_texture_fb_state { /* Colorbuffer. */ - uint32_t colorpitch[PIPE_MAX_TEXTURE_LEVELS]; /* R300_RB3D_COLORPITCH[0-3]*/ + uint32_t colorpitch[R300_MAX_TEXTURE_LEVELS]; /* R300_RB3D_COLORPITCH[0-3]*/ uint32_t us_out_fmt; /* R300_US_OUT_FMT[0-3] */ /* Zbuffer. */ - uint32_t depthpitch[PIPE_MAX_TEXTURE_LEVELS]; /* R300_RB3D_DEPTHPITCH */ + uint32_t depthpitch[R300_MAX_TEXTURE_LEVELS]; /* R300_RB3D_DEPTHPITCH */ uint32_t zb_format; /* R300_ZB_FORMAT */ }; @@ -236,16 +238,16 @@ struct r300_texture { struct pipe_texture tex; /* Offsets into the buffer. */ - unsigned offset[PIPE_MAX_TEXTURE_LEVELS]; + unsigned offset[R300_MAX_TEXTURE_LEVELS]; /* A pitch for each mip-level */ - unsigned pitch[PIPE_MAX_TEXTURE_LEVELS]; + unsigned pitch[R300_MAX_TEXTURE_LEVELS]; /* Size of one zslice or face based on the texture target */ - unsigned layer_size[PIPE_MAX_TEXTURE_LEVELS]; + unsigned layer_size[R300_MAX_TEXTURE_LEVELS]; /* Whether the mipmap level is macrotiled. */ - enum r300_buffer_tiling mip_macrotile[PIPE_MAX_TEXTURE_LEVELS]; + enum r300_buffer_tiling mip_macrotile[R300_MAX_TEXTURE_LEVELS]; /** * If non-zero, override the natural texture layout with -- cgit v1.2.3 From 891f7f4d52656ddbb445ef1992e8de05763ce680 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 14:02:38 -0700 Subject: nv: define NV30/40/50_MAX_TEXTURE_LEVELS --- src/gallium/drivers/nv30/nv30_state.h | 4 +++- src/gallium/drivers/nv40/nv40_state.h | 4 +++- src/gallium/drivers/nv50/nv50_context.h | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_state.h b/src/gallium/drivers/nv30/nv30_state.h index e42e872de7..66c26360cb 100644 --- a/src/gallium/drivers/nv30/nv30_state.h +++ b/src/gallium/drivers/nv30/nv30_state.h @@ -70,6 +70,8 @@ struct nv30_fragment_program { struct nouveau_stateobj *so; }; +#define NV30_MAX_TEXTURE_LEVELS 16 + struct nv30_miptree { struct pipe_texture base; struct nouveau_bo *bo; @@ -80,7 +82,7 @@ struct nv30_miptree { struct { uint pitch; uint *image_offset; - } level[PIPE_MAX_TEXTURE_LEVELS]; + } level[NV30_MAX_TEXTURE_LEVELS]; }; #endif diff --git a/src/gallium/drivers/nv40/nv40_state.h b/src/gallium/drivers/nv40/nv40_state.h index 192074e747..e2e69420ea 100644 --- a/src/gallium/drivers/nv40/nv40_state.h +++ b/src/gallium/drivers/nv40/nv40_state.h @@ -73,6 +73,8 @@ struct nv40_fragment_program { struct nouveau_stateobj *so; }; +#define NV40_MAX_TEXTURE_LEVELS 16 + struct nv40_miptree { struct pipe_texture base; struct nouveau_bo *bo; @@ -83,7 +85,7 @@ struct nv40_miptree { struct { uint pitch; uint *image_offset; - } level[PIPE_MAX_TEXTURE_LEVELS]; + } level[NV40_MAX_TEXTURE_LEVELS]; }; #endif diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index c540594b94..044437e75f 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -90,10 +90,12 @@ struct nv50_miptree_level { unsigned tile_mode; }; +#define NV50_MAX_TEXTURE_LEVELS 16 + struct nv50_miptree { struct nouveau_miptree base; - struct nv50_miptree_level level[PIPE_MAX_TEXTURE_LEVELS]; + struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS]; int image_nr; int total_size; }; -- cgit v1.2.3 From f027d5612901de8e6167e6288c4e24d91d964e7f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 15:19:13 -0700 Subject: llvmpipe/gallivm: checkpoint: array of pointers to mipmap levels Change the texture data_ptr from just a single image pointer to an array of image pointers, indexed by mipmap level. We'll use this for mipmap filtering. For now, the mipmap level is hard-coded to zero. --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 3 +- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 3 +- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 69 +++++++++++++++-------- src/gallium/drivers/llvmpipe/lp_jit.c | 4 +- src/gallium/drivers/llvmpipe/lp_jit.h | 3 +- src/gallium/drivers/llvmpipe/lp_setup.c | 16 ++++-- src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 27 +++++---- 7 files changed, 81 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 29cadcc15a..311c9f1b9e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -162,8 +162,7 @@ lp_build_sample_offset(struct lp_build_context *bld, const struct util_format_description *format_desc, LLVMValueRef x, LLVMValueRef y, - LLVMValueRef y_stride, - LLVMValueRef data_ptr) + LLVMValueRef y_stride) { LLVMValueRef x_stride; LLVMValueRef offset; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 5ba0925bb6..68db91d6fd 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -148,8 +148,7 @@ lp_build_sample_offset(struct lp_build_context *bld, const struct util_format_description *format_desc, LLVMValueRef x, LLVMValueRef y, - LLVMValueRef y_stride, - LLVMValueRef data_ptr); + LLVMValueRef y_stride); void diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 9058f76c1d..1dca29cdd5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -124,13 +124,14 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef x, LLVMValueRef y, LLVMValueRef y_stride, - LLVMValueRef data_ptr, + LLVMValueRef data_array, LLVMValueRef *texel) { struct lp_build_context *int_coord_bld = &bld->int_coord_bld; LLVMValueRef offset; LLVMValueRef packed; LLVMValueRef use_border = NULL; + LLVMValueRef data_ptr; /* use_border = x < 0 || x >= width || y < 0 || y >= height */ if (wrap_mode_uses_border_color(bld->static_state->wrap_s)) { @@ -153,6 +154,16 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, } } + /* XXX always use mipmap level 0 for now */ + { + const int level = 0; + LLVMValueRef indexes[2]; + indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indexes[1] = LLVMConstInt(LLVMInt32Type(), level, 0); + data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, ""); + data_ptr = LLVMBuildLoad(bld->builder, data_ptr, ""); + } + /* * Note: if we find an app which frequently samples the texture border * we might want to implement a true conditional here to avoid sampling @@ -171,8 +182,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, /* convert x,y coords to linear offset from start of texture, in bytes */ offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, - x, y, y_stride, - data_ptr); + x, y, y_stride); assert(bld->format_desc->block.width == 1); assert(bld->format_desc->block.height == 1); @@ -210,19 +220,31 @@ lp_build_sample_packed(struct lp_build_sample_context *bld, LLVMValueRef x, LLVMValueRef y, LLVMValueRef y_stride, - LLVMValueRef data_ptr) + LLVMValueRef data_array) { LLVMValueRef offset; + LLVMValueRef data_ptr; offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, - x, y, y_stride, - data_ptr); + x, y, y_stride); assert(bld->format_desc->block.width == 1); assert(bld->format_desc->block.height == 1); assert(bld->format_desc->block.bits <= bld->texel_type.width); + /* XXX always use mipmap level 0 for now */ + { + const int level = 0; + LLVMValueRef indexes[2]; + /* get data_ptr[level] */ + indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indexes[1] = LLVMConstInt(LLVMInt32Type(), level, 0); + data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, ""); + /* load texture base address */ + data_ptr = LLVMBuildLoad(bld->builder, data_ptr, ""); + } + return lp_build_gather(bld->builder, bld->texel_type.length, bld->format_desc->block.bits, @@ -720,7 +742,7 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, LLVMValueRef width, LLVMValueRef height, LLVMValueRef stride, - LLVMValueRef data_ptr, + LLVMValueRef data_array, LLVMValueRef *texel) { LLVMValueRef x, y; @@ -735,7 +757,7 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, lp_build_name(x, "tex.x.wrapped"); lp_build_name(y, "tex.y.wrapped"); - lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_ptr, texel); + lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_array, texel); } @@ -749,7 +771,7 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, LLVMValueRef width, LLVMValueRef height, LLVMValueRef stride, - LLVMValueRef data_ptr, + LLVMValueRef data_array, LLVMValueRef *texel) { LLVMValueRef s_fpart; @@ -764,10 +786,10 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, lp_build_sample_wrap_linear(bld, t, height, bld->static_state->pot_height, bld->static_state->wrap_t, &y0, &y1, &t_fpart); - lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_ptr, neighbors[0][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_ptr, neighbors[0][1]); - lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_ptr, neighbors[1][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_ptr, neighbors[1][1]); + lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_array, neighbors[0][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_array, neighbors[0][1]); + lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_array, neighbors[1][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_array, neighbors[1][1]); /* TODO: Don't interpolate missing channels */ for(chan = 0; chan < 4; ++chan) { @@ -818,7 +840,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef width, LLVMValueRef height, LLVMValueRef stride, - LLVMValueRef data_ptr, + LLVMValueRef data_array, LLVMValueRef *texel) { LLVMBuilderRef builder = bld->builder; @@ -958,10 +980,10 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, * The higher 8 bits of the resulting elements will be zero. */ - neighbors[0][0] = lp_build_sample_packed(bld, x0, y0, stride, data_ptr); - neighbors[0][1] = lp_build_sample_packed(bld, x1, y0, stride, data_ptr); - neighbors[1][0] = lp_build_sample_packed(bld, x0, y1, stride, data_ptr); - neighbors[1][1] = lp_build_sample_packed(bld, x1, y1, stride, data_ptr); + neighbors[0][0] = lp_build_sample_packed(bld, x0, y0, stride, data_array); + neighbors[0][1] = lp_build_sample_packed(bld, x1, y0, stride, data_array); + neighbors[1][0] = lp_build_sample_packed(bld, x0, y1, stride, data_array); + neighbors[1][1] = lp_build_sample_packed(bld, x1, y1, stride, data_array); neighbors[0][0] = LLVMBuildBitCast(builder, neighbors[0][0], u8n_vec_type, ""); neighbors[0][1] = LLVMBuildBitCast(builder, neighbors[0][1], u8n_vec_type, ""); @@ -1248,7 +1270,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef width; LLVMValueRef height; LLVMValueRef stride; - LLVMValueRef data_ptr; + LLVMValueRef data_array; LLVMValueRef s; LLVMValueRef t; LLVMValueRef r; @@ -1276,7 +1298,8 @@ lp_build_sample_soa(LLVMBuilderRef builder, width = dynamic_state->width(dynamic_state, builder, unit); height = dynamic_state->height(dynamic_state, builder, unit); stride = dynamic_state->stride(dynamic_state, builder, unit); - data_ptr = dynamic_state->data_ptr(dynamic_state, builder, unit); + data_array = dynamic_state->data_ptr(dynamic_state, builder, unit); + /* Note that data_array is an array[level] of pointers to texture images */ s = coords[0]; t = coords[1]; @@ -1292,17 +1315,17 @@ lp_build_sample_soa(LLVMBuilderRef builder, switch (static_state->min_img_filter) { case PIPE_TEX_FILTER_NEAREST: lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, - stride, data_ptr, texel); + stride, data_array, texel); break; case PIPE_TEX_FILTER_LINEAR: if(lp_format_is_rgba8(bld.format_desc) && is_simple_wrap_mode(static_state->wrap_s) && is_simple_wrap_mode(static_state->wrap_t)) lp_build_sample_2d_linear_aos(&bld, s, t, width, height, - stride, data_ptr, texel); + stride, data_array, texel); else lp_build_sample_2d_linear_soa(&bld, s, t, width, height, - stride, data_ptr, texel); + stride, data_array, texel); break; default: assert(0); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index bacff500d6..08c8f93794 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -58,7 +58,9 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) elem_types[LP_JIT_TEXTURE_DEPTH] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_STRIDE] = LLVMInt32Type(); - elem_types[LP_JIT_TEXTURE_DATA] = LLVMPointerType(LLVMInt8Type(), 0); + elem_types[LP_JIT_TEXTURE_DATA] = + LLVMArrayType(LLVMPointerType(LLVMInt8Type(), 0), + LP_MAX_TEXTURE_2D_LEVELS); texture_type = LLVMStructType(elem_types, Elements(elem_types), 0); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 0ebb2826fa..5cc7a12c03 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -39,6 +39,7 @@ #include "gallivm/lp_bld_struct.h" #include "pipe/p_state.h" +#include "lp_texture.h" struct llvmpipe_screen; @@ -51,7 +52,7 @@ struct lp_jit_texture uint32_t depth; uint32_t last_level; uint32_t stride; - const void *data; + const void *data[LP_MAX_TEXTURE_2D_LEVELS]; }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index b0713c3b71..cc7c18c8c0 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -472,19 +472,25 @@ lp_setup_set_sampler_textures( struct setup_context *setup, jit_tex->depth = tex->depth0; jit_tex->last_level = tex->last_level; jit_tex->stride = lp_tex->stride[0]; - if(!lp_tex->dt) { - jit_tex->data = lp_tex->data; + if (!lp_tex->dt) { + /* regular texture - setup array of mipmap level pointers */ + int j; + for (j = 0; j < LP_MAX_TEXTURE_2D_LEVELS; j++) { + jit_tex->data[j] = + (ubyte *) lp_tex->data + lp_tex->level_offset[j]; + } } else { + /* display target texture/surface */ /* * XXX: Where should this be unmapped? */ struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen); struct llvmpipe_winsys *winsys = screen->winsys; - jit_tex->data = winsys->displaytarget_map(winsys, lp_tex->dt, - PIPE_BUFFER_USAGE_CPU_READ); - assert(jit_tex->data); + jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt, + PIPE_BUFFER_USAGE_CPU_READ); + assert(jit_tex->data[0]); } /* the scene references this texture */ diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index fde2d653eb..5a3cf37d6d 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -80,6 +80,9 @@ struct lp_llvm_sampler_soa /** * Fetch the specified member of the lp_jit_texture structure. + * \param emit_load if TRUE, emit the LLVM load instruction to actually + * fetch the field's value. Otherwise, just emit the + * GEP code to address the field. * * @sa http://llvm.org/docs/GetElementPtr.html */ @@ -88,7 +91,8 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, LLVMBuilderRef builder, unsigned unit, unsigned member_index, - const char *member_name) + const char *member_name, + boolean emit_load) { struct llvmpipe_sampler_dynamic_state *state = (struct llvmpipe_sampler_dynamic_state *)base; @@ -109,7 +113,10 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, ptr = LLVMBuildGEP(builder, state->context_ptr, indices, Elements(indices), ""); - res = LLVMBuildLoad(builder, ptr, ""); + if (emit_load) + res = LLVMBuildLoad(builder, ptr, ""); + else + res = ptr; lp_build_name(res, "context.texture%u.%s", unit, member_name); @@ -126,22 +133,22 @@ lp_llvm_texture_member(struct lp_sampler_dynamic_state *base, * sampler code generator a reusable module without dependencies to * llvmpipe internals. */ -#define LP_LLVM_TEXTURE_MEMBER(_name, _index) \ +#define LP_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \ static LLVMValueRef \ lp_llvm_texture_##_name( struct lp_sampler_dynamic_state *base, \ LLVMBuilderRef builder, \ unsigned unit) \ { \ - return lp_llvm_texture_member(base, builder, unit, _index, #_name ); \ + return lp_llvm_texture_member(base, builder, unit, _index, #_name, _emit_load ); \ } -LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH) -LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT) -LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH) -LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL) -LP_LLVM_TEXTURE_MEMBER(stride, LP_JIT_TEXTURE_STRIDE) -LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA) +LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH, TRUE) +LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT, TRUE) +LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH, TRUE) +LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL, TRUE) +LP_LLVM_TEXTURE_MEMBER(stride, LP_JIT_TEXTURE_STRIDE, TRUE) +LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA, FALSE) static void -- cgit v1.2.3 From e799163dec1fd23dadc9d3eaf5e71e9e7d23a818 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 16:19:15 -0700 Subject: vega: remove redundant DEFINES from .c.o rule --- src/gallium/state_trackers/vega/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/vega/Makefile b/src/gallium/state_trackers/vega/Makefile index 037d8dc911..7f04b2aa83 100644 --- a/src/gallium/state_trackers/vega/Makefile +++ b/src/gallium/state_trackers/vega/Makefile @@ -53,7 +53,7 @@ INCLUDE_DIRS = \ .c.o: - $(CC) -c $(INCLUDE_DIRS) $(DEFINES) $(CFLAGS) $< -o $@ + $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ default: depend $(TOP)/$(LIB_DIR)/$(VG_LIB_NAME) -- cgit v1.2.3 From 4243ca1144eef5783ed080cce9db1a8dda2c6360 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Mar 2010 16:20:16 -0700 Subject: gallium: update some comments, remove others which are superfluous --- src/gallium/include/pipe/p_state.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 02558520bf..72635d1031 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -249,7 +249,7 @@ struct pipe_framebuffer_state { unsigned width, height; - /** multiple colorbuffers for multiple render targets */ + /** multiple color buffers for multiple render targets */ unsigned nr_cbufs; struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; @@ -285,12 +285,12 @@ struct pipe_sampler_state struct pipe_surface { struct pipe_reference reference; - enum pipe_format format; /**< PIPE_FORMAT_x */ + enum pipe_format format; unsigned width; /**< logical width in pixels */ unsigned height; /**< logical height in pixels */ unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */ unsigned offset; /**< offset from start of buffer, in bytes */ - unsigned usage; /**< PIPE_BUFFER_USAGE_* */ + unsigned usage; /**< bitmask of PIPE_BUFFER_USAGE_x */ unsigned zslice; struct pipe_texture *texture; /**< texture into which this is a view */ @@ -336,7 +336,7 @@ struct pipe_texture unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */ - unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */ + unsigned tex_usage; /**< bitmask of PIPE_TEXTURE_USAGE_* */ struct pipe_screen *screen; /**< screen that this texture belongs to */ }; @@ -375,7 +375,7 @@ struct pipe_vertex_element unsigned vertex_buffer_index:8; unsigned nr_components:8; - enum pipe_format src_format; /**< PIPE_FORMAT_* */ + enum pipe_format src_format; }; -- cgit v1.2.3 From 2b76e04a8ca92c02e705c6286c55975b0045d9af Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 9 Mar 2010 11:32:17 +0800 Subject: st/egl: Fix KMS build error after winsys handle change. --- src/gallium/state_trackers/egl/kms/native_kms.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c index 418461089a..7322240856 100644 --- a/src/gallium/state_trackers/egl/kms/native_kms.c +++ b/src/gallium/state_trackers/egl/kms/native_kms.c @@ -55,7 +55,7 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask, templ.format = ksurf->color_format; templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; if (ksurf->type == KMS_SURFACE_TYPE_SCANOUT) - templ.tex_usage |= PIPE_TEXTURE_SCANOUT; + templ.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT; } /* create textures */ @@ -100,7 +100,7 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) for (i = 0; i < num_framebuffers; i++) { struct kms_framebuffer *fb; enum native_attachment natt; - unsigned int handle, stride; + struct winsys_handle whandle; uint block_bits; if (i == 0) { @@ -128,13 +128,17 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back) /* TODO detect the real value */ fb->is_passive = TRUE; - if (!kdpy->api->local_handle_from_texture(kdpy->api, - kdpy->base.screen, fb->texture, &stride, &handle)) + memset(&whandle, 0, sizeof(whandle)); + whandle.type = DRM_API_HANDLE_TYPE_KMS; + + if (!kdpy->base.screen->texture_get_handle(kdpy->base.screen, + fb->texture, &whandle)) return FALSE; block_bits = util_format_get_blocksizebits(ksurf->color_format); err = drmModeAddFB(kdpy->fd, ksurf->width, ksurf->height, - block_bits, block_bits, stride, handle, &fb->buffer_id); + block_bits, block_bits, whandle.stride, whandle.handle, + &fb->buffer_id); if (err) { fb->buffer_id = 0; return FALSE; -- cgit v1.2.3 From f2b8f142674749f1b8f49938978493e0425f05fa Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 04:54:43 +0100 Subject: llvmpipe: quads never provoke the first vertex --- src/gallium/drivers/llvmpipe/lp_setup_vbuf.c | 129 ++++++++------------------- 1 file changed, 36 insertions(+), 93 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c index 24291da91e..671e74465c 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c +++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c @@ -231,57 +231,29 @@ lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_QUADS: - if (setup->flatshade_first) { - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - } - } - else { - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - } + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); } break; case PIPE_PRIM_QUAD_STRIP: - if (setup->flatshade_first) { - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride)); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - } - } - else { - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride), - get_vert(vertex_buffer, indices[i-0], stride) ); - } + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-2], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, indices[i-1], stride), + get_vert(vertex_buffer, indices[i-3], stride), + get_vert(vertex_buffer, indices[i-0], stride) ); } break; @@ -415,57 +387,28 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_QUADS: - if (setup->flatshade_first) { - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-3, stride) ); - } - } - else { - for (i = 3; i < nr; i += 4) { - setup->triangle( setup, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride) ); - } + for (i = 3; i < nr; i += 4) { + setup->triangle( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-0, stride) ); } break; case PIPE_PRIM_QUAD_STRIP: - if (setup->flatshade_first) { - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride) ); - setup->triangle( setup, - - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-3, stride) ); - } - } - else { - for (i = 3; i < nr; i += 2) { - setup->triangle( setup, - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride) ); - setup->triangle( setup, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride), - get_vert(vertex_buffer, i-0, stride) ); - } + for (i = 3; i < nr; i += 2) { + setup->triangle( setup, + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-2, stride), + get_vert(vertex_buffer, i-0, stride) ); + setup->triangle( setup, + get_vert(vertex_buffer, i-1, stride), + get_vert(vertex_buffer, i-3, stride), + get_vert(vertex_buffer, i-0, stride) ); } break; -- cgit v1.2.3 From 558ce9964f7edeefbe07b002a341fb9275b3c69b Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sun, 7 Mar 2010 04:56:06 +0100 Subject: softpipe: quads never provoke the first vertex --- src/gallium/drivers/softpipe/sp_prim_vbuf.c | 80 +++++------------------------ 1 file changed, 12 insertions(+), 68 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c index 98c08eaffa..6749243ab4 100644 --- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c +++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c @@ -264,57 +264,29 @@ sp_vbuf_draw(struct vbuf_render *vbr, const ushort *indices, uint nr) break; case PIPE_PRIM_QUADS: - if (softpipe->rasterizer->flatshade_first) { - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - } - } - else { - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, indices[i-3], stride), get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i-0], stride) ); - sp_setup_tri( setup_ctx, + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-0], stride) ); - } } break; case PIPE_PRIM_QUAD_STRIP: - if (softpipe->rasterizer->flatshade_first) { - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-1], stride), - get_vert(vertex_buffer, indices[i-3], stride)); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, indices[i-2], stride), - get_vert(vertex_buffer, indices[i-0], stride), - get_vert(vertex_buffer, indices[i-3], stride) ); - } - } - else { - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, indices[i-3], stride), get_vert(vertex_buffer, indices[i-2], stride), get_vert(vertex_buffer, indices[i-0], stride) ); - sp_setup_tri( setup_ctx, + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, indices[i-1], stride), get_vert(vertex_buffer, indices[i-3], stride), get_vert(vertex_buffer, indices[i-0], stride) ); - } } break; @@ -448,56 +420,28 @@ sp_vbuf_draw_arrays(struct vbuf_render *vbr, uint start, uint nr) break; case PIPE_PRIM_QUADS: - if (softpipe->rasterizer->flatshade_first) { - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-3, stride) ); - } - } - else { - for (i = 3; i < nr; i += 4) { - sp_setup_tri( setup_ctx, + for (i = 3; i < nr; i += 4) { + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, i-3, stride), get_vert(vertex_buffer, i-2, stride), get_vert(vertex_buffer, i-0, stride) ); - sp_setup_tri( setup_ctx, + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, i-2, stride), get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-0, stride) ); - } } break; case PIPE_PRIM_QUAD_STRIP: - if (softpipe->rasterizer->flatshade_first) { - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-1, stride), - get_vert(vertex_buffer, i-3, stride) ); - sp_setup_tri( setup_ctx, - get_vert(vertex_buffer, i-2, stride), - get_vert(vertex_buffer, i-0, stride), - get_vert(vertex_buffer, i-3, stride) ); - } - } - else { - for (i = 3; i < nr; i += 2) { - sp_setup_tri( setup_ctx, + for (i = 3; i < nr; i += 2) { + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, i-3, stride), get_vert(vertex_buffer, i-2, stride), get_vert(vertex_buffer, i-0, stride) ); - sp_setup_tri( setup_ctx, + sp_setup_tri( setup_ctx, get_vert(vertex_buffer, i-1, stride), get_vert(vertex_buffer, i-3, stride), get_vert(vertex_buffer, i-0, stride) ); - } } break; -- cgit v1.2.3 From f3365bceb881b7a5cdd47e6c102ca37454453ce9 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 9 Mar 2010 04:40:55 +0100 Subject: draw: quads never provoke the first vertex --- src/gallium/auxiliary/draw/draw_pt_decompose.h | 40 +++++++------------------ src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h | 38 +++++++---------------- 2 files changed, 20 insertions(+), 58 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pt_decompose.h b/src/gallium/auxiliary/draw/draw_pt_decompose.h index 4ca5b52020..3c44f7c11e 100644 --- a/src/gallium/auxiliary/draw/draw_pt_decompose.h +++ b/src/gallium/auxiliary/draw/draw_pt_decompose.h @@ -105,40 +105,20 @@ static void FUNC( ARGS, case PIPE_PRIM_QUADS: - if (flatfirst) { - for (i = 0; i+3 < count; i += 4) { - QUAD( (i + 1), - (i + 2), - (i + 3), - (i + 0) ); - } - } - else { - for (i = 0; i+3 < count; i += 4) { - QUAD( (i + 0), - (i + 1), - (i + 2), - (i + 3)); - } + for (i = 0; i+3 < count; i += 4) { + QUAD( (i + 0), + (i + 1), + (i + 2), + (i + 3)); } break; case PIPE_PRIM_QUAD_STRIP: - if (flatfirst) { - for (i = 0; i+3 < count; i += 2) { - QUAD( (i + 1), - (i + 3), - (i + 2), - (i + 0) ); - } - } - else { - for (i = 0; i+3 < count; i += 2) { - QUAD( (i + 2), - (i + 0), - (i + 1), - (i + 3)); - } + for (i = 0; i+3 < count; i += 2) { + QUAD( (i + 2), + (i + 0), + (i + 1), + (i + 3)); } break; diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h index 62822a3d56..7cba8547f1 100644 --- a/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h +++ b/src/gallium/auxiliary/draw/draw_pt_vcache_tmp.h @@ -118,39 +118,21 @@ static void FUNC( struct draw_pt_front_end *frontend, case PIPE_PRIM_QUADS: for (i = 0; i+3 < count; i += 4) { - if (flatfirst) { - QUAD( vcache, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, i + 3) ); - } - else { - QUAD( vcache, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 2), - get_elt(elts, i + 3) ); - } + QUAD( vcache, + get_elt(elts, i + 0), + get_elt(elts, i + 1), + get_elt(elts, i + 2), + get_elt(elts, i + 3) ); } break; case PIPE_PRIM_QUAD_STRIP: for (i = 0; i+3 < count; i += 2) { - if (flatfirst) { - QUAD( vcache, - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 3), - get_elt(elts, i + 2) ); - } - else { - QUAD( vcache, - get_elt(elts, i + 2), - get_elt(elts, i + 0), - get_elt(elts, i + 1), - get_elt(elts, i + 3) ); - } + QUAD( vcache, + get_elt(elts, i + 2), + get_elt(elts, i + 0), + get_elt(elts, i + 1), + get_elt(elts, i + 3) ); } break; -- cgit v1.2.3 From 821c830f11fc1c3529a186ace1d1ba3ddeab4957 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 9 Mar 2010 02:10:36 +0100 Subject: r300g: remove hacks from translate_vertex_data_swizzle The first part of the fix of BGRA vertex colors. --- src/gallium/drivers/r300/r300_state_inlines.h | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 2f3a56e1fb..af7827820c 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -453,7 +453,6 @@ r300_translate_vertex_data_type(enum pipe_format format) { static INLINE uint16_t r300_translate_vertex_data_swizzle(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - unsigned swizzle[4], i; assert(format); @@ -463,25 +462,10 @@ r300_translate_vertex_data_swizzle(enum pipe_format format) { return 0; } - /* Swizzles for 8bits formats are in the reversed order, not sure why. */ - if (desc->channel[0].size == 8) { - for (i = 0; i < 4; i++) { - if (desc->swizzle[i] <= 3) { - swizzle[i] = 3 - desc->swizzle[i]; - } else { - swizzle[i] = desc->swizzle[i]; - } - } - } else { - for (i = 0; i < 4; i++) { - swizzle[i] = desc->swizzle[i]; - } - } - - return ((swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | - (swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | - (swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | - (swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | + return ((desc->swizzle[0] << R300_SWIZZLE_SELECT_X_SHIFT) | + (desc->swizzle[1] << R300_SWIZZLE_SELECT_Y_SHIFT) | + (desc->swizzle[2] << R300_SWIZZLE_SELECT_Z_SHIFT) | + (desc->swizzle[3] << R300_SWIZZLE_SELECT_W_SHIFT) | (0xf << R300_WRITE_ENA_SHIFT)); } -- cgit v1.2.3 From da92f6db5bf0d3ac42732df556eb4f96619c9047 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 9 Mar 2010 12:36:34 +0800 Subject: winsys/xlib: Fix a segfault when USE_XSHM is not defined. --- src/gallium/winsys/xlib/xlib_sw_winsys.c | 41 ++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 3e8fefb582..9a4ae39aeb 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -193,6 +193,26 @@ alloc_shm_ximage(struct xm_displaytarget *xm_dt, #endif /* USE_XSHM */ +static void +alloc_ximage(struct xm_displaytarget *xm_dt, + struct xlib_drawable *xmb, + unsigned width, unsigned height) +{ +#ifdef USE_XSHM + if (xm_dt->shm) { + alloc_shm_ximage(xm_dt, xmb, width, height); + return; + } +#endif + + xm_dt->tempImage = XCreateImage(xm_dt->display, + xmb->visual, + xmb->depth, + ZPixmap, 0, + NULL, width, height, + 8, 0); +} + static boolean xm_is_displaytarget_format_supported( struct sw_winsys *ws, enum pipe_format format ) @@ -265,19 +285,20 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, if (no_swap) return; + if (xm_dt->tempImage == NULL) + { + assert(util_format_get_blockwidth(xm_dt->format) == 1); + assert(util_format_get_blockheight(xm_dt->format) == 1); + alloc_ximage(xm_dt, xlib_drawable, + xm_dt->stride / util_format_get_blocksize(xm_dt->format), + xm_dt->height); + if (!xm_dt->tempImage) + return; + } + #ifdef USE_XSHM if (xm_dt->shm) { - if (xm_dt->tempImage == NULL) - { - assert(util_format_get_blockwidth(xm_dt->format) == 1); - assert(util_format_get_blockheight(xm_dt->format) == 1); - alloc_shm_ximage(xm_dt, - xlib_drawable, - xm_dt->stride / util_format_get_blocksize(xm_dt->format), - xm_dt->height); - } - ximage = xm_dt->tempImage; ximage->data = xm_dt->data; -- cgit v1.2.3 From 95c5c69b505f562b61e23fa7dd500dbdd432a70d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 8 Mar 2010 10:09:43 +0800 Subject: st/egl: Use xlib_sw_winsys in ximage backend. --- src/gallium/state_trackers/egl/common/egl_g3d.c | 15 -- src/gallium/state_trackers/egl/common/native.h | 3 - src/gallium/state_trackers/egl/x11/native_x11.c | 13 +- src/gallium/state_trackers/egl/x11/native_x11.h | 2 +- src/gallium/state_trackers/egl/x11/native_ximage.c | 192 ++++------------- src/gallium/state_trackers/egl/x11/sw_winsys.c | 231 --------------------- src/gallium/state_trackers/egl/x11/sw_winsys.h | 40 ---- src/gallium/winsys/drm/Makefile.egl | 3 +- 8 files changed, 47 insertions(+), 452 deletions(-) delete mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.c delete mode 100644 src/gallium/state_trackers/egl/x11/sw_winsys.h (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index 04268c71c5..2f7a8a8f7e 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -507,20 +507,6 @@ egl_g3d_add_configs(_EGLDriver *drv, _EGLDisplay *dpy, EGLint id) return id; } -/** - * Flush the front buffer of the context's draw surface. - */ -static void -egl_g3d_flush_frontbuffer(struct pipe_screen *screen, - struct pipe_surface *surf, void *context_private) -{ - struct egl_g3d_context *gctx = egl_g3d_context(context_private); - struct egl_g3d_surface *gsurf = egl_g3d_surface(gctx->base.DrawSurface); - - if (gsurf) - gsurf->native->flush_frontbuffer(gsurf->native); -} - /** * Re-validate the context. */ @@ -581,7 +567,6 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy, goto fail; } - gdpy->native->screen->flush_frontbuffer = egl_g3d_flush_frontbuffer; gdpy->native->screen->update_buffer = egl_g3d_update_buffer; egl_g3d_init_st(&gdrv->base); diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h index 4f9758545a..4c9217e1a5 100644 --- a/src/gallium/state_trackers/egl/common/native.h +++ b/src/gallium/state_trackers/egl/common/native.h @@ -137,9 +137,6 @@ struct native_display_modeset; struct native_display { /** * The pipe screen of the native display. - * - * Note that the "flush_frontbuffer" and "update_buffer" callbacks will be - * overridden. */ struct pipe_screen *screen; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 3add95d0ac..ef7490503b 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -141,16 +141,9 @@ native_create_display(EGLNativeDisplayType dpy) if (!ndpy) { EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; - boolean use_shm; - - /* - * XXX st/mesa calls pipe_screen::update_buffer in st_validate_state. - * When SHM is used, there is a good chance that the shared memory - * segment is detached before the softpipe tile cache is flushed. - */ - use_shm = FALSE; - _eglLog(level, "use software%s fallback", (use_shm) ? " (SHM)" : ""); - ndpy = x11_create_ximage_display(dpy, use_shm); + + _eglLog(level, "use software fallback"); + ndpy = x11_create_ximage_display(dpy); } return ndpy; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h index 622ddac5df..2e71de1885 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.h +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -29,7 +29,7 @@ #include "common/native.h" struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm); +x11_create_ximage_display(EGLNativeDisplayType dpy); struct native_display * x11_create_dri2_display(EGLNativeDisplayType dpy, struct drm_api *api); diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index a8633b1501..6c6ba24e7b 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -28,17 +28,15 @@ #include #include #include -#include #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_format.h" #include "pipe/p_compiler.h" #include "util/u_simple_screen.h" #include "util/u_inlines.h" -#include "softpipe/sp_winsys.h" +#include "state_tracker/xlib_sw_winsys.h" #include "egllog.h" -#include "sw_winsys.h" #include "native_x11.h" #include "x11_screen.h" @@ -56,19 +54,15 @@ struct ximage_display { struct x11_screen *xscr; int xscr_number; - boolean use_xshm; + struct xm_driver *driver; - struct pipe_winsys *winsys; struct ximage_config *configs; int num_configs; }; struct ximage_buffer { - XImage *ximage; - struct pipe_texture *texture; - XShmSegmentInfo *shm_info; - boolean xshm_attached; + struct xlib_drawable xdraw; }; struct ximage_surface { @@ -119,18 +113,6 @@ ximage_surface_free_buffer(struct native_surface *nsurf, struct ximage_buffer *xbuf = &xsurf->buffers[which]; pipe_texture_reference(&xbuf->texture, NULL); - - if (xbuf->shm_info) { - if (xbuf->xshm_attached) - XShmDetach(xsurf->xdpy->dpy, xbuf->shm_info); - if (xbuf->shm_info->shmaddr != (void *) -1) - shmdt(xbuf->shm_info->shmaddr); - if (xbuf->shm_info->shmid != -1) - shmctl(xbuf->shm_info->shmid, IPC_RMID, 0); - - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->shmid = -1; - } } static boolean @@ -154,40 +136,26 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, templ.depth0 = 1; templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; - if (xbuf->shm_info) { - struct pipe_buffer *pbuf; - unsigned stride, size; - void *addr = NULL; - - stride = util_format_get_stride(xsurf->color_format, xsurf->width); - /* alignment should depend on visual? */ - stride = align(stride, 4); - size = stride * xsurf->height; - - /* create and attach shm object */ - xbuf->shm_info->shmid = shmget(IPC_PRIVATE, size, 0755); - if (xbuf->shm_info->shmid != -1) { - xbuf->shm_info->shmaddr = - shmat(xbuf->shm_info->shmid, NULL, 0); - if (xbuf->shm_info->shmaddr != (void *) -1) { - if (XShmAttach(xsurf->xdpy->dpy, xbuf->shm_info)) { - addr = xbuf->shm_info->shmaddr; - xbuf->xshm_attached = TRUE; - } - } - } - - if (addr) { - pbuf = screen->user_buffer_create(screen, addr, size); - if (pbuf) { - xbuf->texture = - screen->texture_blanket(screen, &templ, &stride, pbuf); - pipe_buffer_reference(&pbuf, NULL); - } + if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { + switch (which) { + case NATIVE_ATTACHMENT_FRONT_LEFT: + case NATIVE_ATTACHMENT_FRONT_RIGHT: + templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + break; + case NATIVE_ATTACHMENT_BACK_LEFT: + case NATIVE_ATTACHMENT_BACK_RIGHT: + templ.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET; + break; + default: + break; } } - else { - xbuf->texture = screen->texture_create(screen, &templ); + xbuf->texture = screen->texture_create(screen, &templ); + if (xbuf->texture) { + xbuf->xdraw.visual = xsurf->visual.visual; + xbuf->xdraw.depth = xsurf->visual.depth; + xbuf->xdraw.drawable = xsurf->drawable; + xbuf->xdraw.gc = xsurf->gc; } /* clean up the buffer if allocation failed */ @@ -257,18 +225,10 @@ ximage_surface_update_buffers(struct native_surface *nsurf, uint buffer_mask) new_valid = 0x0; for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) { if (native_attachment_mask_test(buffer_mask, att)) { - struct ximage_buffer *xbuf = &xsurf->buffers[att]; - /* reallocate the texture */ if (!ximage_surface_alloc_buffer(&xsurf->base, att)) break; - /* update ximage */ - if (xbuf->ximage) { - xbuf->ximage->width = xsurf->width; - xbuf->ximage->height = xsurf->height; - } - new_valid |= (1 << att); if (buffer_mask == new_valid) break; @@ -288,43 +248,22 @@ ximage_surface_draw_buffer(struct native_surface *nsurf, struct ximage_surface *xsurf = ximage_surface(nsurf); struct ximage_buffer *xbuf = &xsurf->buffers[which]; struct pipe_screen *screen = xsurf->xdpy->base.screen; - struct pipe_transfer *transfer; + struct pipe_surface *psurf; if (xsurf->type == XIMAGE_SURFACE_TYPE_PBUFFER) return TRUE; - assert(xsurf->drawable && xbuf->ximage && xbuf->texture); + assert(xsurf->drawable && xbuf->texture); - transfer = screen->get_tex_transfer(screen, xbuf->texture, - 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, xsurf->width, xsurf->height); - if (!transfer) + /* what's the cost of surface creation? */ + psurf = screen->get_tex_surface(screen, + xbuf->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ); + if (!psurf) return FALSE; - xbuf->ximage->bytes_per_line = transfer->stride; - xbuf->ximage->data = screen->transfer_map(screen, transfer); - if (!xbuf->ximage->data) { - screen->tex_transfer_destroy(transfer); - return FALSE; - } - - - if (xbuf->shm_info) - XShmPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height, False); - else - XPutImage(xsurf->xdpy->dpy, xsurf->drawable, xsurf->gc, - xbuf->ximage, 0, 0, 0, 0, xsurf->width, xsurf->height); + screen->flush_frontbuffer(screen, psurf, &xbuf->xdraw); - xbuf->ximage->data = NULL; - screen->transfer_unmap(screen, transfer); - - /* - * softpipe allows the pipe transfer to be re-used, but we don't want to - * rely on that behavior. - */ - screen->tex_transfer_destroy(transfer); - - XSync(xsurf->xdpy->dpy, FALSE); + pipe_surface_reference(&psurf, NULL); return TRUE; } @@ -351,20 +290,20 @@ ximage_surface_swap_buffers(struct native_surface *nsurf) boolean ret; /* display the back buffer first */ - ret = ximage_surface_draw_buffer(nsurf, NATIVE_ATTACHMENT_BACK_LEFT); + ret = ximage_surface_draw_buffer(&xsurf->base, + NATIVE_ATTACHMENT_BACK_LEFT); /* force buffers to be updated in next validation call */ xsurf->server_stamp++; xfront = &xsurf->buffers[NATIVE_ATTACHMENT_FRONT_LEFT]; xback = &xsurf->buffers[NATIVE_ATTACHMENT_BACK_LEFT]; - /* skip swapping so that the front buffer is allocated only when needed */ - if (!xfront->texture) - return ret; - - xtmp = *xfront; - *xfront = *xback; - *xback = xtmp; + /* skip swapping unless there is a front buffer */ + if (xfront->texture) { + xtmp = *xfront; + *xfront = *xback; + *xback = xtmp; + } return ret; } @@ -419,15 +358,8 @@ ximage_surface_destroy(struct native_surface *nsurf) struct ximage_surface *xsurf = ximage_surface(nsurf); int i; - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; + for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) ximage_surface_free_buffer(&xsurf->base, i); - /* xbuf->shm_info is owned by xbuf->ximage? */ - if (xbuf->ximage) { - XDestroyImage(xbuf->ximage); - xbuf->ximage = NULL; - } - } if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) XFreeGC(xsurf->xdpy->dpy, xsurf->gc); @@ -443,7 +375,6 @@ ximage_display_create_surface(struct native_display *ndpy, struct ximage_display *xdpy = ximage_display(ndpy); struct ximage_config *xconf = ximage_config(nconf); struct ximage_surface *xsurf; - int i; xsurf = CALLOC_STRUCT(ximage_surface); if (!xsurf) @@ -466,43 +397,6 @@ ximage_display_create_surface(struct native_display *ndpy, /* initialize the geometry */ ximage_surface_update_buffers(&xsurf->base, 0x0); - - for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) { - struct ximage_buffer *xbuf = &xsurf->buffers[i]; - - if (xdpy->use_xshm) { - xbuf->shm_info = calloc(1, sizeof(*xbuf->shm_info)); - if (xbuf->shm_info) { - /* initialize shm info */ - xbuf->shm_info->shmid = -1; - xbuf->shm_info->shmaddr = (void *) -1; - xbuf->shm_info->readOnly = TRUE; - - xbuf->ximage = XShmCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, NULL, - xbuf->shm_info, - 0, 0); - } - } - else { - xbuf->ximage = XCreateImage(xsurf->xdpy->dpy, - xsurf->visual.visual, - xsurf->visual.depth, - ZPixmap, 0, /* format, offset */ - NULL, /* data */ - 0, 0, /* size */ - 8, /* bitmap_pad */ - 0); /* bytes_per_line */ - } - - if (!xbuf->ximage) { - XFreeGC(xdpy->dpy, xsurf->gc); - free(xsurf); - return NULL; - } - } } xsurf->base.destroy = ximage_surface_destroy; @@ -694,7 +588,6 @@ ximage_display_destroy(struct native_display *ndpy) free(xdpy->configs); xdpy->base.screen->destroy(xdpy->base.screen); - free(xdpy->winsys); x11_screen_destroy(xdpy->xscr); if (xdpy->own_dpy) @@ -703,7 +596,7 @@ ximage_display_destroy(struct native_display *ndpy) } struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) +x11_create_ximage_display(EGLNativeDisplayType dpy) { struct ximage_display *xdpy; @@ -728,11 +621,8 @@ x11_create_ximage_display(EGLNativeDisplayType dpy, boolean use_xshm) return NULL; } - xdpy->use_xshm = - (use_xshm && x11_screen_support(xdpy->xscr, X11_SCREEN_EXTENSION_XSHM)); - - xdpy->winsys = create_sw_winsys(); - xdpy->base.screen = softpipe_create_screen(xdpy->winsys); + xdpy->driver = xlib_sw_winsys_init(); + xdpy->base.screen = xdpy->driver->create_pipe_screen(xdpy->dpy); xdpy->base.destroy = ximage_display_destroy; diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.c b/src/gallium/state_trackers/egl/x11/sw_winsys.c deleted file mode 100644 index 33328aadf2..0000000000 --- a/src/gallium/state_trackers/egl/x11/sw_winsys.c +++ /dev/null @@ -1,231 +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 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. - * - **************************************************************************/ - -/** - * Totally software-based winsys layer. - * Note that the one winsys function that we can't implement here - * is flush_frontbuffer(). - * Whoever uses this code will have to provide that. - * - * Authors: Brian Paul - */ - - -#include "util/u_simple_screen.h" -#include "pipe/p_state.h" -#include "util/u_inlines.h" -#include "util/u_format.h" -#include "util/u_math.h" -#include "util/u_memory.h" - -#include "sw_winsys.h" - - - -/** Subclass of pipe_winsys */ -struct sw_pipe_winsys -{ - struct pipe_winsys Base; - /* no extra fields for now */ -}; - - -/** subclass of pipe_buffer */ -struct sw_pipe_buffer -{ - struct pipe_buffer Base; - boolean UserBuffer; /** Is this a user-space buffer? */ - void *Data; - void *Mapped; -}; - - -/** cast wrapper */ -static INLINE struct sw_pipe_buffer * -sw_pipe_buffer(struct pipe_buffer *b) -{ - return (struct sw_pipe_buffer *) b; -} - - -static const char * -get_name(struct pipe_winsys *pws) -{ - return "software"; -} - - -/** Create new pipe_buffer and allocate storage of given size */ -static struct pipe_buffer * -buffer_create(struct pipe_winsys *pws, - unsigned alignment, - unsigned usage, - unsigned size) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.alignment = alignment; - buffer->Base.usage = usage; - buffer->Base.size = size; - - /* align to 16-byte multiple for Cell */ - buffer->Data = align_malloc(size, MAX2(alignment, 16)); - - return &buffer->Base; -} - - -/** - * Create buffer which wraps user-space data. - */ -static struct pipe_buffer * -user_buffer_create(struct pipe_winsys *pws, void *ptr, unsigned bytes) -{ - struct sw_pipe_buffer *buffer = CALLOC_STRUCT(sw_pipe_buffer); - if (!buffer) - return NULL; - - pipe_reference_init(&buffer->Base.reference, 1); - buffer->Base.size = bytes; - buffer->UserBuffer = TRUE; - buffer->Data = ptr; - - return &buffer->Base; -} - - -static void * -buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buf, unsigned flags) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = buffer->Data; - return buffer->Mapped; -} - - -static void -buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - buffer->Mapped = NULL; -} - - -static void -buffer_destroy(struct pipe_buffer *buf) -{ - struct sw_pipe_buffer *buffer = sw_pipe_buffer(buf); - - if (buffer->Data && !buffer->UserBuffer) { - align_free(buffer->Data); - buffer->Data = NULL; - } - - free(buffer); -} - - -static struct pipe_buffer * -surface_buffer_create(struct pipe_winsys *winsys, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - const unsigned alignment = 64; - unsigned nblocksy; - - nblocksy = util_format_get_nblocksy(format, height); - *stride = align(util_format_get_stride(format, width), alignment); - - return winsys->buffer_create(winsys, alignment, - usage, - *stride * nblocksy); -} - - -static void -fence_reference(struct pipe_winsys *sws, struct pipe_fence_handle **ptr, - struct pipe_fence_handle *fence) -{ - /* no-op */ -} - - -static int -fence_signalled(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -static int -fence_finish(struct pipe_winsys *sws, struct pipe_fence_handle *fence, - unsigned flag) -{ - /* no-op */ - return 0; -} - - -/** - * Create/return a new pipe_winsys object. - */ -struct pipe_winsys * -create_sw_winsys(void) -{ - struct sw_pipe_winsys *ws = CALLOC_STRUCT(sw_pipe_winsys); - if (!ws) - return NULL; - - /* Fill in this struct with callbacks that pipe will need to - * communicate with the window system, buffer manager, etc. - */ - ws->Base.buffer_create = buffer_create; - ws->Base.user_buffer_create = user_buffer_create; - ws->Base.buffer_map = buffer_map; - ws->Base.buffer_unmap = buffer_unmap; - ws->Base.buffer_destroy = buffer_destroy; - - ws->Base.surface_buffer_create = surface_buffer_create; - - ws->Base.fence_reference = fence_reference; - ws->Base.fence_signalled = fence_signalled; - ws->Base.fence_finish = fence_finish; - - ws->Base.flush_frontbuffer = NULL; /* not implemented here! */ - - ws->Base.get_name = get_name; - - return &ws->Base; -} diff --git a/src/gallium/state_trackers/egl/x11/sw_winsys.h b/src/gallium/state_trackers/egl/x11/sw_winsys.h deleted file mode 100644 index f96c5a14b0..0000000000 --- a/src/gallium/state_trackers/egl/x11/sw_winsys.h +++ /dev/null @@ -1,40 +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 files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef SW_WINSYS_H -#define SW_WINSYS_H - - -struct pipe_winsys; - - -extern struct pipe_winsys * -create_sw_winsys(void); - - -#endif /* SW_WINSYS_H */ diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index 8363de6e97..a006ad70b6 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -13,7 +13,8 @@ EGL_DRIVER_OBJECTS = $(EGL_DRIVER_SOURCES:.c=.o) common_LIBS = -ldrm -lm -ldl -x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a +x11_ST = $(TOP)/src/gallium/state_trackers/egl/libeglx11.a \ + $(TOP)/src/gallium/winsys/xlib/libws_xlib.a x11_LIBS = $(common_LIBS) -lX11 -lXext -lXfixes kms_ST = $(TOP)/src/gallium/state_trackers/egl/libeglkms.a -- cgit v1.2.3 From 6f4ce4a4fed9f0f0f0ee89a63e406ab86dae7150 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 10:54:13 +0000 Subject: Squashed commit of gallium-no-texture-blanket commit f90b3f01af82b9522067b1824e21709a6fb2d3af Author: Keith Whitwell Date: Mon Mar 8 14:39:44 2010 +0000 gallium: remove p_screen::surface_buffer_create This isn't very useful without texture_blanket(), which has also been removed. Note that this function hasn't been removed from the old pipe_winsys (u_simple_screen) still used internally by some drivers (eg softpipe). commit 6c462de39a4b9980a5f034a95e580efdfcb8173b Author: Keith Whitwell Date: Mon Mar 8 14:27:40 2010 +0000 egl/x11: disable texture_blanket usage commit b42da9160df9f47224e5b3291b972f41767aa6e5 Merge: 4be2436 3ca9336 Author: Keith Whitwell Date: Mon Mar 8 14:27:24 2010 +0000 Merge commit 'origin/master' into gallium-no-texture-blanket Conflicts: src/gallium/drivers/svga/svga_screen_texture.c commit 4be2436316929e3dfc55bc34d810920c06556b66 Author: Keith Whitwell Date: Thu Mar 4 14:59:26 2010 +0000 gallium: remove texture blanket call No longer needed, except for nouveau and egl/xll/native_ximage.c. Fix for nouveau is to keep the call, but move it to an internal function within nouveau. Fix for that egl/x11 relies on gallium-sw-api branch or its successor. commit 69b6764330367d63c237d0bde9fb96435d0e0257 Author: Keith Whitwell Date: Thu Mar 4 13:35:16 2010 +0000 drm_api: wrap comment --- src/gallium/auxiliary/util/u_simple_screen.c | 16 ----- src/gallium/drivers/i915/i915_texture.c | 38 ------------ src/gallium/drivers/i965/brw_screen_texture.c | 9 +-- src/gallium/drivers/i965/brw_winsys.h | 22 ------- src/gallium/drivers/identity/id_screen.c | 47 --------------- src/gallium/drivers/llvmpipe/lp_screen.c | 13 ---- src/gallium/drivers/llvmpipe/lp_texture.c | 38 ------------ src/gallium/drivers/nouveau/nouveau_screen.c | 3 +- src/gallium/drivers/nouveau/nouveau_screen.h | 12 ++++ src/gallium/drivers/nv30/nv30_miptree.c | 3 +- src/gallium/drivers/nv40/nv40_miptree.c | 3 +- src/gallium/drivers/nv50/nv50_miptree.c | 3 +- src/gallium/drivers/r300/r300_texture.c | 36 ----------- src/gallium/drivers/softpipe/sp_texture.c | 48 +++------------ src/gallium/drivers/svga/svga_screen_texture.c | 65 -------------------- src/gallium/drivers/trace/tr_screen.c | 70 ---------------------- src/gallium/include/pipe/p_screen.h | 28 --------- src/gallium/include/state_tracker/drm_api.h | 5 +- src/gallium/state_trackers/egl/x11/native_ximage.c | 9 ++- 19 files changed, 40 insertions(+), 428 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c index 53f3c16dbc..9203cb6580 100644 --- a/src/gallium/auxiliary/util/u_simple_screen.c +++ b/src/gallium/auxiliary/util/u_simple_screen.c @@ -59,22 +59,7 @@ pass_user_buffer_create(struct pipe_screen *screen, return buffer; } -static struct pipe_buffer * -pass_surface_buffer_create(struct pipe_screen *screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - struct pipe_buffer *buffer = - screen->winsys->surface_buffer_create(screen->winsys, width, height, - format, usage, tex_usage, stride); - buffer->screen = screen; - - return buffer; -} static void * pass_buffer_map(struct pipe_screen *screen, @@ -135,7 +120,6 @@ u_simple_screen_init(struct pipe_screen *screen) { screen->buffer_create = pass_buffer_create; screen->user_buffer_create = pass_user_buffer_create; - screen->surface_buffer_create = pass_surface_buffer_create; screen->buffer_map = pass_buffer_map; screen->buffer_unmap = pass_buffer_unmap; diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 5b1f42313e..3ce52cdcdb 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -724,43 +724,6 @@ i915_texture_get_handle(struct pipe_screen * screen, return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride); } -static struct pipe_texture * -i915_texture_blanket(struct pipe_screen * screen, - const struct pipe_texture *base, - const unsigned *stride, - struct pipe_buffer *buffer) -{ -#if 0 - struct i915_texture *tex; - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - tex = CALLOC_STRUCT(i915_texture); - if (!tex) - return NULL; - - tex->base = *base; - pipe_reference_init(&tex->base.reference, 1); - tex->base.screen = screen; - - tex->stride = stride[0]; - - i915_miptree_set_level_info(tex, 0, 1, base->width0, base->height0, 1); - i915_miptree_set_image_offset(tex, 0, 0, 0, 0); - - pipe_buffer_reference(&tex->buffer, buffer); - - return &tex->base; -#else - return NULL; -#endif -} static void i915_texture_destroy(struct pipe_texture *pt) @@ -923,7 +886,6 @@ i915_init_screen_texture_functions(struct i915_screen *is) is->base.texture_create = i915_texture_create; is->base.texture_from_handle = i915_texture_from_handle; is->base.texture_get_handle = i915_texture_get_handle; - is->base.texture_blanket = i915_texture_blanket; is->base.texture_destroy = i915_texture_destroy; is->base.get_tex_surface = i915_get_tex_surface; is->base.tex_surface_destroy = i915_tex_surface_destroy; diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index caa16ee150..cc79bfc771 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -416,13 +416,7 @@ brw_texture_get_handle(struct pipe_screen *screen, return bscreen->sws->bo_get_handle(tex->bo, whandle, stride); } -static struct pipe_texture *brw_texture_blanket(struct pipe_screen *screen, - const struct pipe_texture *templ, - const unsigned *stride, - struct pipe_buffer *buffer) -{ - return NULL; -} + static void brw_texture_destroy(struct pipe_texture *pt) { @@ -571,7 +565,6 @@ void brw_screen_tex_init( struct brw_screen *brw_screen ) brw_screen->base.texture_from_handle = brw_texture_from_handle; brw_screen->base.texture_get_handle = brw_texture_get_handle; brw_screen->base.texture_destroy = brw_texture_destroy; - brw_screen->base.texture_blanket = brw_texture_blanket; brw_screen->base.get_tex_transfer = brw_get_tex_transfer; brw_screen->base.transfer_map = brw_transfer_map; brw_screen->base.transfer_unmap = brw_transfer_unmap; diff --git a/src/gallium/drivers/i965/brw_winsys.h b/src/gallium/drivers/i965/brw_winsys.h index 139e26e31f..f30c7f1813 100644 --- a/src/gallium/drivers/i965/brw_winsys.h +++ b/src/gallium/drivers/i965/brw_winsys.h @@ -267,28 +267,6 @@ bo_reference(struct brw_winsys_buffer **ptr, struct brw_winsys_buffer *buf) struct pipe_screen *brw_create_screen(struct brw_winsys_screen *iws, unsigned pci_id); -/** - * Get the brw_winsys buffer backing the texture. - * - * TODO UGLY - */ -struct pipe_texture; -boolean brw_texture_get_winsys_buffer(struct pipe_texture *texture, - struct brw_winsys_buffer **buffer, - unsigned *stride); - -/** - * Wrap a brw_winsys buffer with a texture blanket. - * - * TODO UGLY - */ -struct pipe_texture * -brw_texture_blanket_winsys_buffer(struct pipe_screen *screen, - const struct pipe_texture *template, - unsigned pitch, - unsigned tiling, - struct brw_winsys_buffer *buffer); - /************************************************************************* * Cooperative dumping between winsys and driver. TODO: make this diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index 77e15b92f7..b9d0f003d7 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -167,27 +167,7 @@ identity_screen_texture_get_handle(struct pipe_screen *_screen, return screen->texture_get_handle(screen, texture, handle); } -static struct pipe_texture * -identity_screen_texture_blanket(struct pipe_screen *_screen, - const struct pipe_texture *templat, - const unsigned *stride, - struct pipe_buffer *_buffer) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_buffer *id_buffer = identity_buffer(_buffer); - struct pipe_screen *screen = id_screen->screen; - struct pipe_buffer *buffer = id_buffer->buffer; - struct pipe_texture *result; - - result = screen->texture_blanket(screen, - templat, - stride, - buffer); - if (result) - return identity_texture_create(id_screen, result); - return NULL; -} static void identity_screen_texture_destroy(struct pipe_texture *_texture) @@ -331,31 +311,6 @@ identity_screen_user_buffer_create(struct pipe_screen *_screen, return NULL; } -static struct pipe_buffer * -identity_screen_surface_buffer_create(struct pipe_screen *_screen, - unsigned width, - unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct pipe_screen *screen = id_screen->screen; - struct pipe_buffer *result; - - result = screen->surface_buffer_create(screen, - width, - height, - format, - usage, - tex_usage, - stride); - - if (result) - return identity_buffer_create(id_screen, result); - return NULL; -} static void * identity_screen_buffer_map(struct pipe_screen *_screen, @@ -530,7 +485,6 @@ identity_screen_create(struct pipe_screen *screen) id_screen->base.texture_create = identity_screen_texture_create; id_screen->base.texture_from_handle = identity_screen_texture_from_handle; id_screen->base.texture_get_handle = identity_screen_texture_get_handle; - id_screen->base.texture_blanket = identity_screen_texture_blanket; id_screen->base.texture_destroy = identity_screen_texture_destroy; id_screen->base.get_tex_surface = identity_screen_get_tex_surface; id_screen->base.tex_surface_destroy = identity_screen_tex_surface_destroy; @@ -540,7 +494,6 @@ identity_screen_create(struct pipe_screen *screen) id_screen->base.transfer_unmap = identity_screen_transfer_unmap; id_screen->base.buffer_create = identity_screen_buffer_create; id_screen->base.user_buffer_create = identity_screen_user_buffer_create; - id_screen->base.surface_buffer_create = identity_screen_surface_buffer_create; if (screen->buffer_map) id_screen->base.buffer_map = identity_screen_buffer_map; if (screen->buffer_map_range) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 2c6fd67eae..934b0d8439 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -238,18 +238,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, } -static struct pipe_buffer * -llvmpipe_surface_buffer_create(struct pipe_screen *screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned tex_usage, - unsigned usage, - unsigned *stride) -{ - /* This function should never be used */ - assert(0); - return NULL; -} static void @@ -309,7 +297,6 @@ llvmpipe_create_screen(struct llvmpipe_winsys *winsys) screen->base.get_paramf = llvmpipe_get_paramf; screen->base.is_format_supported = llvmpipe_is_format_supported; - screen->base.surface_buffer_create = llvmpipe_surface_buffer_create; screen->base.context_create = llvmpipe_create_context; screen->base.flush_frontbuffer = llvmpipe_flush_frontbuffer; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 7d15e85600..e41d6238ed 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -143,43 +143,6 @@ llvmpipe_texture_create(struct pipe_screen *_screen, } -static struct pipe_texture * -llvmpipe_texture_blanket(struct pipe_screen * screen, - const struct pipe_texture *base, - const unsigned *stride, - struct pipe_buffer *buffer) -{ - /* FIXME */ -#if 0 - struct llvmpipe_texture *lpt; - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - lpt = CALLOC_STRUCT(llvmpipe_texture); - if (!lpt) - return NULL; - - lpt->base = *base; - pipe_reference_init(&lpt->base.reference, 1); - lpt->base.screen = screen; - lpt->stride[0] = stride[0]; - - pipe_buffer_reference(&lpt->buffer, buffer); - - return &lpt->base; -#else - debug_printf("llvmpipe_texture_blanket() not implemented!"); - return NULL; -#endif -} - - static void llvmpipe_texture_destroy(struct pipe_texture *pt) { @@ -409,7 +372,6 @@ void llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen) { screen->texture_create = llvmpipe_texture_create; - screen->texture_blanket = llvmpipe_texture_blanket; screen->texture_destroy = llvmpipe_texture_destroy; screen->get_tex_surface = llvmpipe_get_tex_surface; diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 2013eef0c5..f7d10a591f 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -273,7 +273,8 @@ nouveau_screen_texture_from_handle(struct pipe_screen *pscreen, pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE | PIPE_BUFFER_USAGE_CPU_READ_WRITE; pb->size = nouveau_bo(pb)->size; - pt = pscreen->texture_blanket(pscreen, templ, &whandle->stride, pb); + pt = nouveau_screen(pscreen)->texture_blanket(pscreen, templ, + &whandle->stride, pb); pipe_buffer_reference(&pb, NULL); return pt; } diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h index a7927d88df..f4a7a2bc23 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.h +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -6,6 +6,18 @@ struct nouveau_screen { struct nouveau_device *device; struct nouveau_channel *channel; + /** + * Create a new texture object, using the given template info, but on top of + * existing memory. + * + * It is assumed that the buffer data is layed out according to the expected + * by the hardware. NULL will be returned if any inconsistency is found. + */ + struct pipe_texture * (*texture_blanket)(struct pipe_screen *, + const struct pipe_texture *templat, + const unsigned *stride, + struct pipe_buffer *buffer); + int (*pre_pipebuffer_map_callback) (struct pipe_screen *pscreen, struct pipe_buffer *pb, unsigned usage); }; diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index cb756cf6e6..5ef74a832d 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -232,8 +232,9 @@ void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen) { pscreen->texture_create = nv30_miptree_create; - pscreen->texture_blanket = nv30_miptree_blanket; pscreen->texture_destroy = nv30_miptree_destroy; pscreen->get_tex_surface = nv30_miptree_surface_new; pscreen->tex_surface_destroy = nv30_miptree_surface_del; + + nouveau_screen(pscreen)->texture_blanket = nv50_miptree_blanket; } diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c index b17255dc6b..62e97bcea4 100644 --- a/src/gallium/drivers/nv40/nv40_miptree.c +++ b/src/gallium/drivers/nv40/nv40_miptree.c @@ -227,9 +227,10 @@ void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen) { pscreen->texture_create = nv40_miptree_create; - pscreen->texture_blanket = nv40_miptree_blanket; pscreen->texture_destroy = nv40_miptree_destroy; pscreen->get_tex_surface = nv40_miptree_surface_new; pscreen->tex_surface_destroy = nv40_miptree_surface_del; + + nouveau_screen(pscreen)->texture_blanket = nv40_miptree_blanket; } diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c index a7788249ab..e091cae602 100644 --- a/src/gallium/drivers/nv50/nv50_miptree.c +++ b/src/gallium/drivers/nv50/nv50_miptree.c @@ -255,9 +255,10 @@ void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen) { pscreen->texture_create = nv50_miptree_create; - pscreen->texture_blanket = nv50_miptree_blanket; pscreen->texture_destroy = nv50_miptree_destroy; pscreen->get_tex_surface = nv50_miptree_surface_new; pscreen->tex_surface_destroy = nv50_miptree_surface_del; + + nouveau_screen(pscreen)->texture_blanket = nv50_miptree_blanket; } diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 21e5910450..04124afd4d 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -851,41 +851,6 @@ static void r300_tex_surface_destroy(struct pipe_surface* s) FREE(s); } -static struct pipe_texture* - r300_texture_blanket(struct pipe_screen* screen, - const struct pipe_texture* base, - const unsigned* stride, - struct pipe_buffer* buffer) -{ - struct r300_texture* tex; - struct r300_screen* rscreen = r300_screen(screen); - - /* Support only 2D textures without mipmaps */ - if (base->target != PIPE_TEXTURE_2D || - base->depth0 != 1 || - base->last_level != 0) { - return NULL; - } - - tex = CALLOC_STRUCT(r300_texture); - if (!tex) { - return NULL; - } - - tex->tex = *base; - pipe_reference_init(&tex->tex.reference, 1); - tex->tex.screen = screen; - - tex->stride_override = *stride; - tex->pitch[0] = *stride / util_format_get_blocksize(base->format); - - r300_setup_flags(tex); - r300_setup_texture_state(rscreen, tex); - - pipe_buffer_reference(&tex->buffer, buffer); - - return (struct pipe_texture*)tex; -} static struct pipe_texture* r300_texture_from_handle(struct pipe_screen* screen, @@ -1007,7 +972,6 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen) screen->texture_destroy = r300_texture_destroy; screen->get_tex_surface = r300_get_tex_surface; screen->tex_surface_destroy = r300_tex_surface_destroy; - screen->texture_blanket = r300_texture_blanket; screen->video_surface_create = r300_video_surface_create; screen->video_surface_destroy= r300_video_surface_destroy; diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 6ea060023d..c0052359fd 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -36,6 +36,7 @@ #include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_simple_screen.h" #include "sp_context.h" #include "sp_texture.h" @@ -91,13 +92,13 @@ softpipe_displaytarget_layout(struct pipe_screen *screen, PIPE_BUFFER_USAGE_GPU_READ_WRITE); unsigned tex_usage = spt->base.tex_usage; - spt->buffer = screen->surface_buffer_create( screen, - spt->base.width0, - spt->base.height0, - spt->base.format, - usage, - tex_usage, - &spt->stride[0]); + spt->buffer = screen->winsys->surface_buffer_create( screen->winsys, + spt->base.width0, + spt->base.height0, + spt->base.format, + usage, + tex_usage, + &spt->stride[0]); return spt->buffer != NULL; } @@ -141,38 +142,6 @@ softpipe_texture_create(struct pipe_screen *screen, } -/** - * Create a new pipe_texture which wraps an existing buffer. - */ -static struct pipe_texture * -softpipe_texture_blanket(struct pipe_screen * screen, - const struct pipe_texture *base, - const unsigned *stride, - struct pipe_buffer *buffer) -{ - struct softpipe_texture *spt; - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - spt = CALLOC_STRUCT(softpipe_texture); - if (!spt) - return NULL; - - spt->base = *base; - pipe_reference_init(&spt->base.reference, 1); - spt->base.screen = screen; - spt->stride[0] = stride[0]; - - pipe_buffer_reference(&spt->buffer, buffer); - - return &spt->base; -} static void @@ -459,7 +428,6 @@ void softpipe_init_screen_texture_funcs(struct pipe_screen *screen) { screen->texture_create = softpipe_texture_create; - screen->texture_blanket = softpipe_texture_blanket; screen->texture_destroy = softpipe_texture_destroy; screen->get_tex_surface = softpipe_get_tex_surface; diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 4b045c44d8..5b581debfc 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -359,71 +359,7 @@ error1: } -static struct pipe_texture * -svga_texture_blanket(struct pipe_screen * screen, - const struct pipe_texture *base, - const unsigned *stride, - struct pipe_buffer *buffer) -{ - struct svga_texture *tex; - struct svga_buffer *sbuf = svga_buffer(buffer); - struct svga_winsys_screen *sws = svga_winsys_screen(screen); - assert(screen); - - /* Only supports one type */ - if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || - base->depth0 != 1) { - return NULL; - } - - /** - * We currently can't do texture blanket on - * SVGA3D_BUFFER. Need to blit to a temporary surface? - */ - - assert(sbuf->handle); - if (!sbuf->handle) - return NULL; - - if (svga_translate_format(base->format) != sbuf->key.format) { - unsigned f1 = svga_translate_format(base->format); - unsigned f2 = sbuf->key.format; - - /* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */ - if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) || - (f1 == SVGA3D_A8R8G8B8 && f2 == SVGA3D_X8R8G8B8) || - (f1 == SVGA3D_Z_D24X8 && f2 == SVGA3D_Z_D24S8) ) ) { - debug_printf("%s wrong format %u != %u\n", __FUNCTION__, f1, f2); - return NULL; - } - } - - tex = CALLOC_STRUCT(svga_texture); - if (!tex) - return NULL; - - tex->base = *base; - - if (sbuf->key.format == 1) - tex->base.format = PIPE_FORMAT_B8G8R8X8_UNORM; - else if (sbuf->key.format == 2) - tex->base.format = PIPE_FORMAT_B8G8R8A8_UNORM; - - pipe_reference_init(&tex->base.reference, 1); - tex->base.screen = screen; - - SVGA_DBG(DEBUG_DMA, "blanket sid %p\n", sbuf->handle); - - /* We don't own this storage, so don't try to cache it. - */ - assert(sbuf->key.cachable == 0); - tex->key.cachable = 0; - sws->surface_reference(sws, &tex->handle, sbuf->handle); - - return &tex->base; -} static struct pipe_texture * @@ -984,7 +920,6 @@ svga_screen_init_texture_functions(struct pipe_screen *screen) screen->texture_destroy = svga_texture_destroy; screen->get_tex_surface = svga_get_tex_surface; screen->tex_surface_destroy = svga_tex_surface_destroy; - screen->texture_blanket = svga_texture_blanket; screen->get_tex_transfer = svga_get_tex_transfer; screen->transfer_map = svga_transfer_map; screen->transfer_unmap = svga_transfer_unmap; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index ac0876c3a8..a15addeb8c 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -269,36 +269,6 @@ trace_screen_texture_get_handle(struct pipe_screen *_screen, return screen->texture_get_handle(screen, texture, handle); } -static struct pipe_texture * -trace_screen_texture_blanket(struct pipe_screen *_screen, - const struct pipe_texture *templat, - const unsigned *ppitch, - struct pipe_buffer *_buffer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_buffer *tr_buf = trace_buffer(_buffer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_buffer *buffer = tr_buf->buffer; - unsigned pitch = *ppitch; - struct pipe_texture *result; - - trace_dump_call_begin("pipe_screen", "texture_blanket"); - - 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(ptr, result); - - trace_dump_call_end(); - - result = trace_texture_create(tr_scr, result); - - return result; -} static void @@ -516,45 +486,7 @@ trace_screen_transfer_unmap(struct pipe_screen *_screen, */ -static struct pipe_buffer * -trace_screen_surface_buffer_create(struct pipe_screen *_screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *pstride) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct pipe_screen *screen = tr_scr->screen; - unsigned stride; - struct pipe_buffer *result; - trace_dump_call_begin("pipe_screen", "surface_buffer_create"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(uint, width); - trace_dump_arg(uint, height); - trace_dump_arg(format, format); - trace_dump_arg(uint, usage); - trace_dump_arg(uint, tex_usage); - - result = screen->surface_buffer_create(screen, - width, height, - format, - usage, - tex_usage, - pstride); - - stride = *pstride; - - trace_dump_arg(uint, stride); - - trace_dump_ret(ptr, result); - - trace_dump_call_end(); - - return trace_buffer_create(tr_scr, result); -} static struct pipe_buffer * @@ -965,7 +897,6 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.texture_create = trace_screen_texture_create; tr_scr->base.texture_from_handle = trace_screen_texture_from_handle; tr_scr->base.texture_get_handle = trace_screen_texture_get_handle; - tr_scr->base.texture_blanket = trace_screen_texture_blanket; tr_scr->base.texture_destroy = trace_screen_texture_destroy; tr_scr->base.get_tex_surface = trace_screen_get_tex_surface; tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy; @@ -975,7 +906,6 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.transfer_unmap = trace_screen_transfer_unmap; tr_scr->base.buffer_create = trace_screen_buffer_create; tr_scr->base.user_buffer_create = trace_screen_user_buffer_create; - tr_scr->base.surface_buffer_create = trace_screen_surface_buffer_create; if (screen->buffer_map) tr_scr->base.buffer_map = trace_screen_buffer_map; if (screen->buffer_map_range) diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 617c47e4dc..690455f722 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -127,17 +127,6 @@ struct pipe_screen { struct pipe_texture *tex, struct winsys_handle *handle); - /** - * Create a new texture object, using the given template info, but on top of - * existing memory. - * - * It is assumed that the buffer data is layed out according to the expected - * by the hardware. NULL will be returned if any inconsistency is found. - */ - struct pipe_texture * (*texture_blanket)(struct pipe_screen *, - const struct pipe_texture *templat, - const unsigned *stride, - struct pipe_buffer *buffer); void (*texture_destroy)(struct pipe_texture *pt); @@ -207,23 +196,6 @@ struct pipe_screen { void *ptr, unsigned bytes); - /** - * Allocate storage for a display target surface. - * - * Often surfaces which are meant to be blitted to the front screen (i.e., - * display targets) must be allocated with special characteristics, memory - * pools, or obtained directly from the windowing system. - * - * This callback is invoked by the pipe_screenwhen creating a texture marked - * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying - * buffer storage. - */ - struct pipe_buffer *(*surface_buffer_create)(struct pipe_screen *screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride); /** diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index d3edddd5d4..fe7ef253ef 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -26,8 +26,9 @@ enum drm_create_screen_mode { struct winsys_handle { /** - * Unused for texture_from_handle, always DRM_API_HANDLE_TYPE_SHARED. - * Input to texture_get_handle, use TEXTURE_USAGE to select handle for kms or ipc. + * Unused for texture_from_handle, always + * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle, + * use TEXTURE_USAGE to select handle for kms or ipc. */ unsigned type; /** diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 3421c1951a..a94b1ca6c6 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -156,6 +156,11 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, templ.depth0 = 1; templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET; +#if 0 + /* Interesting and suprising use of texture_blanket + + * user_buffer_create... To be superceded by the sw_winsys branch, + * but currently disabled. + */ if (xbuf->shm_info) { struct pipe_buffer *pbuf; unsigned stride, size; @@ -188,7 +193,9 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, } } } - else { + else +#endif + { xbuf->texture = screen->texture_create(screen, &templ); } -- cgit v1.2.3 From d5bf9c0a5e51d160e7037297faf7657a0e2c6360 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 11:39:40 +0000 Subject: ws/xlib: manage the GC internally No need for the user of this winsys to supply/manage the x11 gc for us. --- src/gallium/include/state_tracker/xlib_sw_winsys.h | 1 - src/gallium/state_trackers/egl/x11/native_ximage.c | 12 ------ src/gallium/state_trackers/glx/xlib/xm_api.c | 12 ------ src/gallium/winsys/xlib/xlib_sw_winsys.c | 43 +++++++++++++++++++--- 4 files changed, 37 insertions(+), 31 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index 915a7b37fb..3cb679426d 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -16,7 +16,6 @@ struct xlib_drawable { Visual *visual; int depth; Drawable drawable; - GC gc; /* temporary? */ }; diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 0006b0caca..0aa25ead25 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -73,8 +73,6 @@ struct ximage_surface { XVisualInfo visual; struct ximage_display *xdpy; - GC gc; - unsigned int server_stamp; unsigned int client_stamp; int width, height; @@ -155,7 +153,6 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, xbuf->xdraw.visual = xsurf->visual.visual; xbuf->xdraw.depth = xsurf->visual.depth; xbuf->xdraw.drawable = xsurf->drawable; - xbuf->xdraw.gc = xsurf->gc; } /* clean up the buffer if allocation failed */ @@ -373,8 +370,6 @@ ximage_surface_destroy(struct native_surface *nsurf) for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) ximage_surface_free_buffer(&xsurf->base, i); - if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) - XFreeGC(xsurf->xdpy->dpy, xsurf->gc); free(xsurf); } @@ -400,13 +395,6 @@ ximage_display_create_surface(struct native_display *ndpy, if (xsurf->type != XIMAGE_SURFACE_TYPE_PBUFFER) { xsurf->drawable = drawable; xsurf->visual = *xconf->visual; - - xsurf->gc = XCreateGC(xdpy->dpy, xsurf->drawable, 0, NULL); - if (!xsurf->gc) { - free(xsurf); - return NULL; - } - /* initialize the geometry */ ximage_surface_update_buffers(&xsurf->base, 0x0); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index d8aa59b3b7..cf9a399209 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -446,8 +446,6 @@ xmesa_free_buffer(XMesaBuffer buffer) /* Unreference. If count = zero we'll really delete the buffer */ _mesa_reference_framebuffer(&fb, NULL); - XFreeGC(b->xm_visual->display, b->ws.gc); - free(buffer); return; @@ -524,16 +522,6 @@ initialize_visual_and_buffer(XMesaVisual v, XMesaBuffer b, printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel); } - if (b && window) { - /* these should have been set in create_xmesa_buffer */ - ASSERT(b->ws.drawable == window); - - - /* X11 graphics context */ - b->ws.gc = XCreateGC( v->display, window, 0, NULL ); - XSetFunction( v->display, b->ws.gc, GXcopy ); - } - return GL_TRUE; } diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 9a4ae39aeb..846d79c0eb 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -73,6 +73,12 @@ struct xm_displaytarget Display *display; Visual *visual; XImage *tempImage; + GC gc; + + /* This is the last drawable that this display target was presented + * against. May need to recreate gc, tempImage when this changes?? + */ + Drawable drawable; XShmSegmentInfo shminfo; int shm; @@ -260,6 +266,12 @@ xm_displaytarget_destroy(struct sw_winsys *ws, FREE(xm_dt->data); } + if (xm_dt->tempImage) + XDestroyImage(xm_dt->tempImage); + + if (xm_dt->gc) + XFreeGC(xm_dt->display, xm_dt->gc); + FREE(xm_dt); } @@ -272,10 +284,11 @@ void xlib_sw_display(struct xlib_drawable *xlib_drawable, struct sw_displaytarget *dt) { - XImage *ximage; - struct xm_displaytarget *xm_dt = xm_displaytarget(dt); static boolean no_swap = 0; static boolean firsttime = 1; + struct xm_displaytarget *xm_dt = xm_displaytarget(dt); + Display *display = xm_dt->display; + XImage *ximage; if (firsttime) { no_swap = getenv("SP_NO_RAST") != NULL; @@ -285,8 +298,21 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, if (no_swap) return; - if (xm_dt->tempImage == NULL) - { + if (xm_dt->drawable != xlib_drawable->drawable) { + if (xm_dt->gc) { + XFreeGC( display, xm_dt->gc ); + xm_dt->gc = NULL; + } + + if (xm_dt->tempImage) { + XDestroyImage( xm_dt->tempImage ); + xm_dt->tempImage = NULL; + } + + xm_dt->drawable = xlib_drawable->drawable; + } + + if (xm_dt->tempImage == NULL) { assert(util_format_get_blockwidth(xm_dt->format) == 1); assert(util_format_get_blockheight(xm_dt->format) == 1); alloc_ximage(xm_dt, xlib_drawable, @@ -296,6 +322,11 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, return; } + if (xm_dt->gc == NULL) { + xm_dt->gc = XCreateGC( display, xlib_drawable->drawable, 0, NULL ); + XSetFunction( display, xm_dt->gc, GXcopy ); + } + #ifdef USE_XSHM if (xm_dt->shm) { @@ -303,7 +334,7 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, ximage->data = xm_dt->data; /* _debug_printf("XSHM\n"); */ - XShmPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc, + XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); } else @@ -323,7 +354,7 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, ximage->bytes_per_line = xm_dt->stride; /* _debug_printf("XPUT\n"); */ - XPutImage(xm_dt->display, xlib_drawable->drawable, xlib_drawable->gc, + XPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height); } } -- cgit v1.2.3 From 8ac10162f1412469698322c1c1baf5aaf78a4645 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 11:48:57 +0000 Subject: ws/xlib: remove USE_XSHM preprocessor macro --- src/gallium/winsys/xlib/SConscript | 2 -- src/gallium/winsys/xlib/xlib_sw_winsys.c | 17 +++-------------- 2 files changed, 3 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 26a13e42b5..587cdb8e38 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -15,8 +15,6 @@ if env['platform'] == 'linux' \ '#/src/gallium/drivers', ]) - env.Append(CPPDEFINES = ['USE_XSHM']) - st_xlib = env.ConvenienceLibrary( target = 'ws_xlib', source = [ diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 846d79c0eb..d03e39a249 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -111,8 +111,6 @@ xm_displaytarget( struct sw_displaytarget *dt ) * X Shared Memory Image extension code */ -#ifdef USE_XSHM - static volatile int mesaXErrorFlag = 0; /** @@ -197,19 +195,16 @@ alloc_shm_ximage(struct xm_displaytarget *xm_dt, xm_dt->shm = 1; } -#endif /* USE_XSHM */ static void alloc_ximage(struct xm_displaytarget *xm_dt, struct xlib_drawable *xmb, unsigned width, unsigned height) { -#ifdef USE_XSHM if (xm_dt->shm) { alloc_shm_ximage(xm_dt, xmb, width, height); return; } -#endif xm_dt->tempImage = XCreateImage(xm_dt->display, xmb->visual, @@ -253,7 +248,6 @@ xm_displaytarget_destroy(struct sw_winsys *ws, struct xm_displaytarget *xm_dt = xm_displaytarget(dt); if (xm_dt->data) { -#ifdef USE_XSHM if (xm_dt->shminfo.shmid >= 0) { shmdt(xm_dt->shminfo.shmaddr); shmctl(xm_dt->shminfo.shmid, IPC_RMID, 0); @@ -261,9 +255,9 @@ xm_displaytarget_destroy(struct sw_winsys *ws, xm_dt->shminfo.shmid = -1; xm_dt->shminfo.shmaddr = (char *) -1; } - else -#endif + else { FREE(xm_dt->data); + } } if (xm_dt->tempImage) @@ -327,7 +321,6 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, XSetFunction( display, xm_dt->gc, GXcopy ); } -#ifdef USE_XSHM if (xm_dt->shm) { ximage = xm_dt->tempImage; @@ -337,9 +330,7 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, XShmPutImage(xm_dt->display, xlib_drawable->drawable, xm_dt->gc, ximage, 0, 0, 0, 0, xm_dt->width, xm_dt->height, False); } - else -#endif - { + else { /* display image in Window */ ximage = xm_dt->tempImage; ximage->data = xm_dt->data; @@ -396,7 +387,6 @@ xm_displaytarget_create(struct sw_winsys *winsys, xm_dt->stride = align(util_format_get_stride(format, width), alignment); size = xm_dt->stride * nblocksy; -#ifdef USE_XSHM if (!debug_get_bool_option("XLIB_NO_SHM", FALSE)) { xm_dt->shminfo.shmid = -1; @@ -407,7 +397,6 @@ xm_displaytarget_create(struct sw_winsys *winsys, if(!xm_dt->data) goto no_data; } -#endif if(!xm_dt->data) { xm_dt->data = align_malloc(size, alignment); -- cgit v1.2.3 From fe94a363e53ac5e19a919ea6eef2e22b4da4fc6f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 12:31:20 +0000 Subject: cell: attempt conversion to sw_winsys --- src/gallium/drivers/cell/ppu/Makefile | 1 + src/gallium/drivers/cell/ppu/cell_buffer.c | 118 +++++++++++++++++++++++ src/gallium/drivers/cell/ppu/cell_buffer.h | 55 +++++++++++ src/gallium/drivers/cell/ppu/cell_context.c | 2 +- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 51 ++-------- src/gallium/drivers/cell/ppu/cell_screen.c | 61 +++++++++--- src/gallium/drivers/cell/ppu/cell_screen.h | 23 ++++- src/gallium/drivers/cell/ppu/cell_state_emit.c | 5 +- src/gallium/drivers/cell/ppu/cell_state_shader.c | 13 +++ src/gallium/drivers/cell/ppu/cell_texture.c | 97 +++++++++++++++---- src/gallium/drivers/cell/ppu/cell_texture.h | 15 ++- src/gallium/drivers/cell/ppu/cell_winsys.h | 47 --------- 12 files changed, 354 insertions(+), 134 deletions(-) create mode 100644 src/gallium/drivers/cell/ppu/cell_buffer.c create mode 100644 src/gallium/drivers/cell/ppu/cell_buffer.h delete mode 100644 src/gallium/drivers/cell/ppu/cell_winsys.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile index c92f8e5cba..8769b826b5 100644 --- a/src/gallium/drivers/cell/ppu/Makefile +++ b/src/gallium/drivers/cell/ppu/Makefile @@ -21,6 +21,7 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a SOURCES = \ cell_batch.c \ + cell_buffer.c \ cell_clear.c \ cell_context.c \ cell_draw_arrays.c \ diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.c b/src/gallium/drivers/cell/ppu/cell_buffer.c new file mode 100644 index 0000000000..770f7328a7 --- /dev/null +++ b/src/gallium/drivers/cell/ppu/cell_buffer.c @@ -0,0 +1,118 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE 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 "util/u_inlines.h" +#include "util/u_memory.h" +#include "util/u_math.h" + +#include "sp_screen.h" +#include "sp_buffer.h" + + +static void * +cell_buffer_map(struct pipe_screen *screen, + struct pipe_buffer *buf, + unsigned flags) +{ + struct cell_buffer *cell_buf = cell_buffer(buf); + return cell_buf->data; +} + + +static void +cell_buffer_unmap(struct pipe_screen *screen, + struct pipe_buffer *buf) +{ +} + + +static void +cell_buffer_destroy(struct pipe_buffer *buf) +{ + struct cell_buffer *sbuf = cell_buffer(buf); + + if (!sbuf->userBuffer) + align_free(sbuf->data); + + FREE(sbuf); +} + + +static struct pipe_buffer * +cell_buffer_create(struct pipe_screen *screen, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct cell_buffer *buffer = CALLOC_STRUCT(cell_buffer); + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.screen = screen; + buffer->base.alignment = MAX2(alignment, 16); + buffer->base.usage = usage; + buffer->base.size = size; + + buffer->data = align_malloc(size, alignment); + + return &buffer->base; +} + + +/** + * Create buffer which wraps user-space data. + */ +static struct pipe_buffer * +cell_user_buffer_create(struct pipe_screen *screen, + void *ptr, + unsigned bytes) +{ + struct cell_buffer *buffer; + + buffer = CALLOC_STRUCT(cell_buffer); + if(!buffer) + return NULL; + + pipe_reference_init(&buffer->base.reference, 1); + buffer->base.screen = screen; + buffer->base.size = bytes; + buffer->userBuffer = TRUE; + buffer->data = ptr; + + return &buffer->base; +} + + +void +cell_init_screen_buffer_funcs(struct pipe_screen *screen) +{ + screen->buffer_create = cell_buffer_create; + screen->user_buffer_create = cell_user_buffer_create; + screen->buffer_map = cell_buffer_map; + screen->buffer_unmap = cell_buffer_unmap; + screen->buffer_destroy = cell_buffer_destroy; +} diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.h b/src/gallium/drivers/cell/ppu/cell_buffer.h new file mode 100644 index 0000000000..ef0a8a70e5 --- /dev/null +++ b/src/gallium/drivers/cell/ppu/cell_buffer.h @@ -0,0 +1,55 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef SP_BUFFER_H +#define SP_BUFFER_H + +#include "pipe/p_compiler.h" +#include "pipe/p_state.h" + + +struct cell_buffer +{ + struct pipe_buffer base; + boolean userBuffer; /** Is this a user-space buffer? */ + void *data; +}; + + +/** Cast wrapper */ +static INLINE struct cell_buffer * +cell_buffer( struct pipe_buffer *buf ) +{ + return (struct cell_buffer *)buf; +} + + +void +cell_init_screen_buffer_funcs(struct pipe_screen *screen); + + +#endif /* SP_BUFFER_H */ diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index 4751ca8957..afcea616d5 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -136,7 +136,7 @@ cell_create_context(struct pipe_screen *screen, memset(cell, 0, sizeof(*cell)); cell->winsys = NULL; /* XXX: fixme - get this from screen? */ - cell->pipe.winsys = screen->winsys; + cell->pipe.winsys = NULL; cell->pipe.screen = screen; cell->pipe.priv = priv; cell->pipe.destroy = cell_destroy_context; diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index db28c26ca8..bd15034a5d 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -39,41 +39,12 @@ #include "cell_draw_arrays.h" #include "cell_state.h" #include "cell_flush.h" +#include "cell_buffer.h" #include "draw/draw_context.h" -static void -cell_map_constant_buffers(struct cell_context *sp) -{ - struct pipe_winsys *ws = sp->pipe.winsys; - uint i; - for (i = 0; i < 2; i++) { - if (sp->constants[i] && sp->constants[i]->size) { - sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i], - PIPE_BUFFER_USAGE_CPU_READ); - cell_flush_buffer_range(sp, sp->mapped_constants[i], - sp->constants[i]->size); - } - } - - draw_set_mapped_constant_buffer(sp->draw, PIPE_SHADER_VERTEX, 0, - sp->mapped_constants[PIPE_SHADER_VERTEX], - sp->constants[PIPE_SHADER_VERTEX]->size); -} - -static void -cell_unmap_constant_buffers(struct cell_context *sp) -{ - struct pipe_winsys *ws = sp->pipe.winsys; - uint i; - for (i = 0; i < 2; i++) { - if (sp->constants[i] && sp->constants[i]->size) - ws->buffer_unmap(ws, sp->constants[i]); - sp->mapped_constants[i] = NULL; - } -} @@ -102,23 +73,17 @@ cell_draw_range_elements(struct pipe_context *pipe, #if 0 cell_map_surfaces(sp); #endif - cell_map_constant_buffers(sp); /* * Map vertex buffers */ for (i = 0; i < sp->num_vertex_buffers; i++) { - 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); + void *buf = cell_buffer(cell->vertex_buffer[i].buffer)->data; draw_set_mapped_vertex_buffer(draw, i, buf); } /* Map index buffer, if present */ if (indexBuffer) { - void *mapped_indexes = pipe_buffer_map(pipe->screen, - indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + void *mapped_indexes = cell_buffer(indexBuffer)->data; draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes); } else { @@ -135,15 +100,17 @@ cell_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_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer); } if (indexBuffer) { draw_set_mapped_element_buffer(draw, 0, NULL); - pipe_buffer_unmap(pipe->screen, indexBuffer); } - /* Note: leave drawing surfaces mapped */ - cell_unmap_constant_buffers(sp); + /* + * TODO: Flush only when a user vertex/index buffer is present + * (or even better, modify draw module to do this + * internally when this condition is seen?) + */ + draw_flush(draw); } diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 77bd849a15..36479e8e0c 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -35,7 +35,9 @@ #include "cell_context.h" #include "cell_screen.h" #include "cell_texture.h" -#include "cell_winsys.h" +#include "cell_buffer.h" + +#include "state_tracker/sw_winsys.h" static const char * @@ -133,19 +135,28 @@ cell_is_format_supported( struct pipe_screen *screen, unsigned tex_usage, unsigned geom_flags ) { - /* cell supports most formats, XXX for now anyway */ + struct sw_winsys *winsys = cell_screen(screen)->winsys; + if (format == PIPE_FORMAT_DXT5_RGBA || format == PIPE_FORMAT_A8B8G8R8_SRGB) return FALSE; - else - return TRUE; + + if (tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { + if (!winsys->is_displaytarget_format_supported(winsys, format)) + return FALSE; + } + + /* This is often a lie. Pull in logic from llvmpipe to fix. + */ + return TRUE; } static void cell_destroy_screen( struct pipe_screen *screen ) { - struct pipe_winsys *winsys = screen->winsys; + struct cell_screen *sp_screen = cell_screen(screen); + struct sw_winsys *winsys = sp_screen->winsys; if(winsys->destroy) winsys->destroy(winsys); @@ -153,6 +164,23 @@ cell_destroy_screen( struct pipe_screen *screen ) FREE(screen); } +/* This used to be overriden by the co-state tracker, but really needs + * to be active with sw_winsys. + */ +static void +cell_flush_frontbuffer(struct pipe_screen *_screen, + struct pipe_surface *surface, + void *context_private) +{ + struct cell_screen *screen = cell_screen(_screen); + struct sw_winsys *winsys = screen->winsys; + struct cell_texture *texture = cell_texture(surface->texture); + + assert(texture->dt); + if (texture->dt) + winsys->displaytarget_display(winsys, texture->dt, context_private); +} + /** * Create a new pipe_screen object @@ -160,26 +188,27 @@ cell_destroy_screen( struct pipe_screen *screen ) * that would be the place to put SPU thread/context info... */ struct pipe_screen * -cell_create_screen(struct pipe_winsys *winsys) +cell_create_screen(struct sw_winsys *winsys) { - struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen); + struct cell_screen *screen = CALLOC_STRUCT(pipe_screen); if (!screen) return NULL; screen->winsys = winsys; + screen->base.winsys = NULL; - screen->destroy = cell_destroy_screen; + screen->base.destroy = cell_destroy_screen; - screen->get_name = cell_get_name; - screen->get_vendor = cell_get_vendor; - screen->get_param = cell_get_param; - screen->get_paramf = cell_get_paramf; - screen->is_format_supported = cell_is_format_supported; - screen->context_create = cell_create_context; + screen->base.get_name = cell_get_name; + screen->base.get_vendor = cell_get_vendor; + screen->base.get_param = cell_get_param; + screen->base.get_paramf = cell_get_paramf; + screen->base.is_format_supported = cell_is_format_supported; + screen->base.context_create = cell_create_context; - cell_init_screen_texture_funcs(screen); - u_simple_screen_init(screen); + cell_init_screen_texture_funcs(&screen->base); + cell_init_screen_buffer_funcs(&screen->base); return screen; } diff --git a/src/gallium/drivers/cell/ppu/cell_screen.h b/src/gallium/drivers/cell/ppu/cell_screen.h index c7e15889d6..6a22433b56 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.h +++ b/src/gallium/drivers/cell/ppu/cell_screen.h @@ -30,12 +30,29 @@ #define CELL_SCREEN_H -struct pipe_screen; -struct pipe_winsys; +#include "pipe/p_screen.h" +struct sw_winsys; + +struct cell_screen { + struct pipe_screen base; + + struct sw_winsys *winsys; + + /* Increments whenever textures are modified. Contexts can track + * this. + */ + unsigned timestamp; +}; + +static INLINE struct cell_screen * +cell_screen( struct pipe_screen *pipe ) +{ + return (struct cell_screen *)pipe; +} extern struct pipe_screen * -cell_create_screen(struct pipe_winsys *winsys); +cell_create_screen(struct sw_winsys *winsys); #endif /* CELL_SCREEN_H */ diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c index a59c7828ac..424e2628a9 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_emit.c +++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c @@ -245,16 +245,13 @@ cell_emit_state(struct cell_context *cell) uint i, j; float *buf = cell_batch_alloc16(cell, ROUNDUP16(32 + num_const * sizeof(float))); uint32_t *ibuf = (uint32_t *) buf; - const float *constants = pipe_buffer_map(cell->pipe.screen, - cell->constants[shader], - PIPE_BUFFER_USAGE_CPU_READ); + const float *constants = cell->mapped_constants[shader]; ibuf[0] = CELL_CMD_STATE_FS_CONSTANTS; ibuf[4] = num_const; j = 8; for (i = 0; i < num_const; i++) { buf[j++] = constants[i]; } - pipe_buffer_unmap(cell->pipe.screen, cell->constants[shader]); } if (cell->dirty & (CELL_NEW_FRAMEBUFFER | diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c index bc6127d7e7..6342402854 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c @@ -34,6 +34,7 @@ #include "cell_context.h" #include "cell_state.h" #include "cell_gen_fp.h" +#include "cell_buffer.h" /** cast wrapper */ @@ -185,15 +186,27 @@ cell_set_constant_buffer(struct pipe_context *pipe, struct pipe_buffer *buf) { struct cell_context *cell = cell_context(pipe); + unsigned size = constants ? constants->size : 0; + const void *data = constants ? cell_buffer(constants)->data : NULL; assert(shader < PIPE_SHADER_TYPES); assert(index == 0); + if (cell->constants[shader] == constants) + return; + draw_flush(cell->draw); /* note: reference counting */ pipe_buffer_reference(&cell->constants[shader], buf); + if(shader == PIPE_SHADER_VERTEX) { + draw_set_mapped_constant_buffer(cell->draw, PIPE_SHADER_VERTEX, 0, + data, size); + } + + cell->mapped_constants[shader] = data; + if (shader == PIPE_SHADER_VERTEX) cell->dirty |= CELL_NEW_VS_CONSTANTS; else if (shader == PIPE_SHADER_FRAGMENT) diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index a5f426795d..f3fc080aa3 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -43,10 +43,13 @@ #include "cell_state.h" #include "cell_texture.h" +#include "state_tracker/sw_winsys.h" -static void -cell_texture_layout(struct cell_texture *ct) + +static boolean +cell_texture_layout(struct pipe_screen *screen, + struct cell_texture *ct) { struct pipe_texture *pt = &ct->base; unsigned level; @@ -82,9 +85,34 @@ cell_texture_layout(struct cell_texture *ct) height = u_minify(height, 1); depth = u_minify(depth, 1); } + + ct->data = align_malloc(ct->buffer_size, 16); + + return ct->data != NULL; } +/** + * Texture layout for simple color buffers. + */ +static boolean +cell_displaytarget_layout(struct pipe_screen *screen, + struct cell_texture * ct) +{ + struct sw_winsys *winsys = cell_screen(screen)->winsys; + + /* Round up the surface size to a multiple of the tile size? + */ + ct->dt = winsys->displaytarget_create(winsys, + ct->base.format, + ct->base.width0, + ct->base.height0, + 16, + &ct->stride[0] ); + + return ct->dt != NULL; +} + static struct pipe_texture * cell_texture_create(struct pipe_screen *screen, const struct pipe_texture *templat) @@ -97,31 +125,46 @@ cell_texture_create(struct pipe_screen *screen, pipe_reference_init(&ct->base.reference, 1); ct->base.screen = screen; - cell_texture_layout(ct); - - ct->buffer = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_PIXEL, - ct->buffer_size); - - if (!ct->buffer) { - FREE(ct); - return NULL; + if (ct->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | + PIPE_TEXTURE_USAGE_SCANOUT | + PIPE_TEXTURE_USAGE_SHARED)) { + if (!cell_displaytarget_layout(screen, ct)) + goto fail; + } + else { + if (!cell_texture_layout(screen, ct)) + goto fail; } return &ct->base; + +fail: + FREE(ct); + return NULL; } static void cell_texture_destroy(struct pipe_texture *pt) { + struct cell_screen *screen = cell_screen(pt->screen); + struct sw_winsys *winsys = screen->winsys; struct cell_texture *ct = cell_texture(pt); if (ct->mapped) { - pipe_buffer_unmap(ct->buffer->screen, ct->buffer); + if (ct->dt) + winsys->displaytarget_unmap(winsys, ct->dt); ct->mapped = NULL; } - pipe_buffer_reference(&ct->buffer, NULL); + if (ct->dt) { + /* display target */ + winsys->displaytarget_destroy(winsys, ct->dt); + } + else { + /* regular texture */ + align_free(ct->data); + } FREE(ct); } @@ -388,12 +431,20 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer) assert(transfer->texture); - if (!ct->mapped) { - /* map now */ - ct->mapped = pipe_buffer_map(screen, ct->buffer, - pipe_transfer_buffer_flags(transfer)); + if (ct->mapped == NULL) { + if (ct->dt) { + struct sw_winsys *winsys = cell_screen(screen)->winsys; + ct->mapped = winsys->displaytarget_map(screen, ct->dt, + pipe_transfer_buffer_flags(transfer)); + } + else { + ct->mapped = ct->data; + } } + if (ct->mapped == NULL) + return NULL; + /* * Create a buffer of ordinary memory for the linear texture. * This is the memory that the user will read/write. @@ -441,9 +492,8 @@ cell_transfer_unmap(struct pipe_screen *screen, const uint stride = ct->stride[level]; if (!ct->mapped) { - /* map now */ - ct->mapped = pipe_buffer_map(screen, ct->buffer, - PIPE_BUFFER_USAGE_CPU_READ); + assert(0); + return; } if (transfer->usage & PIPE_TRANSFER_WRITE) { @@ -461,11 +511,20 @@ cell_transfer_unmap(struct pipe_screen *screen, } } + if (ct->dt) { + /* display target */ + struct sw_winsys *winsys = cell_screen(screen)->winsys; + winsys->displaytarget_unmap(winsys, ct->dt); + } + align_free(ctrans->map); ctrans->map = NULL; } + + + void cell_init_screen_texture_funcs(struct pipe_screen *screen) { diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h index 3ffc0bfdb5..55b983218f 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.h +++ b/src/gallium/drivers/cell/ppu/cell_texture.h @@ -43,8 +43,19 @@ struct cell_texture unsigned long level_offset[CELL_MAX_TEXTURE_LEVELS]; unsigned long stride[CELL_MAX_TEXTURE_LEVELS]; - /** The tiled texture data is held in this buffer */ - struct pipe_buffer *buffer; + /** + * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET + * usage. + */ + struct sw_displaytarget *dt; + + /** + * Malloc'ed data for regular textures, or a mapping to dt above. + */ + void *data; + + /* Size of the linear buffer?? + */ unsigned long buffer_size; /** The buffer above, mapped. This is the memory from which the diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.h b/src/gallium/drivers/cell/ppu/cell_winsys.h deleted file mode 100644 index e227e065ff..0000000000 --- a/src/gallium/drivers/cell/ppu/cell_winsys.h +++ /dev/null @@ -1,47 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - -#ifndef CELL_WINSYS_H -#define CELL_WINSYS_H - -#include "pipe/p_compiler.h" - - -/** - * Very simple winsys at this time. - * Will probably eventually add SPU control info. - */ -struct cell_winsys -{ - uint dummy; -}; - - - - -#endif -- cgit v1.2.3 From e497a58fad878d913a1795b239ddd05870988c58 Mon Sep 17 00:00:00 2001 From: David Heidelberger Date: Tue, 9 Mar 2010 13:50:27 +0100 Subject: nv30: fix typo Signed-off-by: David Heidelberger --- src/gallium/drivers/nv30/nv30_miptree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c index 5ef74a832d..bfa27b632f 100644 --- a/src/gallium/drivers/nv30/nv30_miptree.c +++ b/src/gallium/drivers/nv30/nv30_miptree.c @@ -236,5 +236,5 @@ nv30_screen_init_miptree_functions(struct pipe_screen *pscreen) pscreen->get_tex_surface = nv30_miptree_surface_new; pscreen->tex_surface_destroy = nv30_miptree_surface_del; - nouveau_screen(pscreen)->texture_blanket = nv50_miptree_blanket; + nouveau_screen(pscreen)->texture_blanket = nv30_miptree_blanket; } -- cgit v1.2.3 From fe9f8536f1b1e7a3a2ac10afd8078e8f4d327578 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 14:19:29 +0100 Subject: auxiliary: fix vertex elements cso potentially could have got a match even though the cso was different (in case of different count and first few elements the same). --- src/gallium/auxiliary/cso_cache/cso_cache.h | 7 ++++++- src/gallium/auxiliary/cso_cache/cso_context.c | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h index d884d5410f..fb09b83c62 100644 --- a/src/gallium/auxiliary/cso_cache/cso_cache.h +++ b/src/gallium/auxiliary/cso_cache/cso_cache.h @@ -146,8 +146,13 @@ struct cso_sampler { struct pipe_context *context; }; +struct cso_velems_state { + unsigned count; + struct pipe_vertex_element velems[PIPE_MAX_ATTRIBS]; +}; + struct cso_velements { - struct pipe_vertex_element state[PIPE_MAX_ATTRIBS]; + struct cso_velems_state state; void *data; cso_state_callback delete_state; struct pipe_context *context; diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 95e3c18e53..510366a8d4 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1152,18 +1152,25 @@ enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, unsigned key_size, hash_key; struct cso_hash_iter iter; void *handle; - - key_size = sizeof(struct pipe_vertex_element) * count; - hash_key = cso_construct_key((void*)states, key_size); - iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS, (void*)states, key_size); + struct cso_velems_state velems_state; + + /* need to include the count into the stored state data too. + Otherwise first few count pipe_vertex_elements could be identical even if count + is different, and there's no guarantee the hash would be different in that + case neither */ + key_size = sizeof(struct pipe_vertex_element) * count + sizeof(unsigned); + velems_state.count = count; + memcpy(velems_state.velems, states, sizeof(struct pipe_vertex_element) * count); + hash_key = cso_construct_key((void*)&velems_state, key_size); + iter = cso_find_state_template(ctx->cache, hash_key, CSO_VELEMENTS, (void*)&velems_state, key_size); if (cso_hash_iter_is_null(iter)) { struct cso_velements *cso = MALLOC(sizeof(struct cso_velements)); if (!cso) return PIPE_ERROR_OUT_OF_MEMORY; - memcpy(&cso->state, states, key_size); - cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, count, &cso->state[0]); + memcpy(&cso->state, &velems_state, key_size); + cso->data = ctx->pipe->create_vertex_elements_state(ctx->pipe, count, &cso->state.velems[0]); cso->delete_state = (cso_state_callback)ctx->pipe->delete_vertex_elements_state; cso->context = ctx->pipe; -- cgit v1.2.3 From e8983f70b41ea92a9527cb618db011b5dd136626 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 14:23:00 +0100 Subject: gallium: don't use flexible array members in drivers for vertex elements cso While this c99 feature should work with most compilers, valgrind doesn't really like it, and this only really saves some memory, we don't do this in similar occasions (like the blend state) neither. --- src/gallium/drivers/cell/ppu/cell_context.h | 2 +- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 2 +- src/gallium/drivers/i915/i915_context.h | 2 +- src/gallium/drivers/i915/i915_state.c | 2 +- src/gallium/drivers/i965/brw_pipe_vertex.c | 2 +- src/gallium/drivers/llvmpipe/lp_state.h | 2 +- src/gallium/drivers/llvmpipe/lp_state_vertex.c | 2 +- src/gallium/drivers/softpipe/sp_state.h | 2 +- src/gallium/drivers/softpipe/sp_state_vertex.c | 2 +- src/gallium/drivers/svga/svga_context.h | 2 +- src/gallium/drivers/svga/svga_pipe_vertex.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index 84ad0f3422..584f355804 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -96,7 +96,7 @@ struct cell_buffer_list struct cell_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; } /** diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index 35c919fb6b..d3efb8ecea 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -43,7 +43,7 @@ cell_create_vertex_elements_state(struct pipe_context *pipe, { struct cell_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state) + count * sizeof(*attribs)); + velems = (struct cell_velems_state *) MALLOC(sizeof(struct cell_velems_state)); if (velems) { velems->count = count; memcpy(velems->velem, attribs, sizeof(*attribs) * count); diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 369c63eece..3e383aaa1c 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -189,7 +189,7 @@ struct i915_sampler_state { struct i915_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; }; struct i915_texture { diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 46406065c3..8927dfc33d 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -749,7 +749,7 @@ i915_create_vertex_elements_state(struct pipe_context *pipe, { struct i915_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct i915_velems_state *) MALLOC(sizeof(struct i915_velems_state) + count * sizeof(*attribs)); + velems = (struct i915_velems_state *) MALLOC(sizeof(struct i915_velems_state)); if (velems) { velems->count = count; memcpy(velems->velem, attribs, sizeof(*attribs) * count); diff --git a/src/gallium/drivers/i965/brw_pipe_vertex.c b/src/gallium/drivers/i965/brw_pipe_vertex.c index 3d84fb86fb..d6a840857e 100644 --- a/src/gallium/drivers/i965/brw_pipe_vertex.c +++ b/src/gallium/drivers/i965/brw_pipe_vertex.c @@ -215,7 +215,7 @@ static void* brw_create_vertex_elements_state( struct pipe_context *pipe, const struct pipe_vertex_element *attribs ) { /* note: for the brw_swtnl.c code (if ever we need draw fallback) we'd also need - store the original data */ + to store the original data */ struct brw_context *brw = brw_context(pipe); struct brw_vertex_element_packet *velems; assert(count <= BRW_VEP_MAX); diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 57f5bd0042..6dbdc195bf 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -121,7 +121,7 @@ struct lp_vertex_shader { struct lp_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; }; diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c index 5a9b6d5e18..2ddd110a5f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c @@ -42,7 +42,7 @@ llvmpipe_create_vertex_elements_state(struct pipe_context *pipe, { struct lp_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct lp_velems_state *) MALLOC(sizeof(struct lp_velems_state) + count * sizeof(*attribs)); + velems = (struct lp_velems_state *) MALLOC(sizeof(struct lp_velems_state)); if (velems) { velems->count = count; memcpy(velems->velem, attribs, sizeof(*attribs) * count); diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h index a6b9a841fe..6b01c0f4d7 100644 --- a/src/gallium/drivers/softpipe/sp_state.h +++ b/src/gallium/drivers/softpipe/sp_state.h @@ -102,7 +102,7 @@ struct sp_geometry_shader { struct sp_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; }; diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index e7dc3d002b..a151758ddc 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -43,7 +43,7 @@ softpipe_create_vertex_elements_state(struct pipe_context *pipe, { struct sp_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct sp_velems_state *) MALLOC(sizeof(struct sp_velems_state) + count * sizeof(*attribs)); + velems = (struct sp_velems_state *) MALLOC(sizeof(struct sp_velems_state)); if (velems) { velems->count = count; memcpy(velems->velem, attribs, sizeof(*attribs) * count); diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 4d9f00991a..791d30edc0 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -171,7 +171,7 @@ struct svga_sampler_state { struct svga_velems_state { unsigned count; - struct pipe_vertex_element velem[]; + struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; }; /* Use to calculate differences between state emitted to hardware and diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c index 979deb12af..d4a1280e74 100644 --- a/src/gallium/drivers/svga/svga_pipe_vertex.c +++ b/src/gallium/drivers/svga/svga_pipe_vertex.c @@ -73,7 +73,7 @@ svga_create_vertex_elements_state(struct pipe_context *pipe, { struct svga_velems_state *velems; assert(count <= PIPE_MAX_ATTRIBS); - velems = (struct svga_velems_state *) MALLOC(sizeof(struct svga_velems_state) + count * sizeof(*attribs)); + velems = (struct svga_velems_state *) MALLOC(sizeof(struct svga_velems_state)); if (velems) { velems->count = count; memcpy(velems->velem, attribs, sizeof(*attribs) * count); -- cgit v1.2.3 From 65233674d3598fee90d762b0c2826752f2619f05 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 14:03:41 +0000 Subject: cell: untwiddle surface contents in flush_frontbuffer() Don't make the shared software winsys rely on internal knowledge about the cell driver's texture twiddling. This is just a sketch and hasn't even been compile tested. --- src/gallium/drivers/cell/ppu/cell_screen.c | 16 ------ src/gallium/drivers/cell/ppu/cell_texture.c | 89 ++++++++++++++++++----------- src/gallium/drivers/cell/ppu/cell_texture.h | 1 + src/gallium/winsys/xlib/xlib_cell.c | 81 -------------------------- 4 files changed, 58 insertions(+), 129 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 36479e8e0c..00035be53a 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -164,22 +164,6 @@ cell_destroy_screen( struct pipe_screen *screen ) FREE(screen); } -/* This used to be overriden by the co-state tracker, but really needs - * to be active with sw_winsys. - */ -static void -cell_flush_frontbuffer(struct pipe_screen *_screen, - struct pipe_surface *surface, - void *context_private) -{ - struct cell_screen *screen = cell_screen(_screen); - struct sw_winsys *winsys = screen->winsys; - struct cell_texture *texture = cell_texture(surface->texture); - - assert(texture->dt); - if (texture->dt) - winsys->displaytarget_display(winsys, texture->dt, context_private); -} /** diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index f3fc080aa3..002dd3a9b5 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -108,7 +108,7 @@ cell_displaytarget_layout(struct pipe_screen *screen, ct->base.width0, ct->base.height0, 16, - &ct->stride[0] ); + &ct->dt_stride ); return ct->dt != NULL; } @@ -125,21 +125,29 @@ cell_texture_create(struct pipe_screen *screen, pipe_reference_init(&ct->base.reference, 1); ct->base.screen = screen; + /* Create both a displaytarget (linear) and regular texture + * (twiddled). Convert twiddled->linear at flush_frontbuffer time. + */ if (ct->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET | PIPE_TEXTURE_USAGE_SCANOUT | PIPE_TEXTURE_USAGE_SHARED)) { if (!cell_displaytarget_layout(screen, ct)) goto fail; } - else { - if (!cell_texture_layout(screen, ct)) - goto fail; - } + + if (!cell_texture_layout(screen, ct)) + goto fail; return &ct->base; fail: + if (ct->dt) { + struct sw_winsys winsys = cell_screen(screen)->winsys; + winsys->displaytarget_destroy(winsys, ct->dt); + } + FREE(ct); + return NULL; } @@ -151,20 +159,12 @@ cell_texture_destroy(struct pipe_texture *pt) struct sw_winsys *winsys = screen->winsys; struct cell_texture *ct = cell_texture(pt); - if (ct->mapped) { - if (ct->dt) - winsys->displaytarget_unmap(winsys, ct->dt); - ct->mapped = NULL; - } - if (ct->dt) { /* display target */ winsys->displaytarget_destroy(winsys, ct->dt); } - else { - /* regular texture */ - align_free(ct->data); - } + + align_free(ct->data); FREE(ct); } @@ -432,19 +432,9 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer) assert(transfer->texture); if (ct->mapped == NULL) { - if (ct->dt) { - struct sw_winsys *winsys = cell_screen(screen)->winsys; - ct->mapped = winsys->displaytarget_map(screen, ct->dt, - pipe_transfer_buffer_flags(transfer)); - } - else { - ct->mapped = ct->data; - } + ct->mapped = ct->data; } - if (ct->mapped == NULL) - return NULL; - /* * Create a buffer of ordinary memory for the linear texture. * This is the memory that the user will read/write. @@ -511,18 +501,51 @@ cell_transfer_unmap(struct pipe_screen *screen, } } - if (ct->dt) { - /* display target */ - struct sw_winsys *winsys = cell_screen(screen)->winsys; - winsys->displaytarget_unmap(winsys, ct->dt); - } - align_free(ctrans->map); ctrans->map = NULL; } +/* This used to be overriden by the co-state tracker, but really needs + * to be active with sw_winsys. + * + * Contrasting with llvmpipe and softpipe, this is the only place + * where we use the ct->dt display target in any real sense. + * + * Basically just untwiddle our local data into the linear + * displaytarget. + */ +static void +cell_flush_frontbuffer(struct pipe_screen *_screen, + struct pipe_surface *surface, + void *context_private) +{ + struct cell_screen *screen = cell_screen(_screen); + struct sw_winsys *winsys = screen->winsys; + struct cell_texture *ct = cell_texture(surface->texture); + + if (!ct->dt) + return; + + /* Need to untwiddle from our internal representation here: + */ + { + unsigned *map = winsys->displaytarget_map(winsys, ct->dt); + unsigned *src = (unsigned *)(ct->data + ct->level_offset[surface->level]); + + untwiddle_image_uint(surface->width, + surface->height, + TILE_SIZE, + map, + ct->dt_stride, + src); + + winsys->displaytarget_unmap(winsys, c->dt); + } + + winsys->displaytarget_display(winsys, ct->dt, context_private); +} void @@ -539,4 +562,6 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen) screen->transfer_map = cell_transfer_map; screen->transfer_unmap = cell_transfer_unmap; + + screen->flush_frontbuffer = cell_flush_frontbuffer; } diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h index 55b983218f..b89db1a5a8 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.h +++ b/src/gallium/drivers/cell/ppu/cell_texture.h @@ -48,6 +48,7 @@ struct cell_texture * usage. */ struct sw_displaytarget *dt; + unsigned dt_stride; /** * Malloc'ed data for regular textures, or a mapping to dt above. diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c index ce4efe8851..2ad1aab439 100644 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ b/src/gallium/winsys/xlib/xlib_cell.c @@ -47,88 +47,7 @@ -/** - * For Cell. Basically, rearrange the pixels/quads from this layout: - * +--+--+--+--+ - * |p0|p1|p2|p3|.... - * +--+--+--+--+ - * - * to this layout: - * +--+--+ - * |p0|p1|.... - * +--+--+ - * |p2|p3| - * +--+--+ - */ -static void -twiddle_tile(const uint *tileIn, uint *tileOut) -{ - int y, x; - - for (y = 0; y < TILE_SIZE; y+=2) { - for (x = 0; x < TILE_SIZE; x+=2) { - int k = 4 * (y/2 * TILE_SIZE/2 + x/2); - tileOut[y * TILE_SIZE + (x + 0)] = tileIn[k]; - tileOut[y * TILE_SIZE + (x + 1)] = tileIn[k+1]; - tileOut[(y + 1) * TILE_SIZE + (x + 0)] = tileIn[k+2]; - tileOut[(y + 1) * TILE_SIZE + (x + 1)] = tileIn[k+3]; - } - } -} -/** - * Display a surface that's in a tiled configuration. That is, all the - * pixels for a TILE_SIZExTILE_SIZE block are contiguous in memory. - */ -static void -xm_displaytarget_display(struct sw_winsys *ws, - struct sw_displaytarget *dt, - void *winsys_drawable) -{ - struct xmesa_buffer *xm_buffer = (struct xm_drawable *)winsys_drawable; - XImage *ximage; - struct xm_buffer *xm_buf = xm_buffer( - cell_texture(surf->texture)->buffer); - const uint tilesPerRow = (surf->width + TILE_SIZE - 1) / TILE_SIZE; - uint x, y; - - ximage = b->tempImage; - - /* check that the XImage has been previously initialized */ - assert(ximage->format); - assert(ximage->bitmap_unit); - - /* update XImage's fields */ - ximage->width = TILE_SIZE; - ximage->height = TILE_SIZE; - ximage->bytes_per_line = TILE_SIZE * 4; - - for (y = 0; y < surf->height; y += TILE_SIZE) { - for (x = 0; x < surf->width; x += TILE_SIZE) { - uint tmpTile[TILE_SIZE * TILE_SIZE]; - int tx = x / TILE_SIZE; - int ty = y / TILE_SIZE; - int offset = ty * tilesPerRow + tx; - int w = TILE_SIZE; - int h = TILE_SIZE; - - if (y + h > surf->height) - h = surf->height - y; - if (x + w > surf->width) - w = surf->width - x; - - /* offset in pixels */ - offset *= TILE_SIZE * TILE_SIZE; - - /* twiddle from ximage buffer to temp tile */ - twiddle_tile((uint *) xm_buf->data + offset, tmpTile); - /* display temp tile data */ - ximage->data = (char *) tmpTile; - XPutImage(b->xm_visual->display, b->drawable, b->gc, - ximage, 0, 0, x, y, w, h); - } - } -} -- cgit v1.2.3 From ce30b5bf2c4ff864542c038f59fc69c3e6518acd Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 14:32:44 +0000 Subject: ws/gdi: sketch of gdi changes --- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 2 +- src/gallium/winsys/gdi/gdi_softpipe_winsys.c | 2 +- src/gallium/winsys/gdi/gdi_sw_winsys.c | 214 +++++++++++++++++++++++++++ 3 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 src/gallium/winsys/gdi/gdi_sw_winsys.c (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c index 3d317c70dd..e627028dd4 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c @@ -36,7 +36,7 @@ #include -#include "gdi_winsys.h" +#include "gdi_sw_winsys.h" #include "llvmpipe/lp_texture.h" diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c index 56e84fd066..bb669bbb64 100644 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c @@ -36,7 +36,7 @@ #include -#include "gdi_winsys.h" +#include "gdi_sw_winsys.h" #include "softpipe/sp_texture.h" diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c new file mode 100644 index 0000000000..00c6facd04 --- /dev/null +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.c @@ -0,0 +1,214 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/** + * @file + * LLVMpipe support. + * + * @author Jose Fonseca + */ + + +#include + +#include "pipe/p_format.h" +#include "pipe/p_context.h" +#include "util/u_inlines.h" +#include "util/u_format.h" +#include "util/u_math.h" +#include "util/u_memory.h" +#include "state_tracker/sw_winsys.h" +#include "stw_winsys.h" + + +struct gdi_sw_displaytarget +{ + enum pipe_format format; + unsigned width; + unsigned height; + unsigned stride; + + unsigned size; + + void *data; + + BITMAPINFO bmi; +}; + + +/** Cast wrapper */ +static INLINE struct gdi_sw_displaytarget * +gdi_sw_displaytarget( struct sw_displaytarget *buf ) +{ + return (struct gdi_sw_displaytarget *)buf; +} + + +static boolean +gdi_sw_is_displaytarget_format_supported( struct sw_winsys *ws, + enum pipe_format format ) +{ + switch(format) { + case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: + return TRUE; + + /* TODO: Support other formats possible with BMPs, as described in + * http://msdn.microsoft.com/en-us/library/dd183376(VS.85).aspx */ + + default: + return FALSE; + } +} + + +static void * +gdi_sw_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags ) +{ + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); + + return gdt->data; +} + + +static void +gdi_sw_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt ) +{ + +} + + +static void +gdi_sw_displaytarget_destroy(struct sw_winsys *winsys, + struct sw_displaytarget *dt) +{ + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); + + align_free(gdt->data); + FREE(gdt); +} + + +static struct sw_displaytarget * +gdi_sw_displaytarget_create(struct sw_winsys *winsys, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + struct gdi_sw_displaytarget *gdt; + unsigned cpp; + unsigned bpp; + + gdt = CALLOC_STRUCT(gdi_sw_displaytarget); + if(!gdt) + goto no_gdt; + + gdt->format = format; + gdt->width = width; + gdt->height = height; + + bpp = util_format_get_blocksizebits(format); + cpp = util_format_get_blocksize(format); + + gdt->stride = align(width * cpp, alignment); + gdt->size = gdt->stride * height; + + gdt->data = align_malloc(gdt->size, alignment); + if(!gdt->data) + goto no_data; + + gdt->bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + gdt->bmi.bmiHeader.biWidth = gdt->stride / cpp; + gdt->bmi.bmiHeader.biHeight= -(long)height; + gdt->bmi.bmiHeader.biPlanes = 1; + gdt->bmi.bmiHeader.biBitCount = bpp; + gdt->bmi.bmiHeader.biCompression = BI_RGB; + gdt->bmi.bmiHeader.biSizeImage = 0; + gdt->bmi.bmiHeader.biXPelsPerMeter = 0; + gdt->bmi.bmiHeader.biYPelsPerMeter = 0; + gdt->bmi.bmiHeader.biClrUsed = 0; + gdt->bmi.bmiHeader.biClrImportant = 0; + + *stride = gdt->stride; + return (struct sw_displaytarget *)gdt; + +no_data: + FREE(gdt); +no_gdt: + return NULL; +} + + +static void +gdi_sw_displaytarget_display(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + void *context_private) +{ + struct gdi_softpipe_displaytarget *gdt = gdi_sw_displaytarget(dt); + + /* nasty: + */ + HDC hDC = (HDC)context_private; + + StretchDIBits(hDC, + 0, 0, gdt->width, gdt->height, + 0, 0, gdt->width, gdt->height, + gdt->data, &gdt->bmi, 0, SRCCOPY); +} + + +static void +gdi_sw_destroy(struct sw_winsys *winsys) +{ + FREE(winsys); +} + +struct sw_winsys * +gdi_create_sw_winsys(void) +{ + static struct sw_winsys *winsys; + + winsys = CALLOC_STRUCT(sw_winsys); + if(!winsys) + return NULL; + + winsys->destroy = gdi_sw_destroy; + winsys->is_displaytarget_format_supported = gdi_sw_is_displaytarget_format_supported; + winsys->displaytarget_create = gdi_sw_displaytarget_create; + winsys->displaytarget_map = gdi_sw_displaytarget_map; + winsys->displaytarget_unmap = gdi_sw_displaytarget_unmap; + winsys->displaytarget_display = gdi_sw_displaytarget_display; + winsys->displaytarget_destroy = gdi_sw_displaytarget_destroy; + + return winsys; +} + -- cgit v1.2.3 From 3db9644a9efd37fdefbde9ef5f9e60f44938d614 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 14:49:39 +0000 Subject: ws/gdi: missing file --- src/gallium/winsys/gdi/gdi_sw_winsys.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/gallium/winsys/gdi/gdi_sw_winsys.h (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h new file mode 100644 index 0000000000..7e00d78911 --- /dev/null +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.h @@ -0,0 +1,10 @@ +#ifndef GDI_SW_WINSYS_H +#define GDI_SW_WINSYS_H + +#include "pipe/p_compiler.h" +#include "state_tracker/sw_winsys.h" + +struct sw_winsys * +gdi_create_sw_winsys(void) + +#endif -- cgit v1.2.3 From 73d9400ad65c1ec0a20c29805a9fc1930687988c Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 14:49:02 +0000 Subject: softpipe: silence warning --- src/gallium/drivers/softpipe/sp_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 95def72c54..3d69cfdb11 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -93,7 +93,7 @@ struct softpipe_context { ubyte *mapped_vbuffer[PIPE_MAX_ATTRIBS]; /** Mapped constant buffers */ - void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; + const void *mapped_constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS]; /** Vertex format */ struct vertex_info vertex_info; -- cgit v1.2.3 From b694f321707c98c71478aceb11f814643109367b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 15:02:21 +0000 Subject: winsys/gdi: get softpipe version compiling --- src/gallium/winsys/gdi/SConscript | 8 +++++--- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 26 +++++++++++++++----------- src/gallium/winsys/gdi/gdi_softpipe_winsys.c | 28 ++++++++++++++++------------ src/gallium/winsys/gdi/gdi_sw_winsys.c | 22 +++++++++++++++------- src/gallium/winsys/gdi/gdi_sw_winsys.h | 6 +++++- 5 files changed, 56 insertions(+), 34 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 4b32aa27e1..0a3f141e72 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -18,17 +18,19 @@ if env['platform'] == 'windows': 'ws2_32', ]) - sources = ['gdi_sw_winsys.c'] + sources = [] drivers = [] if 'softpipe' in env['drivers']: - sources = ['gdi_softpipe_winsys.c'] + sources = ['gdi_sw_winsys.c', + 'gdi_softpipe_winsys.c'] drivers = [softpipe] if 'llvmpipe' in env['drivers']: env.Tool('llvm') if 'LLVM_VERSION' in env: - sources = ['gdi_llvmpipe_winsys.c'] + sources = ['gdi_sw_winsys.c', + 'gdi_llvmpipe_winsys.c'] drivers = [llvmpipe] if not sources or not drivers: diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c index e627028dd4..4ea33f673f 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c @@ -36,8 +36,10 @@ #include +#include "stw_winsys.h" #include "gdi_sw_winsys.h" #include "llvmpipe/lp_texture.h" +#include "llvmpipe/lp_screen.h" static struct pipe_screen * @@ -57,7 +59,7 @@ gdi_llvmpipe_screen_create(void) return screen; no_screen: - FREE(winsys); + winsys->destroy(winsys); no_winsys: return NULL; } @@ -70,16 +72,18 @@ gdi_llvmpipe_present(struct pipe_screen *screen, struct pipe_surface *surface, HDC hDC) { - struct llvmpipe_texture *texture; - struct gdi_llvmpipe_displaytarget *gdt; - - texture = llvmpipe_texture(surface->texture); - gdt = gdi_llvmpipe_displaytarget(texture->dt); - - StretchDIBits(hDC, - 0, 0, gdt->width, gdt->height, - 0, 0, gdt->width, gdt->height, - gdt->data, &gdt->bmi, 0, SRCCOPY); + /* This will fail if any interposing layer (trace, debug, etc) has + * been introduced between the state-trackers and llvmpipe. + * + * Ideally this would get replaced with a call to + * pipe_screen::flush_frontbuffer(). + * + * Failing that, it may be necessary for intervening layers to wrap + * other structs such as this stw_winsys as well... + */ + gdi_sw_display(llvmpipe_screen(screen)->winsys, + llvmpipe_texture(surface->texture)->dt, + hDC); } diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c index bb669bbb64..5c5c154c7f 100644 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c @@ -36,14 +36,16 @@ #include +#include "stw_winsys.h" #include "gdi_sw_winsys.h" #include "softpipe/sp_texture.h" +#include "softpipe/sp_screen.h" static struct pipe_screen * gdi_softpipe_screen_create(void) { - static struct softpipe_winsys *winsys; + static struct sw_winsys *winsys; struct pipe_screen *screen; winsys = gdi_create_sw_winsys(); @@ -57,7 +59,7 @@ gdi_softpipe_screen_create(void) return screen; no_screen: - FREE(winsys); + winsys->destroy(winsys); no_winsys: return NULL; } @@ -70,16 +72,18 @@ gdi_softpipe_present(struct pipe_screen *screen, struct pipe_surface *surface, HDC hDC) { - struct softpipe_texture *texture; - struct gdi_softpipe_displaytarget *gdt; - - texture = softpipe_texture(surface->texture); - gdt = gdi_softpipe_displaytarget(texture->dt); - - StretchDIBits(hDC, - 0, 0, gdt->width, gdt->height, - 0, 0, gdt->width, gdt->height, - gdt->data, &gdt->bmi, 0, SRCCOPY); + /* This will fail if any interposing layer (trace, debug, etc) has + * been introduced between the state-trackers and softpipe. + * + * Ideally this would get replaced with a call to + * pipe_screen::flush_frontbuffer(). + * + * Failing that, it may be necessary for intervening layers to wrap + * other structs such as this stw_winsys as well... + */ + gdi_sw_display(softpipe_screen(screen)->winsys, + softpipe_texture(surface->texture)->dt, + hDC); } diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c index 00c6facd04..55f99c4f47 100644 --- a/src/gallium/winsys/gdi/gdi_sw_winsys.c +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.c @@ -43,7 +43,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "state_tracker/sw_winsys.h" -#include "stw_winsys.h" +#include "gdi_sw_winsys.h" struct gdi_sw_displaytarget @@ -168,21 +168,29 @@ no_gdt: } +void +gdi_sw_display( struct sw_winsys *winsys, + struct sw_displaytarget *dt, + HDC hDC ) +{ + struct gdi_sw_displaytarget *gdt = gdi_sw_displaytarget(dt); + + StretchDIBits(hDC, + 0, 0, gdt->width, gdt->height, + 0, 0, gdt->width, gdt->height, + gdt->data, &gdt->bmi, 0, SRCCOPY); +} + static void gdi_sw_displaytarget_display(struct sw_winsys *winsys, struct sw_displaytarget *dt, void *context_private) { - struct gdi_softpipe_displaytarget *gdt = gdi_sw_displaytarget(dt); - /* nasty: */ HDC hDC = (HDC)context_private; - StretchDIBits(hDC, - 0, 0, gdt->width, gdt->height, - 0, 0, gdt->width, gdt->height, - gdt->data, &gdt->bmi, 0, SRCCOPY); + gdi_sw_display(winsys, dt, hDC); } diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h index 7e00d78911..8ecca7bbc3 100644 --- a/src/gallium/winsys/gdi/gdi_sw_winsys.h +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.h @@ -4,7 +4,11 @@ #include "pipe/p_compiler.h" #include "state_tracker/sw_winsys.h" +void gdi_sw_display( struct sw_winsys *winsys, + struct sw_displaytarget *dt, + HDC hDC ); + struct sw_winsys * -gdi_create_sw_winsys(void) +gdi_create_sw_winsys(void); #endif -- cgit v1.2.3 From 706eda30578cbdd1456c09ccc2a570a5d6a99c92 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 9 Mar 2010 15:07:57 +0000 Subject: scons: Add new targets option. This will likely change. Most probably we'll just add an alias to indvidual targets and use the regular scons targets arguments. --- SConstruct | 2 ++ src/SConscript | 9 ++++----- src/gallium/SConscript | 4 ++++ src/gallium/targets/SConscript | 2 +- src/gallium/winsys/xlib/SConscript | 16 ++++++++-------- 5 files changed, 19 insertions(+), 14 deletions(-) (limited to 'src/gallium') diff --git a/SConstruct b/SConstruct index e1c4a1898c..4cadd01363 100644 --- a/SConstruct +++ b/SConstruct @@ -53,6 +53,8 @@ opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon'])) +opts.Add(ListVariable('targets', 'target drivers to build', 'all', + ['xlib'])) opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) diff --git a/src/SConscript b/src/SConscript index cd4896ada4..cf6db730da 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,13 +1,12 @@ Import('*') SConscript('glsl/SConscript') -SConscript('gallium/SConscript') if 'mesa' in env['statetrackers']: - SConscript('mesa/SConscript') + SConscript('mesa/SConscript') -SConscript('gallium/winsys/SConscript') +SConscript('gallium/SConscript') if platform != 'embedded': - SConscript('glut/glx/SConscript') - SConscript('glew/SConscript') + SConscript('glut/glx/SConscript') + SConscript('glew/SConscript') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index d56c5c8461..ba541f9636 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -15,3 +15,7 @@ if platform != 'embedded': if platform == 'windows': SConscript('state_trackers/wgl/SConscript') + +SConscript('winsys/SConscript') + +SConscript('targets/SConscript') diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index 46cbe656f4..266d705f89 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -5,7 +5,7 @@ Import('*') # 'drm/SConscript', # ]) -if 'xlib' in env['winsys']: +if 'xlib' in env['targets']: SConscript([ 'libgl-xlib/SConscript', ]) diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 587cdb8e38..1a1879f128 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -15,13 +15,13 @@ if env['platform'] == 'linux' \ '#/src/gallium/drivers', ]) - st_xlib = env.ConvenienceLibrary( - target = 'ws_xlib', - source = [ - 'xlib_cell.c', - 'xlib_llvmpipe.c', - 'xlib_softpipe.c', - 'xlib_sw_winsys.c', - ] + ws_xlib = env.ConvenienceLibrary( + target = 'ws_xlib', + source = [ + 'xlib_cell.c', + 'xlib_llvmpipe.c', + 'xlib_softpipe.c', + 'xlib_sw_winsys.c', + ] ) Export('ws_xlib') -- cgit v1.2.3 From ff407a117c7bd4e9f370f8ec204d3f7b4e7f91a2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 9 Mar 2010 15:12:19 +0000 Subject: gdi: Fixup llvmpipe gdi winsys too. --- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c index 4ea33f673f..f20c2614e2 100644 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c @@ -45,7 +45,7 @@ static struct pipe_screen * gdi_llvmpipe_screen_create(void) { - static struct llvmpipe_winsys *winsys; + static struct sw_winsys *winsys; struct pipe_screen *screen; winsys = gdi_create_sw_winsys(); -- cgit v1.2.3 From 27a7f9454f190ebb51834e9d2d74c55766cbb29f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Mar 2010 08:12:47 -0700 Subject: cell: fix up assorted compilation problems The driver is pretty much totally broken though. --- src/gallium/drivers/cell/ppu/cell_buffer.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_context.h | 2 +- src/gallium/drivers/cell/ppu/cell_draw_arrays.c | 14 +++++++------- src/gallium/drivers/cell/ppu/cell_fence.c | 8 ++++++-- src/gallium/drivers/cell/ppu/cell_pipe_state.c | 22 ++++++++++++++++------ src/gallium/drivers/cell/ppu/cell_screen.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_state_shader.c | 4 ++-- src/gallium/drivers/cell/ppu/cell_texture.c | 9 ++++++--- src/gallium/drivers/cell/ppu/cell_texture.h | 1 + src/gallium/include/state_tracker/sw_winsys.h | 3 +++ src/gallium/winsys/xlib/xlib_cell.c | 23 +++++++++++++---------- 11 files changed, 59 insertions(+), 35 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.c b/src/gallium/drivers/cell/ppu/cell_buffer.c index 770f7328a7..f56a28d62e 100644 --- a/src/gallium/drivers/cell/ppu/cell_buffer.c +++ b/src/gallium/drivers/cell/ppu/cell_buffer.c @@ -30,8 +30,8 @@ #include "util/u_memory.h" #include "util/u_math.h" -#include "sp_screen.h" -#include "sp_buffer.h" +#include "cell_screen.h" +#include "cell_buffer.h" static void * diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h index a77cc5b906..233b91dec6 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.h +++ b/src/gallium/drivers/cell/ppu/cell_context.h @@ -34,7 +34,7 @@ #include "pipe/p_defines.h" #include "draw/draw_vertex.h" #include "draw/draw_vbuf.h" -#include "cell_winsys.h" +/*#include "cell_winsys.h"*/ #include "cell/common.h" #include "rtasm/rtasm_ppc_spe.h" #include "tgsi/tgsi_scan.h" diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c index bd15034a5d..15d4e8338f 100644 --- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c +++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c @@ -63,21 +63,21 @@ cell_draw_range_elements(struct pipe_context *pipe, unsigned max_index, unsigned mode, unsigned start, unsigned count) { - struct cell_context *sp = cell_context(pipe); - struct draw_context *draw = sp->draw; + struct cell_context *cell = cell_context(pipe); + struct draw_context *draw = cell->draw; unsigned i; - if (sp->dirty) - cell_update_derived( sp ); + if (cell->dirty) + cell_update_derived( cell ); #if 0 - cell_map_surfaces(sp); + cell_map_surfaces(cell); #endif /* * Map vertex buffers */ - for (i = 0; i < sp->num_vertex_buffers; i++) { + for (i = 0; i < cell->num_vertex_buffers; i++) { void *buf = cell_buffer(cell->vertex_buffer[i].buffer)->data; draw_set_mapped_vertex_buffer(draw, i, buf); } @@ -98,7 +98,7 @@ cell_draw_range_elements(struct pipe_context *pipe, /* * unmap vertex/index buffers - will cause draw module to flush */ - for (i = 0; i < sp->num_vertex_buffers; i++) { + for (i = 0; i < cell->num_vertex_buffers; i++) { draw_set_mapped_vertex_buffer(draw, i, NULL); } if (indexBuffer) { diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c index e10071529a..035ef41b89 100644 --- a/src/gallium/drivers/cell/ppu/cell_fence.c +++ b/src/gallium/drivers/cell/ppu/cell_fence.c @@ -92,7 +92,6 @@ cell_add_buffer_to_list(struct cell_context *cell, struct cell_buffer_list *list, struct pipe_buffer *buffer) { - struct pipe_screen *ps = cell->pipe.screen; struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node); /* create new list node which references the buffer, insert at head */ if (node) { @@ -157,8 +156,13 @@ cell_add_fenced_textures(struct cell_context *cell) printf("Adding texture %p buffer %p to list\n", ct, ct->tiled_buffer[level]); #endif - if (ct->buffer) +#if 00 + /* XXX this needs to be fixed/restored! + * Maybe keep pointers to textures, not buffers. + */ + if (ct->base.buffer) cell_add_buffer_to_list(cell, list, ct->buffer); +#endif } } } diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c index 3d8b4409c7..dce10ae7f8 100644 --- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c +++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c @@ -292,17 +292,23 @@ cell_set_sampler_textures(struct pipe_context *pipe, static void cell_map_surfaces(struct cell_context *cell) { +#if 0 struct pipe_screen *screen = cell->pipe.screen; +#endif uint i; for (i = 0; i < 1; i++) { struct pipe_surface *ps = cell->framebuffer.cbufs[i]; if (ps) { struct cell_texture *ct = cell_texture(ps->texture); +#if 0 cell->cbuf_map[i] = screen->buffer_map(screen, ct->buffer, (PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE)); +#else + cell->cbuf_map[i] = ct->data; +#endif } } @@ -310,10 +316,14 @@ cell_map_surfaces(struct cell_context *cell) struct pipe_surface *ps = cell->framebuffer.zsbuf; if (ps) { struct cell_texture *ct = cell_texture(ps->texture); +#if 0 cell->zsbuf_map = screen->buffer_map(screen, ct->buffer, (PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE)); +#else + cell->zsbuf_map = ct->data; +#endif } } } @@ -325,17 +335,17 @@ cell_map_surfaces(struct cell_context *cell) static void cell_unmap_surfaces(struct cell_context *cell) { - struct pipe_screen *screen = cell->pipe.screen; + /*struct pipe_screen *screen = cell->pipe.screen;*/ uint i; for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { struct pipe_surface *ps = cell->framebuffer.cbufs[i]; if (ps && cell->cbuf_map[i]) { - struct cell_texture *ct = cell_texture(ps->texture); + /*struct cell_texture *ct = cell_texture(ps->texture);*/ assert(ps->texture); - assert(ct->buffer); + /*assert(ct->buffer);*/ - screen->buffer_unmap(screen, ct->buffer); + /*screen->buffer_unmap(screen, ct->buffer);*/ cell->cbuf_map[i] = NULL; } } @@ -343,8 +353,8 @@ cell_unmap_surfaces(struct cell_context *cell) { struct pipe_surface *ps = cell->framebuffer.zsbuf; if (ps && cell->zsbuf_map) { - struct cell_texture *ct = cell_texture(ps->texture); - screen->buffer_unmap(screen, ct->buffer); + /*struct cell_texture *ct = cell_texture(ps->texture);*/ + /*screen->buffer_unmap(screen, ct->buffer);*/ cell->zsbuf_map = NULL; } } diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index 00035be53a..fc04767a1e 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -174,7 +174,7 @@ cell_destroy_screen( struct pipe_screen *screen ) struct pipe_screen * cell_create_screen(struct sw_winsys *winsys) { - struct cell_screen *screen = CALLOC_STRUCT(pipe_screen); + struct cell_screen *screen = CALLOC_STRUCT(cell_screen); if (!screen) return NULL; @@ -194,5 +194,5 @@ cell_create_screen(struct sw_winsys *winsys) cell_init_screen_texture_funcs(&screen->base); cell_init_screen_buffer_funcs(&screen->base); - return screen; + return &screen->base; } diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c index 6342402854..9e29ddc2d4 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_shader.c +++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c @@ -183,7 +183,7 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs) static void cell_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, - struct pipe_buffer *buf) + struct pipe_buffer *constants) { struct cell_context *cell = cell_context(pipe); unsigned size = constants ? constants->size : 0; @@ -198,7 +198,7 @@ cell_set_constant_buffer(struct pipe_context *pipe, draw_flush(cell->draw); /* note: reference counting */ - pipe_buffer_reference(&cell->constants[shader], buf); + pipe_buffer_reference(&cell->constants[shader], constants); if(shader == PIPE_SHADER_VERTEX) { draw_set_mapped_constant_buffer(cell->draw, PIPE_SHADER_VERTEX, 0, diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index 002dd3a9b5..c8a1acd86a 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -40,6 +40,7 @@ #include "util/u_memory.h" #include "cell_context.h" +#include "cell_screen.h" #include "cell_state.h" #include "cell_texture.h" @@ -142,7 +143,7 @@ cell_texture_create(struct pipe_screen *screen, fail: if (ct->dt) { - struct sw_winsys winsys = cell_screen(screen)->winsys; + struct sw_winsys *winsys = cell_screen(screen)->winsys; winsys->displaytarget_destroy(winsys, ct->dt); } @@ -531,7 +532,9 @@ cell_flush_frontbuffer(struct pipe_screen *_screen, /* Need to untwiddle from our internal representation here: */ { - unsigned *map = winsys->displaytarget_map(winsys, ct->dt); + unsigned *map = winsys->displaytarget_map(winsys, ct->dt, + (PIPE_BUFFER_USAGE_CPU_READ | + PIPE_BUFFER_USAGE_CPU_WRITE)); unsigned *src = (unsigned *)(ct->data + ct->level_offset[surface->level]); untwiddle_image_uint(surface->width, @@ -541,7 +544,7 @@ cell_flush_frontbuffer(struct pipe_screen *_screen, ct->dt_stride, src); - winsys->displaytarget_unmap(winsys, c->dt); + winsys->displaytarget_unmap(winsys, ct->dt); } winsys->displaytarget_display(winsys, ct->dt, context_private); diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h index b89db1a5a8..2be0579312 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.h +++ b/src/gallium/drivers/cell/ppu/cell_texture.h @@ -28,6 +28,7 @@ #ifndef CELL_TEXTURE_H #define CELL_TEXTURE_H +#include "cell/common.h" struct cell_context; struct pipe_texture; diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h index 719c3f3eee..0de98bbc1c 100644 --- a/src/gallium/include/state_tracker/sw_winsys.h +++ b/src/gallium/include/state_tracker/sw_winsys.h @@ -88,6 +88,9 @@ struct sw_winsys unsigned alignment, unsigned *stride ); + /** + * \param flags bitmask of PIPE_BUFFER_USAGE_x flags + */ void * (*displaytarget_map)( struct sw_winsys *ws, struct sw_displaytarget *dt, diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c index 2ad1aab439..d943953bd1 100644 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ b/src/gallium/winsys/xlib/xlib_cell.c @@ -33,11 +33,8 @@ */ - - #include "xlib.h" - #if defined(GALLIUM_CELL) #include "cell/ppu/cell_texture.h" @@ -46,9 +43,18 @@ #include "util/u_debug.h" - - - +/** + * Display/copy the image in the surface into the X window specified + * by the XMesaBuffer. + */ +static void +xm_cell_displaytarget_display(struct sw_winsys *ws, + struct sw_displaytarget *dt, + void *context_private) +{ + struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private; + xlib_sw_display(xlib_drawable, dt); +} static struct pipe_screen * @@ -64,7 +70,7 @@ xlib_create_cell_screen( Display *dpy ) /* Plug in a little cell-specific code: */ - ws->base.displaytarget_display = xm_cell_displaytarget_display; + winsys->displaytarget_display = xm_cell_displaytarget_display; screen = cell_create_screen(winsys); if (screen == NULL) @@ -80,13 +86,10 @@ fail: } - - struct xm_driver xlib_cell_driver = { .create_pipe_screen = xlib_create_cell_screen, }; - #endif /* GALLIUM_CELL */ -- cgit v1.2.3 From 22812421b5f394af741022f2f65ba19bc7b0aa73 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 16:24:47 +0100 Subject: r300g: fix gallium-vertexlementcso merge damage --- src/gallium/drivers/r300/r300_emit.c | 4 ++-- src/gallium/drivers/r300/r300_render.c | 25 ------------------------- src/gallium/drivers/r300/r300_state_derived.c | 1 - 3 files changed, 2 insertions(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 65377b3865..55e9217fd3 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -1004,7 +1004,7 @@ void r300_emit_buffer_validate(struct r300_context *r300, (struct r300_textures_state*)r300->textures_state.state; struct r300_texture* tex; struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->vertex_element; + struct pipe_vertex_element *velem = r300->velems->velem; struct pipe_buffer *pbuf; unsigned i; boolean invalid = FALSE; @@ -1062,7 +1062,7 @@ validate: } /* ...vertex buffers for HWTCL path... */ if (do_validate_vertex_buffers) { - for (i = 0; i < r300->vertex_element_count; i++) { + for (i = 0; i < r300->velems->count; i++) { pbuf = vbuf[velem[i].vertex_buffer_index].buffer; if (!r300->winsys->add_buffer(r300->winsys, pbuf, diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index d0e06ade40..2605628c02 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -319,31 +319,6 @@ static void r300_emit_draw_elements(struct r300_context *r300, END_CS; } -static boolean r300_setup_vertex_buffers(struct r300_context *r300) -{ - struct pipe_vertex_buffer *vbuf = r300->vertex_buffer; - struct pipe_vertex_element *velem = r300->velems->velem; - struct pipe_buffer *pbuf; - -validate: - for (int i = 0; i < r300->velems->count; i++) { - pbuf = vbuf[velem[i].vertex_buffer_index].buffer; - - if (!r300->winsys->add_buffer(r300->winsys, pbuf, - RADEON_GEM_DOMAIN_GTT, 0)) { - r300->context.flush(&r300->context, 0, NULL); - goto validate; - } - } - - if (!r300->winsys->validate(r300->winsys)) { - r300->context.flush(&r300->context, 0, NULL); - return r300->winsys->validate(r300->winsys); - } - - return TRUE; -} - static void r300_shorten_ubyte_elts(struct r300_context* r300, struct pipe_buffer** elts, unsigned count) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 4422581b51..81a373abad 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -128,7 +128,6 @@ static void r300_vertex_psc(struct r300_context* r300) " in psc\n", vs->info.num_inputs, r300->velems->count); - r300->vertex_element_count); for (i = 0; i < r300->velems->count; i++) { format = r300->velems->velem[i].src_format; -- cgit v1.2.3 From 4d02534628e5fd4cd1231c5d742928b34067f25c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 16:28:59 +0100 Subject: identity: fix copy & paste error --- src/gallium/drivers/identity/id_context.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 05a9dfab77..baf0ae4401 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -378,7 +378,7 @@ identity_delete_vs_state(struct pipe_context *_pipe, } -static void +static void * identity_create_vertex_elements_state(struct pipe_context *_pipe, unsigned num_elements, const struct pipe_vertex_element *vertex_elements) @@ -386,9 +386,9 @@ identity_create_vertex_elements_state(struct pipe_context *_pipe, struct identity_context *id_pipe = identity_context(_pipe); struct pipe_context *pipe = id_pipe->pipe; - pipe->create_vertex_elements_state(pipe, - num_elements, - vertex_elements); + return pipe->create_vertex_elements_state(pipe, + num_elements, + vertex_elements); } static void -- cgit v1.2.3 From 9c8cb12388be6818ac11a28d40034d01047584b2 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 8 Mar 2010 21:35:43 -0800 Subject: r300g: Cleanup old PSC code a bit. --- src/gallium/drivers/r300/r300_state_derived.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 81a373abad..cb2b9bd99f 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -114,13 +114,9 @@ static void r300_vertex_psc(struct r300_context* r300) uint16_t type, swizzle; enum pipe_format format; unsigned i; - int identity[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; - int* stream_tab; memset(vformat, 0, sizeof(struct r300_vertex_stream_state)); - stream_tab = identity; - /* Vertex shaders have no semantics on their inputs, * so PSC should just route stuff based on the vertex elements, * and not on attrib information. */ @@ -133,7 +129,7 @@ static void r300_vertex_psc(struct r300_context* r300) format = r300->velems->velem[i].src_format; type = r300_translate_vertex_data_type(format) | - (stream_tab[i] << R300_DST_VEC_LOC_SHIFT); + (i << R300_DST_VEC_LOC_SHIFT); swizzle = r300_translate_vertex_data_swizzle(format); if (i & 1) { -- cgit v1.2.3 From 141c7cb0d6078b3a2832c4be03ddcf25e35e596b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 8 Mar 2010 23:36:04 -0800 Subject: r300g: Precalculate and CSO-bind PSC state. --- src/gallium/drivers/r300/r300_context.c | 2 - src/gallium/drivers/r300/r300_context.h | 6 +- src/gallium/drivers/r300/r300_state.c | 197 ++++++++++++++++++++++++-- src/gallium/drivers/r300/r300_state_derived.c | 190 +------------------------ 4 files changed, 190 insertions(+), 205 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index e0a5532327..923e1e541f 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -60,7 +60,6 @@ static void r300_destroy_context(struct pipe_context* context) FREE(r300->rs_block_state.state); FREE(r300->scissor_state.state); FREE(r300->textures_state.state); - FREE(r300->vertex_stream_state.state); FREE(r300->vap_output_state.state); FREE(r300->viewport_state.state); FREE(r300->ztop_state.state); @@ -147,7 +146,6 @@ static void r300_setup_atoms(struct r300_context* r300) r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block); r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state); r300->textures_state.state = CALLOC_STRUCT(r300_textures_state); - r300->vertex_stream_state.state = CALLOC_STRUCT(r300_vertex_stream_state); r300->vap_output_state.state = CALLOC_STRUCT(r300_vap_output_state); r300->viewport_state.state = CALLOC_STRUCT(r300_viewport_state); r300->ztop_state.state = CALLOC_STRUCT(r300_ztop_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 80e69924f0..985e339112 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -288,9 +288,11 @@ struct r300_vertex_info { uint32_t vap_prog_stream_cntl_ext[8]; }; -struct r300_velems_state { +struct r300_vertex_element_state { unsigned count; struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS]; + + struct r300_vertex_stream_state vertex_stream; }; extern struct pipe_viewport_state r300_viewport_identity; @@ -365,7 +367,7 @@ struct r300_context { int vertex_buffer_count; int vertex_buffer_max_index; /* Vertex elements for Gallium. */ - struct r300_velems_state *velems; + struct r300_vertex_element_state *velems; /* Vertex info for Draw. */ struct vertex_info vertex_info; diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 7683a423f2..bd4c2766cb 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1046,8 +1046,6 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, if (r300->draw) { draw_flush(r300->draw); draw_set_vertex_buffers(r300->draw, count, buffers); - } else { - r300->vertex_stream_state.dirty = TRUE; } } @@ -1067,37 +1065,209 @@ static boolean r300_validate_aos(struct r300_context *r300) return TRUE; } +static void r300_draw_emit_attrib(struct r300_context* r300, + enum attrib_emit emit, + enum interp_mode interp, + int index) +{ + struct r300_vertex_shader* vs = r300->vs_state.state; + struct tgsi_shader_info* info = &vs->info; + int output; + + output = draw_find_shader_output(r300->draw, + info->output_semantic_name[index], + info->output_semantic_index[index]); + draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output); +} + +static void r300_draw_emit_all_attribs(struct r300_context* r300) +{ + struct r300_vertex_shader* vs = r300->vs_state.state; + struct r300_shader_semantics* vs_outputs = &vs->outputs; + int i, gen_count; + + /* Position. */ + if (vs_outputs->pos != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->pos); + } else { + assert(0); + } + + /* Point size. */ + if (vs_outputs->psize != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS, + vs_outputs->psize); + } + + /* Colors. */ + for (i = 0; i < ATTR_COLOR_COUNT; i++) { + if (vs_outputs->color[i] != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR, + vs_outputs->color[i]); + } + } + + /* XXX Back-face colors. */ + + /* Texture coordinates. */ + gen_count = 0; + for (i = 0; i < ATTR_GENERIC_COUNT; i++) { + if (vs_outputs->generic[i] != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->generic[i]); + gen_count++; + } + } + + /* Fog coordinates. */ + if (vs_outputs->fog != ATTR_UNUSED) { + r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, + vs_outputs->fog); + gen_count++; + } + + /* XXX magic */ + assert(gen_count <= 8); +} + +/* Update the PSC tables. */ +static void r300_vertex_psc(struct r300_vertex_element_state *velems) +{ + struct r300_vertex_stream_state *vstream = &velems->vertex_stream; + uint16_t type, swizzle; + enum pipe_format format; + unsigned i; + + assert(velems->count <= 16); + + /* Vertex shaders have no semantics on their inputs, + * so PSC should just route stuff based on the vertex elements, + * and not on attrib information. */ + for (i = 0; i < velems->count; i++) { + format = velems->velem[i].src_format; + + type = r300_translate_vertex_data_type(format) | + (i << R300_DST_VEC_LOC_SHIFT); + swizzle = r300_translate_vertex_data_swizzle(format); + + if (i & 1) { + vstream->vap_prog_stream_cntl[i >> 1] |= type << 16; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; + } else { + vstream->vap_prog_stream_cntl[i >> 1] |= type; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; + } + } + + /* Set the last vector in the PSC. */ + if (i) { + i -= 1; + } + vstream->vap_prog_stream_cntl[i >> 1] |= + (R300_LAST_VEC << (i & 1 ? 16 : 0)); + + vstream->count = (i >> 1) + 1; +} + +/* Update the PSC tables for SW TCL, using Draw. */ +static void r300_swtcl_vertex_psc(struct r300_context *r300, + struct r300_vertex_element_state *velems) +{ + struct r300_vertex_stream_state *vstream = &velems->vertex_stream; + struct r300_vertex_shader* vs = r300->vs_state.state; + struct vertex_info* vinfo = &r300->vertex_info; + uint16_t type, swizzle; + enum pipe_format format; + unsigned i, attrib_count; + int* vs_output_tab = vs->stream_loc_notcl; + + /* For each Draw attribute, route it to the fragment shader according + * to the vs_output_tab. */ + attrib_count = vinfo->num_attribs; + DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count); + for (i = 0; i < attrib_count; i++) { + DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d," + " vs_output_tab %d\n", vinfo->attrib[i].src_index, + vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, + vs_output_tab[i]); + } + + for (i = 0; i < attrib_count; i++) { + /* Make sure we have a proper destination for our attribute. */ + assert(vs_output_tab[i] != -1); + + format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + + /* Obtain the type of data in this attribute. */ + type = r300_translate_vertex_data_type(format) | + vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT; + + /* Obtain the swizzle for this attribute. Note that the default + * swizzle in the hardware is not XYZW! */ + swizzle = r300_translate_vertex_data_swizzle(format); + + /* Add the attribute to the PSC table. */ + if (i & 1) { + vstream->vap_prog_stream_cntl[i >> 1] |= type << 16; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; + } else { + vstream->vap_prog_stream_cntl[i >> 1] |= type; + vstream->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; + } + } + + /* Set the last vector in the PSC. */ + if (i) { + i -= 1; + } + vstream->vap_prog_stream_cntl[i >> 1] |= + (R300_LAST_VEC << (i & 1 ? 16 : 0)); + + vstream->count = (i >> 1) + 1; +} + static void* r300_create_vertex_elements_state(struct pipe_context* pipe, unsigned count, const struct pipe_vertex_element* attribs) { - struct r300_velems_state *velems; + struct r300_context *r300 = r300_context(pipe); + struct r300_screen* r300screen = r300_screen(pipe->screen); + struct r300_vertex_element_state *velems; - /*XXX should precalculate state here instead of later */ assert(count <= PIPE_MAX_ATTRIBS); - velems = CALLOC_STRUCT(r300_velems_state); - if (velems) { + velems = CALLOC_STRUCT(r300_vertex_element_state); + if (velems != NULL) { velems->count = count; memcpy(velems->velem, attribs, sizeof(struct pipe_vertex_element) * count); + + if (r300screen->caps->has_tcl) { + r300_vertex_psc(velems); + } else { + memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); + r300_draw_emit_all_attribs(r300); + draw_compute_vertex_size(&r300->vertex_info); + r300_swtcl_vertex_psc(r300, velems); + } } return velems; } static void r300_bind_vertex_elements_state(struct pipe_context *pipe, - void *velems) + void *state) { struct r300_context *r300 = r300_context(pipe); - struct r300_velems_state *r300_velems = (struct r300_velems_state *) velems; + struct r300_vertex_element_state *velems = state; if (velems == NULL) { return; } - r300->velems = r300_velems; + r300->velems = velems; if (r300->draw) { draw_flush(r300->draw); - draw_set_vertex_elements(r300->draw, r300_velems->count, r300_velems->velem); + draw_set_vertex_elements(r300->draw, velems->count, velems->velem); } if (!r300_validate_aos(r300)) { @@ -1105,11 +1275,14 @@ static void r300_bind_vertex_elements_state(struct pipe_context *pipe, assert(0); abort(); } + + UPDATE_STATE(&velems->vertex_stream, r300->vertex_stream_state); + r300->vertex_stream_state.size = (1 + velems->vertex_stream.count) * 2; } -static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *velems) +static void r300_delete_vertex_elements_state(struct pipe_context *pipe, void *state) { - FREE(velems); + FREE(state); } static void* r300_create_vs_state(struct pipe_context* pipe, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index cb2b9bd99f..6b9f61acd7 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -37,183 +37,6 @@ /* r300_state_derived: Various bits of state which are dependent upon * currently bound CSO data. */ -static void r300_draw_emit_attrib(struct r300_context* r300, - enum attrib_emit emit, - enum interp_mode interp, - int index) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct tgsi_shader_info* info = &vs->info; - int output; - - output = draw_find_shader_output(r300->draw, - info->output_semantic_name[index], - info->output_semantic_index[index]); - draw_emit_vertex_attr(&r300->vertex_info, emit, interp, output); -} - -static void r300_draw_emit_all_attribs(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_shader_semantics* vs_outputs = &vs->outputs; - int i, gen_count; - - /* Position. */ - if (vs_outputs->pos != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->pos); - } else { - assert(0); - } - - /* Point size. */ - if (vs_outputs->psize != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_1F_PSIZE, INTERP_POS, - vs_outputs->psize); - } - - /* Colors. */ - for (i = 0; i < ATTR_COLOR_COUNT; i++) { - if (vs_outputs->color[i] != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_LINEAR, - vs_outputs->color[i]); - } - } - - /* XXX Back-face colors. */ - - /* Texture coordinates. */ - gen_count = 0; - for (i = 0; i < ATTR_GENERIC_COUNT; i++) { - if (vs_outputs->generic[i] != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->generic[i]); - gen_count++; - } - } - - /* Fog coordinates. */ - if (vs_outputs->fog != ATTR_UNUSED) { - r300_draw_emit_attrib(r300, EMIT_4F, INTERP_PERSPECTIVE, - vs_outputs->fog); - gen_count++; - } - - /* XXX magic */ - assert(gen_count <= 8); -} - -/* Update the PSC tables. */ -/* XXX move this function into r300_state.c after TCL-bypass gets removed - * XXX because this one is dependent only on vertex elements. */ -static void r300_vertex_psc(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_vertex_stream_state *vformat = - (struct r300_vertex_stream_state*)r300->vertex_stream_state.state; - uint16_t type, swizzle; - enum pipe_format format; - unsigned i; - - memset(vformat, 0, sizeof(struct r300_vertex_stream_state)); - - /* Vertex shaders have no semantics on their inputs, - * so PSC should just route stuff based on the vertex elements, - * and not on attrib information. */ - DBG(r300, DBG_DRAW, "r300: vs expects %d attribs, routing %d elements" - " in psc\n", - vs->info.num_inputs, - r300->velems->count); - - for (i = 0; i < r300->velems->count; i++) { - format = r300->velems->velem[i].src_format; - - type = r300_translate_vertex_data_type(format) | - (i << R300_DST_VEC_LOC_SHIFT); - swizzle = r300_translate_vertex_data_swizzle(format); - - if (i & 1) { - vformat->vap_prog_stream_cntl[i >> 1] |= type << 16; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; - } else { - vformat->vap_prog_stream_cntl[i >> 1] |= type; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; - } - } - - assert(i <= 15); - - /* Set the last vector in the PSC. */ - if (i) { - i -= 1; - } - vformat->vap_prog_stream_cntl[i >> 1] |= - (R300_LAST_VEC << (i & 1 ? 16 : 0)); - - vformat->count = (i >> 1) + 1; - r300->vertex_stream_state.size = (1 + vformat->count) * 2; -} - -/* Update the PSC tables for SW TCL, using Draw. */ -static void r300_swtcl_vertex_psc(struct r300_context* r300) -{ - struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_vertex_stream_state *vformat = - (struct r300_vertex_stream_state*)r300->vertex_stream_state.state; - struct vertex_info* vinfo = &r300->vertex_info; - uint16_t type, swizzle; - enum pipe_format format; - unsigned i, attrib_count; - int* vs_output_tab = vs->stream_loc_notcl; - - memset(vformat, 0, sizeof(struct r300_vertex_stream_state)); - - /* For each Draw attribute, route it to the fragment shader according - * to the vs_output_tab. */ - attrib_count = vinfo->num_attribs; - DBG(r300, DBG_DRAW, "r300: attrib count: %d\n", attrib_count); - for (i = 0; i < attrib_count; i++) { - DBG(r300, DBG_DRAW, "r300: attrib: offset %d, interp %d, size %d," - " vs_output_tab %d\n", vinfo->attrib[i].src_index, - vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit, - vs_output_tab[i]); - } - - for (i = 0; i < attrib_count; i++) { - /* Make sure we have a proper destination for our attribute. */ - assert(vs_output_tab[i] != -1); - - format = draw_translate_vinfo_format(vinfo->attrib[i].emit); - - /* Obtain the type of data in this attribute. */ - type = r300_translate_vertex_data_type(format) | - vs_output_tab[i] << R300_DST_VEC_LOC_SHIFT; - - /* Obtain the swizzle for this attribute. Note that the default - * swizzle in the hardware is not XYZW! */ - swizzle = r300_translate_vertex_data_swizzle(format); - - /* Add the attribute to the PSC table. */ - if (i & 1) { - vformat->vap_prog_stream_cntl[i >> 1] |= type << 16; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; - } else { - vformat->vap_prog_stream_cntl[i >> 1] |= type; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle; - } - } - - /* Set the last vector in the PSC. */ - if (i) { - i -= 1; - } - vformat->vap_prog_stream_cntl[i >> 1] |= - (R300_LAST_VEC << (i & 1 ? 16 : 0)); - - vformat->count = (i >> 1) + 1; - r300->vertex_stream_state.size = (1 + vformat->count) * 2; -} - static void r300_rs_col(struct r300_rs_block* rs, int id, int ptr, boolean swizzle_0001) { @@ -428,18 +251,8 @@ static void r300_update_rs_block(struct r300_context* r300, static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_vertex_shader* vs = r300->vs_state.state; - struct r300_screen* r300screen = r300_screen(r300->context.screen); r300_update_rs_block(r300, &vs->outputs, &r300->fs->inputs); - - if (r300screen->caps->has_tcl) { - r300_vertex_psc(r300); - } else { - memset(&r300->vertex_info, 0, sizeof(struct vertex_info)); - r300_draw_emit_all_attribs(r300); - draw_compute_vertex_size(&r300->vertex_info); - r300_swtcl_vertex_psc(r300); - } } static boolean r300_dsa_writes_depth_stencil(struct r300_dsa_state* dsa) @@ -572,8 +385,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { - if (r300->rs_block_state.dirty || - r300->vertex_stream_state.dirty) { /* XXX put updating PSC out of this file */ + if (r300->rs_block_state.dirty) { r300_update_derived_shader_state(r300); } -- cgit v1.2.3 From a73fd447d4bb3d509fedf52b18a50fccab618298 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 9 Mar 2010 07:30:27 -0800 Subject: cso: Fix typo in assert. --- src/gallium/auxiliary/cso_cache/cso_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 292e489312..f8cb01467c 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1248,7 +1248,7 @@ enum pipe_error cso_set_vertex_elements(struct cso_context *ctx, void cso_save_vertex_elements(struct cso_context *ctx) { - assert(!ctx->velements); + assert(!ctx->velements_saved); ctx->velements_saved = ctx->velements; } -- cgit v1.2.3 From 3c57c01a44c294e69d902207b2ec94d28a397a51 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 15:25:42 +0000 Subject: ws/xlib: remove self-knowledge about users of xlib winsys Several software rasterizers can make use of this winsys, but there isn't any reason why the winsys itself should know about them. This change moves that information into the libgl-xlib target. Need to fix up other targets making use of this winsys. --- src/gallium/drivers/cell/ppu/cell_public.h | 10 +++ src/gallium/drivers/cell/ppu/cell_screen.c | 1 + src/gallium/drivers/cell/ppu/cell_screen.h | 3 - src/gallium/drivers/llvmpipe/lp_public.h | 10 +++ src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/llvmpipe/lp_screen.h | 2 - src/gallium/drivers/softpipe/sp_public.h | 10 +++ src/gallium/drivers/softpipe/sp_screen.c | 1 + src/gallium/drivers/softpipe/sp_screen.h | 8 -- src/gallium/include/state_tracker/xlib_sw_winsys.h | 10 ++- src/gallium/targets/libgl-xlib/xlib.c | 65 ++++++++++++--- src/gallium/winsys/xlib/Makefile | 6 +- src/gallium/winsys/xlib/SConscript | 3 - src/gallium/winsys/xlib/xlib.c | 49 ----------- src/gallium/winsys/xlib/xlib.h | 18 ---- src/gallium/winsys/xlib/xlib_cell.c | 95 ---------------------- src/gallium/winsys/xlib/xlib_llvmpipe.c | 79 ------------------ src/gallium/winsys/xlib/xlib_softpipe.c | 68 ---------------- src/gallium/winsys/xlib/xlib_sw_winsys.c | 4 +- 19 files changed, 96 insertions(+), 347 deletions(-) create mode 100644 src/gallium/drivers/cell/ppu/cell_public.h create mode 100644 src/gallium/drivers/llvmpipe/lp_public.h create mode 100644 src/gallium/drivers/softpipe/sp_public.h delete mode 100644 src/gallium/winsys/xlib/xlib.c delete mode 100644 src/gallium/winsys/xlib/xlib.h delete mode 100644 src/gallium/winsys/xlib/xlib_cell.c delete mode 100644 src/gallium/winsys/xlib/xlib_llvmpipe.c delete mode 100644 src/gallium/winsys/xlib/xlib_softpipe.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_public.h b/src/gallium/drivers/cell/ppu/cell_public.h new file mode 100644 index 0000000000..7e2e093565 --- /dev/null +++ b/src/gallium/drivers/cell/ppu/cell_public.h @@ -0,0 +1,10 @@ +#ifndef CELL_PUBLIC_H +#define CELL_PUBLIC_H + +struct pipe_screen; +struct sw_winsys; + +struct pipe_screen * +cell_create_screen(struct sw_winsys *winsys); + +#endif diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c index fc04767a1e..31fd963d19 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.c +++ b/src/gallium/drivers/cell/ppu/cell_screen.c @@ -36,6 +36,7 @@ #include "cell_screen.h" #include "cell_texture.h" #include "cell_buffer.h" +#include "cell_public.h" #include "state_tracker/sw_winsys.h" diff --git a/src/gallium/drivers/cell/ppu/cell_screen.h b/src/gallium/drivers/cell/ppu/cell_screen.h index 6a22433b56..baff9d3b7d 100644 --- a/src/gallium/drivers/cell/ppu/cell_screen.h +++ b/src/gallium/drivers/cell/ppu/cell_screen.h @@ -51,8 +51,5 @@ cell_screen( struct pipe_screen *pipe ) return (struct cell_screen *)pipe; } -extern struct pipe_screen * -cell_create_screen(struct sw_winsys *winsys); - #endif /* CELL_SCREEN_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_public.h b/src/gallium/drivers/llvmpipe/lp_public.h new file mode 100644 index 0000000000..ec6b660b48 --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_public.h @@ -0,0 +1,10 @@ +#ifndef LP_PUBLIC_H +#define LP_PUBLIC_H + +struct pipe_screen; +struct sw_winsys; + +struct pipe_screen * +llvmpipe_create_screen(struct sw_winsys *winsys); + +#endif diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 9bb3043320..5093f58bb1 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -38,6 +38,7 @@ #include "lp_screen.h" #include "lp_context.h" #include "lp_debug.h" +#include "lp_public.h" #include "state_tracker/sw_winsys.h" diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index 0c86283605..f4e62cbf08 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -76,7 +76,5 @@ llvmpipe_screen( struct pipe_screen *pipe ) } -struct pipe_screen * -llvmpipe_create_screen(struct sw_winsys *winsys); #endif /* LP_SCREEN_H */ diff --git a/src/gallium/drivers/softpipe/sp_public.h b/src/gallium/drivers/softpipe/sp_public.h new file mode 100644 index 0000000000..62d0903d87 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_public.h @@ -0,0 +1,10 @@ +#ifndef SP_PUBLIC_H +#define SP_PUBLIC_H + +struct pipe_screen; +struct sw_winsys; + +struct pipe_screen * +softpipe_create_screen(struct sw_winsys *winsys); + +#endif diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index 44680ea70c..e0a2ef604e 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -36,6 +36,7 @@ #include "sp_screen.h" #include "sp_context.h" #include "sp_buffer.h" +#include "sp_public.h" static const char * diff --git a/src/gallium/drivers/softpipe/sp_screen.h b/src/gallium/drivers/softpipe/sp_screen.h index 4d7d8bada2..f741454c9e 100644 --- a/src/gallium/drivers/softpipe/sp_screen.h +++ b/src/gallium/drivers/softpipe/sp_screen.h @@ -59,12 +59,4 @@ softpipe_screen( struct pipe_screen *pipe ) -/** - * Create a softpipe screen that uses the - * given winsys for allocating buffers. - */ -struct pipe_screen *softpipe_create_screen( struct sw_winsys * ); - - - #endif /* SP_SCREEN_H */ diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index 3cb679426d..13dc837712 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -18,13 +18,17 @@ struct xlib_drawable { Drawable drawable; }; - +/* This is the interface required by the glx/xlib state tracker. Why + * is it being defined in this file? + */ struct xm_driver { struct pipe_screen *(*create_pipe_screen)( Display *display ); }; -/* Called by the libgl-xlib target code to build the rendering stack. +/* This is the public interface to the ws/xlib module. Why isn't it + * being defined in that directory? */ -struct xm_driver *xlib_sw_winsys_init( void ); +struct sw_winsys *xlib_create_sw_winsys( Display *display ); + #endif diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 7cae0884e8..6651bd538e 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -34,28 +34,71 @@ #include "state_tracker/xlib_sw_winsys.h" #include "xm_winsys.h" #include "util/u_debug.h" - +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "cell/ppu/cell_public.h" /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; -static void _init( void ) __attribute__((constructor)); + +static struct pipe_screen * +create_screen( struct sw_winsys *winsys ) +{ +#if defined(GALLIUM_CELL) + if (!getenv("GALLIUM_NOCELL")) + return cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + return llvmpipe_create_screen( winsys ); +#endif + + return softpipe_create_screen( winsys ); +} + + + +static struct pipe_screen * +xlib_create_screen( Display *display ) +{ + struct sw_winsys *winsys; + struct pipe_screen *screen; + + winsys = xlib_create_sw_winsys( display ); + if (winsys == NULL) + return NULL; + + screen = create_screen(winsys); + if (screen == NULL) + goto fail; + + return screen; + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + + +struct xm_driver xlib_driver = +{ + .create_pipe_screen = xlib_create_screen, +}; + + + /* Build the rendering stack. */ +static void _init( void ) __attribute__((constructor)); static void _init( void ) { - struct xm_driver *driver; - - /* Initialize the xlib software winsys. Later on, once Display and - * other parameters are known, this will be used to create the - * gallium driver (such as softpipe), etc. - */ - driver = xlib_sw_winsys_init(); - /* Initialize the xlib libgl code, pass in the winsys: */ - xmesa_set_driver( driver ); + xmesa_set_driver( &xlib_driver ); } diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index bb631b16ce..68542b488d 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -9,11 +9,7 @@ LIBRARY_INCLUDES = \ -I$(TOP)/src/gallium/auxiliary C_SOURCES = \ - xlib.c \ - xlib_cell.c \ - xlib_sw_winsys.c \ - xlib_llvmpipe.c \ - xlib_softpipe.c + xlib_sw_winsys.c include ../../Makefile.template diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index 1a1879f128..d4009df991 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -18,9 +18,6 @@ if env['platform'] == 'linux' \ ws_xlib = env.ConvenienceLibrary( target = 'ws_xlib', source = [ - 'xlib_cell.c', - 'xlib_llvmpipe.c', - 'xlib_softpipe.c', 'xlib_sw_winsys.c', ] ) diff --git a/src/gallium/winsys/xlib/xlib.c b/src/gallium/winsys/xlib/xlib.c deleted file mode 100644 index 6ca9e362e7..0000000000 --- a/src/gallium/winsys/xlib/xlib.c +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - -#include "xlib.h" -#include "util/u_debug.h" - -struct xm_driver *xlib_sw_winsys_init( void ) -{ -#if defined(GALLIUM_CELL) - if (!getenv("GALLIUM_NOCELL")) - return &xlib_cell_driver; -#endif - -#if defined(GALLIUM_LLVMPIPE) - return &xlib_llvmpipe_driver; -#endif - - return &xlib_softpipe_driver; -} diff --git a/src/gallium/winsys/xlib/xlib.h b/src/gallium/winsys/xlib/xlib.h deleted file mode 100644 index 3c20048616..0000000000 --- a/src/gallium/winsys/xlib/xlib.h +++ /dev/null @@ -1,18 +0,0 @@ - -#ifndef XLIB_H -#define XLIB_H - -#include "pipe/p_compiler.h" -#include "state_tracker/xlib_sw_winsys.h" - -extern struct xm_driver xlib_softpipe_driver; -extern struct xm_driver xlib_llvmpipe_driver; -extern struct xm_driver xlib_cell_driver; - -struct sw_winsys *xlib_create_sw_winsys( Display *display ); - -void xlib_sw_display(struct xlib_drawable *xm_buffer, - struct sw_displaytarget *dt); - - -#endif diff --git a/src/gallium/winsys/xlib/xlib_cell.c b/src/gallium/winsys/xlib/xlib_cell.c deleted file mode 100644 index d943953bd1..0000000000 --- a/src/gallium/winsys/xlib/xlib_cell.c +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - -#include "xlib.h" - -#if defined(GALLIUM_CELL) - -#include "cell/ppu/cell_texture.h" -#include "cell/ppu/cell_screen.h" -#include "state_tracker/sw_winsys.h" -#include "util/u_debug.h" - - -/** - * Display/copy the image in the surface into the X window specified - * by the XMesaBuffer. - */ -static void -xm_cell_displaytarget_display(struct sw_winsys *ws, - struct sw_displaytarget *dt, - void *context_private) -{ - struct xlib_drawable *xlib_drawable = (struct xlib_drawable *)context_private; - xlib_sw_display(xlib_drawable, dt); -} - - -static struct pipe_screen * -xlib_create_cell_screen( Display *dpy ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_sw_winsys( dpy ); - if (winsys == NULL) - return NULL; - - /* Plug in a little cell-specific code: - */ - - winsys->displaytarget_display = xm_cell_displaytarget_display; - - screen = cell_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - -struct xm_driver xlib_cell_driver = -{ - .create_pipe_screen = xlib_create_cell_screen, -}; - - -#endif /* GALLIUM_CELL */ diff --git a/src/gallium/winsys/xlib/xlib_llvmpipe.c b/src/gallium/winsys/xlib/xlib_llvmpipe.c deleted file mode 100644 index 8b66b7459d..0000000000 --- a/src/gallium/winsys/xlib/xlib_llvmpipe.c +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - * Brian Paul - */ - - - - -#include "xlib.h" - - -#if defined(GALLIUM_LLVMPIPE) - -#include "llvmpipe/lp_texture.h" -#include "llvmpipe/lp_screen.h" -#include "state_tracker/xlib_sw_winsys.h" -#include "util/u_debug.h" - -static struct pipe_screen * -xlib_create_llvmpipe_screen( Display *display ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - - screen = llvmpipe_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - -struct xm_driver xlib_llvmpipe_driver = -{ - .create_pipe_screen = xlib_create_llvmpipe_screen, -}; - - - -#endif /* GALLIUM_LLVMPIPE */ diff --git a/src/gallium/winsys/xlib/xlib_softpipe.c b/src/gallium/winsys/xlib/xlib_softpipe.c deleted file mode 100644 index 08b7f08837..0000000000 --- a/src/gallium/winsys/xlib/xlib_softpipe.c +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - - -#include "xlib.h" -#include "softpipe/sp_texture.h" -#include "softpipe/sp_screen.h" -#include "state_tracker/xlib_sw_winsys.h" -#include "util/u_debug.h" - -static struct pipe_screen * -xlib_create_softpipe_screen( Display *display ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - - screen = softpipe_create_screen(winsys); - if (screen == NULL) - goto fail; - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - - - -struct xm_driver xlib_softpipe_driver = -{ - .create_pipe_screen = xlib_create_softpipe_screen, -}; - - - diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index d03e39a249..0ee589943e 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -47,8 +47,6 @@ #include "state_tracker/xlib_sw_winsys.h" -#include "xlib.h" - #include #include #include @@ -274,7 +272,7 @@ xm_displaytarget_destroy(struct sw_winsys *ws, * Display/copy the image in the surface into the X window specified * by the XMesaBuffer. */ -void +static void xlib_sw_display(struct xlib_drawable *xlib_drawable, struct sw_displaytarget *dt) { -- cgit v1.2.3 From 999932bf1feed4cbf834b2c81510aab09dda56dc Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 15:58:45 +0000 Subject: targets/libgl-xlib: add code to inject trace and identity layers Finally we can inject layers for debug, trace and "other" with relative ease between state-tracker and driver. --- src/gallium/drivers/trace/tr_drm.c | 1 + src/gallium/drivers/trace/tr_public.h | 37 ++++++++++++++++++++++++++++ src/gallium/drivers/trace/tr_screen.h | 3 --- src/gallium/state_trackers/glx/xlib/xm_api.c | 8 +----- src/gallium/targets/libgl-xlib/Makefile | 2 ++ src/gallium/targets/libgl-xlib/xlib.c | 16 +++++++++++- 6 files changed, 56 insertions(+), 11 deletions(-) create mode 100644 src/gallium/drivers/trace/tr_public.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index c16989fa52..906b3262e4 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -33,6 +33,7 @@ #include "tr_context.h" #include "tr_buffer.h" #include "tr_texture.h" +#include "tr_public.h" struct trace_drm_api { diff --git a/src/gallium/drivers/trace/tr_public.h b/src/gallium/drivers/trace/tr_public.h new file mode 100644 index 0000000000..da31c24e64 --- /dev/null +++ b/src/gallium/drivers/trace/tr_public.h @@ -0,0 +1,37 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef TR_PUBLIC_H +#define TR_PUBLIC_H + +struct pipe_screen; +struct pipe_context; + +struct pipe_screen * +trace_screen_create(struct pipe_screen *screen); + +#endif /* TR_PUBLIC_H */ diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index fe5a0fa190..597e2fc265 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -99,9 +99,6 @@ trace_enabled(void); struct trace_screen * trace_screen(struct pipe_screen *screen); -struct pipe_screen * -trace_screen_create(struct pipe_screen *screen); - void trace_screen_user_buffer_update(struct pipe_screen *screen, struct pipe_buffer *buffer); diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index cf9a399209..b8647d71c6 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -63,10 +63,6 @@ #include "pipe/p_screen.h" #include "pipe/p_context.h" -#include "trace/tr_screen.h" -#include "trace/tr_context.h" -#include "trace/tr_texture.h" - #include "xm_winsys.h" #include @@ -87,7 +83,6 @@ void xmesa_set_driver( const struct xm_driver *templ ) */ pipe_mutex _xmesa_lock; -static struct pipe_screen *_screen = NULL; static struct pipe_screen *screen = NULL; @@ -709,8 +704,7 @@ xmesa_init( Display *display ) static GLboolean firstTime = GL_TRUE; if (firstTime) { pipe_mutex_init(_xmesa_lock); - _screen = driver.create_pipe_screen( display ); - screen = trace_screen_create( _screen ); + screen = driver.create_pipe_screen( display ); firstTime = GL_FALSE; } } diff --git a/src/gallium/targets/libgl-xlib/Makefile b/src/gallium/targets/libgl-xlib/Makefile index 8ffe4dbf24..5a4e035c2e 100644 --- a/src/gallium/targets/libgl-xlib/Makefile +++ b/src/gallium/targets/libgl-xlib/Makefile @@ -39,6 +39,8 @@ LIBS = \ $(GALLIUM_DRIVERS) \ $(TOP)/src/gallium/state_trackers/glx/xlib/libxlib.a \ $(TOP)/src/gallium/winsys/xlib/libws_xlib.a \ + $(TOP)/src/gallium/drivers/trace/libtrace.a \ + $(TOP)/src/gallium/drivers/identity/libidentity.a \ $(TOP)/src/mesa/libglapi.a \ $(TOP)/src/mesa/libmesagallium.a \ $(GALLIUM_AUXILIARIES) \ diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 6651bd538e..7881bc2cb1 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -36,8 +36,11 @@ #include "util/u_debug.h" #include "softpipe/sp_public.h" #include "llvmpipe/lp_public.h" +#include "identity/id_public.h" +#include "trace/tr_public.h" #include "cell/ppu/cell_public.h" + /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; @@ -46,7 +49,7 @@ static struct pipe_screen * create_screen( struct sw_winsys *winsys ) { #if defined(GALLIUM_CELL) - if (!getenv("GALLIUM_NOCELL")) + if (!debug_get_bool_option("GALLIUM_NOCELL", FALSE)) return cell_create_screen( winsys ); #endif @@ -73,6 +76,17 @@ xlib_create_screen( Display *display ) if (screen == NULL) goto fail; + /* Finally we have somewhere to inject layers into the stack in a + * clean fashion: + */ + if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { + screen = identity_screen_create(screen); + } + + if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { + screen = trace_screen_create( screen ); + } + return screen; fail: -- cgit v1.2.3 From 09a7c25e7661887be31f3cd340010b99b407ef16 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 7 Mar 2010 01:24:57 +0000 Subject: util: Use bitshift arithmetic for pack too. --- src/gallium/auxiliary/util/u_format_pack.py | 77 ++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 19 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py index b49039db39..409d024c63 100644 --- a/src/gallium/auxiliary/util/u_format_pack.py +++ b/src/gallium/auxiliary/util/u_format_pack.py @@ -418,31 +418,70 @@ def generate_format_pack(format, src_channel, src_native_type, src_suffix): dst_native_type = native_type(format) + assert format.layout == PLAIN + + inv_swizzle = format.inv_swizzles() + print 'static INLINE void' print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type) print '{' - print ' union util_format_%s pixel;' % format.short_name() - - assert format.layout == PLAIN + + if format.is_bitmask(): + depth = format.block_size() + print ' uint%u_t value = 0;' % depth - inv_swizzle = format.inv_swizzles() + shift = 0 + for i in range(4): + dst_channel = format.channels[i] + if inv_swizzle[i] is not None: + value = 'rgba'[inv_swizzle[i]] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = '0' + if dst_channel.type in (UNSIGNED, SIGNED): + if shift + dst_channel.size < depth: + value = '(%s) & 0x%x' % (value, (1 << dst_channel.size) - 1) + if shift: + value = '(%s) << %u' % (value, shift) + if dst_channel.type == SIGNED: + # Cast to unsigned + value = '(uint%u_t)(%s) ' % (depth, value) + else: + value = None + if value is not None: + print ' value |= %s;' % (value) + + shift += dst_channel.size - for i in range(4): - dst_channel = format.channels[i] - width = dst_channel.size - if inv_swizzle[i] is None: - continue - value = 'rgba'[inv_swizzle[i]] - value = conversion_expr(src_channel, dst_channel, dst_native_type, value) - if format.colorspace == ZS: - if i == 3: - value = get_one(dst_channel) - elif i >= 1: - value = '0' - print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + print '#ifdef PIPE_ARCH_BIG_ENDIAN' + print ' value = util_bswap%u(value);' % depth + print '#endif' + + print ' *(uint%u_t *)dst = value;' % depth - bswap_format(format) - print ' memcpy(dst, &pixel, sizeof pixel);' + else: + print ' union util_format_%s pixel;' % format.short_name() + + for i in range(4): + dst_channel = format.channels[i] + width = dst_channel.size + if inv_swizzle[i] is None: + continue + value = 'rgba'[inv_swizzle[i]] + value = conversion_expr(src_channel, dst_channel, dst_native_type, value) + if format.colorspace == ZS: + if i == 3: + value = get_one(dst_channel) + elif i >= 1: + value = '0' + print ' pixel.chan.%s = %s;' % (dst_channel.name, value) + + bswap_format(format) + print ' memcpy(dst, &pixel, sizeof pixel);' + print '}' print -- cgit v1.2.3 From e0f10a6fca34619f61c3533b68d89dcb1ff2627c Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 17:27:45 +0100 Subject: util: simplify util_format_get_nr_components helper since the number of components is now stored in the pipe format description, we obviously no longer need to figure this out ourselves. --- src/gallium/auxiliary/util/u_format.h | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h index 20fdaca007..c08fdcafcc 100644 --- a/src/gallium/auxiliary/util/u_format.h +++ b/src/gallium/auxiliary/util/u_format.h @@ -423,14 +423,7 @@ static INLINE unsigned util_format_get_nr_components(enum pipe_format format) { const struct util_format_description *desc = util_format_description(format); - unsigned chan; - unsigned nr_comp = 0; - for (chan = 0; chan < 4; chan++) { - if (desc->channel[chan].size != 0) { - nr_comp++; - } - } - return nr_comp; + return desc->nr_channels; } /* -- cgit v1.2.3 From 2ccae040a458ad0f95ee46916e2ea467d5cf9d02 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Mar 2010 09:37:50 -0700 Subject: gallivm: checkpoint: nearest mipmap filtering The LOD is computed from texcoord partial derivatives and used to select a mipmap level. Still some bugs in texel fetching. Lots of rough edges and unfinished parts but the basics are in place. Lots of changes to the lp_bld_arit.c code to support non-vector/scalar datatypes. --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 143 +++++- src/gallium/auxiliary/gallivm/lp_bld_const.c | 8 +- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 100 ++-- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 592 +++++++++++++--------- src/gallium/auxiliary/gallivm/lp_bld_type.h | 50 +- 5 files changed, 601 insertions(+), 292 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 32f9e5201c..e2c6788397 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -644,13 +644,26 @@ lp_build_abs(struct lp_build_context *bld, if(type.floating) { /* Mask out the sign bit */ - LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - unsigned long long absMask = ~(1ULL << (type.width - 1)); - LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask)); - a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); - a = LLVMBuildAnd(bld->builder, a, mask, ""); - a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); - return a; + if (type.length == 1) { + LLVMTypeRef int_type = LLVMIntType(type.width); + LLVMTypeRef float_type = LLVMFloatType(); + unsigned long long absMask = ~(1ULL << (type.width - 1)); + LLVMValueRef mask = LLVMConstInt(int_type, absMask, 0); + a = LLVMBuildBitCast(bld->builder, a, int_type, ""); + a = LLVMBuildAnd(bld->builder, a, mask, ""); + a = LLVMBuildBitCast(bld->builder, a, float_type, ""); + return a; + } + else { + /* vector of floats */ + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); + unsigned long long absMask = ~(1ULL << (type.width - 1)); + LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask)); + a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); + a = LLVMBuildAnd(bld->builder, a, mask, ""); + a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); + return a; + } } if(type.width*type.length == 128 && util_cpu_caps.has_ssse3) { @@ -753,7 +766,7 @@ lp_build_set_sign(struct lp_build_context *bld, /** - * Convert vector of int to vector of float. + * Convert vector of (or scalar) int to vector of (or scalar) float. */ LLVMValueRef lp_build_int_to_float(struct lp_build_context *bld, @@ -764,7 +777,11 @@ lp_build_int_to_float(struct lp_build_context *bld, assert(type.floating); /*assert(lp_check_value(type, a));*/ - { + if (type.length == 1) { + LLVMTypeRef float_type = LLVMFloatType(); + return LLVMBuildSIToFP(bld->builder, a, float_type, ""); + } + else { LLVMTypeRef vec_type = lp_build_vec_type(type); /*LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);*/ LLVMValueRef res; @@ -921,12 +938,18 @@ lp_build_itrunc(struct lp_build_context *bld, LLVMValueRef a) { const struct lp_type type = bld->type; - LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); assert(type.floating); - assert(lp_check_value(type, a)); - return LLVMBuildFPToSI(bld->builder, a, int_vec_type, ""); + if (type.length == 1) { + LLVMTypeRef int_type = LLVMIntType(type.width); + return LLVMBuildFPTrunc(bld->builder, a, int_type, ""); + } + else { + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); + assert(lp_check_value(type, a)); + return LLVMBuildFPToSI(bld->builder, a, int_vec_type, ""); + } } @@ -939,6 +962,15 @@ lp_build_iround(struct lp_build_context *bld, LLVMValueRef res; assert(type.floating); + + if (type.length == 1) { + /* scalar float to int */ + LLVMTypeRef int_type = LLVMIntType(type.width); + /* XXX we want rounding here! */ + res = LLVMBuildFPToSI(bld->builder, a, int_type, ""); + return res; + } + assert(lp_check_value(type, a)); if(util_cpu_caps.has_sse4_1) { @@ -1207,6 +1239,7 @@ lp_build_polynomial(struct lp_build_context *bld, unsigned num_coeffs) { const struct lp_type type = bld->type; + LLVMTypeRef float_type = LLVMFloatType(); LLVMValueRef res = NULL; unsigned i; @@ -1216,7 +1249,13 @@ lp_build_polynomial(struct lp_build_context *bld, __FUNCTION__); for (i = num_coeffs; i--; ) { - LLVMValueRef coeff = lp_build_const_scalar(type, coeffs[i]); + LLVMValueRef coeff; + + if (type.length == 1) + coeff = LLVMConstReal(float_type, coeffs[i]); + else + coeff = lp_build_const_scalar(type, coeffs[i]); + if(res) res = lp_build_add(bld, coeff, lp_build_mul(bld, x, res)); else @@ -1410,11 +1449,87 @@ lp_build_log2_approx(struct lp_build_context *bld, } +/** scalar version of above function */ +static void +lp_build_float_log2_approx(struct lp_build_context *bld, + LLVMValueRef x, + LLVMValueRef *p_exp, + LLVMValueRef *p_floor_log2, + LLVMValueRef *p_log2) +{ + const struct lp_type type = bld->type; + LLVMTypeRef float_type = LLVMFloatType(); + LLVMTypeRef int_type = LLVMIntType(type.width); + + LLVMValueRef expmask = LLVMConstInt(int_type, 0x7f800000, 0); + LLVMValueRef mantmask = LLVMConstInt(int_type, 0x007fffff, 0); + LLVMValueRef one = LLVMConstBitCast(bld->one, int_type); + + LLVMValueRef i = NULL; + LLVMValueRef exp = NULL; + LLVMValueRef mant = NULL; + LLVMValueRef logexp = NULL; + LLVMValueRef logmant = NULL; + LLVMValueRef res = NULL; + + if(p_exp || p_floor_log2 || p_log2) { + /* TODO: optimize the constant case */ + if(LLVMIsConstant(x)) + debug_printf("%s: inefficient/imprecise constant arithmetic\n", + __FUNCTION__); + + assert(type.floating && type.width == 32); + + i = LLVMBuildBitCast(bld->builder, x, int_type, ""); + + /* exp = (float) exponent(x) */ + exp = LLVMBuildAnd(bld->builder, i, expmask, ""); + } + + if(p_floor_log2 || p_log2) { + LLVMValueRef c23 = LLVMConstInt(int_type, 23, 0); + LLVMValueRef c127 = LLVMConstInt(int_type, 127, 0); + logexp = LLVMBuildLShr(bld->builder, exp, c23, ""); + logexp = LLVMBuildSub(bld->builder, logexp, c127, ""); + logexp = LLVMBuildSIToFP(bld->builder, logexp, float_type, ""); + } + + if(p_log2) { + /* mant = (float) mantissa(x) */ + mant = LLVMBuildAnd(bld->builder, i, mantmask, ""); + mant = LLVMBuildOr(bld->builder, mant, one, ""); + mant = LLVMBuildBitCast(bld->builder, mant, float_type, ""); + + logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial, + Elements(lp_build_log2_polynomial)); + + /* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/ + logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildSub(bld->builder, mant, bld->one, ""), ""); + + res = LLVMBuildAdd(bld->builder, logmant, logexp, ""); + } + + if(p_exp) + *p_exp = exp; + + if(p_floor_log2) + *p_floor_log2 = logexp; + + if(p_log2) + *p_log2 = res; +} + + LLVMValueRef lp_build_log2(struct lp_build_context *bld, LLVMValueRef x) { LLVMValueRef res; - lp_build_log2_approx(bld, x, NULL, NULL, &res); + if (bld->type.length == 1) { + lp_build_float_log2_approx(bld, x, NULL, NULL, &res); + } + else { + lp_build_log2_approx(bld, x, NULL, NULL, &res); + } return res; } diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c index c8eaa8c394..53447757e8 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c @@ -264,10 +264,16 @@ lp_build_one(struct lp_type type) for(i = 1; i < type.length; ++i) elems[i] = elems[0]; - return LLVMConstVector(elems, type.length); + if (type.length == 1) + return elems[0]; + else + return LLVMConstVector(elems, type.length); } +/** + * Build constant-valued vector from a scalar value. + */ LLVMValueRef lp_build_const_scalar(struct lp_type type, double val) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index 2726747eae..7c585fda78 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -198,7 +198,7 @@ lp_build_compare(LLVMBuilderRef builder, return res; } - } + } /* if (type.width * type.length == 128) */ #endif if(type.floating) { @@ -238,20 +238,25 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildFCmp(builder, op, a, b, ""); res = LLVMBuildSelect(builder, cond, ones, zeros, ""); #else - debug_printf("%s: warning: using slow element-wise vector comparison\n", - __FUNCTION__); res = LLVMGetUndef(int_vec_type); - for(i = 0; i < type.length; ++i) { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); - cond = LLVMBuildFCmp(builder, op, - LLVMBuildExtractElement(builder, a, index, ""), - LLVMBuildExtractElement(builder, b, index, ""), - ""); - cond = LLVMBuildSelect(builder, cond, - LLVMConstExtractElement(ones, index), - LLVMConstExtractElement(zeros, index), - ""); - res = LLVMBuildInsertElement(builder, res, cond, index, ""); + if (type.length == 1) { + res = LLVMBuildFCmp(builder, op, a, b, ""); + } + else { + debug_printf("%s: warning: using slow element-wise float" + " vector comparison\n", __FUNCTION__); + for (i = 0; i < type.length; ++i) { + LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); + cond = LLVMBuildFCmp(builder, op, + LLVMBuildExtractElement(builder, a, index, ""), + LLVMBuildExtractElement(builder, b, index, ""), + ""); + cond = LLVMBuildSelect(builder, cond, + LLVMConstExtractElement(ones, index), + LLVMConstExtractElement(zeros, index), + ""); + res = LLVMBuildInsertElement(builder, res, cond, index, ""); + } } #endif } @@ -286,20 +291,26 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildICmp(builder, op, a, b, ""); res = LLVMBuildSelect(builder, cond, ones, zeros, ""); #else - debug_printf("%s: warning: using slow element-wise int vector comparison\n", - __FUNCTION__); res = LLVMGetUndef(int_vec_type); - for(i = 0; i < type.length; ++i) { - LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); - cond = LLVMBuildICmp(builder, op, - LLVMBuildExtractElement(builder, a, index, ""), - LLVMBuildExtractElement(builder, b, index, ""), - ""); - cond = LLVMBuildSelect(builder, cond, - LLVMConstExtractElement(ones, index), - LLVMConstExtractElement(zeros, index), - ""); - res = LLVMBuildInsertElement(builder, res, cond, index, ""); + if (type.length == 1) { + res = LLVMBuildICmp(builder, op, a, b, ""); + } + else { + debug_printf("%s: warning: using slow element-wise int" + " vector comparison\n", __FUNCTION__); + + for(i = 0; i < type.length; ++i) { + LLVMValueRef index = LLVMConstInt(LLVMInt32Type(), i, 0); + cond = LLVMBuildICmp(builder, op, + LLVMBuildExtractElement(builder, a, index, ""), + LLVMBuildExtractElement(builder, b, index, ""), + ""); + cond = LLVMBuildSelect(builder, cond, + LLVMConstExtractElement(ones, index), + LLVMConstExtractElement(zeros, index), + ""); + res = LLVMBuildInsertElement(builder, res, cond, index, ""); + } } #endif } @@ -339,26 +350,31 @@ lp_build_select(struct lp_build_context *bld, if(a == b) return a; - if(type.floating) { - LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); - b = LLVMBuildBitCast(bld->builder, b, int_vec_type, ""); + if (type.length == 1) { + res = LLVMBuildSelect(bld->builder, mask, a, b, ""); } + else { + if(type.floating) { + LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); + a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); + b = LLVMBuildBitCast(bld->builder, b, int_vec_type, ""); + } - a = LLVMBuildAnd(bld->builder, a, mask, ""); + a = LLVMBuildAnd(bld->builder, a, mask, ""); - /* This often gets translated to PANDN, but sometimes the NOT is - * pre-computed and stored in another constant. The best strategy depends - * on available registers, so it is not a big deal -- hopefully LLVM does - * the right decision attending the rest of the program. - */ - b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), ""); + /* This often gets translated to PANDN, but sometimes the NOT is + * pre-computed and stored in another constant. The best strategy depends + * on available registers, so it is not a big deal -- hopefully LLVM does + * the right decision attending the rest of the program. + */ + b = LLVMBuildAnd(bld->builder, b, LLVMBuildNot(bld->builder, mask, ""), ""); - res = LLVMBuildOr(bld->builder, a, b, ""); + res = LLVMBuildOr(bld->builder, a, b, ""); - if(type.floating) { - LLVMTypeRef vec_type = lp_build_vec_type(type); - res = LLVMBuildBitCast(bld->builder, res, vec_type, ""); + if(type.floating) { + LLVMTypeRef vec_type = lp_build_vec_type(type); + res = LLVMBuildBitCast(bld->builder, res, vec_type, ""); + } } return res; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 1dca29cdd5..a965d394f4 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -65,6 +65,14 @@ struct lp_build_sample_context const struct util_format_description *format_desc; + /** regular scalar float type */ + struct lp_type float_type; + struct lp_build_context float_bld; + + /** regular scalar float type */ + struct lp_type int_type; + struct lp_build_context int_bld; + /** Incoming coordinates type and build context */ struct lp_type coord_type; struct lp_build_context coord_bld; @@ -108,6 +116,27 @@ wrap_mode_uses_border_color(unsigned mode) } +static LLVMValueRef +lp_build_get_mipmap_level(struct lp_build_sample_context *bld, + LLVMValueRef data_array, LLVMValueRef level) +{ + LLVMValueRef indexes[2], data_ptr; + indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indexes[1] = level; + data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, ""); + data_ptr = LLVMBuildLoad(bld->builder, data_ptr, ""); + return data_ptr; +} + + +static LLVMValueRef +lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld, + LLVMValueRef data_array, int level) +{ + LLVMValueRef lvl = LLVMConstInt(LLVMInt32Type(), level, 0); + return lp_build_get_mipmap_level(bld, data_array, lvl); +} + /** * Gen code to fetch a texel from a texture at int coords (x, y). @@ -124,14 +153,13 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef x, LLVMValueRef y, LLVMValueRef y_stride, - LLVMValueRef data_array, + LLVMValueRef data_ptr, LLVMValueRef *texel) { struct lp_build_context *int_coord_bld = &bld->int_coord_bld; LLVMValueRef offset; LLVMValueRef packed; LLVMValueRef use_border = NULL; - LLVMValueRef data_ptr; /* use_border = x < 0 || x >= width || y < 0 || y >= height */ if (wrap_mode_uses_border_color(bld->static_state->wrap_s)) { @@ -154,16 +182,6 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, } } - /* XXX always use mipmap level 0 for now */ - { - const int level = 0; - LLVMValueRef indexes[2]; - indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); - indexes[1] = LLVMConstInt(LLVMInt32Type(), level, 0); - data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, ""); - data_ptr = LLVMBuildLoad(bld->builder, data_ptr, ""); - } - /* * Note: if we find an app which frequently samples the texture border * we might want to implement a true conditional here to avoid sampling @@ -233,17 +251,8 @@ lp_build_sample_packed(struct lp_build_sample_context *bld, assert(bld->format_desc->block.height == 1); assert(bld->format_desc->block.bits <= bld->texel_type.width); - /* XXX always use mipmap level 0 for now */ - { - const int level = 0; - LLVMValueRef indexes[2]; - /* get data_ptr[level] */ - indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); - indexes[1] = LLVMConstInt(LLVMInt32Type(), level, 0); - data_ptr = LLVMBuildGEP(bld->builder, data_array, indexes, 2, ""); - /* load texture base address */ - data_ptr = LLVMBuildLoad(bld->builder, data_ptr, ""); - } + /* get pointer to mipmap level 0 data */ + data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); return lp_build_gather(bld->builder, bld->texel_type.length, @@ -733,7 +742,210 @@ lp_build_sample_wrap_nearest(struct lp_build_sample_context *bld, /** - * Sample 2D texture with nearest filtering. + * Codegen equivalent for u_minify(). + * Return max(1, base_size >> level); + */ +static LLVMValueRef +lp_build_minify(struct lp_build_sample_context *bld, + LLVMValueRef base_size, + LLVMValueRef level) +{ + LLVMValueRef size = LLVMBuildAShr(bld->builder, base_size, level, "minify"); + size = lp_build_max(&bld->int_coord_bld, size, bld->int_coord_bld.one); + return size; +} + + +static int +texture_dims(enum pipe_texture_target tex) +{ + switch (tex) { + case PIPE_TEXTURE_1D: + return 1; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_CUBE: + return 2; + case PIPE_TEXTURE_3D: + return 3; + default: + assert(0 && "bad texture target in texture_dims()"); + return 2; + } +} + + +/** + * Generate code to compute texture level of detail (lambda). + * \param s vector of texcoord s values + * \param t vector of texcoord t values + * \param r vector of texcoord r values + * \param width scalar int texture width + * \param height scalar int texture height + * \param depth scalar int texture depth + */ +static LLVMValueRef +lp_build_lod_selector(struct lp_build_sample_context *bld, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef width, + LLVMValueRef height, + LLVMValueRef depth) + +{ + const int dims = texture_dims(bld->static_state->target); + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *float_bld = &bld->float_bld; + LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(), bld->static_state->lod_bias); + LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod); + LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->max_lod); + + LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0); + LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0); + LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0); + + LLVMValueRef s0, s1, s2; + LLVMValueRef t0, t1, t2; + LLVMValueRef r0, r1, r2; + LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; + LLVMValueRef rho, lod; + + /* + * dsdx = abs(s[1] - s[0]); + * dsdy = abs(s[2] - s[0]); + * dtdx = abs(t[1] - t[0]); + * dtdy = abs(t[2] - t[0]); + * drdx = abs(r[1] - r[0]); + * drdy = abs(r[2] - r[0]); + * XXX we're assuming a four-element quad in 2x2 layout here. + */ + s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0"); + s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1"); + s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2"); + dsdx = LLVMBuildSub(bld->builder, s1, s0, ""); + dsdx = lp_build_abs(float_bld, dsdx); + dsdy = LLVMBuildSub(bld->builder, s2, s0, ""); + dsdy = lp_build_abs(float_bld, dsdy); + if (dims > 1) { + t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0"); + t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1"); + t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2"); + dtdx = LLVMBuildSub(bld->builder, t1, t0, ""); + dtdx = lp_build_abs(float_bld, dtdx); + dtdy = LLVMBuildSub(bld->builder, t2, t0, ""); + dtdy = lp_build_abs(float_bld, dtdy); + if (dims > 2) { + r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0"); + r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1"); + r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2"); + drdx = LLVMBuildSub(bld->builder, r1, r0, ""); + drdx = lp_build_abs(float_bld, drdx); + drdy = LLVMBuildSub(bld->builder, r2, r0, ""); + drdy = lp_build_abs(float_bld, drdy); + } + } + + /* Compute rho = max of all partial derivatives scaled by texture size. + * XXX this could be vectorized somewhat + */ + rho = LLVMBuildMul(bld->builder, + lp_build_max(float_bld, dsdx, dsdy), + lp_build_int_to_float(float_bld, width), ""); + if (dims > 1) { + LLVMValueRef max; + max = LLVMBuildMul(bld->builder, + lp_build_max(float_bld, dtdx, dtdy), + lp_build_int_to_float(float_bld, height), ""); + rho = lp_build_max(float_bld, rho, max); + if (dims > 2) { + max = LLVMBuildMul(bld->builder, + lp_build_max(float_bld, drdx, drdy), + lp_build_int_to_float(float_bld, depth), ""); + rho = lp_build_max(float_bld, rho, max); + } + } + + /* compute lod = log2(rho) */ + lod = lp_build_log2(float_bld, rho); + + /* add lod bias */ + lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "LOD bias"); + + /* clamp lod */ + lod = lp_build_clamp(float_bld, lod, min_lod, max_lod); + + return lod; +} + + +/** + * For PIPE_TEX_MIPFILTER_NEAREST, convert float LOD to integer + * mipmap level index. + * Note: this is all scalar code. + * \param lod scalar float texture level of detail + * \param level_out returns integer + */ +static void +lp_build_nearest_mip_level(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef lod, + LLVMValueRef *level_out) +{ + struct lp_build_context *float_bld = &bld->float_bld; + struct lp_build_context *int_bld = &bld->int_bld; + LLVMValueRef last_level, level; + + LLVMValueRef zero = LLVMConstInt(LLVMInt32Type(), 0, 0); + + last_level = bld->dynamic_state->last_level(bld->dynamic_state, + bld->builder, unit); + + /* convert float lod to integer */ + level = lp_build_iround(float_bld, lod); + + /* clamp level to legal range of levels */ + *level_out = lp_build_clamp(int_bld, level, zero, last_level); +} + + +/** + * For PIPE_TEX_MIPFILTER_LINEAR, convert float LOD to integer to + * two (adjacent) mipmap level indexes. Later, we'll sample from those + * two mipmap levels and interpolate between them. + */ +static void +lp_build_linear_mip_levels(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef lod, + LLVMValueRef *level0_out, + LLVMValueRef *level1_out, + LLVMValueRef *weight_out) +{ + struct lp_build_context *coord_bld = &bld->coord_bld; + struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + LLVMValueRef last_level, level; + + last_level = bld->dynamic_state->last_level(bld->dynamic_state, + bld->builder, unit); + + /* convert float lod to integer */ + level = lp_build_ifloor(coord_bld, lod); + + /* compute level 0 and clamp to legal range of levels */ + *level0_out = lp_build_clamp(int_coord_bld, level, + int_coord_bld->zero, + last_level); + /* compute level 1 and clamp to legal range of levels */ + *level1_out = lp_build_add(int_coord_bld, *level0_out, int_coord_bld->one); + *level1_out = lp_build_min(int_coord_bld, *level1_out, int_coord_bld->zero); + + *weight_out = lp_build_fract(coord_bld, lod); +} + + + +/** + * Sample 2D texture with nearest filtering, no mipmapping. */ static void lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, @@ -746,6 +958,7 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, LLVMValueRef *texel) { LLVMValueRef x, y; + LLVMValueRef data_ptr; x = lp_build_sample_wrap_nearest(bld, s, width, bld->static_state->pot_width, @@ -757,7 +970,63 @@ lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, lp_build_name(x, "tex.x.wrapped"); lp_build_name(y, "tex.y.wrapped"); - lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_array, texel); + /* get pointer to mipmap level 0 data */ + data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); + + lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_ptr, texel); +} + + +/** + * Sample 2D texture with nearest filtering, nearest mipmap. + */ +static void +lp_build_sample_2d_nearest_mip_nearest_soa(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef width, + LLVMValueRef height, + LLVMValueRef width_vec, + LLVMValueRef height_vec, + LLVMValueRef stride, + LLVMValueRef data_array, + LLVMValueRef *texel) +{ + LLVMValueRef x, y; + LLVMValueRef lod, ilevel, ilevel_vec; + LLVMValueRef data_ptr; + + /* compute float LOD */ + lod = lp_build_lod_selector(bld, s, t, NULL, width, height, NULL); + + /* convert LOD to int */ + lp_build_nearest_mip_level(bld, unit, lod, &ilevel); + + ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel); + + /* compute width_vec, height at mipmap level 'ilevel' */ + width_vec = lp_build_minify(bld, width_vec, ilevel_vec); + height_vec = lp_build_minify(bld, height_vec, ilevel_vec); + stride = lp_build_minify(bld, stride, ilevel_vec); + + x = lp_build_sample_wrap_nearest(bld, s, width_vec, + bld->static_state->pot_width, + bld->static_state->wrap_s); + y = lp_build_sample_wrap_nearest(bld, t, height_vec, + bld->static_state->pot_height, + bld->static_state->wrap_t); + + lp_build_name(x, "tex.x.wrapped"); + lp_build_name(y, "tex.y.wrapped"); + + /* get pointer to mipmap level [ilevel] data */ + if (0) + data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); + else + data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); + + lp_build_sample_texel_soa(bld, width_vec, height_vec, x, y, stride, data_ptr, texel); } @@ -779,6 +1048,7 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, LLVMValueRef x0, x1; LLVMValueRef y0, y1; LLVMValueRef neighbors[2][2][4]; + LLVMValueRef data_ptr; unsigned chan; lp_build_sample_wrap_linear(bld, s, width, bld->static_state->pot_width, @@ -786,10 +1056,13 @@ lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, lp_build_sample_wrap_linear(bld, t, height, bld->static_state->pot_height, bld->static_state->wrap_t, &y0, &y1, &t_fpart); - lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_array, neighbors[0][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_array, neighbors[0][1]); - lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_array, neighbors[1][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_array, neighbors[1][1]); + /* get pointer to mipmap level 0 data */ + data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); + + lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_ptr, neighbors[0][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_ptr, neighbors[0][1]); + lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_ptr, neighbors[1][0]); + lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_ptr, neighbors[1][1]); /* TODO: Don't interpolate missing channels */ for(chan = 0; chan < 4; ++chan) { @@ -857,7 +1130,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef packed, packed_lo, packed_hi; LLVMValueRef unswizzled[4]; - lp_build_context_init(&i32, builder, lp_type_int(32)); + lp_build_context_init(&i32, builder, lp_type_int_vec(32)); lp_build_context_init(&h16, builder, lp_type_ufixed(16)); lp_build_context_init(&u8n, builder, lp_type_unorm(8)); @@ -1066,194 +1339,11 @@ lp_build_sample_compare(struct lp_build_sample_context *bld, } -static int -texture_dims(enum pipe_texture_target tex) -{ - switch (tex) { - case PIPE_TEXTURE_1D: - return 1; - case PIPE_TEXTURE_2D: - case PIPE_TEXTURE_CUBE: - return 2; - case PIPE_TEXTURE_3D: - return 3; - default: - assert(0 && "bad texture target in texture_dims()"); - return 2; - } -} - - -/** - * Generate code to compute texture level of detail (lambda). - * \param s vector of texcoord s values - * \param t vector of texcoord t values - * \param r vector of texcoord r values - * \param width scalar int texture width - * \param height scalar int texture height - * \param depth scalar int texture depth - */ -static LLVMValueRef -lp_build_lod_selector(struct lp_build_sample_context *bld, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef r, - LLVMValueRef width, - LLVMValueRef height, - LLVMValueRef depth) - -{ - const int dims = texture_dims(bld->static_state->target); - struct lp_build_context *coord_bld = &bld->coord_bld; - - LLVMValueRef lod_bias = lp_build_const_scalar(bld->coord_bld.type, - bld->static_state->lod_bias); - LLVMValueRef min_lod = lp_build_const_scalar(bld->coord_bld.type, - bld->static_state->min_lod); - LLVMValueRef max_lod = lp_build_const_scalar(bld->coord_bld.type, - bld->static_state->max_lod); - - LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0); - LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0); - LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0); - - LLVMValueRef s0, s1, s2; - LLVMValueRef t0, t1, t2; - LLVMValueRef r0, r1, r2; - LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy; - LLVMValueRef rho, lod; - - /* - * dsdx = abs(s[1] - s[0]); - * dsdy = abs(s[2] - s[0]); - * dtdx = abs(t[1] - t[0]); - * dtdy = abs(t[2] - t[0]); - * drdx = abs(r[1] - r[0]); - * drdy = abs(r[2] - r[0]); - * XXX we're assuming a four-element quad in 2x2 layout here. - */ - s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0"); - s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1"); - s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2"); - dsdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, s1, s0)); - dsdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, s2, s0)); - if (dims > 1) { - t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0"); - t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1"); - t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2"); - dtdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, t1, t0)); - dtdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, t2, t0)); - if (dims > 2) { - r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0"); - r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1"); - r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2"); - drdx = lp_build_abs(coord_bld, lp_build_sub(coord_bld, r1, r0)); - drdy = lp_build_abs(coord_bld, lp_build_sub(coord_bld, r2, r0)); - } - } - - /* Compute rho = max of all partial derivatives scaled by texture size. - * XXX this can be vectorized somewhat - */ - rho = lp_build_mul(coord_bld, - lp_build_max(coord_bld, dsdx, dsdy), - lp_build_int_to_float(coord_bld, width)); - if (dims > 1) { - LLVMValueRef max; - max = lp_build_mul(coord_bld, - lp_build_max(coord_bld, dtdx, dtdy), - lp_build_int_to_float(coord_bld, height)); - rho = lp_build_max(coord_bld, rho, max); - if (dims > 2) { - max = lp_build_mul(coord_bld, - lp_build_max(coord_bld, drdx, drdy), - lp_build_int_to_float(coord_bld, depth)); - rho = lp_build_max(coord_bld, rho, max); - } - } - - /* compute lod = log2(rho) */ - lod = lp_build_log2(coord_bld, rho); - - /* add lod bias */ - lod = lp_build_add(coord_bld, lod, lod_bias); - - /* clamp lod */ - lod = lp_build_clamp(coord_bld, lod, min_lod, max_lod); - - return lod; -} - - -/** - * For PIPE_TEX_MIPFILTER_NEAREST, convert float LOD to integer - * mipmap level index. - * \param lod scalar float texture level of detail - * \param level_out returns integer - */ -static void -lp_build_nearest_mip_level(struct lp_build_sample_context *bld, - unsigned unit, - LLVMValueRef lod, - LLVMValueRef *level_out) -{ - struct lp_build_context *coord_bld = &bld->coord_bld; - struct lp_build_context *int_coord_bld = &bld->int_coord_bld; - LLVMValueRef last_level, level; - - last_level = bld->dynamic_state->last_level(bld->dynamic_state, - bld->builder, unit); - - /* convert float lod to integer */ - level = lp_build_iround(coord_bld, lod); - - /* clamp level to legal range of levels */ - *level_out = lp_build_clamp(int_coord_bld, level, - int_coord_bld->zero, - last_level); -} - - -/** - * For PIPE_TEX_MIPFILTER_LINEAR, convert float LOD to integer to - * two (adjacent) mipmap level indexes. Later, we'll sample from those - * two mipmap levels and interpolate between them. - */ -static void -lp_build_linear_mip_levels(struct lp_build_sample_context *bld, - unsigned unit, - LLVMValueRef lod, - LLVMValueRef *level0_out, - LLVMValueRef *level1_out, - LLVMValueRef *weight_out) -{ - struct lp_build_context *coord_bld = &bld->coord_bld; - struct lp_build_context *int_coord_bld = &bld->int_coord_bld; - LLVMValueRef last_level, level; - - last_level = bld->dynamic_state->last_level(bld->dynamic_state, - bld->builder, unit); - - /* convert float lod to integer */ - level = lp_build_ifloor(coord_bld, lod); - - /* compute level 0 and clamp to legal range of levels */ - *level0_out = lp_build_clamp(int_coord_bld, level, - int_coord_bld->zero, - last_level); - /* compute level 1 and clamp to legal range of levels */ - *level1_out = lp_build_add(int_coord_bld, *level0_out, int_coord_bld->one); - *level1_out = lp_build_min(int_coord_bld, *level1_out, int_coord_bld->zero); - - *weight_out = lp_build_fract(coord_bld, lod); -} - - - /** * Build texture sampling code. * 'texel' will return a vector of four LLVMValueRefs corresponding to * R, G, B, A. + * \param type vector float type to use for coords, etc. */ void lp_build_sample_soa(LLVMBuilderRef builder, @@ -1267,17 +1357,19 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef *texel) { struct lp_build_sample_context bld; - LLVMValueRef width; - LLVMValueRef height; - LLVMValueRef stride; + LLVMValueRef width, width_vec; + LLVMValueRef height, height_vec; + LLVMValueRef stride, stride_vec; LLVMValueRef data_array; LLVMValueRef s; LLVMValueRef t; LLVMValueRef r; + boolean done = FALSE; (void) lp_build_lod_selector; /* temporary to silence warning */ (void) lp_build_nearest_mip_level; (void) lp_build_linear_mip_levels; + (void) lp_build_minify; /* Setup our build context */ memset(&bld, 0, sizeof bld); @@ -1285,10 +1377,16 @@ lp_build_sample_soa(LLVMBuilderRef builder, bld.static_state = static_state; bld.dynamic_state = dynamic_state; bld.format_desc = util_format_description(static_state->format); + + bld.float_type = lp_type_float(32); + bld.int_type = lp_type_int(32); bld.coord_type = type; bld.uint_coord_type = lp_uint_type(type); bld.int_coord_type = lp_int_type(type); bld.texel_type = type; + + lp_build_context_init(&bld.float_bld, builder, bld.float_type); + lp_build_context_init(&bld.int_bld, builder, bld.int_type); lp_build_context_init(&bld.coord_bld, builder, bld.coord_type); lp_build_context_init(&bld.uint_coord_bld, builder, bld.uint_coord_type); lp_build_context_init(&bld.int_coord_bld, builder, bld.int_coord_type); @@ -1305,30 +1403,56 @@ lp_build_sample_soa(LLVMBuilderRef builder, t = coords[1]; r = coords[2]; - width = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); - height = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); - stride = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride); + width_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); + height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); + stride_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride); if(static_state->target == PIPE_TEXTURE_1D) t = bld.coord_bld.zero; - switch (static_state->min_img_filter) { - case PIPE_TEX_FILTER_NEAREST: - lp_build_sample_2d_nearest_soa(&bld, s, t, width, height, - stride, data_array, texel); + switch (static_state->min_mip_filter) { + case PIPE_TEX_MIPFILTER_NONE: break; - case PIPE_TEX_FILTER_LINEAR: - if(lp_format_is_rgba8(bld.format_desc) && - is_simple_wrap_mode(static_state->wrap_s) && - is_simple_wrap_mode(static_state->wrap_t)) - lp_build_sample_2d_linear_aos(&bld, s, t, width, height, - stride, data_array, texel); - else - lp_build_sample_2d_linear_soa(&bld, s, t, width, height, - stride, data_array, texel); + case PIPE_TEX_MIPFILTER_NEAREST: + + switch (static_state->min_img_filter) { + case PIPE_TEX_FILTER_NEAREST: + lp_build_sample_2d_nearest_mip_nearest_soa(&bld, unit, + s, t, + width, height, + width_vec, height_vec, + stride_vec, + data_array, texel); + done = TRUE; + break; + } + + break; + case PIPE_TEX_MIPFILTER_LINEAR: break; default: - assert(0); + assert(0 && "invalid mip filter"); + } + + if (!done) { + switch (static_state->min_img_filter) { + case PIPE_TEX_FILTER_NEAREST: + lp_build_sample_2d_nearest_soa(&bld, s, t, width_vec, height_vec, + stride_vec, data_array, texel); + break; + case PIPE_TEX_FILTER_LINEAR: + if(lp_format_is_rgba8(bld.format_desc) && + is_simple_wrap_mode(static_state->wrap_s) && + is_simple_wrap_mode(static_state->wrap_t)) + lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, + stride_vec, data_array, texel); + else + lp_build_sample_2d_linear_soa(&bld, s, t, width_vec, height_vec, + stride_vec, data_array, texel); + break; + default: + assert(0); + } } /* FIXME: respect static_state->min_mip_filter */; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 16946cc28a..4daa904e63 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -103,7 +103,7 @@ struct lp_type { unsigned width:14; /** - * Vector length. + * Vector length. If length==1, this is a scalar (float/int) type. * * width*length should be a power of two greater or equal to eight. * @@ -139,11 +139,28 @@ struct lp_build_context }; +/** Create scalar float type */ static INLINE struct lp_type lp_type_float(unsigned width) { struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); + res_type.floating = TRUE; + res_type.sign = TRUE; + res_type.width = width; + res_type.length = 1; + + return res_type; +} + + +/** Create vector of float type */ +static INLINE struct lp_type +lp_type_float_vec(unsigned width) +{ + struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); res_type.floating = TRUE; res_type.sign = TRUE; @@ -154,11 +171,27 @@ lp_type_float(unsigned width) } +/** Create scalar int type */ static INLINE struct lp_type lp_type_int(unsigned width) { struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); + res_type.sign = TRUE; + res_type.width = width; + res_type.length = 1; + + return res_type; +} + + +/** Create vector int type */ +static INLINE struct lp_type +lp_type_int_vec(unsigned width) +{ + struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); res_type.sign = TRUE; res_type.width = width; @@ -168,11 +201,26 @@ lp_type_int(unsigned width) } +/** Create scalar uint type */ static INLINE struct lp_type lp_type_uint(unsigned width) { struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); + res_type.width = width; + res_type.length = 1; + + return res_type; +} + + +/** Create vector uint type */ +static INLINE struct lp_type +lp_type_uint_vec(unsigned width) +{ + struct lp_type res_type; + memset(&res_type, 0, sizeof res_type); res_type.width = width; res_type.length = LP_NATIVE_VECTOR_WIDTH / width; -- cgit v1.2.3 From c27ffc5215573d6ff106d4770168117adea884f9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 9 Mar 2010 17:08:36 +0000 Subject: scons: Fix the libg-xlib Sconscript. --- src/gallium/targets/libgl-xlib/SConscript | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/targets/libgl-xlib/SConscript b/src/gallium/targets/libgl-xlib/SConscript index 92e508ee50..efa7e797d1 100644 --- a/src/gallium/targets/libgl-xlib/SConscript +++ b/src/gallium/targets/libgl-xlib/SConscript @@ -28,35 +28,40 @@ env.Append(CPPPATH = [ env.Append(CPPDEFINES = ['USE_XSHM']) +env.Prepend(LIBS = [ + st_xlib, + ws_xlib, + trace, + identity, + glapi, + mesa, + glsl, + gallium, +]) + sources = [ 'xlib.c', ] -drivers = [trace] - if 'softpipe' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_SOFTPIPE') - sources += ['xlib_softpipe.c', 'xlib_sw_winsys.c'] - drivers += [softpipe] + env.Prepend(LIBS = [softpipe]) if 'llvmpipe' in env['drivers']: env.Tool('llvm') if 'LLVM_VERSION' in env: env.Append(CPPDEFINES = 'GALLIUM_LLVMPIPE') env.Tool('udis86') - sources += ['xlib_llvmpipe.c', 'xlib_sw_winsys.c'] - drivers += [llvmpipe] + env.Prepend(LIBS = [llvmpipe]) if 'cell' in env['drivers']: env.Append(CPPDEFINES = 'GALLIUM_CELL') - sources += ['xlib_cell.c'] - drivers += [cell] + env.Prepend(LIBS = [cell]) # TODO: write a wrapper function http://www.scons.org/wiki/WrapperFunctions libgl = env.SharedLibrary( target ='GL', source = sources, - LIBS = st_xlib + glapi + mesa + glsl + drivers + gallium + env['LIBS'], ) if not env['dri']: -- cgit v1.2.3 From d0aea650320fec0b8e01110eeee22b1f3700d587 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 17:27:58 +0000 Subject: gallium: create helper for swrast+xlib combination Several targets may want to reuse this code. It's pretty simple, not sure if this is really a win. --- src/gallium/auxiliary/Makefile | 3 +- src/gallium/include/state_tracker/xlib_sw_winsys.h | 11 +--- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_public.h | 44 ++++++++++++++ src/gallium/state_trackers/glx/xlib/xm_winsys.h | 42 ------------- src/gallium/targets/libgl-xlib/xlib.c | 70 ++-------------------- src/gallium/winsys/drm/i965/xlib/xlib_i965.c | 2 +- 7 files changed, 55 insertions(+), 119 deletions(-) create mode 100644 src/gallium/state_trackers/glx/xlib/xm_public.h delete mode 100644 src/gallium/state_trackers/glx/xlib/xm_winsys.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 68b1a3e854..c84e8d781d 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -131,7 +131,8 @@ C_SOURCES = \ vl/vl_mpeg12_mc_renderer.c \ vl/vl_compositor.c \ vl/vl_csc.c \ - vl/vl_shader_build.c + vl/vl_shader_build.c \ + target-helpers/swrast_xlib.c GALLIVM_SOURCES = \ gallivm/lp_bld_alpha.c \ diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h index 13dc837712..f22c22bb62 100644 --- a/src/gallium/include/state_tracker/xlib_sw_winsys.h +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -9,8 +9,9 @@ struct pipe_screen; struct pipe_surface; /* This is what the xlib software winsys expects to find in the - * "private" field of flush_frontbuffers(). Xlib-based state trackers - * somehow need to know this. + * "private" field of flush_frontbuffers(). + * + * Xlib-based state trackers somehow need to know this. */ struct xlib_drawable { Visual *visual; @@ -18,12 +19,6 @@ struct xlib_drawable { Drawable drawable; }; -/* This is the interface required by the glx/xlib state tracker. Why - * is it being defined in this file? - */ -struct xm_driver { - struct pipe_screen *(*create_pipe_screen)( Display *display ); -}; /* This is the public interface to the ws/xlib module. Why isn't it * being defined in that directory? diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index b8647d71c6..568bc6e962 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -63,7 +63,7 @@ #include "pipe/p_screen.h" #include "pipe/p_context.h" -#include "xm_winsys.h" +#include "xm_public.h" #include diff --git a/src/gallium/state_trackers/glx/xlib/xm_public.h b/src/gallium/state_trackers/glx/xlib/xm_public.h new file mode 100644 index 0000000000..ac6a8ffb27 --- /dev/null +++ b/src/gallium/state_trackers/glx/xlib/xm_public.h @@ -0,0 +1,44 @@ + +/************************************************************************** + * + * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef XM_WINSYS_H +#define XM_WINSYS_H + +struct xm_driver; + +/* This is the driver interface required by the glx/xlib state tracker. + */ +struct xm_driver { + struct pipe_screen *(*create_pipe_screen)( Display *display ); +}; + +extern void +xmesa_set_driver( const struct xm_driver *driver ); + + +#endif diff --git a/src/gallium/state_trackers/glx/xlib/xm_winsys.h b/src/gallium/state_trackers/glx/xlib/xm_winsys.h deleted file mode 100644 index 648f1c90ef..0000000000 --- a/src/gallium/state_trackers/glx/xlib/xm_winsys.h +++ /dev/null @@ -1,42 +0,0 @@ - -/************************************************************************** - * - * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - -#ifndef XM_WINSYS_H -#define XM_WINSYS_H - -struct pipe_context; -struct pipe_screen; -struct pipe_surface; -struct xlib_drawable; - - -extern void -xmesa_set_driver( const struct xm_driver *driver ); - - -#endif diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 7881bc2cb1..54764440e7 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -30,81 +30,19 @@ * Authors: * Keith Whitwell */ - -#include "state_tracker/xlib_sw_winsys.h" -#include "xm_winsys.h" -#include "util/u_debug.h" -#include "softpipe/sp_public.h" -#include "llvmpipe/lp_public.h" -#include "identity/id_public.h" -#include "trace/tr_public.h" -#include "cell/ppu/cell_public.h" - +#include "pipe/p_compiler.h" +#include "target-helpers/swrast_xlib.h" +#include "xm_public.h" /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; - -static struct pipe_screen * -create_screen( struct sw_winsys *winsys ) -{ -#if defined(GALLIUM_CELL) - if (!debug_get_bool_option("GALLIUM_NOCELL", FALSE)) - return cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) - return llvmpipe_create_screen( winsys ); -#endif - - return softpipe_create_screen( winsys ); -} - - - -static struct pipe_screen * -xlib_create_screen( Display *display ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - - screen = create_screen(winsys); - if (screen == NULL) - goto fail; - - /* Finally we have somewhere to inject layers into the stack in a - * clean fashion: - */ - if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { - screen = identity_screen_create(screen); - } - - if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { - screen = trace_screen_create( screen ); - } - - return screen; - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - struct xm_driver xlib_driver = { - .create_pipe_screen = xlib_create_screen, + .create_pipe_screen = swrast_xlib_create_screen, }; - - /* Build the rendering stack. */ static void _init( void ) __attribute__((constructor)); diff --git a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c index 74501eeb16..063e9f600b 100644 --- a/src/gallium/winsys/drm/i965/xlib/xlib_i965.c +++ b/src/gallium/winsys/drm/i965/xlib/xlib_i965.c @@ -38,7 +38,7 @@ #include "pipe/p_error.h" #include "pipe/p_context.h" -#include "xm_winsys.h" +#include "xm_public.h" #include "i965/brw_winsys.h" #include "i965/brw_screen.h" -- cgit v1.2.3 From 5e72b89b89fe172638afa66abdd6607d11970e5a Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 17:31:50 +0000 Subject: egl/x11: use swrast-xlib helper --- src/gallium/state_trackers/egl/x11/native_ximage.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 0aa25ead25..7d1462d4b7 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -32,9 +32,9 @@ #include "util/u_math.h" #include "util/u_format.h" #include "pipe/p_compiler.h" -#include "util/u_simple_screen.h" #include "util/u_inlines.h" #include "state_tracker/xlib_sw_winsys.h" +#include "target-helpers/swrast_xlib.h" #include "egllog.h" #include "native_x11.h" @@ -640,8 +640,7 @@ x11_create_ximage_display(EGLNativeDisplayType dpy) return NULL; } - xdpy->driver = xlib_sw_winsys_init(); - xdpy->base.screen = xdpy->driver->create_pipe_screen(xdpy->dpy); + xdpy->base.screen = swrast_xlib_create_screen(xdpy->dpy); xdpy->base.destroy = ximage_display_destroy; xdpy->base.get_param = ximage_display_get_param; -- cgit v1.2.3 From 25b9aafbd2f2d0737c23b4c59778c4e41f046d39 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 17:55:19 +0000 Subject: ws/xlib: no dependency on mesa state tracker --- src/gallium/winsys/xlib/SConscript | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript index d4009df991..2af6153b4c 100644 --- a/src/gallium/winsys/xlib/SConscript +++ b/src/gallium/winsys/xlib/SConscript @@ -4,8 +4,7 @@ Import('*') -if env['platform'] == 'linux' \ - and 'mesa' in env['statetrackers']: +if env['platform'] == 'linux': env = env.Clone() -- cgit v1.2.3 From 0df858a8d541e342dfe569091b665c2a6dff7ef0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 17:57:13 +0000 Subject: gallium: create target for gdi libgl --- src/gallium/targets/libgl-gdi/SConscript | 51 +++++++++ .../targets/libgl-gdi/gdi_llvmpipe_winsys.c | 123 +++++++++++++++++++++ .../targets/libgl-gdi/gdi_softpipe_winsys.c | 123 +++++++++++++++++++++ src/gallium/winsys/gdi/SConscript | 52 ++------- src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c | 123 --------------------- src/gallium/winsys/gdi/gdi_softpipe_winsys.c | 123 --------------------- src/gallium/winsys/gdi/gdi_sw_winsys.c | 2 +- 7 files changed, 309 insertions(+), 288 deletions(-) create mode 100644 src/gallium/targets/libgl-gdi/SConscript create mode 100644 src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c create mode 100644 src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c delete mode 100644 src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c delete mode 100644 src/gallium/winsys/gdi/gdi_softpipe_winsys.c (limited to 'src/gallium') diff --git a/src/gallium/targets/libgl-gdi/SConscript b/src/gallium/targets/libgl-gdi/SConscript new file mode 100644 index 0000000000..57704440ce --- /dev/null +++ b/src/gallium/targets/libgl-gdi/SConscript @@ -0,0 +1,51 @@ +####################################################################### +# SConscript for gdi winsys + +Import('*') + +if env['platform'] == 'windows': + + env = env.Clone() + + env.Append(CPPPATH = [ + '#src/gallium/state_trackers/wgl', + ]) + + env.Append(LIBS = [ + 'gdi32', + 'user32', + 'kernel32', + 'ws2_32', + ]) + + sources = [] + drivers = [] + + if 'softpipe' in env['drivers']: + sources = ['gdi_softpipe_winsys.c'] + drivers = [softpipe] + + if 'llvmpipe' in env['drivers']: + env.Tool('llvm') + if 'LLVM_VERSION' in env: + sources = ['gdi_llvmpipe_winsys.c'] + drivers = [llvmpipe] + + if not sources or not drivers: + print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled' + Return() + + if env['gcc']: + sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] + else: + sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] + + drivers += [trace] + + env['no_import_lib'] = 1 + + env.SharedLibrary( + target ='opengl32', + source = sources, + LIBS = wgl + ws_gdi + glapi + mesa + drivers + gallium + glsl + env['LIBS'], + ) diff --git a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c new file mode 100644 index 0000000000..f20c2614e2 --- /dev/null +++ b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c @@ -0,0 +1,123 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/** + * @file + * LLVMpipe support. + * + * @author Jose Fonseca + */ + + +#include + +#include "stw_winsys.h" +#include "gdi_sw_winsys.h" +#include "llvmpipe/lp_texture.h" +#include "llvmpipe/lp_screen.h" + + +static struct pipe_screen * +gdi_llvmpipe_screen_create(void) +{ + static struct sw_winsys *winsys; + struct pipe_screen *screen; + + winsys = gdi_create_sw_winsys(); + if(!winsys) + goto no_winsys; + + screen = llvmpipe_create_screen(winsys); + if(!screen) + goto no_screen; + + return screen; + +no_screen: + winsys->destroy(winsys); +no_winsys: + return NULL; +} + + + + +static void +gdi_llvmpipe_present(struct pipe_screen *screen, + struct pipe_surface *surface, + HDC hDC) +{ + /* This will fail if any interposing layer (trace, debug, etc) has + * been introduced between the state-trackers and llvmpipe. + * + * Ideally this would get replaced with a call to + * pipe_screen::flush_frontbuffer(). + * + * Failing that, it may be necessary for intervening layers to wrap + * other structs such as this stw_winsys as well... + */ + gdi_sw_display(llvmpipe_screen(screen)->winsys, + llvmpipe_texture(surface->texture)->dt, + hDC); +} + + +static const struct stw_winsys stw_winsys = { + &gdi_llvmpipe_screen_create, + &gdi_llvmpipe_present, + NULL, /* get_adapter_luid */ + NULL, /* shared_surface_open */ + NULL, /* shared_surface_close */ + NULL /* compose */ +}; + + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + stw_init(&stw_winsys); + stw_init_thread(); + break; + + case DLL_THREAD_ATTACH: + stw_init_thread(); + break; + + case DLL_THREAD_DETACH: + stw_cleanup_thread(); + break; + + case DLL_PROCESS_DETACH: + stw_cleanup_thread(); + stw_cleanup(); + break; + } + return TRUE; +} diff --git a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c new file mode 100644 index 0000000000..5c5c154c7f --- /dev/null +++ b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c @@ -0,0 +1,123 @@ +/************************************************************************** + * + * Copyright 2009 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/** + * @file + * LLVMpipe support. + * + * @author Jose Fonseca + */ + + +#include + +#include "stw_winsys.h" +#include "gdi_sw_winsys.h" +#include "softpipe/sp_texture.h" +#include "softpipe/sp_screen.h" + + +static struct pipe_screen * +gdi_softpipe_screen_create(void) +{ + static struct sw_winsys *winsys; + struct pipe_screen *screen; + + winsys = gdi_create_sw_winsys(); + if(!winsys) + goto no_winsys; + + screen = softpipe_create_screen(winsys); + if(!screen) + goto no_screen; + + return screen; + +no_screen: + winsys->destroy(winsys); +no_winsys: + return NULL; +} + + + + +static void +gdi_softpipe_present(struct pipe_screen *screen, + struct pipe_surface *surface, + HDC hDC) +{ + /* This will fail if any interposing layer (trace, debug, etc) has + * been introduced between the state-trackers and softpipe. + * + * Ideally this would get replaced with a call to + * pipe_screen::flush_frontbuffer(). + * + * Failing that, it may be necessary for intervening layers to wrap + * other structs such as this stw_winsys as well... + */ + gdi_sw_display(softpipe_screen(screen)->winsys, + softpipe_texture(surface->texture)->dt, + hDC); +} + + +static const struct stw_winsys stw_winsys = { + &gdi_softpipe_screen_create, + &gdi_softpipe_present, + NULL, /* get_adapter_luid */ + NULL, /* shared_surface_open */ + NULL, /* shared_surface_close */ + NULL /* compose */ +}; + + +BOOL WINAPI +DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + stw_init(&stw_winsys); + stw_init_thread(); + break; + + case DLL_THREAD_ATTACH: + stw_init_thread(); + break; + + case DLL_THREAD_DETACH: + stw_cleanup_thread(); + break; + + case DLL_PROCESS_DETACH: + stw_cleanup_thread(); + stw_cleanup(); + break; + } + return TRUE; +} diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 0a3f141e72..80f6c0e477 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -1,5 +1,6 @@ ####################################################################### -# SConscript for gdi winsys +# SConscript for xlib winsys + Import('*') @@ -8,46 +9,15 @@ if env['platform'] == 'windows': env = env.Clone() env.Append(CPPPATH = [ - '#src/gallium/state_trackers/wgl', - ]) - - env.Append(LIBS = [ - 'gdi32', - 'user32', - 'kernel32', - 'ws2_32', + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', ]) - sources = [] - drivers = [] - - if 'softpipe' in env['drivers']: - sources = ['gdi_sw_winsys.c', - 'gdi_softpipe_winsys.c'] - drivers = [softpipe] - - if 'llvmpipe' in env['drivers']: - env.Tool('llvm') - if 'LLVM_VERSION' in env: - sources = ['gdi_sw_winsys.c', - 'gdi_llvmpipe_winsys.c'] - drivers = [llvmpipe] - - if not sources or not drivers: - print 'warning: softpipe or llvmpipe not selected, gdi winsys disabled' - Return() - - if env['gcc']: - sources += ['#src/gallium/state_trackers/wgl/opengl32.mingw.def'] - else: - sources += ['#src/gallium/state_trackers/wgl/opengl32.def'] - - drivers += [trace] - - env['no_import_lib'] = 1 - - env.SharedLibrary( - target ='opengl32', - source = sources, - LIBS = wgl + glapi + mesa + drivers + gallium + glsl + env['LIBS'], + ws_xlib = env.ConvenienceLibrary( + target = 'ws_gdi', + source = [ + 'gdi_sw_winsys.c', + ] ) + Export('ws_gdi') diff --git a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c b/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c deleted file mode 100644 index f20c2614e2..0000000000 --- a/src/gallium/winsys/gdi/gdi_llvmpipe_winsys.c +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * @file - * LLVMpipe support. - * - * @author Jose Fonseca - */ - - -#include - -#include "stw_winsys.h" -#include "gdi_sw_winsys.h" -#include "llvmpipe/lp_texture.h" -#include "llvmpipe/lp_screen.h" - - -static struct pipe_screen * -gdi_llvmpipe_screen_create(void) -{ - static struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = gdi_create_sw_winsys(); - if(!winsys) - goto no_winsys; - - screen = llvmpipe_create_screen(winsys); - if(!screen) - goto no_screen; - - return screen; - -no_screen: - winsys->destroy(winsys); -no_winsys: - return NULL; -} - - - - -static void -gdi_llvmpipe_present(struct pipe_screen *screen, - struct pipe_surface *surface, - HDC hDC) -{ - /* This will fail if any interposing layer (trace, debug, etc) has - * been introduced between the state-trackers and llvmpipe. - * - * Ideally this would get replaced with a call to - * pipe_screen::flush_frontbuffer(). - * - * Failing that, it may be necessary for intervening layers to wrap - * other structs such as this stw_winsys as well... - */ - gdi_sw_display(llvmpipe_screen(screen)->winsys, - llvmpipe_texture(surface->texture)->dt, - hDC); -} - - -static const struct stw_winsys stw_winsys = { - &gdi_llvmpipe_screen_create, - &gdi_llvmpipe_present, - NULL, /* get_adapter_luid */ - NULL, /* shared_surface_open */ - NULL, /* shared_surface_close */ - NULL /* compose */ -}; - - -BOOL WINAPI -DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - stw_init(&stw_winsys); - stw_init_thread(); - break; - - case DLL_THREAD_ATTACH: - stw_init_thread(); - break; - - case DLL_THREAD_DETACH: - stw_cleanup_thread(); - break; - - case DLL_PROCESS_DETACH: - stw_cleanup_thread(); - stw_cleanup(); - break; - } - return TRUE; -} diff --git a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c b/src/gallium/winsys/gdi/gdi_softpipe_winsys.c deleted file mode 100644 index 5c5c154c7f..0000000000 --- a/src/gallium/winsys/gdi/gdi_softpipe_winsys.c +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * @file - * LLVMpipe support. - * - * @author Jose Fonseca - */ - - -#include - -#include "stw_winsys.h" -#include "gdi_sw_winsys.h" -#include "softpipe/sp_texture.h" -#include "softpipe/sp_screen.h" - - -static struct pipe_screen * -gdi_softpipe_screen_create(void) -{ - static struct sw_winsys *winsys; - struct pipe_screen *screen; - - winsys = gdi_create_sw_winsys(); - if(!winsys) - goto no_winsys; - - screen = softpipe_create_screen(winsys); - if(!screen) - goto no_screen; - - return screen; - -no_screen: - winsys->destroy(winsys); -no_winsys: - return NULL; -} - - - - -static void -gdi_softpipe_present(struct pipe_screen *screen, - struct pipe_surface *surface, - HDC hDC) -{ - /* This will fail if any interposing layer (trace, debug, etc) has - * been introduced between the state-trackers and softpipe. - * - * Ideally this would get replaced with a call to - * pipe_screen::flush_frontbuffer(). - * - * Failing that, it may be necessary for intervening layers to wrap - * other structs such as this stw_winsys as well... - */ - gdi_sw_display(softpipe_screen(screen)->winsys, - softpipe_texture(surface->texture)->dt, - hDC); -} - - -static const struct stw_winsys stw_winsys = { - &gdi_softpipe_screen_create, - &gdi_softpipe_present, - NULL, /* get_adapter_luid */ - NULL, /* shared_surface_open */ - NULL, /* shared_surface_close */ - NULL /* compose */ -}; - - -BOOL WINAPI -DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: - stw_init(&stw_winsys); - stw_init_thread(); - break; - - case DLL_THREAD_ATTACH: - stw_init_thread(); - break; - - case DLL_THREAD_DETACH: - stw_cleanup_thread(); - break; - - case DLL_PROCESS_DETACH: - stw_cleanup_thread(); - stw_cleanup(); - break; - } - return TRUE; -} diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.c b/src/gallium/winsys/gdi/gdi_sw_winsys.c index 55f99c4f47..f5c0b7d56e 100644 --- a/src/gallium/winsys/gdi/gdi_sw_winsys.c +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.c @@ -28,7 +28,7 @@ /** * @file - * LLVMpipe support. + * GDI software rasterizer support. * * @author Jose Fonseca */ -- cgit v1.2.3 From 3cadd983e875ebd2ccdde5287af1dcd3abad6db8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 18:01:47 +0000 Subject: ws/gdi: fix typo --- src/gallium/winsys/gdi/SConscript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/SConscript b/src/gallium/winsys/gdi/SConscript index 80f6c0e477..1267fc6eea 100644 --- a/src/gallium/winsys/gdi/SConscript +++ b/src/gallium/winsys/gdi/SConscript @@ -14,7 +14,7 @@ if env['platform'] == 'windows': '#/src/gallium/drivers', ]) - ws_xlib = env.ConvenienceLibrary( + ws_gdi = env.ConvenienceLibrary( target = 'ws_gdi', source = [ 'gdi_sw_winsys.c', -- cgit v1.2.3 From bf50d40f1ba68a0f19ca06196af99c01efce1e76 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 9 Mar 2010 20:12:52 +0100 Subject: r300g: kill pf_component_count --- src/gallium/drivers/r300/r300_state_inlines.h | 29 +-------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index af7827820c..a32924ed0a 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -348,39 +348,12 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) return 0; } -/* Utility function to count the number of components in RGBAZS formats. - * XXX should go to util or p_format.h */ -static INLINE unsigned pf_component_count(enum pipe_format format) { - unsigned count = 0; - - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0)) { - count++; - } - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1)) { - count++; - } - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2)) { - count++; - } - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3)) { - count++; - } - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) { - count++; - } - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) { - count++; - } - - return count; -} - /* Translate pipe_formats into PSC vertex types. */ static INLINE uint16_t r300_translate_vertex_data_type(enum pipe_format format) { uint32_t result = 0; const struct util_format_description *desc; - unsigned components = pf_component_count(format); + unsigned components = util_format_get_nr_components(format); desc = util_format_description(format); -- cgit v1.2.3 From 9cdaadc92f7ca91d01daf5573bff2c75416ad274 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 19:15:28 +0000 Subject: target-helpers: missing files --- src/gallium/auxiliary/target-helpers/swrast_xlib.c | 106 +++++++++++++++++++++ src/gallium/auxiliary/target-helpers/swrast_xlib.h | 15 +++ 2 files changed, 121 insertions(+) create mode 100644 src/gallium/auxiliary/target-helpers/swrast_xlib.c create mode 100644 src/gallium/auxiliary/target-helpers/swrast_xlib.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.c b/src/gallium/auxiliary/target-helpers/swrast_xlib.c new file mode 100644 index 0000000000..bf30ff68c1 --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/swrast_xlib.c @@ -0,0 +1,106 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/* + * Authors: + * Keith Whitwell + */ + +#include "swrast_xlib.h" + +#include "state_tracker/xlib_sw_winsys.h" +#include "util/u_debug.h" +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "identity/id_public.h" +#include "trace/tr_public.h" +#include "cell/ppu/cell_public.h" + + +/* Helper function to build a subset of a driver stack consisting of + * one of the software rasterizers (cell, llvmpipe, softpipe) and the + * xlib winsys. + * + * This can be called by any target that builds on top of this + * combination. + */ +struct pipe_screen * +swrast_xlib_create_screen( Display *display ) +{ + struct sw_winsys *winsys; + struct pipe_screen *screen = NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = xlib_create_sw_winsys( display ); + if (winsys == NULL) + return NULL; + + /* Create a software rasterizer on top of that winsys: + */ +#if defined(GALLIUM_CELL) + if (screen == NULL && + !debug_get_bool_option("GALLIUM_NO_CELL", FALSE)) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && + !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) + screen = llvmpipe_create_screen( winsys ); +#endif + + if (screen == NULL) + screen = softpipe_create_screen( winsys ); + + if (screen == NULL) + goto fail; + + /* Inject any wrapping layers we want to here: + */ + if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { + screen = identity_screen_create(screen); + } + + if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { + screen = trace_screen_create( screen ); + } + + return screen; + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + + + + diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.h b/src/gallium/auxiliary/target-helpers/swrast_xlib.h new file mode 100644 index 0000000000..3a0f713d54 --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/swrast_xlib.h @@ -0,0 +1,15 @@ +#ifndef SWRAST_XLIB_HELPER_H +#define SWRAST_XLIB_HELPER_H + +#include +#include "pipe/p_compiler.h" + +/* Helper to build the xlib winsys, choose between the software + * rasterizers and construct the lower part of a driver stack. + * + * Just add a state tracker. + */ +struct pipe_screen *swrast_xlib_create_screen( Display *display ); + + +#endif -- cgit v1.2.3 From 0d6b0b0d9d5257cc8fb95786b6cd77d088bdb35e Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Tue, 9 Mar 2010 19:05:32 +0100 Subject: cso: don't forget to release vertex elements state --- src/gallium/auxiliary/cso_cache/cso_context.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index f8cb01467c..6500891a10 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -289,6 +289,7 @@ void cso_release_all( struct cso_context *ctx ) ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); + ctx->pipe->bind_vertex_elements_state( ctx->pipe, NULL ); } for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { -- cgit v1.2.3 From 02716cf7d16543d5dedc6e550895d77139ad2432 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 9 Mar 2010 19:47:30 +0000 Subject: null: Add a null software winsys. One where framebuffer data will be read via texture transfers. Useful for e.g., python state tracker. --- configs/default | 2 +- src/gallium/winsys/SConscript | 4 + src/gallium/winsys/null/Makefile | 16 ++++ src/gallium/winsys/null/SConscript | 21 ++++++ src/gallium/winsys/null/null_sw_winsys.c | 124 +++++++++++++++++++++++++++++++ src/gallium/winsys/null/null_sw_winsys.h | 40 ++++++++++ 6 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 src/gallium/winsys/null/Makefile create mode 100644 src/gallium/winsys/null/SConscript create mode 100644 src/gallium/winsys/null/null_sw_winsys.c create mode 100644 src/gallium/winsys/null/null_sw_winsys.h (limited to 'src/gallium') diff --git a/configs/default b/configs/default index fb1a35522e..a6a92efe8f 100644 --- a/configs/default +++ b/configs/default @@ -100,7 +100,7 @@ GALLIUM_DIRS = auxiliary drivers state_trackers GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) -GALLIUM_WINSYS_DIRS = drm xlib +GALLIUM_WINSYS_DIRS = drm null xlib GALLIUM_TARGET_DIRS = libgl-xlib GALLIUM_WINSYS_DRM_DIRS = swrast GALLIUM_STATE_TRACKERS_DIRS = glx vega diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 30c3378dff..4567d17447 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -1,5 +1,9 @@ Import('*') +SConscript([ + 'null/SConscript', +]) + if env['dri']: SConscript([ 'drm/SConscript', diff --git a/src/gallium/winsys/null/Makefile b/src/gallium/winsys/null/Makefile new file mode 100644 index 0000000000..3a3fb75ab3 --- /dev/null +++ b/src/gallium/winsys/null/Makefile @@ -0,0 +1,16 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = ws_null + +LIBRARY_INCLUDES = \ + -I$(TOP)/src/gallium/include \ + -I$(TOP)/src/gallium/drivers \ + -I$(TOP)/src/gallium/auxiliary + +C_SOURCES = \ + null_sw_winsys.c + +include ../../Makefile.template + + diff --git a/src/gallium/winsys/null/SConscript b/src/gallium/winsys/null/SConscript new file mode 100644 index 0000000000..21837dc60c --- /dev/null +++ b/src/gallium/winsys/null/SConscript @@ -0,0 +1,21 @@ +####################################################################### +# SConscript for xlib winsys + + +Import('*') + +env = env.Clone() + +env.Append(CPPPATH = [ + '#/src/gallium/include', + '#/src/gallium/auxiliary', + '#/src/gallium/drivers', +]) + +ws_null = env.ConvenienceLibrary( + target = 'ws_null', + source = [ + 'null_sw_winsys.c', + ] +) +Export('ws_null') diff --git a/src/gallium/winsys/null/null_sw_winsys.c b/src/gallium/winsys/null/null_sw_winsys.c new file mode 100644 index 0000000000..d961d34860 --- /dev/null +++ b/src/gallium/winsys/null/null_sw_winsys.c @@ -0,0 +1,124 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + +/** + * @file + * Null software rasterizer winsys. + * + * There is no present support. Framebuffer data needs to be obtained via + * transfers. + * + * @author Jose Fonseca + */ + + +#include "pipe/p_format.h" +#include "util/u_memory.h" +#include "state_tracker/sw_winsys.h" +#include "null_sw_winsys.h" + + +static boolean +null_sw_is_displaytarget_format_supported(struct sw_winsys *ws, + enum pipe_format format ) +{ + return FALSE; +} + + +static void * +null_sw_displaytarget_map(struct sw_winsys *ws, + struct sw_displaytarget *dt, + unsigned flags ) +{ + assert(0); + return NULL; +} + + +static void +null_sw_displaytarget_unmap(struct sw_winsys *ws, + struct sw_displaytarget *dt ) +{ + assert(0); +} + + +static void +null_sw_displaytarget_destroy(struct sw_winsys *winsys, + struct sw_displaytarget *dt) +{ + assert(0); +} + + +static struct sw_displaytarget * +null_sw_displaytarget_create(struct sw_winsys *winsys, + enum pipe_format format, + unsigned width, unsigned height, + unsigned alignment, + unsigned *stride) +{ + return NULL; +} + + +static void +null_sw_displaytarget_display(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + void *context_private) +{ + assert(0); +} + + +static void +null_sw_destroy(struct sw_winsys *winsys) +{ + FREE(winsys); +} + + +struct sw_winsys * +null_sw_create(void) +{ + static struct sw_winsys *winsys; + + winsys = CALLOC_STRUCT(sw_winsys); + if (!winsys) + return NULL; + + winsys->destroy = null_sw_destroy; + winsys->is_displaytarget_format_supported = null_sw_is_displaytarget_format_supported; + winsys->displaytarget_create = null_sw_displaytarget_create; + winsys->displaytarget_map = null_sw_displaytarget_map; + winsys->displaytarget_unmap = null_sw_displaytarget_unmap; + winsys->displaytarget_display = null_sw_displaytarget_display; + winsys->displaytarget_destroy = null_sw_displaytarget_destroy; + + return winsys; +} diff --git a/src/gallium/winsys/null/null_sw_winsys.h b/src/gallium/winsys/null/null_sw_winsys.h new file mode 100644 index 0000000000..1986186feb --- /dev/null +++ b/src/gallium/winsys/null/null_sw_winsys.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef NULL_SW_WINSYS_H_ +#define NULL_SW_WINSYS_H_ + + +struct sw_winsys; + + +struct sw_winsys * +null_sw_create(void); + + +#endif /* NULL_SW_WINSYS_H_ */ -- cgit v1.2.3 From dc1e4cf87fdab5a57049fbf4180e3597d80323cd Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Mar 2010 19:14:34 +0100 Subject: svga: Don't do culling while the software pipeline is active. It does it for us, and additionally introduces potentially back-facing triangles. --- src/gallium/drivers/svga/svga_state_rss.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_state_rss.c b/src/gallium/drivers/svga/svga_state_rss.c index 107cc403b4..b7195d246b 100644 --- a/src/gallium/drivers/svga/svga_state_rss.c +++ b/src/gallium/drivers/svga/svga_state_rss.c @@ -191,15 +191,24 @@ static int emit_rss( struct svga_context *svga, EMIT_RS( svga, svga->curr.stencil_ref.ref_value[0], STENCILREF, fail ); } - if (dirty & SVGA_NEW_RAST) + if (dirty & (SVGA_NEW_RAST | SVGA_NEW_NEED_PIPELINE)) { const struct svga_rasterizer_state *curr = svga->curr.rast; + unsigned cullmode = curr->cullmode; /* Shademode: still need to rearrange index list to move * flat-shading PV first vertex. */ EMIT_RS( svga, curr->shademode, SHADEMODE, fail ); - EMIT_RS( svga, curr->cullmode, CULLMODE, fail ); + + /* Don't do culling while the software pipeline is active. It + * does it for us, and additionally introduces potentially + * back-facing triangles. + */ + if (svga->state.sw.need_pipeline) + cullmode = SVGA3D_FACE_NONE; + + EMIT_RS( svga, cullmode, CULLMODE, fail ); EMIT_RS( svga, curr->scissortestenable, SCISSORTESTENABLE, fail ); EMIT_RS( svga, curr->multisampleantialias, MULTISAMPLEANTIALIAS, fail ); EMIT_RS( svga, curr->lastpixel, LASTPIXEL, fail ); -- cgit v1.2.3 From fe14868d96d4820dba73c3a507d191b8a73c6870 Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Tue, 9 Mar 2010 22:03:24 +0200 Subject: drop stray XFree86Server, XGLServer --- src/gallium/include/pipe/p_compiler.h | 5 ----- src/mesa/glapi/glapi_getproc.c | 8 ++++---- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index b93b38310a..e2766d15cd 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -31,13 +31,8 @@ #include "p_config.h" -#ifndef XFree86Server #include #include -#else -#include "xf86_ansic.h" -#include "xf86_libc.h" -#endif #include #include diff --git a/src/mesa/glapi/glapi_getproc.c b/src/mesa/glapi/glapi_getproc.c index a6dbf173e8..2b89a8f4f4 100644 --- a/src/mesa/glapi/glapi_getproc.c +++ b/src/mesa/glapi/glapi_getproc.c @@ -53,7 +53,7 @@ # endif #endif -#if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) && !defined(XGLServer) +#if !defined(DISPATCH_FUNCTION_SIZE) && !defined(XFree86Server) # define NEED_FUNCTION_POINTER #endif @@ -112,7 +112,7 @@ extern const GLubyte gl_dispatch_functions_start[]; #endif /* USE_X86_ASM */ -#if !defined(XFree86Server) && !defined(XGLServer) +#if !defined(XFree86Server) /** * Return dispatch function address for the named static (built-in) function. @@ -140,7 +140,7 @@ get_static_proc_address(const char *funcName) } } -#endif /* !defined(XFree86Server) && !defined(XGLServer) */ +#endif /* !defined(XFree86Server) */ @@ -724,7 +724,7 @@ _glapi_get_proc_address(const char *funcName) } } -#if !defined( XFree86Server ) && !defined( XGLServer ) +#if !defined( XFree86Server ) /* search static functions */ { const _glapi_proc func = get_static_proc_address(funcName); -- cgit v1.2.3 From 1f92cf55e1d19864a51e620a14c6912e94cd14ea Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 10 Mar 2010 09:48:33 +0800 Subject: st/egl: Fix build errors in ximage backend after merge. This fixes assorted merge conflicts when master is merged to gallium-sw-api-2 in 0c96690a5b6e1c2d114e7ec5f1e9d60a4ff2a330. --- src/gallium/state_trackers/egl/x11/native_x11.c | 2 +- src/gallium/state_trackers/egl/x11/native_x11.h | 3 ++- src/gallium/state_trackers/egl/x11/native_ximage.c | 11 +++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/egl/x11/native_x11.c b/src/gallium/state_trackers/egl/x11/native_x11.c index 2b3edbc006..c6eb17ab1a 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.c +++ b/src/gallium/state_trackers/egl/x11/native_x11.c @@ -144,7 +144,7 @@ native_create_display(EGLNativeDisplayType dpy, EGLint level = (force_sw) ? _EGL_INFO : _EGL_WARNING; _eglLog(level, "use software fallback"); - ndpy = x11_create_ximage_display(dpy); + ndpy = x11_create_ximage_display(dpy, event_handler); } return ndpy; diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h index 21ed6a2e06..1566524926 100644 --- a/src/gallium/state_trackers/egl/x11/native_x11.h +++ b/src/gallium/state_trackers/egl/x11/native_x11.h @@ -29,7 +29,8 @@ #include "common/native.h" struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy); +x11_create_ximage_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler); struct native_display * x11_create_dri2_display(EGLNativeDisplayType dpy, diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 7d1462d4b7..544b3b4276 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -51,11 +51,11 @@ struct ximage_display { Display *dpy; boolean own_dpy; + struct native_event_handler *event_handler; + struct x11_screen *xscr; int xscr_number; - struct xm_driver *driver; - struct ximage_config *configs; int num_configs; }; @@ -138,7 +138,7 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf, switch (which) { case NATIVE_ATTACHMENT_FRONT_LEFT: case NATIVE_ATTACHMENT_FRONT_RIGHT: - templ.tex_usage |= PIPE_TEXTURE_USAGE_PRIMARY; + templ.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT; break; case NATIVE_ATTACHMENT_BACK_LEFT: case NATIVE_ATTACHMENT_BACK_RIGHT: @@ -615,7 +615,8 @@ ximage_display_destroy(struct native_display *ndpy) } struct native_display * -x11_create_ximage_display(EGLNativeDisplayType dpy) +x11_create_ximage_display(EGLNativeDisplayType dpy, + struct native_event_handler *event_handler) { struct ximage_display *xdpy; @@ -633,6 +634,8 @@ x11_create_ximage_display(EGLNativeDisplayType dpy) xdpy->own_dpy = TRUE; } + xdpy->event_handler = event_handler; + xdpy->xscr_number = DefaultScreen(xdpy->dpy); xdpy->xscr = x11_screen_create(xdpy->dpy, xdpy->xscr_number); if (!xdpy->xscr) { -- cgit v1.2.3 From 9a8342ebcd83a2022b3c9b9539c5b15ac56d6440 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 10 Mar 2010 10:12:45 +0800 Subject: winsys/drm: Handle circular dependencies in Makefile.egl. The libraries have circular dependencies. Use --start-group and --end-group when producing the final shared libraries. --- src/gallium/winsys/drm/Makefile.egl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/Makefile.egl b/src/gallium/winsys/drm/Makefile.egl index a006ad70b6..bc5dd3a53b 100644 --- a/src/gallium/winsys/drm/Makefile.egl +++ b/src/gallium/winsys/drm/Makefile.egl @@ -39,8 +39,10 @@ $(EGL_DISPLAY_LIBS): $(TOP)/$(LIB_DIR)/%.so: %.so define mklib-egl $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) $($(1)_ST) \ - $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $($(1)_LIBS) $(EGL_DRIVER_LIBS) + $(MKLIB_OPTIONS) $(EGL_DRIVER_OBJECTS) \ + -Wl,--start-group $($(1)_ST) $(EGL_DRIVER_PIPES) \ + $(GALLIUM_AUXILIARIES) -Wl,--end-group \ + $($(1)_LIBS) $(EGL_DRIVER_LIBS) endef egl_x11_$(EGL_DRIVER_NAME).so: $(EGL_DRIVER_OBJECTS) $(x11_ST) $(EGL_DRIVER_PIPES) $(GALLIUM_AUXILIARIES) Makefile -- cgit v1.2.3 From 007f25b3bde88de550d6ddba6a96769e4f3d5ce7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Tue, 9 Mar 2010 20:03:35 -0800 Subject: r300g: Reorder regs, save one dword. Or, put another way, save 10% on rendering calls. --- src/gallium/drivers/r300/r300_render.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 2605628c02..9c001ae186 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -183,7 +183,7 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, } } - dwords = 10 + count * vertex_size; + dwords = 9 + count * vertex_size; r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + dwords); r300_emit_buffer_validate(r300, FALSE, NULL); @@ -193,8 +193,9 @@ static void r300_emit_draw_arrays_immediate(struct r300_context *r300, OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); OUT_CS_REG(R300_VAP_VTX_SIZE, vertex_size); - OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0); - OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count - 1); + OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX, 2); + OUT_CS(count - 1); + OUT_CS(0); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_IMMD_2, count * vertex_size); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (count << 16) | r300_translate_primitive(mode)); @@ -238,15 +239,16 @@ static void r300_emit_draw_arrays(struct r300_context *r300, if (alt_num_verts) { assert(count < (1 << 24)); - BEGIN_CS(10); + BEGIN_CS(9); OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); } else { - BEGIN_CS(8); + BEGIN_CS(7); } OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); - OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, 0); - OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, count - 1); + OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX, 2); + OUT_CS(count - 1); + OUT_CS(0); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | r300_translate_primitive(mode) | @@ -281,15 +283,16 @@ static void r300_emit_draw_elements(struct r300_context *r300, maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); if (alt_num_verts) { - BEGIN_CS(16); + BEGIN_CS(15); OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count); } else { - BEGIN_CS(14); + BEGIN_CS(13); } OUT_CS_REG(R300_GA_COLOR_CONTROL, r300_provoking_vertex_fixes(r300, mode)); - OUT_CS_REG(R300_VAP_VF_MIN_VTX_INDX, minIndex); - OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, maxIndex); + OUT_CS_REG_SEQ(R300_VAP_VF_MAX_VTX_INDX, 2); + OUT_CS(maxIndex); + OUT_CS(minIndex); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0); if (indexSize == 4) { count_dwords = count; -- cgit v1.2.3 From ac2b35fd2d5008a39fa394b7b04fd29b899d3e55 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 11:45:08 +1000 Subject: nv50: use relocs rather than re-uploading TIC all the time --- src/gallium/drivers/nv50/nv50_context.h | 1 + src/gallium/drivers/nv50/nv50_state_validate.c | 3 +-- src/gallium/drivers/nv50/nv50_tex.c | 30 ++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index e91a61b27d..2cb5538c54 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -249,6 +249,7 @@ extern void nv50_so_init_sifc(struct nv50_context *nv50, unsigned offset, unsigned size); /* nv50_tex.c */ +extern void nv50_tex_relocs(struct nv50_context *); extern void nv50_tex_validate(struct nv50_context *); /* nv50_transfer.c */ diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index c974cc92dc..0d30957ee3 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -290,8 +290,7 @@ nv50_state_flush_notify(struct nouveau_channel *chan) { struct nv50_context *nv50 = chan->user_private; - if (nv50->state.tic_upload && !(nv50->dirty & NV50_NEW_TEXTURE)) - so_emit(chan, nv50->state.tic_upload); + nv50_tex_relocs(nv50); so_emit_reloc_markers(chan, nv50->state.fb); so_emit_reloc_markers(chan, nv50->state.vertprog); diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index de0560e20c..ed3440fcc1 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -24,6 +24,7 @@ #include "nv50_texture.h" #include "nouveau/nouveau_stateobj.h" +#include "nouveau/nouveau_reloc.h" #include "util/u_format.h" @@ -194,6 +195,35 @@ nv50_validate_textures(struct nv50_context *nv50, struct nouveau_stateobj *so, return TRUE; } +void +nv50_tex_relocs(struct nv50_context *nv50) +{ + struct nouveau_channel *chan = nv50->screen->tesla->channel; + int p, unit; + + p = PIPE_SHADER_FRAGMENT; + for (unit = 0; unit < nv50->miptree_nr[p]; unit++) { + if (!nv50->miptree[p][unit]) + continue; + nouveau_reloc_emit(chan, nv50->screen->tic, + ((p * 32) + unit) * 32, NULL, + nv50->miptree[p][unit]->base.bo, 0, 0, + NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | + NOUVEAU_BO_RD, 0, 0); + } + + p = PIPE_SHADER_VERTEX; + for (unit = 0; unit < nv50->miptree_nr[p]; unit++) { + if (!nv50->miptree[p][unit]) + continue; + nouveau_reloc_emit(chan, nv50->screen->tic, + ((p * 32) + unit) * 32, NULL, + nv50->miptree[p][unit]->base.bo, 0, 0, + NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | + NOUVEAU_BO_RD, 0, 0); + } +} + void nv50_tex_validate(struct nv50_context *nv50) { -- cgit v1.2.3 From 62ab89785b55e60b978dc2b32995676859299c80 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 14:26:25 +1000 Subject: nv50: rework state emission --- src/gallium/drivers/nv50/nv50_context.c | 42 +-- src/gallium/drivers/nv50/nv50_context.h | 39 +-- src/gallium/drivers/nv50/nv50_program.c | 31 +- src/gallium/drivers/nv50/nv50_screen.c | 4 +- src/gallium/drivers/nv50/nv50_state_validate.c | 430 ++++++++++++------------- src/gallium/drivers/nv50/nv50_tex.c | 7 +- src/gallium/drivers/nv50/nv50_vbo.c | 7 +- 7 files changed, 249 insertions(+), 311 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 7be12fcdef..eff012c14d 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -46,43 +46,13 @@ static void nv50_destroy(struct pipe_context *pipe) { struct nv50_context *nv50 = nv50_context(pipe); + int i; - if (nv50->state.fb) - so_ref(NULL, &nv50->state.fb); - if (nv50->state.blend) - so_ref(NULL, &nv50->state.blend); - if (nv50->state.blend_colour) - so_ref(NULL, &nv50->state.blend_colour); - if (nv50->state.zsa) - so_ref(NULL, &nv50->state.zsa); - if (nv50->state.rast) - so_ref(NULL, &nv50->state.rast); - if (nv50->state.stipple) - so_ref(NULL, &nv50->state.stipple); - if (nv50->state.scissor) - so_ref(NULL, &nv50->state.scissor); - if (nv50->state.viewport) - so_ref(NULL, &nv50->state.viewport); - if (nv50->state.tsc_upload) - so_ref(NULL, &nv50->state.tsc_upload); - if (nv50->state.tic_upload) - so_ref(NULL, &nv50->state.tic_upload); - if (nv50->state.vertprog) - so_ref(NULL, &nv50->state.vertprog); - if (nv50->state.fragprog) - so_ref(NULL, &nv50->state.fragprog); - if (nv50->state.geomprog) - so_ref(NULL, &nv50->state.geomprog); - if (nv50->state.fp_linkage) - so_ref(NULL, &nv50->state.fp_linkage); - if (nv50->state.gp_linkage) - so_ref(NULL, &nv50->state.gp_linkage); - if (nv50->state.vtxfmt) - so_ref(NULL, &nv50->state.vtxfmt); - if (nv50->state.vtxbuf) - so_ref(NULL, &nv50->state.vtxbuf); - if (nv50->state.vtxattr) - so_ref(NULL, &nv50->state.vtxattr); + for (i = 0; i < 64; i++) { + if (!nv50->state.hw[i]) + continue; + so_ref(NULL, &nv50->state.hw[i]); + } draw_destroy(nv50->draw); diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 2cb5538c54..5fa3911114 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -123,27 +123,11 @@ nv50_surface(struct pipe_surface *pt) } struct nv50_state { - unsigned dirty; + struct nouveau_stateobj *hw[64]; + uint64_t hw_dirty; - struct nouveau_stateobj *fb; - struct nouveau_stateobj *blend; - struct nouveau_stateobj *blend_colour; - struct nouveau_stateobj *zsa; - struct nouveau_stateobj *stencil_ref; - struct nouveau_stateobj *rast; - struct nouveau_stateobj *stipple; - struct nouveau_stateobj *scissor; unsigned scissor_enabled; - struct nouveau_stateobj *viewport; - struct nouveau_stateobj *tsc_upload; - struct nouveau_stateobj *tic_upload; unsigned miptree_nr[PIPE_SHADER_TYPES]; - struct nouveau_stateobj *vertprog; - struct nouveau_stateobj *fragprog; - struct nouveau_stateobj *geomprog; - struct nouveau_stateobj *fp_linkage; - struct nouveau_stateobj *gp_linkage; - struct nouveau_stateobj *vtxfmt; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; struct nouveau_stateobj *instbuf; @@ -224,18 +208,23 @@ extern void nv50_draw_elements_instanced(struct pipe_context *pipe, unsigned startInstance, unsigned instanceCount); extern void nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso); -extern void nv50_vbo_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj *nv50_vbo_validate(struct nv50_context *nv50); /* nv50_clear.c */ extern void nv50_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, double depth, unsigned stencil); /* nv50_program.c */ -extern void nv50_vertprog_validate(struct nv50_context *nv50); -extern void nv50_fragprog_validate(struct nv50_context *nv50); -extern void nv50_geomprog_validate(struct nv50_context *nv50); -extern void nv50_fp_linkage_validate(struct nv50_context *nv50); -extern void nv50_gp_linkage_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj * +nv50_vertprog_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj * +nv50_fragprog_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj * +nv50_geomprog_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj * +nv50_fp_linkage_validate(struct nv50_context *nv50); +extern struct nouveau_stateobj * +nv50_gp_linkage_validate(struct nv50_context *nv50); extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p); @@ -250,7 +239,7 @@ extern void nv50_so_init_sifc(struct nv50_context *nv50, /* nv50_tex.c */ extern void nv50_tex_relocs(struct nv50_context *); -extern void nv50_tex_validate(struct nv50_context *); +extern struct nouveau_stateobj *nv50_tex_validate(struct nv50_context *); /* nv50_transfer.c */ extern void diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 2372cbbef6..50bb982076 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -4270,7 +4270,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p) FREE(up); } -void +struct nouveau_stateobj * nv50_vertprog_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -4301,11 +4301,10 @@ nv50_vertprog_validate(struct nv50_context *nv50) so_data (so, p->cfg.high_temp); so_method(so, tesla, NV50TCL_VP_START_ID, 1); so_data (so, 0); /* program start offset */ - so_ref(so, &nv50->state.vertprog); - so_ref(NULL, &so); + return so; } -void +struct nouveau_stateobj * nv50_fragprog_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -4337,11 +4336,10 @@ nv50_fragprog_validate(struct nv50_context *nv50) so_data (so, p->cfg.regs[3]); so_method(so, tesla, NV50TCL_FP_START_ID, 1); so_data (so, 0); /* program start offset */ - so_ref(so, &nv50->state.fragprog); - so_ref(NULL, &so); + return so; } -void +struct nouveau_stateobj * nv50_geomprog_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -4373,8 +4371,7 @@ nv50_geomprog_validate(struct nv50_context *nv50) so_data (so, p->cfg.vert_count); so_method(so, tesla, NV50TCL_GP_START_ID, 1); so_data (so, 0); - so_ref(so, &nv50->state.geomprog); - so_ref(NULL, &so); + return so; } static uint32_t @@ -4454,7 +4451,7 @@ nv50_vec4_map(uint32_t *map32, int mid, uint8_t zval, uint32_t lin[4], return mid; } -void +struct nouveau_stateobj * nv50_fp_linkage_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -4580,8 +4577,7 @@ nv50_fp_linkage_validate(struct nv50_context *nv50) so_method(so, tesla, NV50TCL_GP_ENABLE, 1); so_data (so, (vp->type == PIPE_SHADER_GEOMETRY) ? 1 : 0); - so_ref(so, &nv50->state.fp_linkage); - so_ref(NULL, &so); + return so; } static int @@ -4615,7 +4611,7 @@ construct_vp_gp_mapping(uint32_t *map32, int m, return m; } -void +struct nouveau_stateobj * nv50_gp_linkage_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -4625,10 +4621,8 @@ nv50_gp_linkage_validate(struct nv50_context *nv50) uint32_t map[16]; int m = 0; - if (!gp) { - so_ref(NULL, &nv50->state.gp_linkage); - return; - } + if (!gp) + return NULL; memset(map, 0, sizeof(map)); m = construct_vp_gp_mapping(map, m, vp, gp); @@ -4646,8 +4640,7 @@ nv50_gp_linkage_validate(struct nv50_context *nv50) so_method(so, tesla, NV50TCL_VP_RESULT_MAP(0), m); so_datap (so, map, m); - so_ref(so, &nv50->state.gp_linkage); - so_ref(NULL, &so); + return so; } void diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index eed6031eaf..b530de64b6 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -215,9 +215,9 @@ nv50_pre_pipebuffer_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, /* Our vtxbuf got mapped, it can no longer be considered part of current * state, remove it to avoid emitting reloc markers. */ - if (ctx && ctx->state.vtxbuf && so_bo_is_reloc(ctx->state.vtxbuf, + if (ctx && ctx->state.hw[17] && so_bo_is_reloc(ctx->state.hw[17], nouveau_bo(pb))) { - so_ref(NULL, &ctx->state.vtxbuf); + so_ref(NULL, &ctx->state.hw[17]); ctx->dirty |= NV50_NEW_ARRAYS; } diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 0d30957ee3..abdb9a55c8 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -25,8 +25,8 @@ #include "nv50_context.h" #include "nouveau/nouveau_stateobj.h" -static void -nv50_state_validate_fb(struct nv50_context *nv50) +static struct nouveau_stateobj * +validate_fb(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *so = so_new(32, 79, 18); @@ -169,10 +169,8 @@ nv50_state_validate_fb(struct nv50_context *nv50) /* we set scissors to framebuffer size when they're 'turned off' */ nv50->dirty |= NV50_NEW_SCISSOR; - so_ref(NULL, &nv50->state.scissor); - - so_ref(so, &nv50->state.fb); - so_ref(NULL, &so); + so_ref(NULL, &nv50->state.hw[12]); + return so; } static void @@ -199,261 +197,251 @@ nv50_validate_samplers(struct nv50_context *nv50, struct nouveau_stateobj *so, } } -static void -nv50_state_emit(struct nv50_context *nv50) +static struct nouveau_stateobj * +validate_blend(struct nv50_context *nv50) { - struct nv50_screen *screen = nv50->screen; - struct nouveau_channel *chan = screen->base.channel; + struct nouveau_stateobj *so = NULL; + so_ref(nv50->blend->so, &so); + return so; +} - /* XXX: this is racy for multiple contexts active on separate - * threads. - */ - if (screen->cur_ctx != nv50) { - if (nv50->state.fb) - nv50->state.dirty |= NV50_NEW_FRAMEBUFFER; - if (nv50->state.blend) - nv50->state.dirty |= NV50_NEW_BLEND; - if (nv50->state.zsa) - nv50->state.dirty |= NV50_NEW_ZSA; - if (nv50->state.vertprog) - nv50->state.dirty |= NV50_NEW_VERTPROG; - if (nv50->state.fragprog) - nv50->state.dirty |= NV50_NEW_FRAGPROG; - if (nv50->state.geomprog) - nv50->state.dirty |= NV50_NEW_GEOMPROG; - if (nv50->state.rast) - nv50->state.dirty |= NV50_NEW_RASTERIZER; - if (nv50->state.blend_colour) - nv50->state.dirty |= NV50_NEW_BLEND_COLOUR; - if (nv50->state.stencil_ref) - nv50->state.dirty |= NV50_NEW_STENCIL_REF; - if (nv50->state.stipple) - nv50->state.dirty |= NV50_NEW_STIPPLE; - if (nv50->state.scissor) - nv50->state.dirty |= NV50_NEW_SCISSOR; - if (nv50->state.viewport) - nv50->state.dirty |= NV50_NEW_VIEWPORT; - if (nv50->state.tsc_upload) - nv50->state.dirty |= NV50_NEW_SAMPLER; - if (nv50->state.tic_upload) - nv50->state.dirty |= NV50_NEW_TEXTURE; - if (nv50->state.vtxfmt && nv50->state.vtxbuf) - nv50->state.dirty |= NV50_NEW_ARRAYS; - screen->cur_ctx = nv50; - } +static struct nouveau_stateobj * +validate_zsa(struct nv50_context *nv50) +{ + struct nouveau_stateobj *so = NULL; + so_ref(nv50->zsa->so, &so); + return so; +} - if (nv50->state.dirty & NV50_NEW_FRAMEBUFFER) - so_emit(chan, nv50->state.fb); - if (nv50->state.dirty & NV50_NEW_BLEND) - so_emit(chan, nv50->state.blend); - if (nv50->state.dirty & NV50_NEW_ZSA) - so_emit(chan, nv50->state.zsa); - if (nv50->state.dirty & NV50_NEW_VERTPROG) - so_emit(chan, nv50->state.vertprog); - if (nv50->state.dirty & NV50_NEW_FRAGPROG) - so_emit(chan, nv50->state.fragprog); - if (nv50->state.dirty & NV50_NEW_GEOMPROG && nv50->state.geomprog) - so_emit(chan, nv50->state.geomprog); - if (nv50->state.dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG | - NV50_NEW_GEOMPROG | NV50_NEW_RASTERIZER)) - so_emit(chan, nv50->state.fp_linkage); - if ((nv50->state.dirty & (NV50_NEW_VERTPROG | NV50_NEW_GEOMPROG)) - && nv50->state.gp_linkage) - so_emit(chan, nv50->state.gp_linkage); - if (nv50->state.dirty & NV50_NEW_RASTERIZER) - so_emit(chan, nv50->state.rast); - if (nv50->state.dirty & NV50_NEW_BLEND_COLOUR) - so_emit(chan, nv50->state.blend_colour); - if (nv50->state.dirty & NV50_NEW_STENCIL_REF) - so_emit(chan, nv50->state.stencil_ref); - if (nv50->state.dirty & NV50_NEW_STIPPLE) - so_emit(chan, nv50->state.stipple); - if (nv50->state.dirty & NV50_NEW_SCISSOR) - so_emit(chan, nv50->state.scissor); - if (nv50->state.dirty & NV50_NEW_VIEWPORT) - so_emit(chan, nv50->state.viewport); - if (nv50->state.dirty & NV50_NEW_SAMPLER) - so_emit(chan, nv50->state.tsc_upload); - if (nv50->state.dirty & NV50_NEW_TEXTURE) - so_emit(chan, nv50->state.tic_upload); - if (nv50->state.dirty & NV50_NEW_ARRAYS) { - so_emit(chan, nv50->state.vtxfmt); - so_emit(chan, nv50->state.vtxbuf); - if (nv50->state.vtxattr) - so_emit(chan, nv50->state.vtxattr); - } - nv50->state.dirty = 0; +static struct nouveau_stateobj * +validate_rast(struct nv50_context *nv50) +{ + struct nouveau_stateobj *so = NULL; + so_ref(nv50->rasterizer->so, &so); + return so; } -void -nv50_state_flush_notify(struct nouveau_channel *chan) +static struct nouveau_stateobj * +validate_blend_colour(struct nv50_context *nv50) { - struct nv50_context *nv50 = chan->user_private; + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_stateobj *so = so_new(1, 4, 0); + + so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4); + so_data (so, fui(nv50->blend_colour.color[0])); + so_data (so, fui(nv50->blend_colour.color[1])); + so_data (so, fui(nv50->blend_colour.color[2])); + so_data (so, fui(nv50->blend_colour.color[3])); + return so; +} - nv50_tex_relocs(nv50); +static struct nouveau_stateobj * +validate_stencil_ref(struct nv50_context *nv50) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_stateobj *so = so = so_new(2, 2, 0); - so_emit_reloc_markers(chan, nv50->state.fb); - so_emit_reloc_markers(chan, nv50->state.vertprog); - so_emit_reloc_markers(chan, nv50->state.fragprog); - so_emit_reloc_markers(chan, nv50->state.vtxbuf); - so_emit_reloc_markers(chan, nv50->screen->static_init); + so_method(so, tesla, NV50TCL_STENCIL_FRONT_FUNC_REF, 1); + so_data (so, nv50->stencil_ref.ref_value[0]); + so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 1); + so_data (so, nv50->stencil_ref.ref_value[1]); + return so; +} - if (nv50->state.instbuf) - so_emit_reloc_markers(chan, nv50->state.instbuf); +static struct nouveau_stateobj * +validate_stipple(struct nv50_context *nv50) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_stateobj *so = so_new(1, 32, 0); + int i; + + so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); + for (i = 0; i < 32; i++) + so_data(so, util_bswap32(nv50->stipple.stipple[i])); + return so; } -boolean -nv50_state_validate(struct nv50_context *nv50) +static struct nouveau_stateobj * +validate_scissor(struct nv50_context *nv50) { + struct pipe_rasterizer_state *rast = &nv50->rasterizer->pipe; + struct pipe_scissor_state *s = &nv50->scissor; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *so; - unsigned i; - if (nv50->dirty & NV50_NEW_FRAMEBUFFER) - nv50_state_validate_fb(nv50); + if (nv50->state.hw[12] && + (rast->scissor == 0 && nv50->state.scissor_enabled == 0)) + return NULL; + nv50->state.scissor_enabled = rast->scissor; - if (nv50->dirty & NV50_NEW_BLEND) - so_ref(nv50->blend->so, &nv50->state.blend); + so = so_new(1, 2, 0); + so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); + if (nv50->state.scissor_enabled) { + so_data(so, (s->maxx << 16) | s->minx); + so_data(so, (s->maxy << 16) | s->miny); + } else { + so_data(so, (nv50->framebuffer.width << 16)); + so_data(so, (nv50->framebuffer.height << 16)); + } - if (nv50->dirty & NV50_NEW_ZSA) - so_ref(nv50->zsa->so, &nv50->state.zsa); + return so; +} - if (nv50->dirty & (NV50_NEW_VERTPROG | NV50_NEW_VERTPROG_CB)) - nv50_vertprog_validate(nv50); +static struct nouveau_stateobj * +validate_viewport(struct nv50_context *nv50) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_stateobj *so = so_new(5, 9, 0); + + so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); + so_data (so, fui(nv50->viewport.translate[0])); + so_data (so, fui(nv50->viewport.translate[1])); + so_data (so, fui(nv50->viewport.translate[2])); + so_method(so, tesla, NV50TCL_VIEWPORT_SCALE_X(0), 3); + so_data (so, fui(nv50->viewport.scale[0])); + so_data (so, fui(nv50->viewport.scale[1])); + so_data (so, fui(nv50->viewport.scale[2])); + + so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1); + so_data (so, 1); + /* 0x0000 = remove whole primitive only (xyz) + * 0x1018 = remove whole primitive only (xy), clamp z + * 0x1080 = clip primitive (xyz) + * 0x1098 = clip primitive (xy), clamp z + */ + so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1); + so_data (so, 0x1080); + /* no idea what 0f90 does */ + so_method(so, tesla, 0x0f90, 1); + so_data (so, 0); - if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_FRAGPROG_CB)) - nv50_fragprog_validate(nv50); + return so; +} - if (nv50->dirty & (NV50_NEW_GEOMPROG | NV50_NEW_GEOMPROG_CB)) - nv50_geomprog_validate(nv50); +static struct nouveau_stateobj * +validate_sampler(struct nv50_context *nv50) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_stateobj *so; + unsigned nr = 0, i; - if (nv50->dirty & (NV50_NEW_FRAGPROG | NV50_NEW_VERTPROG | - NV50_NEW_GEOMPROG | NV50_NEW_RASTERIZER)) - nv50_fp_linkage_validate(nv50); + for (i = 0; i < PIPE_SHADER_TYPES; ++i) + nr += nv50->sampler_nr[i]; - if (nv50->dirty & (NV50_NEW_GEOMPROG | NV50_NEW_VERTPROG)) - nv50_gp_linkage_validate(nv50); + so = so_new(1 + 5 * PIPE_SHADER_TYPES, + 1 + 19 * PIPE_SHADER_TYPES + nr * 8, + PIPE_SHADER_TYPES * 2); - if (nv50->dirty & NV50_NEW_RASTERIZER) - so_ref(nv50->rasterizer->so, &nv50->state.rast); + nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); + nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT); - if (nv50->dirty & NV50_NEW_BLEND_COLOUR) { - so = so_new(1, 4, 0); - so_method(so, tesla, NV50TCL_BLEND_COLOR(0), 4); - so_data (so, fui(nv50->blend_colour.color[0])); - so_data (so, fui(nv50->blend_colour.color[1])); - so_data (so, fui(nv50->blend_colour.color[2])); - so_data (so, fui(nv50->blend_colour.color[3])); - so_ref(so, &nv50->state.blend_colour); - so_ref(NULL, &so); - } - - if (nv50->dirty & NV50_NEW_STENCIL_REF) { - so = so_new(2, 2, 0); - so_method(so, tesla, NV50TCL_STENCIL_FRONT_FUNC_REF, 1); - so_data (so, nv50->stencil_ref.ref_value[0]); - so_method(so, tesla, NV50TCL_STENCIL_BACK_FUNC_REF, 1); - so_data (so, nv50->stencil_ref.ref_value[1]); - so_ref(so, &nv50->state.stencil_ref); - so_ref(NULL, &so); - } + so_method(so, tesla, 0x1334, 1); /* flush TSC */ + so_data (so, 0); - if (nv50->dirty & NV50_NEW_STIPPLE) { - so = so_new(1, 32, 0); - so_method(so, tesla, NV50TCL_POLYGON_STIPPLE_PATTERN(0), 32); - for (i = 0; i < 32; i++) - so_data(so, util_bswap32(nv50->stipple.stipple[i])); - so_ref(so, &nv50->state.stipple); - so_ref(NULL, &so); - } + return so; +} - if (nv50->dirty & (NV50_NEW_SCISSOR | NV50_NEW_RASTERIZER)) { - struct pipe_rasterizer_state *rast = &nv50->rasterizer->pipe; - struct pipe_scissor_state *s = &nv50->scissor; +static struct nouveau_stateobj * +validate_vtxbuf(struct nv50_context *nv50) +{ + struct nouveau_stateobj *so = NULL; + so_ref(nv50->state.vtxbuf, &so); + return so; +} - if (nv50->state.scissor && - (rast->scissor == 0 && nv50->state.scissor_enabled == 0)) - goto scissor_uptodate; - nv50->state.scissor_enabled = rast->scissor; +static struct nouveau_stateobj * +validate_vtxattr(struct nv50_context *nv50) +{ + struct nouveau_stateobj *so = NULL; + so_ref(nv50->state.vtxattr, &so); + return so; +} - so = so_new(1, 2, 0); - so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); - if (nv50->state.scissor_enabled) { - so_data(so, (s->maxx << 16) | s->minx); - so_data(so, (s->maxy << 16) | s->miny); - } else { - so_data(so, (nv50->framebuffer.width << 16)); - so_data(so, (nv50->framebuffer.height << 16)); - } - so_ref(so, &nv50->state.scissor); - so_ref(NULL, &so); - nv50->state.dirty |= NV50_NEW_SCISSOR; - } -scissor_uptodate: - - if (nv50->dirty & (NV50_NEW_VIEWPORT | NV50_NEW_RASTERIZER)) { - if (nv50->state.viewport && - !(nv50->dirty & NV50_NEW_VIEWPORT)) - goto viewport_uptodate; - - so = so_new(5, 9, 0); - so_method(so, tesla, NV50TCL_VIEWPORT_TRANSLATE_X(0), 3); - so_data (so, fui(nv50->viewport.translate[0])); - so_data (so, fui(nv50->viewport.translate[1])); - so_data (so, fui(nv50->viewport.translate[2])); - so_method(so, tesla, NV50TCL_VIEWPORT_SCALE_X(0), 3); - so_data (so, fui(nv50->viewport.scale[0])); - so_data (so, fui(nv50->viewport.scale[1])); - so_data (so, fui(nv50->viewport.scale[2])); - - so_method(so, tesla, NV50TCL_VIEWPORT_TRANSFORM_EN, 1); - so_data (so, 1); - /* 0x0000 = remove whole primitive only (xyz) - * 0x1018 = remove whole primitive only (xy), clamp z - * 0x1080 = clip primitive (xyz) - * 0x1098 = clip primitive (xy), clamp z - */ - so_method(so, tesla, NV50TCL_VIEW_VOLUME_CLIP_CTRL, 1); - so_data (so, 0x1080); - /* no idea what 0f90 does */ - so_method(so, tesla, 0x0f90, 1); - so_data (so, 0); +struct state_validate { + struct nouveau_stateobj *(*func)(struct nv50_context *nv50); + unsigned states; +} validate_list[] = { + { validate_fb , NV50_NEW_FRAMEBUFFER }, + { validate_blend , NV50_NEW_BLEND }, + { validate_zsa , NV50_NEW_ZSA }, + { nv50_vertprog_validate , NV50_NEW_VERTPROG | NV50_NEW_VERTPROG_CB }, + { nv50_fragprog_validate , NV50_NEW_FRAGPROG | NV50_NEW_FRAGPROG_CB }, + { nv50_geomprog_validate , NV50_NEW_GEOMPROG | NV50_NEW_GEOMPROG_CB }, + { nv50_fp_linkage_validate, NV50_NEW_VERTPROG | NV50_NEW_GEOMPROG | + NV50_NEW_FRAGPROG | NV50_NEW_RASTERIZER }, + { nv50_gp_linkage_validate, NV50_NEW_VERTPROG | NV50_NEW_GEOMPROG }, + { validate_rast , NV50_NEW_RASTERIZER }, + { validate_blend_colour , NV50_NEW_BLEND_COLOUR }, + { validate_stencil_ref , NV50_NEW_STENCIL_REF }, + { validate_stipple , NV50_NEW_STIPPLE }, + { validate_scissor , NV50_NEW_SCISSOR | NV50_NEW_RASTERIZER }, + { validate_viewport , NV50_NEW_VIEWPORT }, + { validate_sampler , NV50_NEW_SAMPLER }, + { nv50_tex_validate , NV50_NEW_TEXTURE | NV50_NEW_SAMPLER }, + { nv50_vbo_validate , NV50_NEW_ARRAYS }, + { validate_vtxbuf , NV50_NEW_ARRAYS }, + { validate_vtxattr , NV50_NEW_ARRAYS }, + {} +}; +#define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0])) - so_ref(so, &nv50->state.viewport); - so_ref(NULL, &so); - nv50->state.dirty |= NV50_NEW_VIEWPORT; - } -viewport_uptodate: +void +nv50_state_flush_notify(struct nouveau_channel *chan) +{ + struct nv50_context *nv50 = chan->user_private; - if (nv50->dirty & NV50_NEW_SAMPLER) { - unsigned nr = 0; + nv50_tex_relocs(nv50); - for (i = 0; i < PIPE_SHADER_TYPES; ++i) - nr += nv50->sampler_nr[i]; + so_emit_reloc_markers(chan, nv50->state.hw[0]); /* fb */ + so_emit_reloc_markers(chan, nv50->state.hw[3]); /* vp */ + so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */ + so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */ + so_emit_reloc_markers(chan, nv50->screen->static_init); - so = so_new(1 + 5 * PIPE_SHADER_TYPES, - 1 + 19 * PIPE_SHADER_TYPES + nr * 8, - PIPE_SHADER_TYPES * 2); +#if 0 + if (nv50->state.instbuf) + so_emit_reloc_markers(chan, nv50->state.instbuf); +#endif +} - nv50_validate_samplers(nv50, so, PIPE_SHADER_VERTEX); - nv50_validate_samplers(nv50, so, PIPE_SHADER_FRAGMENT); +boolean +nv50_state_validate(struct nv50_context *nv50) +{ + struct nouveau_channel *chan = nv50->screen->base.channel; + int i; - so_method(so, tesla, 0x1334, 1); /* flush TSC */ - so_data (so, 0); + if (nv50->screen->cur_ctx != nv50) { + for (i = 0; i < validate_list_len; i++) { + if (nv50->state.hw[i]) + nv50->state.hw_dirty |= (1 << i); + } - so_ref(so, &nv50->state.tsc_upload); - so_ref(NULL, &so); + nv50->screen->cur_ctx = nv50; } - if (nv50->dirty & (NV50_NEW_TEXTURE | NV50_NEW_SAMPLER)) - nv50_tex_validate(nv50); + for (i = 0; i < validate_list_len; i++) { + struct state_validate *validate = &validate_list[i]; + struct nouveau_stateobj *so; + + if (!(nv50->dirty & validate->states)) + continue; - if (nv50->dirty & NV50_NEW_ARRAYS) - nv50_vbo_validate(nv50); + so = validate->func(nv50); + if (!so) + continue; - nv50->state.dirty |= nv50->dirty; + so_ref(so, &nv50->state.hw[i]); + so_ref(NULL, &so); + nv50->state.hw_dirty |= (1 << i); + } nv50->dirty = 0; - nv50_state_emit(nv50); + + while (nv50->state.hw_dirty) { + i = ffs(nv50->state.hw_dirty) - 1; + nv50->state.hw_dirty &= ~(1 << i); + + so_emit(chan, nv50->state.hw[i]); + } return TRUE; } diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index ed3440fcc1..4c48b12cd8 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -224,7 +224,7 @@ nv50_tex_relocs(struct nv50_context *nv50) } } -void +struct nouveau_stateobj * nv50_tex_validate(struct nv50_context *nv50) { struct nouveau_stateobj *so; @@ -247,12 +247,11 @@ nv50_tex_validate(struct nv50_context *nv50) so_ref(NULL, &so); NOUVEAU_ERR("failed tex validate\n"); - return; + return NULL; } so_method(so, tesla, 0x1330, 1); /* flush TIC */ so_data (so, 0); - so_ref(so, &nv50->state.tic_upload); - so_ref(NULL, &so); + return so; } diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index c1dcb93b48..3e540013c4 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -792,7 +792,7 @@ nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso) } } -void +struct nouveau_stateobj * nv50_vbo_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; @@ -801,7 +801,7 @@ nv50_vbo_validate(struct nv50_context *nv50) /* don't validate if Gallium took away our buffers */ if (nv50->vtxbuf_nr == 0) - return; + return NULL; nv50->vbo_fifo = 0; for (i = 0; i < nv50->vtxbuf_nr; ++i) @@ -875,12 +875,11 @@ nv50_vbo_validate(struct nv50_context *nv50) } nv50->state.vtxelt_nr = nv50->vtxelt->num_elements; - so_ref (vtxfmt, &nv50->state.vtxfmt); so_ref (vtxbuf, &nv50->state.vtxbuf); so_ref (vtxattr, &nv50->state.vtxattr); so_ref (NULL, &vtxbuf); - so_ref (NULL, &vtxfmt); so_ref (NULL, &vtxattr); + return vtxfmt; } typedef void (*pfn_push)(struct nouveau_channel *, void *); -- cgit v1.2.3 From e1d015fe222a3f6f942426c39fb1a17188df8d57 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 14:43:21 +1000 Subject: nv50: ensure enough room for state changes in current pushbuf Also allows the nv50_state_validate() caller to request a minimum amount of space that itself requires, not all callers accurately use this yet but the simple cases are now accounted for. Rendering will also be dropped on the floor if validate fails now. --- src/gallium/drivers/nv50/nv50_clear.c | 2 +- src/gallium/drivers/nv50/nv50_context.h | 2 +- src/gallium/drivers/nv50/nv50_state_validate.c | 39 ++++++++++++++++++-------- src/gallium/drivers/nv50/nv50_vbo.c | 12 +++++--- 4 files changed, 38 insertions(+), 17 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_clear.c b/src/gallium/drivers/nv50/nv50_clear.c index e0b2d2880b..8afc95c9fc 100644 --- a/src/gallium/drivers/nv50/nv50_clear.c +++ b/src/gallium/drivers/nv50/nv50_clear.c @@ -36,7 +36,7 @@ nv50_clear(struct pipe_context *pipe, unsigned buffers, struct pipe_framebuffer_state *fb = &nv50->framebuffer; unsigned mode = 0, i; - if (!nv50_state_validate(nv50)) + if (!nv50_state_validate(nv50, 64)) return; if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) { diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 5fa3911114..ef0e99f0b1 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -229,7 +229,7 @@ extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p); /* nv50_state_validate.c */ -extern boolean nv50_state_validate(struct nv50_context *nv50); +extern boolean nv50_state_validate(struct nv50_context *nv50, unsigned dwords); extern void nv50_state_flush_notify(struct nouveau_channel *chan); extern void nv50_so_init_sifc(struct nv50_context *nv50, diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index abdb9a55c8..b01a3d87de 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -405,19 +405,11 @@ nv50_state_flush_notify(struct nouveau_channel *chan) } boolean -nv50_state_validate(struct nv50_context *nv50) +nv50_state_validate(struct nv50_context *nv50, unsigned nr_dwords) { struct nouveau_channel *chan = nv50->screen->base.channel; - int i; - - if (nv50->screen->cur_ctx != nv50) { - for (i = 0; i < validate_list_len; i++) { - if (nv50->state.hw[i]) - nv50->state.hw_dirty |= (1 << i); - } - - nv50->screen->cur_ctx = nv50; - } + unsigned nr_relocs = 0; + int ret, i; for (i = 0; i < validate_list_len; i++) { struct state_validate *validate = &validate_list[i]; @@ -430,12 +422,37 @@ nv50_state_validate(struct nv50_context *nv50) if (!so) continue; + nr_dwords += (so->total + so->cur); + nr_relocs += so->cur_reloc; + so_ref(so, &nv50->state.hw[i]); so_ref(NULL, &so); nv50->state.hw_dirty |= (1 << i); } nv50->dirty = 0; + if (nv50->screen->cur_ctx != nv50) { + for (i = 0; i < validate_list_len; i++) { + if (!nv50->state.hw[i] || + (nv50->state.hw_dirty & (1 << i))) + continue; + + nr_dwords += (nv50->state.hw[i]->total + + nv50->state.hw[i]->cur); + nr_relocs += nv50->state.hw[i]->cur_reloc; + nv50->state.hw_dirty |= (1 << i); + } + + nv50->screen->cur_ctx = nv50; + } + + ret = MARK_RING(chan, nr_dwords, nr_relocs); + if (ret) { + debug_printf("MARK_RING(%d, %d) failed: %d\n", + nr_dwords, nr_relocs, ret); + return FALSE; + } + while (nv50->state.hw_dirty) { i = ffs(nv50->state.hw_dirty) - 1; nv50->state.hw_dirty &= ~(1 << i); diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 3e540013c4..ce2e479cfd 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -425,7 +425,8 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) nv50_upload_user_vbufs(nv50); - nv50_state_validate(nv50); + if (!nv50_state_validate(nv50, 0)) + return; nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); @@ -477,7 +478,8 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, struct nouveau_grobj *tesla = nv50->screen->tesla; boolean ret; - nv50_state_validate(nv50); + if (!nv50_state_validate(nv50, 11)) + return; BEGIN_RING(chan, tesla, 0x142c, 1); OUT_RING (chan, 0); @@ -633,7 +635,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) nv50_upload_user_vbufs(nv50); - nv50_state_validate(nv50); + if (!nv50_state_validate(nv50, 0)) + return; nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); @@ -677,7 +680,8 @@ nv50_draw_elements(struct pipe_context *pipe, struct pipe_screen *pscreen = pipe->screen; void *map; - nv50_state_validate(nv50); + if (!nv50_state_validate(nv50, 14)) + return; BEGIN_RING(chan, tesla, 0x142c, 1); OUT_RING (chan, 0); -- cgit v1.2.3 From c926ed0e76bdbf842170f9396856e9cedb6e718f Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 14:55:54 +1000 Subject: nv50: always emit dummy relocs for all still-referenced buffers --- src/gallium/drivers/nv50/nv50_state_validate.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index b01a3d87de..12e427d38b 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -405,10 +405,10 @@ nv50_state_flush_notify(struct nouveau_channel *chan) } boolean -nv50_state_validate(struct nv50_context *nv50, unsigned nr_dwords) +nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) { struct nouveau_channel *chan = nv50->screen->base.channel; - unsigned nr_relocs = 0; + unsigned nr_relocs = 128, nr_dwords = wait_dwords + 128; int ret, i; for (i = 0; i < validate_list_len; i++) { @@ -460,6 +460,12 @@ nv50_state_validate(struct nv50_context *nv50, unsigned nr_dwords) so_emit(chan, nv50->state.hw[i]); } + /* Yes, really, we need to do this. If a buffer that is referenced + * on the hardware isn't part of changed state above, without doing + * this the kernel is given no clue that the buffer is being used + * still. This can cause all sorts of fun issues. + */ + nv50_state_flush_notify(chan); return TRUE; } -- cgit v1.2.3 From 3f804b0f199680e981c70376f55ecc5fe8d16aec Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 14:59:28 +1000 Subject: nv50: remove horrific abuse of nouveau_channel.flush_notify Really though, using this at all is just not a good idea in the 3D driver. I'm almost certain the hardware will not like a reloc appearing between begin()/end().. Anyways, this is still better than before, more fixes to come.. --- src/gallium/drivers/nv50/nv50_context.c | 1 - src/gallium/drivers/nv50/nv50_vbo.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index eff012c14d..0eb42f323f 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -93,7 +93,6 @@ nv50_create(struct pipe_screen *pscreen, void *priv) nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; screen->base.channel->user_private = nv50; - screen->base.channel->flush_notify = nv50_state_flush_notify; nv50_init_surface_functions(nv50); nv50_init_state_functions(nv50); diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index ce2e479cfd..215dfb74fc 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -427,6 +427,7 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 0)) return; + chan->flush_notify = nv50_state_flush_notify; nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); @@ -464,6 +465,8 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); } + + chan->flush_notify = NULL; nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); @@ -480,6 +483,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, if (!nv50_state_validate(nv50, 11)) return; + chan->flush_notify = nv50_state_flush_notify; BEGIN_RING(chan, tesla, 0x142c, 1); OUT_RING (chan, 0); @@ -500,6 +504,7 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + chan->flush_notify = NULL; nv50_unmap_vbufs(nv50); /* XXX: not sure what to do if ret != TRUE: flush and retry? @@ -637,6 +642,7 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 0)) return; + chan->flush_notify = nv50_state_flush_notify; nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); @@ -664,6 +670,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); } + + chan->flush_notify = NULL; nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); @@ -682,6 +690,7 @@ nv50_draw_elements(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 14)) return; + chan->flush_notify = nv50_state_flush_notify; BEGIN_RING(chan, tesla, 0x142c, 1); OUT_RING (chan, 0); @@ -720,6 +729,7 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); + chan->flush_notify = NULL; } static INLINE boolean -- cgit v1.2.3 From 2a84db24b33993844ba5e5c036edca78718d2425 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 3 Mar 2010 15:02:53 +1000 Subject: nv50: remove pre_pipebuffer_map hack.... --- src/gallium/drivers/nv50/nv50_screen.c | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index b530de64b6..2a1b64ffdc 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -202,28 +202,6 @@ nv50_screen_destroy(struct pipe_screen *pscreen) FREE(screen); } -static int -nv50_pre_pipebuffer_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, - unsigned usage) -{ - struct nv50_screen *screen = nv50_screen(pscreen); - struct nv50_context *ctx = screen->cur_ctx; - - if (!(pb->usage & PIPE_BUFFER_USAGE_VERTEX)) - return 0; - - /* Our vtxbuf got mapped, it can no longer be considered part of current - * state, remove it to avoid emitting reloc markers. - */ - if (ctx && ctx->state.hw[17] && so_bo_is_reloc(ctx->state.hw[17], - nouveau_bo(pb))) { - so_ref(NULL, &ctx->state.hw[17]); - ctx->dirty |= NV50_NEW_ARRAYS; - } - - return 0; -} - struct pipe_screen * nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) { @@ -252,7 +230,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) pscreen->get_paramf = nv50_screen_get_paramf; pscreen->is_format_supported = nv50_screen_is_format_supported; pscreen->context_create = nv50_create; - screen->base.pre_pipebuffer_map_callback = nv50_pre_pipebuffer_map; nv50_screen_init_miptree_functions(pscreen); nv50_transfer_init_screen_functions(pscreen); -- cgit v1.2.3 From 0e6af1fcaaca6be94a1a0aba287a569299e27295 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Mar 2010 09:52:47 +1000 Subject: nv50: avoid unnecessary vp/gp/fp state changes --- src/gallium/drivers/nv50/nv50_program.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 50bb982076..c857816b31 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -4286,6 +4286,9 @@ nv50_vertprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); + if (!(nv50->dirty & NV50_NEW_VERTPROG)) + return NULL; + so = so_new(5, 7, 2); so_method(so, tesla, NV50TCL_VP_ADDRESS_HIGH, 2); so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | @@ -4320,6 +4323,9 @@ nv50_fragprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); + if (!(nv50->dirty & NV50_NEW_FRAGPROG)) + return NULL; + so = so_new(6, 7, 2); so_method(so, tesla, NV50TCL_FP_ADDRESS_HIGH, 2); so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | @@ -4355,6 +4361,9 @@ nv50_geomprog_validate(struct nv50_context *nv50) nv50_program_validate_data(nv50, p); nv50_program_validate_code(nv50, p); + if (!(nv50->dirty & NV50_NEW_GEOMPROG)) + return NULL; + so = so_new(6, 7, 2); so_method(so, tesla, NV50TCL_GP_ADDRESS_HIGH, 2); so_reloc (so, p->bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | -- cgit v1.2.3 From 885d2eceb1517fa11be902ef826de3ba8620d085 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Mar 2010 10:55:50 +1000 Subject: nv50: move magic 0x142c stuff to after state emission --- src/gallium/drivers/nv50/nv50_state_validate.c | 9 ++++++++- src/gallium/drivers/nv50/nv50_vbo.c | 10 ---------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 12e427d38b..0f27605372 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -408,7 +408,8 @@ boolean nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) { struct nouveau_channel *chan = nv50->screen->base.channel; - unsigned nr_relocs = 128, nr_dwords = wait_dwords + 128; + struct nouveau_grobj *tesla = nv50->screen->tesla; + unsigned nr_relocs = 128, nr_dwords = wait_dwords + 128 + 4; int ret, i; for (i = 0; i < validate_list_len; i++) { @@ -466,6 +467,12 @@ nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) * still. This can cause all sorts of fun issues. */ nv50_state_flush_notify(chan); + + /* No idea.. */ + BEGIN_RING(chan, tesla, 0x142c, 1); + OUT_RING (chan, 0); + BEGIN_RING(chan, tesla, 0x142c, 1); + OUT_RING (chan, 0); return TRUE; } diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 215dfb74fc..c099afe212 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -485,11 +485,6 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, return; chan->flush_notify = nv50_state_flush_notify; - BEGIN_RING(chan, tesla, 0x142c, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, 0x142c, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); @@ -692,11 +687,6 @@ nv50_draw_elements(struct pipe_context *pipe, return; chan->flush_notify = nv50_state_flush_notify; - BEGIN_RING(chan, tesla, 0x142c, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, 0x142c, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); -- cgit v1.2.3 From 2b8c0cf16959c07341309484da41b2e9a17e5266 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Mar 2010 11:13:51 +1000 Subject: nv50: make use of scissor enable/disable method --- src/gallium/drivers/nv50/nv50_context.h | 1 - src/gallium/drivers/nv50/nv50_screen.c | 4 ---- src/gallium/drivers/nv50/nv50_state.c | 5 ++++- src/gallium/drivers/nv50/nv50_state_validate.c | 23 ++++------------------- 4 files changed, 8 insertions(+), 25 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index ef0e99f0b1..973fdd23a2 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -126,7 +126,6 @@ struct nv50_state { struct nouveau_stateobj *hw[64]; uint64_t hw_dirty; - unsigned scissor_enabled; unsigned miptree_nr[PIPE_SHADER_TYPES]; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 2a1b64ffdc..114ae9b386 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -485,10 +485,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_method(so, screen->tesla, NV50TCL_LINKED_TSC, 1); so_data (so, 1); - /* activate first scissor rectangle */ - so_method(so, screen->tesla, NV50TCL_SCISSOR_ENABLE(0), 1); - so_data (so, 1); - so_method(so, screen->tesla, NV50TCL_EDGEFLAG_ENABLE, 1); so_data (so, 1); /* default edgeflag to TRUE */ diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index ffbf3473a1..b0e5552eff 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -302,7 +302,7 @@ static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { - struct nouveau_stateobj *so = so_new(15, 21, 0); + struct nouveau_stateobj *so = so_new(16, 22, 0); struct nouveau_grobj *tesla = nv50_context(pipe)->screen->tesla; struct nv50_rasterizer_stateobj *rso = CALLOC_STRUCT(nv50_rasterizer_stateobj); @@ -314,6 +314,9 @@ nv50_rasterizer_state_create(struct pipe_context *pipe, * - point_sprite / sprite_coord_mode */ + so_method(so, tesla, NV50TCL_SCISSOR_ENABLE(0), 1); + so_data (so, cso->scissor); + so_method(so, tesla, NV50TCL_SHADE_MODEL, 1); so_data (so, cso->flatshade ? NV50TCL_SHADE_MODEL_FLAT : NV50TCL_SHADE_MODEL_SMOOTH); diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 0f27605372..2aaee31c0e 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -167,9 +167,6 @@ validate_fb(struct nv50_context *nv50) so_data (so, w << 16); so_data (so, h << 16); - /* we set scissors to framebuffer size when they're 'turned off' */ - nv50->dirty |= NV50_NEW_SCISSOR; - so_ref(NULL, &nv50->state.hw[12]); return so; } @@ -264,26 +261,14 @@ validate_stipple(struct nv50_context *nv50) static struct nouveau_stateobj * validate_scissor(struct nv50_context *nv50) { - struct pipe_rasterizer_state *rast = &nv50->rasterizer->pipe; - struct pipe_scissor_state *s = &nv50->scissor; struct nouveau_grobj *tesla = nv50->screen->tesla; + struct pipe_scissor_state *s = &nv50->scissor; struct nouveau_stateobj *so; - if (nv50->state.hw[12] && - (rast->scissor == 0 && nv50->state.scissor_enabled == 0)) - return NULL; - nv50->state.scissor_enabled = rast->scissor; - so = so_new(1, 2, 0); so_method(so, tesla, NV50TCL_SCISSOR_HORIZ(0), 2); - if (nv50->state.scissor_enabled) { - so_data(so, (s->maxx << 16) | s->minx); - so_data(so, (s->maxy << 16) | s->miny); - } else { - so_data(so, (nv50->framebuffer.width << 16)); - so_data(so, (nv50->framebuffer.height << 16)); - } - + so_data (so, (s->maxx << 16) | s->minx); + so_data (so, (s->maxy << 16) | s->miny); return so; } @@ -374,7 +359,7 @@ struct state_validate { { validate_blend_colour , NV50_NEW_BLEND_COLOUR }, { validate_stencil_ref , NV50_NEW_STENCIL_REF }, { validate_stipple , NV50_NEW_STIPPLE }, - { validate_scissor , NV50_NEW_SCISSOR | NV50_NEW_RASTERIZER }, + { validate_scissor , NV50_NEW_SCISSOR }, { validate_viewport , NV50_NEW_VIEWPORT }, { validate_sampler , NV50_NEW_SAMPLER }, { nv50_tex_validate , NV50_NEW_TEXTURE | NV50_NEW_SAMPLER }, -- cgit v1.2.3 From a527716e81a81f73c73d3744b4803c27a053ade2 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Mar 2010 13:47:41 +1000 Subject: nv50: rip out inline push draw paths temporarily --- src/gallium/drivers/nv50/nv50_context.h | 2 - src/gallium/drivers/nv50/nv50_vbo.c | 561 +------------------------------- 2 files changed, 12 insertions(+), 551 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 973fdd23a2..15f33fa4f4 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -163,8 +163,6 @@ struct nv50_context { unsigned sampler_nr[PIPE_SHADER_TYPES]; struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; unsigned miptree_nr[PIPE_SHADER_TYPES]; - - uint16_t vbo_fifo; }; static INLINE struct nv50_context * diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index c099afe212..bab9530852 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -27,18 +27,6 @@ #include "nv50_context.h" -static boolean -nv50_push_elements_u08(struct nv50_context *, uint8_t *, unsigned); - -static boolean -nv50_push_elements_u16(struct nv50_context *, uint16_t *, unsigned); - -static boolean -nv50_push_elements_u32(struct nv50_context *, uint32_t *, unsigned); - -static boolean -nv50_push_arrays(struct nv50_context *, unsigned, unsigned); - #define NV50_USING_LOATHED_EDGEFLAG(ctx) ((ctx)->vertprog->cfg.edgeflag_in < 16) static INLINE unsigned @@ -162,61 +150,6 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve) return (hw_type | hw_size); } -/* For instanced drawing from user buffers, hitting the FIFO repeatedly - * with the same vertex data is probably worse than uploading all data. - */ -static boolean -nv50_upload_vtxbuf(struct nv50_context *nv50, unsigned i) -{ - struct nv50_screen *nscreen = nv50->screen; - struct pipe_screen *pscreen = &nscreen->base.base; - struct pipe_buffer *buf = nscreen->strm_vbuf[i]; - struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; - uint8_t *src; - unsigned size = align(vb->buffer->size, 4096); - - if (buf && buf->size < size) - pipe_buffer_reference(&nscreen->strm_vbuf[i], NULL); - - if (!nscreen->strm_vbuf[i]) { - nscreen->strm_vbuf[i] = pipe_buffer_create( - pscreen, 0, PIPE_BUFFER_USAGE_VERTEX, size); - buf = nscreen->strm_vbuf[i]; - } - - src = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ); - if (!src) - return FALSE; - src += vb->buffer_offset; - - size = (vb->max_index + 1) * vb->stride + 16; /* + 16 is for stride 0 */ - if (vb->buffer_offset + size > vb->buffer->size) - size = vb->buffer->size - vb->buffer_offset; - - pipe_buffer_write(pscreen, buf, vb->buffer_offset, size, src); - pipe_buffer_unmap(pscreen, vb->buffer); - - vb->buffer = buf; /* don't pipe_reference, this is a private copy */ - return TRUE; -} - -static void -nv50_upload_user_vbufs(struct nv50_context *nv50) -{ - unsigned i; - - if (nv50->vbo_fifo) - nv50->dirty |= NV50_NEW_ARRAYS; - if (!(nv50->dirty & NV50_NEW_ARRAYS)) - return; - - for (i = 0; i < nv50->vtxbuf_nr; ++i) { - if (nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX) - continue; - nv50_upload_vtxbuf(nv50, i); - } -} - static void nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) { @@ -257,36 +190,6 @@ nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) } } -static unsigned -init_per_instance_arrays_immd(struct nv50_context *nv50, - unsigned startInstance, - unsigned pos[16], unsigned step[16]) -{ - struct nouveau_bo *bo; - unsigned i, b, count = 0; - - for (i = 0; i < nv50->vtxelt->num_elements; ++i) { - if (!nv50->vtxelt->pipe[i].instance_divisor) - continue; - ++count; - b = nv50->vtxelt->pipe[i].vertex_buffer_index; - - pos[i] = nv50->vtxelt->pipe[i].src_offset + - nv50->vtxbuf[b].buffer_offset + - startInstance * nv50->vtxbuf[b].stride; - step[i] = startInstance % - nv50->vtxelt->pipe[i].instance_divisor; - - bo = nouveau_bo(nv50->vtxbuf[b].buffer); - if (!bo->map) - nouveau_bo_map(bo, NOUVEAU_BO_RD); - - nv50_set_static_vtxattr(nv50, i, (uint8_t *)bo->map + pos[i]); - } - - return count; -} - static unsigned init_per_instance_arrays(struct nv50_context *nv50, unsigned startInstance, @@ -299,10 +202,6 @@ init_per_instance_arrays(struct nv50_context *nv50, unsigned i, b, count = 0, num_elements = nv50->vtxelt->num_elements; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; - if (nv50->vbo_fifo) - return init_per_instance_arrays_immd(nv50, startInstance, - pos, step); - so = so_new(num_elements, num_elements * 2, num_elements * 2); for (i = 0; i < nv50->vtxelt->num_elements; ++i) { @@ -338,28 +237,6 @@ init_per_instance_arrays(struct nv50_context *nv50, return count; } -static void -step_per_instance_arrays_immd(struct nv50_context *nv50, - unsigned pos[16], unsigned step[16]) -{ - struct nouveau_bo *bo; - unsigned i, b; - - for (i = 0; i < nv50->vtxelt->num_elements; ++i) { - if (!nv50->vtxelt->pipe[i].instance_divisor) - continue; - if (++step[i] != nv50->vtxelt->pipe[i].instance_divisor) - continue; - b = nv50->vtxelt->pipe[i].vertex_buffer_index; - bo = nouveau_bo(nv50->vtxbuf[b].buffer); - - step[i] = 0; - pos[i] += nv50->vtxbuf[b].stride; - - nv50_set_static_vtxattr(nv50, i, (uint8_t *)bo->map + pos[i]); - } -} - static void step_per_instance_arrays(struct nv50_context *nv50, unsigned pos[16], unsigned step[16]) @@ -371,11 +248,6 @@ step_per_instance_arrays(struct nv50_context *nv50, unsigned i, b, num_elements = nv50->vtxelt->num_elements; const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; - if (nv50->vbo_fifo) { - step_per_instance_arrays_immd(nv50, pos, step); - return; - } - so = so_new(num_elements, num_elements * 2, num_elements * 2); for (i = 0; i < nv50->vtxelt->num_elements; ++i) { @@ -401,16 +273,6 @@ step_per_instance_arrays(struct nv50_context *nv50, so_emit(chan, nv50->state.instbuf); } -static INLINE void -nv50_unmap_vbufs(struct nv50_context *nv50) -{ - unsigned i; - - for (i = 0; i < nv50->vtxbuf_nr; ++i) - if (nouveau_bo(nv50->vtxbuf[i].buffer)->map) - nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer)); -} - void nv50_draw_arrays_instanced(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count, @@ -422,9 +284,6 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, unsigned i, nz_divisors; unsigned step[16], pos[16]; - if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) - nv50_upload_user_vbufs(nv50); - if (!nv50_state_validate(nv50, 0)) return; chan->flush_notify = nv50_state_flush_notify; @@ -437,14 +296,9 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); - - if (nv50->vbo_fifo) - nv50_push_arrays(nv50, start, count); - else { - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); - } + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); @@ -454,20 +308,14 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode) | (1 << 28)); - - if (nv50->vbo_fifo) - nv50_push_arrays(nv50, start, count); - else { - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); - } + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); } chan->flush_notify = NULL; - nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); } @@ -479,7 +327,6 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - boolean ret; if (!nv50_state_validate(nv50, 11)) return; @@ -487,24 +334,13 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); - - if (nv50->vbo_fifo) - ret = nv50_push_arrays(nv50, start, count); - else { - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); - ret = TRUE; - } + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); + OUT_RING (chan, start); + OUT_RING (chan, count); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); chan->flush_notify = NULL; - nv50_unmap_vbufs(nv50); - - /* XXX: not sure what to do if ret != TRUE: flush and retry? - */ - assert(ret); } static INLINE boolean @@ -516,9 +352,6 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, map += start; - if (nv50->vbo_fifo) - return nv50_push_elements_u08(nv50, map, count); - if (count & 1) { BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1); OUT_RING (chan, map[0]); @@ -549,9 +382,6 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, map += start; - if (nv50->vbo_fifo) - return nv50_push_elements_u16(nv50, map, count); - if (count & 1) { BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1); OUT_RING (chan, map[0]); @@ -582,9 +412,6 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, map += start; - if (nv50->vbo_fifo) - return nv50_push_elements_u32(nv50, map, count); - while (count) { unsigned nr = count > 2047 ? 2047 : count; @@ -632,9 +459,6 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); - if (!NV50_USING_LOATHED_EDGEFLAG(nv50)) - nv50_upload_user_vbufs(nv50); - if (!nv50_state_validate(nv50, 0)) return; chan->flush_notify = nv50_state_flush_notify; @@ -667,7 +491,6 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, } chan->flush_notify = NULL; - nv50_unmap_vbufs(nv50); so_ref(NULL, &nv50->state.instbuf); } @@ -690,13 +513,13 @@ nv50_draw_elements(struct pipe_context *pipe, BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); - if (!nv50->vbo_fifo && indexSize == 4) { + if (indexSize == 4) { BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x30000, 0); OUT_RING (chan, count); nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer), start << 2, count << 2); } else - if (!nv50->vbo_fifo && indexSize == 2) { + if (indexSize == 2) { unsigned vb_start = (start & ~1); unsigned vb_end = (start + count + 1) & ~1; unsigned dwords = (vb_end - vb_start) >> 1; @@ -713,7 +536,6 @@ nv50_draw_elements(struct pipe_context *pipe, map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); nv50_draw_elements_inline(nv50, map, indexSize, start, count); - nv50_unmap_vbufs(nv50); pipe_buffer_unmap(pscreen, indexBuffer); } @@ -806,15 +628,8 @@ nv50_vbo_validate(struct nv50_context *nv50) /* don't validate if Gallium took away our buffers */ if (nv50->vtxbuf_nr == 0) return NULL; - nv50->vbo_fifo = 0; - for (i = 0; i < nv50->vtxbuf_nr; ++i) - if (nv50->vtxbuf[i].stride && - !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX)) - nv50->vbo_fifo = 0xffff; - - if (NV50_USING_LOATHED_EDGEFLAG(nv50)) - nv50->vbo_fifo = 0xffff; /* vertprog can't set edgeflag */ + assert(!NV50_USING_LOATHED_EDGEFLAG(nv50)); n_ve = MAX2(nv50->vtxelt->num_elements, nv50->state.vtxelt_nr); @@ -837,19 +652,9 @@ nv50_vbo_validate(struct nv50_context *nv50) so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); so_data (vtxbuf, 0); - - nv50->vbo_fifo &= ~(1 << i); continue; } - if (nv50->vbo_fifo) { - so_data (vtxfmt, hw | - (ve->instance_divisor ? (1 << 4) : i)); - so_method(vtxbuf, tesla, - NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); - so_data (vtxbuf, 0); - continue; - } so_data(vtxfmt, hw | i); so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3); @@ -886,346 +691,4 @@ nv50_vbo_validate(struct nv50_context *nv50) return vtxfmt; } -typedef void (*pfn_push)(struct nouveau_channel *, void *); - -struct nv50_vbo_emitctx -{ - pfn_push push[16]; - uint8_t *map[16]; - unsigned stride[16]; - unsigned nr_ve; - unsigned vtx_dwords; - unsigned vtx_max; - - float edgeflag; - unsigned ve_edgeflag; -}; -static INLINE void -emit_vtx_next(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit) -{ - unsigned i; - - for (i = 0; i < emit->nr_ve; ++i) { - emit->push[i](chan, emit->map[i]); - emit->map[i] += emit->stride[i]; - } -} - -static INLINE void -emit_vtx(struct nouveau_channel *chan, struct nv50_vbo_emitctx *emit, - uint32_t vi) -{ - unsigned i; - - for (i = 0; i < emit->nr_ve; ++i) - emit->push[i](chan, emit->map[i] + emit->stride[i] * vi); -} - -static INLINE boolean -nv50_map_vbufs(struct nv50_context *nv50) -{ - int i; - - for (i = 0; i < nv50->vtxbuf_nr; ++i) { - struct pipe_vertex_buffer *vb = &nv50->vtxbuf[i]; - unsigned size = vb->stride * (vb->max_index + 1) + 16; - - if (nouveau_bo(vb->buffer)->map) - continue; - - size = vb->stride * (vb->max_index + 1) + 16; - size = MIN2(size, vb->buffer->size); - if (!size) - size = vb->buffer->size; - - if (nouveau_bo_map_range(nouveau_bo(vb->buffer), - 0, size, NOUVEAU_BO_RD)) - break; - } - - if (i == nv50->vtxbuf_nr) - return TRUE; - for (; i >= 0; --i) - nouveau_bo_unmap(nouveau_bo(nv50->vtxbuf[i].buffer)); - return FALSE; -} - -static void -emit_b32_1(struct nouveau_channel *chan, void *data) -{ - uint32_t *v = data; - - OUT_RING(chan, v[0]); -} - -static void -emit_b32_2(struct nouveau_channel *chan, void *data) -{ - uint32_t *v = data; - - OUT_RING(chan, v[0]); - OUT_RING(chan, v[1]); -} - -static void -emit_b32_3(struct nouveau_channel *chan, void *data) -{ - uint32_t *v = data; - - OUT_RING(chan, v[0]); - OUT_RING(chan, v[1]); - OUT_RING(chan, v[2]); -} - -static void -emit_b32_4(struct nouveau_channel *chan, void *data) -{ - uint32_t *v = data; - - OUT_RING(chan, v[0]); - OUT_RING(chan, v[1]); - OUT_RING(chan, v[2]); - OUT_RING(chan, v[3]); -} - -static void -emit_b16_1(struct nouveau_channel *chan, void *data) -{ - uint16_t *v = data; - - OUT_RING(chan, v[0]); -} - -static void -emit_b16_3(struct nouveau_channel *chan, void *data) -{ - uint16_t *v = data; - - OUT_RING(chan, (v[1] << 16) | v[0]); - OUT_RING(chan, v[2]); -} - -static void -emit_b08_1(struct nouveau_channel *chan, void *data) -{ - uint8_t *v = data; - - OUT_RING(chan, v[0]); -} - -static void -emit_b08_3(struct nouveau_channel *chan, void *data) -{ - uint8_t *v = data; - - OUT_RING(chan, (v[2] << 16) | (v[1] << 8) | v[0]); -} - -static boolean -emit_prepare(struct nv50_context *nv50, struct nv50_vbo_emitctx *emit, - unsigned start) -{ - unsigned i; - - if (nv50_map_vbufs(nv50) == FALSE) - return FALSE; - - emit->ve_edgeflag = nv50->vertprog->cfg.edgeflag_in; - - emit->edgeflag = 0.5f; - emit->nr_ve = 0; - emit->vtx_dwords = 0; - - for (i = 0; i < nv50->vtxelt->num_elements; ++i) { - struct pipe_vertex_element *ve; - struct pipe_vertex_buffer *vb; - unsigned n, size, nr_components; - const struct util_format_description *desc; - - ve = &nv50->vtxelt->pipe[i]; - vb = &nv50->vtxbuf[ve->vertex_buffer_index]; - if (!(nv50->vbo_fifo & (1 << i)) || ve->instance_divisor) - continue; - n = emit->nr_ve++; - - emit->stride[n] = vb->stride; - emit->map[n] = (uint8_t *)nouveau_bo(vb->buffer)->map + - vb->buffer_offset + - (start * vb->stride + ve->src_offset); - - desc = util_format_description(ve->src_format); - assert(desc); - - size = util_format_get_component_bits( - ve->src_format, UTIL_FORMAT_COLORSPACE_RGB, 0); - nr_components = util_format_get_nr_components(ve->src_format); - - assert(nr_components > 0 && nr_components <= 4); - - /* It shouldn't be necessary to push the implicit 1s - * for case 3 and size 8 cases 1, 2, 3. - */ - switch (size) { - default: - NOUVEAU_ERR("unsupported vtxelt size: %u\n", size); - return FALSE; - case 32: - switch (nr_components) { - case 1: emit->push[n] = emit_b32_1; break; - case 2: emit->push[n] = emit_b32_2; break; - case 3: emit->push[n] = emit_b32_3; break; - case 4: emit->push[n] = emit_b32_4; break; - } - emit->vtx_dwords += nr_components; - break; - case 16: - switch (nr_components) { - case 1: emit->push[n] = emit_b16_1; break; - case 2: emit->push[n] = emit_b32_1; break; - case 3: emit->push[n] = emit_b16_3; break; - case 4: emit->push[n] = emit_b32_2; break; - } - emit->vtx_dwords += (nr_components + 1) >> 1; - break; - case 8: - switch (nr_components) { - case 1: emit->push[n] = emit_b08_1; break; - case 2: emit->push[n] = emit_b16_1; break; - case 3: emit->push[n] = emit_b08_3; break; - case 4: emit->push[n] = emit_b32_1; break; - } - emit->vtx_dwords += 1; - break; - } - } - - emit->vtx_max = 512 / emit->vtx_dwords; - if (emit->ve_edgeflag < 16) - emit->vtx_max = 1; - - return TRUE; -} - -static INLINE void -set_edgeflag(struct nouveau_channel *chan, - struct nouveau_grobj *tesla, - struct nv50_vbo_emitctx *emit, uint32_t index) -{ - unsigned i = emit->ve_edgeflag; - - if (i < 16) { - float f = *((float *)(emit->map[i] + index * emit->stride[i])); - - if (emit->edgeflag != f) { - emit->edgeflag = f; - - BEGIN_RING(chan, tesla, 0x15e4, 1); - OUT_RING (chan, f ? 1 : 0); - } - } -} - -static boolean -nv50_push_arrays(struct nv50_context *nv50, unsigned start, unsigned count) -{ - struct nouveau_channel *chan = nv50->screen->base.channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nv50_vbo_emitctx emit; - - if (emit_prepare(nv50, &emit, start) == FALSE) - return FALSE; - - while (count) { - unsigned i, dw, nr = MIN2(count, emit.vtx_max); - dw = nr * emit.vtx_dwords; - - set_edgeflag(chan, tesla, &emit, 0); /* nr will be 1 */ - - BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); - for (i = 0; i < nr; ++i) - emit_vtx_next(chan, &emit); - - count -= nr; - } - - return TRUE; -} - -static boolean -nv50_push_elements_u32(struct nv50_context *nv50, uint32_t *map, unsigned count) -{ - struct nouveau_channel *chan = nv50->screen->base.channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nv50_vbo_emitctx emit; - - if (emit_prepare(nv50, &emit, 0) == FALSE) - return FALSE; - - while (count) { - unsigned i, dw, nr = MIN2(count, emit.vtx_max); - dw = nr * emit.vtx_dwords; - - set_edgeflag(chan, tesla, &emit, *map); - - BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); - for (i = 0; i < nr; ++i) - emit_vtx(chan, &emit, *map++); - - count -= nr; - } - - return TRUE; -} - -static boolean -nv50_push_elements_u16(struct nv50_context *nv50, uint16_t *map, unsigned count) -{ - struct nouveau_channel *chan = nv50->screen->base.channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nv50_vbo_emitctx emit; - - if (emit_prepare(nv50, &emit, 0) == FALSE) - return FALSE; - - while (count) { - unsigned i, dw, nr = MIN2(count, emit.vtx_max); - dw = nr * emit.vtx_dwords; - - set_edgeflag(chan, tesla, &emit, *map); - - BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); - for (i = 0; i < nr; ++i) - emit_vtx(chan, &emit, *map++); - - count -= nr; - } - - return TRUE; -} - -static boolean -nv50_push_elements_u08(struct nv50_context *nv50, uint8_t *map, unsigned count) -{ - struct nouveau_channel *chan = nv50->screen->base.channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nv50_vbo_emitctx emit; - - if (emit_prepare(nv50, &emit, 0) == FALSE) - return FALSE; - - while (count) { - unsigned i, dw, nr = MIN2(count, emit.vtx_max); - dw = nr * emit.vtx_dwords; - - set_edgeflag(chan, tesla, &emit, *map); - - BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, dw); - for (i = 0; i < nr; ++i) - emit_vtx(chan, &emit, *map++); - - count -= nr; - } - - return TRUE; -} -- cgit v1.2.3 From 621c4609f871d3e84d5f7fd98f11ee9ddf2a1f7c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Mar 2010 10:08:12 +1000 Subject: nv50: reimplement draw_arrays_instanced(), do draw_arrays() in terms of it This makes draw_arrays()/draw_arrays_instanced() do the right thing and not require the (probably broken anyway) flush_notify() usage. It also fixes a potential bug in the behaviour of reading InstanceID from shaders, where 0 should be read for non-instanced drawing, previously it was possible to read non-0 ids if mixing instanced/non-instanced. --- src/gallium/drivers/nv50/nv50_vbo.c | 278 +++++++++++++++++------------------- 1 file changed, 134 insertions(+), 144 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index bab9530852..5a9728d7be 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -150,127 +150,58 @@ nv50_vbo_vtxelt_to_hw(struct pipe_vertex_element *ve) return (hw_type | hw_size); } -static void -nv50_set_static_vtxattr(struct nv50_context *nv50, unsigned i, void *data) -{ - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; - float v[4]; - enum pipe_format pf = nv50->vtxelt->pipe[i].src_format; - unsigned nr_components = util_format_get_nr_components(pf); - - util_format_read_4f(pf, v, 0, data, 0, 0, 0, 1, 1); - - switch (nr_components) { - case 4: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_4F_X(i), 4); - OUT_RINGf (chan, v[0]); - OUT_RINGf (chan, v[1]); - OUT_RINGf (chan, v[2]); - OUT_RINGf (chan, v[3]); - break; - case 3: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_3F_X(i), 3); - OUT_RINGf (chan, v[0]); - OUT_RINGf (chan, v[1]); - OUT_RINGf (chan, v[2]); - break; - case 2: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_2F_X(i), 2); - OUT_RINGf (chan, v[0]); - OUT_RINGf (chan, v[1]); - break; - case 1: - BEGIN_RING(chan, tesla, NV50TCL_VTX_ATTR_1F(i), 1); - OUT_RINGf (chan, v[0]); - break; - default: - assert(0); - break; - } -} - -static unsigned -init_per_instance_arrays(struct nv50_context *nv50, - unsigned startInstance, - unsigned pos[16], unsigned step[16]) -{ - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; +struct instance { struct nouveau_bo *bo; - struct nouveau_stateobj *so; - unsigned i, b, count = 0, num_elements = nv50->vtxelt->num_elements; - const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + unsigned delta; + unsigned stride; + unsigned step; + unsigned divisor; +}; - so = so_new(num_elements, num_elements * 2, num_elements * 2); +static void +instance_init(struct nv50_context *nv50, struct instance *a, unsigned first) +{ + int i; - for (i = 0; i < nv50->vtxelt->num_elements; ++i) { - if (!nv50->vtxelt->pipe[i].instance_divisor) - continue; - ++count; - b = nv50->vtxelt->pipe[i].vertex_buffer_index; + for (i = 0; i < nv50->vtxelt->num_elements; i++) { + struct pipe_vertex_element *ve = &nv50->vtxelt->pipe[i]; + struct pipe_vertex_buffer *vb; - pos[i] = nv50->vtxelt->pipe[i].src_offset + - nv50->vtxbuf[b].buffer_offset + - startInstance * nv50->vtxbuf[b].stride; + a[i].divisor = ve->instance_divisor; + if (a[i].divisor) { + vb = &nv50->vtxbuf[ve->vertex_buffer_index]; - if (!startInstance) { - step[i] = 0; - continue; + a[i].bo = nouveau_bo(vb->buffer); + a[i].stride = vb->stride; + a[i].step = first % a[i].divisor; + a[i].delta = vb->buffer_offset + ve->src_offset + + (first * a[i].stride); } - step[i] = startInstance % - nv50->vtxelt->pipe[i].instance_divisor; - - bo = nouveau_bo(nv50->vtxbuf[b].buffer); - - so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); - } - - if (count && startInstance) { - so_ref (so, &nv50->state.instbuf); /* for flush notify */ - so_emit(chan, nv50->state.instbuf); } - so_ref (NULL, &so); - - return count; } static void -step_per_instance_arrays(struct nv50_context *nv50, - unsigned pos[16], unsigned step[16]) +instance_step(struct nv50_context *nv50, struct instance *a) { + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; - struct nouveau_bo *bo; - struct nouveau_stateobj *so; - unsigned i, b, num_elements = nv50->vtxelt->num_elements; - const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; - - so = so_new(num_elements, num_elements * 2, num_elements * 2); + int i; - for (i = 0; i < nv50->vtxelt->num_elements; ++i) { - if (!nv50->vtxelt->pipe[i].instance_divisor) + for (i = 0; i < nv50->vtxelt->num_elements; i++) { + if (!a[i].divisor) continue; - b = nv50->vtxelt->pipe[i].vertex_buffer_index; - if (++step[i] == nv50->vtxelt->pipe[i].instance_divisor) { - step[i] = 0; - pos[i] += nv50->vtxbuf[b].stride; + BEGIN_RING(chan, tesla, + NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); + OUT_RELOCh(chan, a[i].bo, a[i].delta, NOUVEAU_BO_RD | + NOUVEAU_BO_VRAM | NOUVEAU_BO_GART); + OUT_RELOCl(chan, a[i].bo, a[i].delta, NOUVEAU_BO_RD | + NOUVEAU_BO_VRAM | NOUVEAU_BO_GART); + if (++a[i].step == a[i].divisor) { + a[i].step = 0; + a[i].delta += a[i].stride; } - - bo = nouveau_bo(nv50->vtxbuf[b].buffer); - - so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); } - - so_ref (so, &nv50->state.instbuf); /* for flush notify */ - so_ref (NULL, &so); - - so_emit(chan, nv50->state.instbuf); } void @@ -281,66 +212,43 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - unsigned i, nz_divisors; - unsigned step[16], pos[16]; + struct instance a[16]; + unsigned prim = nv50_prim(mode); - if (!nv50_state_validate(nv50, 0)) + instance_init(nv50, a, startInstance); + if (!nv50_state_validate(nv50, 10 + 16*3)) return; - chan->flush_notify = nv50_state_flush_notify; - - nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); OUT_RING (chan, NV50_CB_AUX | (24 << 8)); OUT_RING (chan, startInstance); - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode)); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); - OUT_RING (chan, 0); - - for (i = 1; i < instanceCount; i++) { - if (nz_divisors) /* any non-zero array divisors ? */ - step_per_instance_arrays(nv50, pos, step); + while (instanceCount--) { + if (AVAIL_RING(chan) < (7 + 16*3)) { + FIRE_RING(chan); + if (!nv50_state_validate(nv50, 7 + 16*3)) { + assert(0); + return; + } + } + instance_step(nv50, a); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode) | (1 << 28)); + OUT_RING (chan, prim); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); OUT_RING (chan, start); OUT_RING (chan, count); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); - } - - chan->flush_notify = NULL; - so_ref(NULL, &nv50->state.instbuf); + prim |= (1 << 28); + } } void nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count) { - struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->tesla->channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - - if (!nv50_state_validate(nv50, 11)) - return; - chan->flush_notify = nv50_state_flush_notify; - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode)); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); - OUT_RING (chan, 0); - - chan->flush_notify = NULL; + nv50_draw_arrays_instanced(pipe, mode, start, count, 0, 1); } static INLINE boolean @@ -442,6 +350,88 @@ nv50_draw_elements_inline(struct nv50_context *nv50, } } +static unsigned +init_per_instance_arrays(struct nv50_context *nv50, + unsigned startInstance, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct nouveau_bo *bo; + struct nouveau_stateobj *so; + unsigned i, b, count = 0; + const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + ++count; + b = nv50->vtxelt[i].vertex_buffer_index; + + pos[i] = nv50->vtxelt[i].src_offset + + nv50->vtxbuf[b].buffer_offset + + startInstance * nv50->vtxbuf[b].stride; + + if (!startInstance) { + step[i] = 0; + continue; + } + step[i] = startInstance % nv50->vtxelt[i].instance_divisor; + + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + + so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); + } + + if (count && startInstance) { + so_ref (so, &nv50->state.instbuf); /* for flush notify */ + so_emit(chan, nv50->state.instbuf); + } + so_ref (NULL, &so); + + return count; +} + +static void +step_per_instance_arrays(struct nv50_context *nv50, + unsigned pos[16], unsigned step[16]) +{ + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct nouveau_bo *bo; + struct nouveau_stateobj *so; + unsigned i, b; + const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + + so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + if (!nv50->vtxelt[i].instance_divisor) + continue; + b = nv50->vtxelt[i].vertex_buffer_index; + + if (++step[i] == nv50->vtxelt[i].instance_divisor) { + step[i] = 0; + pos[i] += nv50->vtxbuf[b].stride; + } + + bo = nouveau_bo(nv50->vtxbuf[b].buffer); + + so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); + } + + so_ref (so, &nv50->state.instbuf); /* for flush notify */ + so_ref (NULL, &so); + + so_emit(chan, nv50->state.instbuf); +} + void nv50_draw_elements_instanced(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, -- cgit v1.2.3 From d8a415425e7761a7bed03a0c383cb3839eaf1b4b Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Fri, 5 Mar 2010 13:25:01 +1000 Subject: nv50: reimplement draw_elements_instance(), use for draw_elements() too This makes draw_elements()/draw_elements_instanced() do the right thing for the non-inline elements cases, and not require flush_notify(). --- src/gallium/drivers/nv50/nv50_vbo.c | 252 +++++++++++++----------------------- 1 file changed, 93 insertions(+), 159 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 5a9728d7be..54a2fa730a 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -332,104 +332,65 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, return TRUE; } -static INLINE void -nv50_draw_elements_inline(struct nv50_context *nv50, - void *map, unsigned indexSize, - unsigned start, unsigned count) -{ - switch (indexSize) { - case 1: - nv50_draw_elements_inline_u08(nv50, map, start, count); - break; - case 2: - nv50_draw_elements_inline_u16(nv50, map, start, count); - break; - case 4: - nv50_draw_elements_inline_u32(nv50, map, start, count); - break; - } -} - -static unsigned -init_per_instance_arrays(struct nv50_context *nv50, - unsigned startInstance, - unsigned pos[16], unsigned step[16]) -{ - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; - struct nouveau_bo *bo; - struct nouveau_stateobj *so; - unsigned i, b, count = 0; - const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; - - so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); - - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) - continue; - ++count; - b = nv50->vtxelt[i].vertex_buffer_index; - - pos[i] = nv50->vtxelt[i].src_offset + - nv50->vtxbuf[b].buffer_offset + - startInstance * nv50->vtxbuf[b].stride; - - if (!startInstance) { - step[i] = 0; - continue; - } - step[i] = startInstance % nv50->vtxelt[i].instance_divisor; - - bo = nouveau_bo(nv50->vtxbuf[b].buffer); - - so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); - } - - if (count && startInstance) { - so_ref (so, &nv50->state.instbuf); /* for flush notify */ - so_emit(chan, nv50->state.instbuf); - } - so_ref (NULL, &so); - - return count; -} - static void -step_per_instance_arrays(struct nv50_context *nv50, - unsigned pos[16], unsigned step[16]) +nv50_draw_elements_inline(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, unsigned indexSize, + unsigned mode, unsigned start, unsigned count, + unsigned startInstance, unsigned instanceCount) { + struct pipe_screen *pscreen = pipe->screen; + struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; - struct nouveau_bo *bo; - struct nouveau_stateobj *so; - unsigned i, b; - const uint32_t rl = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD; + struct instance a[16]; + unsigned prim = nv50_prim(mode); + void *map; - so = so_new(nv50->vtxelt_nr, nv50->vtxelt_nr * 2, nv50->vtxelt_nr * 2); + map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + assert(map); + if (!map) + return; - for (i = 0; i < nv50->vtxelt_nr; ++i) { - if (!nv50->vtxelt[i].instance_divisor) - continue; - b = nv50->vtxelt[i].vertex_buffer_index; + instance_init(nv50, a, startInstance); + if (!nv50_state_validate(nv50, 0)) + return; - if (++step[i] == nv50->vtxelt[i].instance_divisor) { - step[i] = 0; - pos[i] += nv50->vtxbuf[b].stride; + BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); + OUT_RING (chan, NV50_CB_AUX | (24 << 8)); + OUT_RING (chan, startInstance); + while (instanceCount--) { + if (AVAIL_RING(chan) < (7 + 16*3)) { + FIRE_RING(chan); + if (!nv50_state_validate(nv50, 0)) { + assert(0); + return; + } } + instance_step(nv50, a); - bo = nouveau_bo(nv50->vtxbuf[b].buffer); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, prim); + switch (indexSize) { + case 1: + nv50_draw_elements_inline_u08(nv50, map, start, count); + break; + case 2: + nv50_draw_elements_inline_u16(nv50, map, start, count); + break; + case 4: + nv50_draw_elements_inline_u32(nv50, map, start, count); + break; + default: + assert(0); + break; + } + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); - so_method(so, tesla, NV50TCL_VERTEX_ARRAY_START_HIGH(i), 2); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, bo, pos[i], rl | NOUVEAU_BO_LOW, 0, 0); + prim |= (1 << 28); } - so_ref (so, &nv50->state.instbuf); /* for flush notify */ - so_ref (NULL, &so); - - so_emit(chan, nv50->state.instbuf); + pipe_buffer_unmap(pscreen, indexBuffer); } void @@ -440,49 +401,62 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, unsigned startInstance, unsigned instanceCount) { struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; - struct nouveau_channel *chan = tesla->channel; - struct pipe_screen *pscreen = pipe->screen; - void *map; - unsigned i, nz_divisors; - unsigned step[16], pos[16]; - - map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + struct instance a[16]; + unsigned prim = nv50_prim(mode); - if (!nv50_state_validate(nv50, 0)) + if (indexSize == 1) { + nv50_draw_elements_inline(pipe, indexBuffer, indexSize, + mode, start, count, startInstance, + instanceCount); return; - chan->flush_notify = nv50_state_flush_notify; + } - nz_divisors = init_per_instance_arrays(nv50, startInstance, pos, step); + instance_init(nv50, a, startInstance); + if (!nv50_state_validate(nv50, 13 + 16*3)) + return; BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); OUT_RING (chan, NV50_CB_AUX | (24 << 8)); OUT_RING (chan, startInstance); - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode)); - - nv50_draw_elements_inline(nv50, map, indexSize, start, count); - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); - OUT_RING (chan, 0); - - for (i = 1; i < instanceCount; ++i) { - if (nz_divisors) /* any non-zero array divisors ? */ - step_per_instance_arrays(nv50, pos, step); + while (instanceCount--) { + if (AVAIL_RING(chan) < (7 + 16*3)) { + FIRE_RING(chan); + if (!nv50_state_validate(nv50, 10 + 16*3)) { + assert(0); + return; + } + } + instance_step(nv50, a); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode) | (1 << 28)); - - nv50_draw_elements_inline(nv50, map, indexSize, start, count); - + OUT_RING (chan, prim); + if (indexSize == 4) { + BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x30000, 0); + OUT_RING (chan, count); + nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer), + start << 2, count << 2); + } else + if (indexSize == 2) { + unsigned vb_start = (start & ~1); + unsigned vb_end = (start + count + 1) & ~1; + unsigned dwords = (vb_end - vb_start) >> 1; + + BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16_SETUP, 1); + OUT_RING (chan, ((start & 1) << 31) | count); + BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x30000, 0); + OUT_RING (chan, dwords); + nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer), + vb_start << 1, dwords << 2); + BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16_SETUP, 1); + OUT_RING (chan, 0); + } BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); - } - chan->flush_notify = NULL; - - so_ref(NULL, &nv50->state.instbuf); + prim |= (1 << 28); + } } void @@ -490,48 +464,8 @@ nv50_draw_elements(struct pipe_context *pipe, struct pipe_buffer *indexBuffer, unsigned indexSize, unsigned mode, unsigned start, unsigned count) { - struct nv50_context *nv50 = nv50_context(pipe); - struct nouveau_channel *chan = nv50->screen->tesla->channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - struct pipe_screen *pscreen = pipe->screen; - void *map; - - if (!nv50_state_validate(nv50, 14)) - return; - chan->flush_notify = nv50_state_flush_notify; - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, nv50_prim(mode)); - - if (indexSize == 4) { - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x30000, 0); - OUT_RING (chan, count); - nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer), - start << 2, count << 2); - } else - if (indexSize == 2) { - unsigned vb_start = (start & ~1); - unsigned vb_end = (start + count + 1) & ~1; - unsigned dwords = (vb_end - vb_start) >> 1; - - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16_SETUP, 1); - OUT_RING (chan, ((start & 1) << 31) | count); - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x30000, 0); - OUT_RING (chan, dwords); - nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer), - vb_start << 1, dwords << 2); - BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16_SETUP, 1); - OUT_RING (chan, 0); - } else { - map = pipe_buffer_map(pscreen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - nv50_draw_elements_inline(nv50, map, indexSize, start, count); - pipe_buffer_unmap(pscreen, indexBuffer); - } - - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); - OUT_RING (chan, 0); - chan->flush_notify = NULL; + nv50_draw_elements_instanced(pipe, indexBuffer, indexSize, + mode, start, count, 0, 1); } static INLINE boolean -- cgit v1.2.3 From 0842829c1813d47e6fdf3de09167d243c029cc90 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 8 Mar 2010 13:27:46 +1000 Subject: nv50: when doing inline indices, split elt lists so they fit into pushbuf --- src/gallium/drivers/nouveau/nouveau_util.h | 100 +++++++++++++++ src/gallium/drivers/nv50/nv50_vbo.c | 187 ++++++++++++++++------------- 2 files changed, 202 insertions(+), 85 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_util.h b/src/gallium/drivers/nouveau/nouveau_util.h index a10114beab..7f16e31c3f 100644 --- a/src/gallium/drivers/nouveau/nouveau_util.h +++ b/src/gallium/drivers/nouveau/nouveau_util.h @@ -88,4 +88,104 @@ static INLINE unsigned log2i(unsigned i) return r; } +struct u_split_prim { + void *priv; + void (*emit)(void *priv, unsigned start, unsigned count); + void (*edge)(void *priv, boolean enabled); + + unsigned mode; + unsigned start; + unsigned p_start; + unsigned p_end; + + int repeat_first:1; + int close_first:1; + int edgeflag_off:1; +}; + +static inline void +u_split_prim_init(struct u_split_prim *s, + unsigned mode, unsigned start, unsigned count) +{ + if (mode == PIPE_PRIM_LINE_LOOP) { + s->mode = PIPE_PRIM_LINE_STRIP; + s->close_first = 1; + } else { + s->mode = mode; + s->close_first = 0; + } + s->start = start; + s->p_start = start; + s->p_end = start + count; + s->edgeflag_off = 0; + s->repeat_first = 0; +} + +static INLINE boolean +u_split_prim_next(struct u_split_prim *s, unsigned max_verts) +{ + int repeat = 0; + + if (s->repeat_first) { + s->emit(s->priv, s->start, 1); + max_verts--; + if (s->edgeflag_off) { + s->edge(s->priv, TRUE); + s->edgeflag_off = FALSE; + } + } + + if (s->p_start + s->close_first + max_verts >= s->p_end) { + s->emit(s->priv, s->p_start, s->p_end - s->p_start); + if (s->close_first) + s->emit(s->priv, s->start, 1); + return TRUE; + } + + switch (s->mode) { + case PIPE_PRIM_LINES: + max_verts &= ~1; + break; + case PIPE_PRIM_LINE_STRIP: + repeat = 1; + break; + case PIPE_PRIM_POLYGON: + max_verts--; + s->emit(s->priv, s->p_start, max_verts); + s->edge(s->priv, FALSE); + s->emit(s->priv, s->p_start + max_verts, 1); + s->p_start += max_verts; + s->repeat_first = TRUE; + s->edgeflag_off = TRUE; + return FALSE; + case PIPE_PRIM_TRIANGLES: + max_verts = max_verts - (max_verts % 3); + break; + case PIPE_PRIM_TRIANGLE_STRIP: + /* to ensure winding stays correct, always split + * on an even number of generated triangles + */ + max_verts = max_verts & ~1; + repeat = 2; + break; + case PIPE_PRIM_TRIANGLE_FAN: + s->repeat_first = TRUE; + repeat = 1; + break; + case PIPE_PRIM_QUADS: + max_verts &= ~3; + break; + case PIPE_PRIM_QUAD_STRIP: + max_verts &= ~1; + repeat = 2; + break; + default: + break; + } + + s->emit (s->priv, s->p_start, max_verts); + s->p_start += (max_verts - repeat); + return FALSE; +} + #endif diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 54a2fa730a..8f3c1aaf46 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -25,6 +25,7 @@ #include "util/u_inlines.h" #include "util/u_format.h" +#include "nouveau/nouveau_util.h" #include "nv50_context.h" #define NV50_USING_LOATHED_EDGEFLAG(ctx) ((ctx)->vertprog->cfg.edgeflag_in < 16) @@ -251,85 +252,83 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, nv50_draw_arrays_instanced(pipe, mode, start, count, 0, 1); } -static INLINE boolean -nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, - unsigned start, unsigned count) -{ - struct nouveau_channel *chan = nv50->screen->tesla->channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; +struct inline_ctx { + struct nv50_context *nv50; + void *map; +}; - map += start; +static void +inline_elt08(void *priv, unsigned start, unsigned count) +{ + struct inline_ctx *ctx = priv; + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + uint8_t *map = (uint8_t *)ctx->map + start; if (count & 1) { BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1); OUT_RING (chan, map[0]); map++; - count--; + count &= ~1; } - while (count) { - unsigned nr = count > 2046 ? 2046 : count; - int i; - - BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, nr >> 1); - for (i = 0; i < nr; i += 2) - OUT_RING (chan, (map[i + 1] << 16) | map[i]); + count >>= 1; + if (!count) + return; - count -= nr; - map += nr; + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, count); + while (count--) { + OUT_RING(chan, (map[1] << 16) | map[0]); + map += 2; } - return TRUE; } -static INLINE boolean -nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, - unsigned start, unsigned count) +static void +inline_elt16(void *priv, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->tesla->channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; - - map += start; + struct inline_ctx *ctx = priv; + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + uint16_t *map = (uint16_t *)ctx->map + start; if (count & 1) { BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32, 1); OUT_RING (chan, map[0]); + count &= ~1; map++; - count--; } - while (count) { - unsigned nr = count > 2046 ? 2046 : count; - int i; - - BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, nr >> 1); - for (i = 0; i < nr; i += 2) - OUT_RING (chan, (map[i + 1] << 16) | map[i]); + count >>= 1; + if (!count) + return; - count -= nr; - map += nr; + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U16, count); + while (count--) { + OUT_RING(chan, (map[1] << 16) | map[0]); + map += 2; } - return TRUE; } -static INLINE boolean -nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, - unsigned start, unsigned count) +static void +inline_elt32(void *priv, unsigned start, unsigned count) { - struct nouveau_channel *chan = nv50->screen->tesla->channel; - struct nouveau_grobj *tesla = nv50->screen->tesla; + struct inline_ctx *ctx = priv; + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; - map += start; - - while (count) { - unsigned nr = count > 2047 ? 2047 : count; + BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U32, count); + OUT_RINGp (chan, (uint32_t *)ctx->map + start, count); +} - BEGIN_RING_NI(chan, tesla, NV50TCL_VB_ELEMENT_U32, nr); - OUT_RINGp (chan, map, nr); +static void +inline_edgeflag(void *priv, boolean enabled) +{ + struct inline_ctx *ctx = priv; + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; - count -= nr; - map += nr; - } - return TRUE; + BEGIN_RING(chan, tesla, NV50TCL_EDGEFLAG_ENABLE, 1); + OUT_RING (chan, enabled ? 1 : 0); } static void @@ -343,51 +342,68 @@ nv50_draw_elements_inline(struct pipe_context *pipe, struct nouveau_channel *chan = nv50->screen->tesla->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct instance a[16]; - unsigned prim = nv50_prim(mode); - void *map; - - map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); - assert(map); - if (!map) + struct inline_ctx ctx; + struct u_split_prim s; + boolean nzi = FALSE; + unsigned overhead; + + overhead = 16*3; /* potential instance adjustments */ + overhead += 4; /* Begin()/End() */ + overhead += 4; /* potential edgeflag disable/reenable */ + overhead += 3; /* potentially 3 VTX_ELT_U16/U32 packet headers */ + + s.priv = &ctx; + if (indexSize == 1) + s.emit = inline_elt08; + else + if (indexSize == 2) + s.emit = inline_elt16; + else + s.emit = inline_elt32; + s.edge = inline_edgeflag; + + ctx.nv50 = nv50; + ctx.map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); + assert(ctx.map); + if (!ctx.map) return; instance_init(nv50, a, startInstance); - if (!nv50_state_validate(nv50, 0)) + if (!nv50_state_validate(nv50, overhead + 6 + 3)) return; BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); OUT_RING (chan, NV50_CB_AUX | (24 << 8)); OUT_RING (chan, startInstance); while (instanceCount--) { - if (AVAIL_RING(chan) < (7 + 16*3)) { - FIRE_RING(chan); - if (!nv50_state_validate(nv50, 0)) { - assert(0); - return; + unsigned max_verts; + boolean done; + + u_split_prim_init(&s, mode, start, count); + do { + if (AVAIL_RING(chan) < (overhead + 6)) { + FIRE_RING(chan); + if (!nv50_state_validate(nv50, (overhead + 6))) { + assert(0); + return; + } } - } - instance_step(nv50, a); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); - OUT_RING (chan, prim); - switch (indexSize) { - case 1: - nv50_draw_elements_inline_u08(nv50, map, start, count); - break; - case 2: - nv50_draw_elements_inline_u16(nv50, map, start, count); - break; - case 4: - nv50_draw_elements_inline_u32(nv50, map, start, count); - break; - default: - assert(0); - break; - } - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); - OUT_RING (chan, 0); + max_verts = AVAIL_RING(chan) - overhead; + if (max_verts > 2047) + max_verts = 2047; + if (indexSize != 4) + max_verts <<= 1; + instance_step(nv50, a); + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(s.mode) | (nzi ? (1<<28) : 0)); + done = u_split_prim_next(&s, max_verts); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + } while (!done); - prim |= (1 << 28); + nzi = TRUE; } pipe_buffer_unmap(pscreen, indexBuffer); @@ -406,7 +422,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, struct instance a[16]; unsigned prim = nv50_prim(mode); - if (indexSize == 1) { + if (!(indexBuffer->usage & PIPE_BUFFER_USAGE_INDEX) || + indexSize == 1) { nv50_draw_elements_inline(pipe, indexBuffer, indexSize, mode, start, count, startInstance, instanceCount); -- cgit v1.2.3 From 160bda24ed3b8f74d58cfcf55349c6d9e92fb442 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 8 Mar 2010 17:06:38 +1000 Subject: nv50: re-add immediate mode vertex submission paths --- src/gallium/drivers/nv50/Makefile | 3 +- src/gallium/drivers/nv50/nv50_context.h | 9 + src/gallium/drivers/nv50/nv50_push.c | 357 ++++++++++++++++++++++++++++++++ src/gallium/drivers/nv50/nv50_vbo.c | 38 +++- 4 files changed, 399 insertions(+), 8 deletions(-) create mode 100644 src/gallium/drivers/nv50/nv50_push.c (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/Makefile b/src/gallium/drivers/nv50/Makefile index 612aea28a3..5d622e1c13 100644 --- a/src/gallium/drivers/nv50/Makefile +++ b/src/gallium/drivers/nv50/Makefile @@ -16,6 +16,7 @@ C_SOURCES = \ nv50_surface.c \ nv50_tex.c \ nv50_transfer.c \ - nv50_vbo.c + nv50_vbo.c \ + nv50_push.c include ../../Makefile.template diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 15f33fa4f4..35abfba93b 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -163,6 +163,8 @@ struct nv50_context { unsigned sampler_nr[PIPE_SHADER_TYPES]; struct nv50_miptree *miptree[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; unsigned miptree_nr[PIPE_SHADER_TYPES]; + + unsigned vbo_fifo; }; static INLINE struct nv50_context * @@ -207,6 +209,13 @@ extern void nv50_draw_elements_instanced(struct pipe_context *pipe, extern void nv50_vtxelt_construct(struct nv50_vtxelt_stateobj *cso); extern struct nouveau_stateobj *nv50_vbo_validate(struct nv50_context *nv50); +/* nv50_push.c */ +extern void +nv50_push_elements_instanced(struct pipe_context *, struct pipe_buffer *, + unsigned idxsize, unsigned mode, unsigned start, + unsigned count, unsigned i_start, + unsigned i_count); + /* nv50_clear.c */ extern void nv50_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, double depth, unsigned stencil); diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c new file mode 100644 index 0000000000..b615f4e054 --- /dev/null +++ b/src/gallium/drivers/nv50/nv50_push.c @@ -0,0 +1,357 @@ +#include "pipe/p_context.h" +#include "pipe/p_state.h" +#include "util/u_inlines.h" +#include "util/u_format.h" + +#include "nouveau/nouveau_util.h" +#include "nv50_context.h" + +static INLINE unsigned +nv50_prim(unsigned mode) +{ + switch (mode) { + case PIPE_PRIM_POINTS: return NV50TCL_VERTEX_BEGIN_POINTS; + case PIPE_PRIM_LINES: return NV50TCL_VERTEX_BEGIN_LINES; + case PIPE_PRIM_LINE_LOOP: return NV50TCL_VERTEX_BEGIN_LINE_LOOP; + case PIPE_PRIM_LINE_STRIP: return NV50TCL_VERTEX_BEGIN_LINE_STRIP; + case PIPE_PRIM_TRIANGLES: return NV50TCL_VERTEX_BEGIN_TRIANGLES; + case PIPE_PRIM_TRIANGLE_STRIP: + return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP; + case PIPE_PRIM_TRIANGLE_FAN: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN; + case PIPE_PRIM_QUADS: return NV50TCL_VERTEX_BEGIN_QUADS; + case PIPE_PRIM_QUAD_STRIP: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP; + case PIPE_PRIM_POLYGON: return NV50TCL_VERTEX_BEGIN_POLYGON; + case PIPE_PRIM_LINES_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_LINES_ADJACENCY; + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_LINE_STRIP_ADJACENCY; + case PIPE_PRIM_TRIANGLES_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_TRIANGLES_ADJACENCY; + case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP_ADJACENCY; + default: + break; + } + + NOUVEAU_ERR("invalid primitive type %d\n", mode); + return NV50TCL_VERTEX_BEGIN_POINTS; +} + +struct push_context { + struct nv50_context *nv50; + + unsigned vtx_size; + + void *idxbuf; + unsigned idxsize; + + float edgeflag; + int edgeflag_attr; + + struct { + void *map; + unsigned stride; + unsigned divisor; + unsigned step; + void (*push)(struct nouveau_channel *, void *); + } attr[16]; + unsigned attr_nr; +}; + +static void +emit_b32_1(struct nouveau_channel *chan, void *data) +{ + uint32_t *v = data; + + OUT_RING(chan, v[0]); +} + +static void +emit_b32_2(struct nouveau_channel *chan, void *data) +{ + uint32_t *v = data; + + OUT_RING(chan, v[0]); + OUT_RING(chan, v[1]); +} + +static void +emit_b32_3(struct nouveau_channel *chan, void *data) +{ + uint32_t *v = data; + + OUT_RING(chan, v[0]); + OUT_RING(chan, v[1]); + OUT_RING(chan, v[2]); +} + +static void +emit_b32_4(struct nouveau_channel *chan, void *data) +{ + uint32_t *v = data; + + OUT_RING(chan, v[0]); + OUT_RING(chan, v[1]); + OUT_RING(chan, v[2]); + OUT_RING(chan, v[3]); +} + +static void +emit_b16_1(struct nouveau_channel *chan, void *data) +{ + uint16_t *v = data; + + OUT_RING(chan, v[0]); +} + +static void +emit_b16_3(struct nouveau_channel *chan, void *data) +{ + uint16_t *v = data; + + OUT_RING(chan, (v[1] << 16) | v[0]); + OUT_RING(chan, v[2]); +} + +static void +emit_b08_1(struct nouveau_channel *chan, void *data) +{ + uint8_t *v = data; + + OUT_RING(chan, v[0]); +} + +static void +emit_b08_3(struct nouveau_channel *chan, void *data) +{ + uint8_t *v = data; + + OUT_RING(chan, (v[2] << 16) | (v[1] << 8) | v[0]); +} + +static INLINE void +emit_vertex(struct push_context *ctx, unsigned n) +{ + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + int i; + + if (ctx->edgeflag_attr < 16) { + float *edgeflag = ctx->attr[ctx->edgeflag_attr].map + + ctx->attr[ctx->edgeflag_attr].stride * n; + + if (*edgeflag != ctx->edgeflag) { + BEGIN_RING(chan, tesla, NV50TCL_EDGEFLAG_ENABLE, 1); + OUT_RING (chan, *edgeflag ? 1 : 0); + ctx->edgeflag = *edgeflag; + } + } + + BEGIN_RING_NI(chan, tesla, NV50TCL_VERTEX_DATA, ctx->vtx_size); + for (i = 0; i < ctx->attr_nr; i++) + ctx->attr[i].push(chan, ctx->attr[i].map + ctx->attr[i].stride * n); +} + +static void +emit_edgeflag(void *priv, boolean enabled) +{ + struct push_context *ctx = priv; + struct nouveau_grobj *tesla = ctx->nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + + BEGIN_RING(chan, tesla, NV50TCL_EDGEFLAG_ENABLE, 1); + OUT_RING (chan, enabled ? 1 : 0); +} + +static void +emit_elt08(void *priv, unsigned start, unsigned count) +{ + struct push_context *ctx = priv; + uint8_t *idxbuf = ctx->idxbuf; + + while (count--) + emit_vertex(ctx, idxbuf[start++]); +} + +static void +emit_elt16(void *priv, unsigned start, unsigned count) +{ + struct push_context *ctx = priv; + uint16_t *idxbuf = ctx->idxbuf; + + while (count--) + emit_vertex(ctx, idxbuf[start++]); +} + +static void +emit_elt32(void *priv, unsigned start, unsigned count) +{ + struct push_context *ctx = priv; + uint32_t *idxbuf = ctx->idxbuf; + + while (count--) + emit_vertex(ctx, idxbuf[start++]); +} + +static void +emit_verts(void *priv, unsigned start, unsigned count) +{ + while (count--) + emit_vertex(priv, start++); +} + +void +nv50_push_elements_instanced(struct pipe_context *pipe, + struct pipe_buffer *idxbuf, unsigned idxsize, + unsigned mode, unsigned start, unsigned count, + unsigned i_start, unsigned i_count) +{ + struct nv50_context *nv50 = nv50_context(pipe); + struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_channel *chan = tesla->channel; + struct push_context ctx; + const unsigned p_overhead = 4 + /* begin/end */ + 4; /* potential edgeflag enable/disable */ + const unsigned v_overhead = 1 + /* VERTEX_DATA packet header */ + 2; /* potential edgeflag modification */ + struct u_split_prim s; + unsigned vtx_size; + boolean nzi = FALSE; + int i; + + ctx.nv50 = nv50; + ctx.attr_nr = 0; + ctx.idxbuf = NULL; + ctx.vtx_size = 0; + ctx.edgeflag = 0.5f; + ctx.edgeflag_attr = nv50->vertprog->cfg.edgeflag_in; + + /* map vertex buffers, determine vertex size */ + for (i = 0; i < nv50->vtxelt->num_elements; i++) { + struct pipe_vertex_element *ve = &nv50->vtxelt->pipe[i]; + struct pipe_vertex_buffer *vb = &nv50->vtxbuf[ve->vertex_buffer_index]; + struct nouveau_bo *bo = nouveau_bo(vb->buffer); + unsigned size, nr_components, n; + + if (!(nv50->vbo_fifo & (1 << i))) + continue; + n = ctx.attr_nr++; + + if (nouveau_bo_map(bo, NOUVEAU_BO_RD)) { + assert(bo->map); + return; + } + ctx.attr[n].map = bo->map + vb->buffer_offset + ve->src_offset; + nouveau_bo_unmap(bo); + + ctx.attr[n].stride = vb->stride; + ctx.attr[n].divisor = ve->instance_divisor; + if (ctx.attr[n].divisor) { + ctx.attr[n].step = i_start % ve->instance_divisor; + ctx.attr[n].map += i_start * vb->stride; + } + + size = util_format_get_component_bits(ve->src_format, + UTIL_FORMAT_COLORSPACE_RGB, 0); + nr_components = util_format_get_nr_components(ve->src_format); + switch (size) { + case 8: + switch (nr_components) { + case 1: ctx.attr[n].push = emit_b08_1; break; + case 2: ctx.attr[n].push = emit_b16_1; break; + case 3: ctx.attr[n].push = emit_b08_3; break; + case 4: ctx.attr[n].push = emit_b32_1; break; + } + ctx.vtx_size++; + break; + case 16: + switch (nr_components) { + case 1: ctx.attr[n].push = emit_b16_1; break; + case 2: ctx.attr[n].push = emit_b32_1; break; + case 3: ctx.attr[n].push = emit_b16_3; break; + case 4: ctx.attr[n].push = emit_b32_2; break; + } + ctx.vtx_size += (nr_components + 1) >> 1; + break; + case 32: + switch (nr_components) { + case 1: ctx.attr[n].push = emit_b32_1; break; + case 2: ctx.attr[n].push = emit_b32_2; break; + case 3: ctx.attr[n].push = emit_b32_3; break; + case 4: ctx.attr[n].push = emit_b32_4; break; + } + ctx.vtx_size += nr_components; + break; + default: + assert(0); + return; + } + } + vtx_size = ctx.vtx_size + v_overhead; + + /* map index buffer, if present */ + if (idxbuf) { + struct nouveau_bo *bo = nouveau_bo(idxbuf); + + if (nouveau_bo_map(bo, NOUVEAU_BO_RD)) { + assert(bo->map); + return; + } + ctx.idxbuf = bo->map; + ctx.idxsize = idxsize; + nouveau_bo_unmap(bo); + } + + s.priv = &ctx; + s.edge = emit_edgeflag; + if (idxbuf) { + if (idxsize == 1) + s.emit = emit_elt08; + else + if (idxsize == 2) + s.emit = emit_elt16; + else + s.emit = emit_elt32; + } else + s.emit = emit_verts; + + /* per-instance loop */ + BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); + OUT_RING (chan, NV50_CB_AUX | (24 << 8)); + OUT_RING (chan, i_start); + while (i_count--) { + unsigned max_verts; + boolean done; + + for (i = 0; i < ctx.attr_nr; i++) { + if (!ctx.attr[i].divisor || + ctx.attr[i].divisor != ++ctx.attr[i].step) + continue; + ctx.attr[i].step = 0; + ctx.attr[i].map += ctx.attr[i].stride; + } + + u_split_prim_init(&s, mode, start, count); + do { + if (AVAIL_RING(chan) < p_overhead + (6 * vtx_size)) { + FIRE_RING(chan); + if (!nv50_state_validate(nv50, p_overhead + (6 * vtx_size))) { + assert(0); + return; + } + } + + max_verts = AVAIL_RING(chan); + max_verts -= p_overhead; + max_verts /= vtx_size; + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); + OUT_RING (chan, nv50_prim(s.mode) | (nzi ? (1 << 28) : 0)); + done = u_split_prim_next(&s, max_verts); + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); + OUT_RING (chan, 0); + } while (!done); + + nzi = TRUE; + } +} diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 8f3c1aaf46..9d49ad6db2 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -220,6 +220,13 @@ nv50_draw_arrays_instanced(struct pipe_context *pipe, if (!nv50_state_validate(nv50, 10 + 16*3)) return; + if (nv50->vbo_fifo) { + nv50_push_elements_instanced(pipe, NULL, 0, mode, start, + count, startInstance, + instanceCount); + return; + } + BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); OUT_RING (chan, NV50_CB_AUX | (24 << 8)); OUT_RING (chan, startInstance); @@ -422,18 +429,23 @@ nv50_draw_elements_instanced(struct pipe_context *pipe, struct instance a[16]; unsigned prim = nv50_prim(mode); - if (!(indexBuffer->usage & PIPE_BUFFER_USAGE_INDEX) || - indexSize == 1) { + instance_init(nv50, a, startInstance); + if (!nv50_state_validate(nv50, 13 + 16*3)) + return; + + if (nv50->vbo_fifo) { + nv50_push_elements_instanced(pipe, indexBuffer, indexSize, + mode, start, count, startInstance, + instanceCount); + return; + } else + if (!(indexBuffer->usage & PIPE_BUFFER_USAGE_INDEX) || indexSize == 1) { nv50_draw_elements_inline(pipe, indexBuffer, indexSize, mode, start, count, startInstance, instanceCount); return; } - instance_init(nv50, a, startInstance); - if (!nv50_state_validate(nv50, 13 + 16*3)) - return; - BEGIN_RING(chan, tesla, NV50TCL_CB_ADDR, 2); OUT_RING (chan, NV50_CB_AUX | (24 << 8)); OUT_RING (chan, startInstance); @@ -570,7 +582,9 @@ nv50_vbo_validate(struct nv50_context *nv50) if (nv50->vtxbuf_nr == 0) return NULL; - assert(!NV50_USING_LOATHED_EDGEFLAG(nv50)); + if (NV50_USING_LOATHED_EDGEFLAG(nv50)) + nv50->vbo_fifo = 0xffff; + nv50->vbo_fifo = 0xffff; n_ve = MAX2(nv50->vtxelt->num_elements, nv50->state.vtxelt_nr); @@ -590,6 +604,16 @@ nv50_vbo_validate(struct nv50_context *nv50) nv50_vbo_static_attrib(nv50, i, &vtxattr, ve, vb)) { so_data(vtxfmt, hw | (1 << 4)); + so_method(vtxbuf, tesla, + NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); + so_data (vtxbuf, 0); + + nv50->vbo_fifo &= ~(1 << i); + continue; + } + + if (nv50->vbo_fifo) { + so_data (vtxfmt, hw | (ve->instance_divisor ? (1 << 4) : i)); so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); so_data (vtxbuf, 0); -- cgit v1.2.3 From 4796986c9874134e47b00ae2280c3d7fc65111df Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 9 Mar 2010 14:04:14 +1000 Subject: nv50: add option to force immediate-mode submission, disable by default --- src/gallium/drivers/nv50/nv50_screen.c | 7 +++++-- src/gallium/drivers/nv50/nv50_screen.h | 2 ++ src/gallium/drivers/nv50/nv50_vbo.c | 9 +++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 114ae9b386..7e2e8aa336 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -95,6 +95,8 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, static int nv50_screen_get_param(struct pipe_screen *pscreen, int param) { + struct nv50_screen *screen = nv50_screen(pscreen); + switch (param) { case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: return 32; @@ -132,9 +134,9 @@ nv50_screen_get_param(struct pipe_screen *pscreen, int param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; case NOUVEAU_CAP_HW_VTXBUF: - return 1; + return screen->force_push ? 0 : 1; case NOUVEAU_CAP_HW_IDXBUF: - return 1; + return screen->force_push ? 0 : 1; case PIPE_CAP_INDEP_BLEND_ENABLE: return 1; case PIPE_CAP_INDEP_BLEND_FUNC: @@ -493,6 +495,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_ref (NULL, &so); nouveau_pushbuf_flush(chan, 0); + screen->force_push = debug_get_bool_option("NV50_ALWAYS_PUSH", FALSE); return pscreen; } diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index 2687b72127..d1bc80cb9e 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -28,6 +28,8 @@ struct nv50_screen { struct nouveau_bo *tsc; struct nouveau_stateobj *static_init; + + boolean force_push; }; static INLINE struct nv50_screen * diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 9d49ad6db2..7eedd49271 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -582,9 +582,14 @@ nv50_vbo_validate(struct nv50_context *nv50) if (nv50->vtxbuf_nr == 0) return NULL; - if (NV50_USING_LOATHED_EDGEFLAG(nv50)) + if (nv50->screen->force_push || NV50_USING_LOATHED_EDGEFLAG(nv50)) nv50->vbo_fifo = 0xffff; - nv50->vbo_fifo = 0xffff; + + for (i = 0; i < nv50->vtxbuf_nr; i++) { + if (nv50->vtxbuf[i].stride && + !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX)) + nv50->vbo_fifo = 0xffff; + } n_ve = MAX2(nv50->vtxelt->num_elements, nv50->state.vtxelt_nr); -- cgit v1.2.3 From 3f93fa601097ded6993deecb90225242b20307e0 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 9 Mar 2010 14:52:30 +1000 Subject: nv50: move nv50_prim() into a header file rather than duplicating --- src/gallium/drivers/nv50/nv50_context.h | 31 +++++++++++++++++++++++++++++++ src/gallium/drivers/nv50/nv50_push.c | 31 ------------------------------- src/gallium/drivers/nv50/nv50_vbo.c | 31 ------------------------------- 3 files changed, 31 insertions(+), 62 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 35abfba93b..f65b328a56 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -259,4 +259,35 @@ nv50_upload_sifc(struct nv50_context *nv50, struct pipe_context * nv50_create(struct pipe_screen *pscreen, void *priv); +static INLINE unsigned +nv50_prim(unsigned mode) +{ + switch (mode) { + case PIPE_PRIM_POINTS: return NV50TCL_VERTEX_BEGIN_POINTS; + case PIPE_PRIM_LINES: return NV50TCL_VERTEX_BEGIN_LINES; + case PIPE_PRIM_LINE_LOOP: return NV50TCL_VERTEX_BEGIN_LINE_LOOP; + case PIPE_PRIM_LINE_STRIP: return NV50TCL_VERTEX_BEGIN_LINE_STRIP; + case PIPE_PRIM_TRIANGLES: return NV50TCL_VERTEX_BEGIN_TRIANGLES; + case PIPE_PRIM_TRIANGLE_STRIP: + return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP; + case PIPE_PRIM_TRIANGLE_FAN: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN; + case PIPE_PRIM_QUADS: return NV50TCL_VERTEX_BEGIN_QUADS; + case PIPE_PRIM_QUAD_STRIP: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP; + case PIPE_PRIM_POLYGON: return NV50TCL_VERTEX_BEGIN_POLYGON; + case PIPE_PRIM_LINES_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_LINES_ADJACENCY; + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_LINE_STRIP_ADJACENCY; + case PIPE_PRIM_TRIANGLES_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_TRIANGLES_ADJACENCY; + case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: + return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP_ADJACENCY; + default: + break; + } + + NOUVEAU_ERR("invalid primitive type %d\n", mode); + return NV50TCL_VERTEX_BEGIN_POINTS; +} + #endif diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c index b615f4e054..96a1f32d30 100644 --- a/src/gallium/drivers/nv50/nv50_push.c +++ b/src/gallium/drivers/nv50/nv50_push.c @@ -6,37 +6,6 @@ #include "nouveau/nouveau_util.h" #include "nv50_context.h" -static INLINE unsigned -nv50_prim(unsigned mode) -{ - switch (mode) { - case PIPE_PRIM_POINTS: return NV50TCL_VERTEX_BEGIN_POINTS; - case PIPE_PRIM_LINES: return NV50TCL_VERTEX_BEGIN_LINES; - case PIPE_PRIM_LINE_LOOP: return NV50TCL_VERTEX_BEGIN_LINE_LOOP; - case PIPE_PRIM_LINE_STRIP: return NV50TCL_VERTEX_BEGIN_LINE_STRIP; - case PIPE_PRIM_TRIANGLES: return NV50TCL_VERTEX_BEGIN_TRIANGLES; - case PIPE_PRIM_TRIANGLE_STRIP: - return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP; - case PIPE_PRIM_TRIANGLE_FAN: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN; - case PIPE_PRIM_QUADS: return NV50TCL_VERTEX_BEGIN_QUADS; - case PIPE_PRIM_QUAD_STRIP: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP; - case PIPE_PRIM_POLYGON: return NV50TCL_VERTEX_BEGIN_POLYGON; - case PIPE_PRIM_LINES_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_LINES_ADJACENCY; - case PIPE_PRIM_LINE_STRIP_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_LINE_STRIP_ADJACENCY; - case PIPE_PRIM_TRIANGLES_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_TRIANGLES_ADJACENCY; - case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP_ADJACENCY; - default: - break; - } - - NOUVEAU_ERR("invalid primitive type %d\n", mode); - return NV50TCL_VERTEX_BEGIN_POINTS; -} - struct push_context { struct nv50_context *nv50; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 7eedd49271..2b06b81056 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -30,37 +30,6 @@ #define NV50_USING_LOATHED_EDGEFLAG(ctx) ((ctx)->vertprog->cfg.edgeflag_in < 16) -static INLINE unsigned -nv50_prim(unsigned mode) -{ - switch (mode) { - case PIPE_PRIM_POINTS: return NV50TCL_VERTEX_BEGIN_POINTS; - case PIPE_PRIM_LINES: return NV50TCL_VERTEX_BEGIN_LINES; - case PIPE_PRIM_LINE_LOOP: return NV50TCL_VERTEX_BEGIN_LINE_LOOP; - case PIPE_PRIM_LINE_STRIP: return NV50TCL_VERTEX_BEGIN_LINE_STRIP; - case PIPE_PRIM_TRIANGLES: return NV50TCL_VERTEX_BEGIN_TRIANGLES; - case PIPE_PRIM_TRIANGLE_STRIP: - return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP; - case PIPE_PRIM_TRIANGLE_FAN: return NV50TCL_VERTEX_BEGIN_TRIANGLE_FAN; - case PIPE_PRIM_QUADS: return NV50TCL_VERTEX_BEGIN_QUADS; - case PIPE_PRIM_QUAD_STRIP: return NV50TCL_VERTEX_BEGIN_QUAD_STRIP; - case PIPE_PRIM_POLYGON: return NV50TCL_VERTEX_BEGIN_POLYGON; - case PIPE_PRIM_LINES_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_LINES_ADJACENCY; - case PIPE_PRIM_LINE_STRIP_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_LINE_STRIP_ADJACENCY; - case PIPE_PRIM_TRIANGLES_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_TRIANGLES_ADJACENCY; - case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: - return NV50TCL_VERTEX_BEGIN_TRIANGLE_STRIP_ADJACENCY; - default: - break; - } - - NOUVEAU_ERR("invalid primitive type %d\n", mode); - return NV50TCL_VERTEX_BEGIN_POINTS; -} - static INLINE uint32_t nv50_vbo_type_to_hw(enum pipe_format format) { -- cgit v1.2.3 From 9b233ce7de7923feb4b8ef4e1994baa4f13daeef Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 9 Mar 2010 14:56:46 +1000 Subject: nv50: remove unnecessary macro --- src/gallium/drivers/nv50/nv50_vbo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index 2b06b81056..6b9c1ee231 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -28,8 +28,6 @@ #include "nouveau/nouveau_util.h" #include "nv50_context.h" -#define NV50_USING_LOATHED_EDGEFLAG(ctx) ((ctx)->vertprog->cfg.edgeflag_in < 16) - static INLINE uint32_t nv50_vbo_type_to_hw(enum pipe_format format) { @@ -551,7 +549,8 @@ nv50_vbo_validate(struct nv50_context *nv50) if (nv50->vtxbuf_nr == 0) return NULL; - if (nv50->screen->force_push || NV50_USING_LOATHED_EDGEFLAG(nv50)) + if (nv50->screen->force_push || + nv50->vertprog->cfg.edgeflag_in < 16) nv50->vbo_fifo = 0xffff; for (i = 0; i < nv50->vtxbuf_nr; i++) { -- cgit v1.2.3 From 7b7fcb08542ddd63ed6ef4c6304aade3684db948 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 9 Mar 2010 15:29:12 +1000 Subject: nv50: remove nv50_context.state.instbuf --- src/gallium/drivers/nv50/nv50_context.h | 1 - src/gallium/drivers/nv50/nv50_state_validate.c | 5 ----- 2 files changed, 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index f65b328a56..6865686690 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -129,7 +129,6 @@ struct nv50_state { unsigned miptree_nr[PIPE_SHADER_TYPES]; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; - struct nouveau_stateobj *instbuf; unsigned vtxelt_nr; }; diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 2aaee31c0e..61be3a45fd 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -382,11 +382,6 @@ nv50_state_flush_notify(struct nouveau_channel *chan) so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */ so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */ so_emit_reloc_markers(chan, nv50->screen->static_init); - -#if 0 - if (nv50->state.instbuf) - so_emit_reloc_markers(chan, nv50->state.instbuf); -#endif } boolean -- cgit v1.2.3 From 139062946df4fba62a1e411073b61d4b0eeb034c Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Tue, 9 Mar 2010 15:30:08 +1000 Subject: nv50: inline nv50_state_flush_notify() It's (rightly) not called from anywhere else now --- src/gallium/drivers/nv50/nv50_context.h | 1 - src/gallium/drivers/nv50/nv50_state_validate.c | 21 ++++++--------------- 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 6865686690..8793c2aac5 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -235,7 +235,6 @@ extern void nv50_program_destroy(struct nv50_context *nv50, /* nv50_state_validate.c */ extern boolean nv50_state_validate(struct nv50_context *nv50, unsigned dwords); -extern void nv50_state_flush_notify(struct nouveau_channel *chan); extern void nv50_so_init_sifc(struct nv50_context *nv50, struct nouveau_stateobj *so, diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 61be3a45fd..2c8e7ca798 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -370,20 +370,6 @@ struct state_validate { }; #define validate_list_len (sizeof(validate_list) / sizeof(validate_list[0])) -void -nv50_state_flush_notify(struct nouveau_channel *chan) -{ - struct nv50_context *nv50 = chan->user_private; - - nv50_tex_relocs(nv50); - - so_emit_reloc_markers(chan, nv50->state.hw[0]); /* fb */ - so_emit_reloc_markers(chan, nv50->state.hw[3]); /* vp */ - so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */ - so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */ - so_emit_reloc_markers(chan, nv50->screen->static_init); -} - boolean nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) { @@ -446,7 +432,12 @@ nv50_state_validate(struct nv50_context *nv50, unsigned wait_dwords) * this the kernel is given no clue that the buffer is being used * still. This can cause all sorts of fun issues. */ - nv50_state_flush_notify(chan); + nv50_tex_relocs(nv50); + so_emit_reloc_markers(chan, nv50->state.hw[0]); /* fb */ + so_emit_reloc_markers(chan, nv50->state.hw[3]); /* vp */ + so_emit_reloc_markers(chan, nv50->state.hw[4]); /* fp */ + so_emit_reloc_markers(chan, nv50->state.hw[17]); /* vb */ + so_emit_reloc_markers(chan, nv50->screen->static_init); /* No idea.. */ BEGIN_RING(chan, tesla, 0x142c, 1); -- cgit v1.2.3 From ed7f73e161b93b4a83bb6ad6b6aa6cfcb65dc4b0 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 10 Mar 2010 15:22:53 +1000 Subject: nouveau: translate PIPE_BUFFER_USAGE_UNSYNCHRONIZED --- src/gallium/drivers/nouveau/nouveau_screen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index f7d10a591f..b1ad686022 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -124,7 +124,7 @@ nouveau_screen_map_flags(unsigned pipe) if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK) flags |= NOUVEAU_BO_NOWAIT; else - if (pipe & 0 /*PIPE_BUFFER_USAGE_UNSYNCHRONIZED*/) + if (pipe & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) flags |= NOUVEAU_BO_NOSYNC; return flags; -- cgit v1.2.3 From eeaa0861bfc98a06ceec269801271b7453c4fcbd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 07:23:29 +0000 Subject: llvmpipe: Cope with null Vertex element cso. CSO can often be null. For example: 1. at initialization 2. using an util module (u_blit) right after initialization (it will push state and pop the previous null state) 3. at shutdown time (state shouldn't be bound when being destroyed) Glean was hitting 2. --- src/gallium/drivers/llvmpipe/lp_state_vertex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_state_vertex.c b/src/gallium/drivers/llvmpipe/lp_state_vertex.c index 2ddd110a5f..f6427aa908 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vertex.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vertex.c @@ -61,7 +61,8 @@ llvmpipe_bind_vertex_elements_state(struct pipe_context *pipe, llvmpipe->dirty |= LP_NEW_VERTEX; - draw_set_vertex_elements(llvmpipe->draw, lp_velems->count, lp_velems->velem); + if (velems) + draw_set_vertex_elements(llvmpipe->draw, lp_velems->count, lp_velems->velem); } void -- cgit v1.2.3 From 3e38dbe3d3371f0a37dd35582301ae2b1507e5d2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 09:22:02 +0000 Subject: gallium: plumb winsys-drawable-handle through to state tracker The state trackers need this value so that they can supply it as the "void *" argument to flush_frontbuffer. Fixes single-buffer rendering. --- src/gallium/state_trackers/dri/dri_context.c | 12 +++++++++--- src/gallium/state_trackers/egl/common/egl_g3d.c | 9 +++++++-- src/gallium/state_trackers/egl/common/st_public_tmp.h | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 5 +++-- src/gallium/state_trackers/vega/vg_tracker.c | 10 +++++++++- src/gallium/state_trackers/vega/vg_tracker.h | 3 ++- src/gallium/state_trackers/wgl/stw_context.c | 6 +++--- src/mesa/state_tracker/st_context.c | 8 ++++++-- src/mesa/state_tracker/st_public.h | 3 ++- 9 files changed, 42 insertions(+), 16 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_context.c b/src/gallium/state_trackers/dri/dri_context.c index 908cef454e..2f991c39e3 100644 --- a/src/gallium/state_trackers/dri/dri_context.c +++ b/src/gallium/state_trackers/dri/dri_context.c @@ -128,7 +128,7 @@ dri_unbind_context(__DRIcontext * cPriv) if (--ctx->bind_count == 0) { if (ctx->st && ctx->st == st_get_current()) { st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL); - st_make_current(NULL, NULL, NULL); + st_make_current(NULL, NULL, NULL, NULL); } } } @@ -161,7 +161,13 @@ dri_make_current(__DRIcontext * cPriv, ctx->r_stamp = driReadPriv->lastStamp - 1; } - st_make_current(ctx->st, draw->stfb, read->stfb); + /* DRI co-state tracker currently overrides flush_frontbuffer. + * When this is fixed, will need to pass the drawable in the + * fourth parameter here so that when Mesa calls + * flush_frontbuffer directly (in front-buffer rendering), it + * will have access to the drawable argument: + */ + st_make_current(ctx->st, draw->stfb, read->stfb, NULL); if (__dri1_api_hooks) { dri1_update_drawables(ctx, draw, read); @@ -170,7 +176,7 @@ dri_make_current(__DRIcontext * cPriv, ctx->pipe->priv); } } else { - st_make_current(NULL, NULL, NULL); + st_make_current(NULL, NULL, NULL, NULL); } return GL_TRUE; diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c index f54c51a668..e4972d493d 100644 --- a/src/gallium/state_trackers/egl/common/egl_g3d.c +++ b/src/gallium/state_trackers/egl/common/egl_g3d.c @@ -892,8 +892,13 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, if (gctx) { ok = egl_g3d_realloc_context(dpy, &gctx->base); if (ok) { + /* XXX: need to pass the winsys argument for + * flush_frontbuffer in the fourth parameter here: + */ ok = gctx->stapi->st_make_current(gctx->st_ctx, - gctx->draw.st_fb, gctx->read.st_fb); + gctx->draw.st_fb, + gctx->read.st_fb, + NULL); if (ok) { egl_g3d_validate_context(dpy, &gctx->base); if (gdraw->base.Type == EGL_WINDOW_BIT) { @@ -905,7 +910,7 @@ egl_g3d_make_current(_EGLDriver *drv, _EGLDisplay *dpy, } } else if (old_gctx) { - ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL); + ok = old_gctx->stapi->st_make_current(NULL, NULL, NULL, NULL); old_gctx->base.WindowRenderBuffer = EGL_NONE; } diff --git a/src/gallium/state_trackers/egl/common/st_public_tmp.h b/src/gallium/state_trackers/egl/common/st_public_tmp.h index 507a0ec402..562dd68c15 100644 --- a/src/gallium/state_trackers/egl/common/st_public_tmp.h +++ b/src/gallium/state_trackers/egl/common/st_public_tmp.h @@ -9,7 +9,7 @@ ST_PUBLIC(st_get_framebuffer_surface, int, struct st_f ST_PUBLIC(st_get_framebuffer_texture, int, struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture) ST_PUBLIC(st_framebuffer_private, void *, struct st_framebuffer *stfb) ST_PUBLIC(st_unreference_framebuffer, void, struct st_framebuffer *stfb) -ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read) +ST_PUBLIC(st_make_current, GLboolean, struct st_context *st, struct st_framebuffer *draw, struct st_framebuffer *read, void *winsys_drawable_handle) ST_PUBLIC(st_get_current, struct st_context *, void) ST_PUBLIC(st_flush, void, struct st_context *st, uint pipeFlushFlags, struct pipe_fence_handle **fence) ST_PUBLIC(st_finish, void, struct st_context *st) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 568bc6e962..f4d7133d2f 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1020,7 +1020,8 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, c->xm_buffer = drawBuffer; c->xm_read_buffer = readBuffer; - st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb); + st_make_current(c->st, drawBuffer->stfb, readBuffer->stfb, + &drawBuffer->ws); xmesa_check_and_update_buffer_size(c, drawBuffer); if (readBuffer != drawBuffer) @@ -1031,7 +1032,7 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, } else { /* Detach */ - st_make_current( NULL, NULL, NULL ); + st_make_current( NULL, NULL, NULL, NULL ); } return GL_TRUE; diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index 57d3baad7f..a002e50faf 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -376,11 +376,19 @@ void st_unreference_framebuffer(struct st_framebuffer *stfb) boolean st_make_current(struct vg_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read) + struct st_framebuffer *read, + void *winsys_drawable_handle) { vg_set_current_context(st); if (st) { st->draw_buffer = draw; + + /* VG state tracker doesn't seem to do front-buffer rendering + * (no calls to flush_frontbuffer). If it ever did start doing + * that, it would need to pass this value down in the + * flush_frontbuffer call: + */ + st->pipe->priv = winsys_drawable_handle; } return VG_TRUE; } diff --git a/src/gallium/state_trackers/vega/vg_tracker.h b/src/gallium/state_trackers/vega/vg_tracker.h index c1196954a7..165a6b7a33 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.h +++ b/src/gallium/state_trackers/vega/vg_tracker.h @@ -101,7 +101,8 @@ void st_unreference_framebuffer(struct st_framebuffer *stfb); PUBLIC boolean st_make_current(struct vg_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read); + struct st_framebuffer *read, + void *winsys_drawable_handle); PUBLIC struct vg_context *st_get_current(void); diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 05ccd5febc..866f485a40 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -226,7 +226,7 @@ DrvDeleteContext( /* Unbind current if deleting current context. */ if (curctx == ctx) - st_make_current( NULL, NULL, NULL ); + st_make_current( NULL, NULL, NULL, NULL ); st_destroy_context(ctx->st); FREE(ctx); @@ -317,7 +317,7 @@ stw_make_current( } if (hdc == NULL || dhglrc == 0) { - return st_make_current( NULL, NULL, NULL ); + return st_make_current( NULL, NULL, NULL, NULL ); } pipe_mutex_lock( stw_dev->ctx_mutex ); @@ -352,7 +352,7 @@ stw_make_current( /* pass to stw_flush_frontbuffer as context_private */ ctx->st->pipe->priv = hdc; - if(!st_make_current( ctx->st, fb->stfb, fb->stfb )) + if(!st_make_current( ctx->st, fb->stfb, fb->stfb, hdc )) goto fail; success: diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 0358a70726..09f891d691 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -272,7 +272,8 @@ void st_destroy_context( struct st_context *st ) GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read) + struct st_framebuffer *read, + void *winsys_drawable_handle ) { /* Call this periodically to detect when the user has begun using * GL rendering from multiple threads. @@ -280,10 +281,13 @@ st_make_current(struct st_context *st, _glapi_check_multithread(); if (st) { - if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) + if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) { + st->pipe->priv = NULL; return GL_FALSE; + } _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); + st->pipe->priv = winsys_drawable_handle; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 0824356cec..4b40d6d044 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -105,7 +105,8 @@ void st_unreference_framebuffer( struct st_framebuffer *stfb ); PUBLIC GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read); + struct st_framebuffer *read, + void *winsys_drawable_handle); PUBLIC struct st_context *st_get_current(void); -- cgit v1.2.3 From 7ce6b3130698aada770dc54b58e7b62e9cf20ad7 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 09:51:41 +0000 Subject: trace: include tr_public.h --- src/gallium/drivers/trace/tr_screen.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index a15addeb8c..86ddb99540 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -35,6 +35,7 @@ #include "tr_texture.h" #include "tr_context.h" #include "tr_screen.h" +#include "tr_public.h" #include "util/u_inlines.h" #include "pipe/p_format.h" -- cgit v1.2.3 From 80f86d22b2d16e3191dfeedcb9ea94bf30db68a5 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 09:52:25 +0000 Subject: st/wgl: add missing paramter --- src/gallium/state_trackers/wgl/stw_context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/wgl/stw_context.c b/src/gallium/state_trackers/wgl/stw_context.c index 866f485a40..1f11b649c3 100644 --- a/src/gallium/state_trackers/wgl/stw_context.c +++ b/src/gallium/state_trackers/wgl/stw_context.c @@ -367,7 +367,7 @@ success: fail: if(fb) stw_framebuffer_release(fb); - st_make_current( NULL, NULL, NULL ); + st_make_current( NULL, NULL, NULL, NULL ); return FALSE; } -- cgit v1.2.3 From 5235c5aac7c3a2e4af41cb70864245cc254fb797 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 10:00:08 +0000 Subject: Revert "r300-gallium: Skeleton for integrating into the python statetracker." This reverts commit 2d56d0839e6db0861131893d67fe23734800085a. Never actually used. --- src/gallium/winsys/drm/radeon/python/README | 15 - src/gallium/winsys/drm/radeon/python/SConscript | 33 -- .../drm/radeon/python/radeon_hardpipe_winsys.c | 132 ----- src/gallium/winsys/drm/radeon/python/xf86dri.c | 605 --------------------- src/gallium/winsys/drm/radeon/python/xf86dri.h | 123 ----- src/gallium/winsys/drm/radeon/python/xf86dristr.h | 389 ------------- 6 files changed, 1297 deletions(-) delete mode 100644 src/gallium/winsys/drm/radeon/python/README delete mode 100644 src/gallium/winsys/drm/radeon/python/SConscript delete mode 100644 src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c delete mode 100644 src/gallium/winsys/drm/radeon/python/xf86dri.c delete mode 100644 src/gallium/winsys/drm/radeon/python/xf86dri.h delete mode 100644 src/gallium/winsys/drm/radeon/python/xf86dristr.h (limited to 'src/gallium') diff --git a/src/gallium/winsys/drm/radeon/python/README b/src/gallium/winsys/drm/radeon/python/README deleted file mode 100644 index 339836a592..0000000000 --- a/src/gallium/winsys/drm/radeon/python/README +++ /dev/null @@ -1,15 +0,0 @@ -Python bindings for the radeon gallium driver. - - -See gallium/src/gallium/state_trackers/python/README for more information. - - -Build as: - - scons debug=1 statetrackers=python winsys=drm/radeon/python - -Run as: - - export PYTHONPATH=$PWD/build/linux-x86-debug/gallium/winsys/drm/radeon/python:$PWD/build/linux-x86-debug/gallium/state_trackers/python - - python progs/gallium/python/samples/tri.py diff --git a/src/gallium/winsys/drm/radeon/python/SConscript b/src/gallium/winsys/drm/radeon/python/SConscript deleted file mode 100644 index 91cae98697..0000000000 --- a/src/gallium/winsys/drm/radeon/python/SConscript +++ /dev/null @@ -1,33 +0,0 @@ -import os.path - -Import('*') - -if env['platform'] == 'linux': - - env = env.Clone() - - env.Tool('python') - - env.ParseConfig('pkg-config --cflags --libs libdrm') - - env.Prepend(CPPPATH = [ - '#src/gallium/state_trackers/python', - '../core', - ]) - - drivers = [ - softpipe, - radeon, - trace, - ] - - sources = [ - 'radeon_hardpipe_winsys.c', - 'xf86dri.c', - ] - - env.SharedLibrary( - target ='_gallium', - source = sources, - LIBS = [pyst] + drivers + gallium + env['LIBS'], - ) diff --git a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c b/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c deleted file mode 100644 index fc63081a4c..0000000000 --- a/src/gallium/winsys/drm/radeon/python/radeon_hardpipe_winsys.c +++ /dev/null @@ -1,132 +0,0 @@ - /************************************************************************** - * - * Copyright 2009 VMware, Inc. - * 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 VMWARE 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 -#include -#include - -#include -#include -#include - -#include "pipe/p_screen.h" -#include "pipe/p_context.h" - -#include "st_winsys.h" - -#include "radeon_winsys.h" - -#include "xf86dri.h" - - -/* XXX: Force init_gallium symbol to be linked */ -extern void init_gallium(void); -void (*force_init_gallium_linkage)(void) = &init_gallium; - - -static struct pipe_screen * -radeon_hardpipe_screen_create(void) -{ - Display *dpy; - Window rootWin; - XWindowAttributes winAttr; - int isCapable; - int screen; - char *driverName; - char *curBusID; - unsigned magic; - int ddxDriverMajor; - int ddxDriverMinor; - int ddxDriverPatch; - drm_handle_t sAreaOffset; - int ret; - int drmFD; - drm_context_t hHWContext; - XID id; - - dpy = XOpenDisplay(":0"); - if (!dpy) { - fprintf(stderr, "Open Display Failed\n"); - return NULL; - } - - screen = DefaultScreen(dpy); - rootWin = RootWindow(dpy, screen); - XGetWindowAttributes(dpy, rootWin, &winAttr); - - ret = uniDRIQueryDirectRenderingCapable(dpy, screen, &isCapable); - if (!ret || !isCapable) { - fprintf(stderr, "No DRI on this display:sceen\n"); - goto error; - } - - if (!uniDRIOpenConnection(dpy, screen, &sAreaOffset, - &curBusID)) { - fprintf(stderr, "Could not open DRI connection.\n"); - goto error; - } - - if (!uniDRIGetClientDriverName(dpy, screen, &ddxDriverMajor, - &ddxDriverMinor, &ddxDriverPatch, - &driverName)) { - fprintf(stderr, "Could not get DRI driver name.\n"); - goto error; - } - - if ((drmFD = drmOpen(NULL, curBusID)) < 0) { - perror("DRM Device could not be opened"); - goto error; - } - - drmGetMagic(drmFD, &magic); - if (!uniDRIAuthConnection(dpy, screen, magic)) { - fprintf(stderr, "Could not get X server to authenticate us.\n"); - goto error; - } - - if (!uniDRICreateContext(dpy, screen, winAttr.visual, - &id, &hHWContext)) { - fprintf(stderr, "Could not create DRI context.\n"); - goto error; - } - - /* FIXME: create a radeon pipe_screen from drmFD and hHWContext */ - - return NULL; - -error: - return NULL; -} - - - - -const struct st_winsys st_hardpipe_winsys = { - &radeon_hardpipe_screen_create, -}; - diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.c b/src/gallium/winsys/drm/radeon/python/xf86dri.c deleted file mode 100644 index 1736f1e54f..0000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dri.c +++ /dev/null @@ -1,605 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Faith - * - */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define NEED_REPLIES -#include -#include -#include -#include "xf86dristr.h" - -static XExtensionInfo _xf86dri_info_data; -static XExtensionInfo *xf86dri_info = &_xf86dri_info_data; -static char xf86dri_extension_name[] = XF86DRINAME; - -#define uniDRICheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86dri_extension_name, val) - -/***************************************************************************** - * * - * private utility routines * - * * - *****************************************************************************/ - -static int close_display(Display * dpy, XExtCodes * extCodes); -static /* const */ XExtensionHooks xf86dri_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info, - xf86dri_extension_name, &xf86dri_extension_hooks, - 0, NULL) - - static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info) - -/***************************************************************************** - * * - * public XFree86-DRI Extension routines * - * * - *****************************************************************************/ -#if 0 -#include -#define TRACE(msg) fprintf(stderr,"uniDRI%s\n", msg); -#else -#define TRACE(msg) -#endif - Bool uniDRIQueryExtension(dpy, event_basep, error_basep) - Display *dpy; - int *event_basep, *error_basep; -{ - XExtDisplayInfo *info = find_display(dpy); - - TRACE("QueryExtension..."); - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - TRACE("QueryExtension... return True"); - return True; - } else { - TRACE("QueryExtension... return False"); - return False; - } -} - -Bool -uniDRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion) - Display *dpy; - int *majorVersion; - int *minorVersion; - int *patchVersion; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryVersionReply rep; - xXF86DRIQueryVersionReq *req; - - TRACE("QueryVersion..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryVersion; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return False"); - return False; - } - *majorVersion = rep.majorVersion; - *minorVersion = rep.minorVersion; - *patchVersion = rep.patchVersion; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryVersion... return True"); - return True; -} - -Bool -uniDRIQueryDirectRenderingCapable(dpy, screen, isCapable) - Display *dpy; - int screen; - Bool *isCapable; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIQueryDirectRenderingCapableReply rep; - xXF86DRIQueryDirectRenderingCapableReq *req; - - TRACE("QueryDirectRenderingCapable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIQueryDirectRenderingCapable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIQueryDirectRenderingCapable; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return False"); - return False; - } - *isCapable = rep.isCapable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("QueryDirectRenderingCapable... return True"); - return True; -} - -Bool -uniDRIOpenConnection(dpy, screen, hSAREA, busIdString) - Display *dpy; - int screen; - drm_handle_t *hSAREA; - char **busIdString; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIOpenConnectionReply rep; - xXF86DRIOpenConnectionReq *req; - - TRACE("OpenConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIOpenConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIOpenConnection; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - - *hSAREA = rep.hSAREALow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hSAREA |= ((unsigned long)rep.hSAREAHigh) << 32; - } -#endif - if (rep.length) { - if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) { - _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return False"); - return False; - } - _XReadPad(dpy, *busIdString, rep.busIdStringLength); - } else { - *busIdString = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("OpenConnection... return True"); - return True; -} - -Bool -uniDRIAuthConnection(dpy, screen, magic) - Display *dpy; - int screen; - drm_magic_t magic; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIAuthConnectionReq *req; - xXF86DRIAuthConnectionReply rep; - - TRACE("AuthConnection..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIAuthConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIAuthConnection; - req->screen = screen; - req->magic = magic; - rep.authenticated = 0; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return False"); - return False; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("AuthConnection... return True"); - return True; -} - -Bool -uniDRICloseConnection(dpy, screen) - Display *dpy; - int screen; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICloseConnectionReq *req; - - TRACE("CloseConnection..."); - - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICloseConnection, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICloseConnection; - req->screen = screen; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CloseConnection... return True"); - return True; -} - -Bool -uniDRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, - ddxDriverMinorVersion, ddxDriverPatchVersion, - clientDriverName) - Display *dpy; - int screen; - int *ddxDriverMajorVersion; - int *ddxDriverMinorVersion; - int *ddxDriverPatchVersion; - char **clientDriverName; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetClientDriverNameReply rep; - xXF86DRIGetClientDriverNameReq *req; - - TRACE("GetClientDriverName..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetClientDriverName, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetClientDriverName; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - - *ddxDriverMajorVersion = rep.ddxDriverMajorVersion; - *ddxDriverMinorVersion = rep.ddxDriverMinorVersion; - *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; - - if (rep.length) { - if (!(*clientDriverName = - (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { - _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return False"); - return False; - } - _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength); - } else { - *clientDriverName = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetClientDriverName... return True"); - return True; -} - -Bool -uniDRICreateContextWithConfig(dpy, screen, configID, context, hHWContext) - Display *dpy; - int screen; - int configID; - XID *context; - drm_context_t *hHWContext; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateContextReply rep; - xXF86DRICreateContextReq *req; - - TRACE("CreateContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateContext; - req->visual = configID; - req->screen = screen; - *context = XAllocID(dpy); - req->context = *context; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return False"); - return False; - } - *hHWContext = rep.hHWContext; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateContext... return True"); - return True; -} - -Bool -uniDRICreateContext(dpy, screen, visual, context, hHWContext) - Display *dpy; - int screen; - Visual *visual; - XID *context; - drm_context_t *hHWContext; -{ - return uniDRICreateContextWithConfig(dpy, screen, visual->visualid, - context, hHWContext); -} - -Bool -uniDRIDestroyContext(Display * ndpy, int screen, XID context) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyContextReq *req; - - TRACE("DestroyContext..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyContext, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyContext; - req->screen = screen; - req->context = context; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyContext... return True"); - return True; -} - -Bool -uniDRICreateDrawable(Display * ndpy, int screen, - Drawable drawable, drm_drawable_t * hHWDrawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRICreateDrawableReply rep; - xXF86DRICreateDrawableReq *req; - - TRACE("CreateDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRICreateDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRICreateDrawable; - req->screen = screen; - req->drawable = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return False"); - return False; - } - *hHWDrawable = rep.hHWDrawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("CreateDrawable... return True"); - return True; -} - -Bool -uniDRIDestroyDrawable(Display * ndpy, int screen, Drawable drawable) -{ - Display *const dpy = (Display *) ndpy; - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIDestroyDrawableReq *req; - - TRACE("DestroyDrawable..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIDestroyDrawable, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIDestroyDrawable; - req->screen = screen; - req->drawable = drawable; - UnlockDisplay(dpy); - SyncHandle(); - TRACE("DestroyDrawable... return True"); - return True; -} - -Bool -uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDrawableInfoReply rep; - xXF86DRIGetDrawableInfoReq *req; - int total_rects; - - TRACE("GetDrawableInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDrawableInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDrawableInfo; - req->screen = screen; - req->drawable = drawable; - - if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } - *index = rep.drawableTableIndex; - *stamp = rep.drawableTableStamp; - *X = (int)rep.drawableX; - *Y = (int)rep.drawableY; - *W = (int)rep.drawableWidth; - *H = (int)rep.drawableHeight; - *numClipRects = rep.numClipRects; - total_rects = *numClipRects; - - *backX = rep.backX; - *backY = rep.backY; - *numBackClipRects = rep.numBackClipRects; - total_rects += *numBackClipRects; - -#if 0 - /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks - * backwards compatibility (Because of the >> 2 shift) but the fix - * enables multi-threaded apps to work. - */ - if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply) + - total_rects * sizeof(drm_clip_rect_t)) + - 3) & ~3) >> 2)) { - _XEatData(dpy, rep.length); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return False"); - return False; - } -#endif - - if (*numClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numClipRects); - - *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pClipRects) - _XRead(dpy, (char *)*pClipRects, len); - } else { - *pClipRects = NULL; - } - - if (*numBackClipRects) { - int len = sizeof(drm_clip_rect_t) * (*numBackClipRects); - - *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1); - if (*pBackClipRects) - _XRead(dpy, (char *)*pBackClipRects, len); - } else { - *pBackClipRects = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDrawableInfo... return True"); - return True; -} - -Bool -uniDRIGetDeviceInfo(dpy, screen, hFrameBuffer, - fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate) - Display *dpy; - int screen; - drm_handle_t *hFrameBuffer; - int *fbOrigin; - int *fbSize; - int *fbStride; - int *devPrivateSize; - void **pDevPrivate; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86DRIGetDeviceInfoReply rep; - xXF86DRIGetDeviceInfoReq *req; - - TRACE("GetDeviceInfo..."); - uniDRICheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86DRIGetDeviceInfo, req); - req->reqType = info->codes->major_opcode; - req->driReqType = X_XF86DRIGetDeviceInfo; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - - *hFrameBuffer = rep.hFrameBufferLow; -#ifdef LONG64 - if (sizeof(drm_handle_t) == 8) { - *hFrameBuffer |= ((unsigned long)rep.hFrameBufferHigh) << 32; - } -#endif - - *fbOrigin = rep.framebufferOrigin; - *fbSize = rep.framebufferSize; - *fbStride = rep.framebufferStride; - *devPrivateSize = rep.devPrivateSize; - - if (rep.length) { - if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) { - _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return False"); - return False; - } - _XRead(dpy, (char *)*pDevPrivate, rep.devPrivateSize); - } else { - *pDevPrivate = NULL; - } - - UnlockDisplay(dpy); - SyncHandle(); - TRACE("GetDeviceInfo... return True"); - return True; -} diff --git a/src/gallium/winsys/drm/radeon/python/xf86dri.h b/src/gallium/winsys/drm/radeon/python/xf86dri.h deleted file mode 100644 index bf6de37d9d..0000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dri.h +++ /dev/null @@ -1,123 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT 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 xf86dri.h - * Protocol numbers and function prototypes for DRI X protocol. - * - * \author Kevin E. Martin - * \author Jens Owen - * \author Rickard E. (Rik) Faith - */ - -#ifndef _XF86DRI_H_ -#define _XF86DRI_H_ - -#include -#include -#include - -#define X_XF86DRIQueryVersion 0 -#define X_XF86DRIQueryDirectRenderingCapable 1 -#define X_XF86DRIOpenConnection 2 -#define X_XF86DRICloseConnection 3 -#define X_XF86DRIGetClientDriverName 4 -#define X_XF86DRICreateContext 5 -#define X_XF86DRIDestroyContext 6 -#define X_XF86DRICreateDrawable 7 -#define X_XF86DRIDestroyDrawable 8 -#define X_XF86DRIGetDrawableInfo 9 -#define X_XF86DRIGetDeviceInfo 10 -#define X_XF86DRIAuthConnection 11 -#define X_XF86DRIOpenFullScreen 12 /* Deprecated */ -#define X_XF86DRICloseFullScreen 13 /* Deprecated */ - -#define XF86DRINumberEvents 0 - -#define XF86DRIClientNotLocal 0 -#define XF86DRIOperationNotSupported 1 -#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1) - -#ifndef _XF86DRI_SERVER_ - -_XFUNCPROTOBEGIN - Bool uniDRIQueryExtension(Display * dpy, int *event_base, - int *error_base); - -Bool uniDRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion, - int *patchVersion); - -Bool uniDRIQueryDirectRenderingCapable(Display * dpy, int screen, - Bool * isCapable); - -Bool uniDRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA, - char **busIDString); - -Bool uniDRIAuthConnection(Display * dpy, int screen, drm_magic_t magic); - -Bool uniDRICloseConnection(Display * dpy, int screen); - -Bool uniDRIGetClientDriverName(Display * dpy, int screen, - int *ddxDriverMajorVersion, - int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, - char **clientDriverName); - -Bool uniDRICreateContext(Display * dpy, int screen, Visual * visual, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -Bool uniDRICreateContextWithConfig(Display * dpy, int screen, int configID, - XID * ptr_to_returned_context_id, - drm_context_t * hHWContext); - -extern Bool uniDRIDestroyContext(Display * dpy, int screen, XID context_id); - -extern Bool uniDRICreateDrawable(Display * dpy, int screen, - Drawable drawable, - drm_drawable_t * hHWDrawable); - -extern Bool uniDRIDestroyDrawable(Display * dpy, int screen, - Drawable drawable); - -Bool uniDRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable, - unsigned int *index, unsigned int *stamp, - int *X, int *Y, int *W, int *H, - int *numClipRects, drm_clip_rect_t ** pClipRects, - int *backX, int *backY, - int *numBackClipRects, - drm_clip_rect_t ** pBackClipRects); - -Bool uniDRIGetDeviceInfo(Display * dpy, int screen, - drm_handle_t * hFrameBuffer, int *fbOrigin, - int *fbSize, int *fbStride, int *devPrivateSize, - void **pDevPrivate); - -_XFUNCPROTOEND -#endif /* _XF86DRI_SERVER_ */ -#endif /* _XF86DRI_H_ */ diff --git a/src/gallium/winsys/drm/radeon/python/xf86dristr.h b/src/gallium/winsys/drm/radeon/python/xf86dristr.h deleted file mode 100644 index d898996360..0000000000 --- a/src/gallium/winsys/drm/radeon/python/xf86dristr.h +++ /dev/null @@ -1,389 +0,0 @@ -/************************************************************************** - -Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. -Copyright 2000 VA Linux Systems, Inc. -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 PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR -ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin - * Jens Owen - * Rickard E. (Rik) Fiath - * - */ - -#ifndef _XF86DRISTR_H_ -#define _XF86DRISTR_H_ - -#include "xf86dri.h" - -#define XF86DRINAME "XFree86-DRI" - -/* The DRI version number. This was originally set to be the same of the - * XFree86 version number. However, this version is really indepedent of - * the XFree86 version. - * - * Version History: - * 4.0.0: Original - * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02 - * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02 - */ -#define XF86DRI_MAJOR_VERSION 4 -#define XF86DRI_MINOR_VERSION 1 -#define XF86DRI_PATCH_VERSION 0 - -typedef struct _XF86DRIQueryVersion -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIQueryVersion */ - CARD16 length B16; -} xXF86DRIQueryVersionReq; - -#define sz_xXF86DRIQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DRI protocol */ - CARD16 minorVersion B16; /* minor version of DRI protocol */ - CARD32 patchVersion B32; /* patch version of DRI protocol */ - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIQueryVersionReply; - -#define sz_xXF86DRIQueryVersionReply 32 - -typedef struct _XF86DRIQueryDirectRenderingCapable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIQueryDirectRenderingCapableReq; - -#define sz_xXF86DRIQueryDirectRenderingCapableReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - BOOL isCapable; - BOOL pad2; - BOOL pad3; - BOOL pad4; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; - CARD32 pad9 B32; -} xXF86DRIQueryDirectRenderingCapableReply; - -#define sz_xXF86DRIQueryDirectRenderingCapableReply 32 - -typedef struct _XF86DRIOpenConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIOpenConnectionReq; - -#define sz_xXF86DRIOpenConnectionReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hSAREALow B32; - CARD32 hSAREAHigh B32; - CARD32 busIdStringLength B32; - CARD32 pad6 B32; - CARD32 pad7 B32; - CARD32 pad8 B32; -} xXF86DRIOpenConnectionReply; - -#define sz_xXF86DRIOpenConnectionReply 32 - -typedef struct _XF86DRIAuthConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; - CARD32 magic B32; -} xXF86DRIAuthConnectionReq; - -#define sz_xXF86DRIAuthConnectionReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 authenticated B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIAuthConnectionReply; - -#define zx_xXF86DRIAuthConnectionReply 32 - -typedef struct _XF86DRICloseConnection -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseConnection */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRICloseConnectionReq; - -#define sz_xXF86DRICloseConnectionReq 8 - -typedef struct _XF86DRIGetClientDriverName -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetClientDriverName */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetClientDriverNameReq; - -#define sz_xXF86DRIGetClientDriverNameReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 ddxDriverMajorVersion B32; - CARD32 ddxDriverMinorVersion B32; - CARD32 ddxDriverPatchVersion B32; - CARD32 clientDriverNameLength B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIGetClientDriverNameReply; - -#define sz_xXF86DRIGetClientDriverNameReply 32 - -typedef struct _XF86DRICreateContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 visual B32; - CARD32 context B32; -} xXF86DRICreateContextReq; - -#define sz_xXF86DRICreateContextReq 16 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWContext B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateContextReply; - -#define sz_xXF86DRICreateContextReply 32 - -typedef struct _XF86DRIDestroyContext -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyContext */ - CARD16 length B16; - CARD32 screen B32; - CARD32 context B32; -} xXF86DRIDestroyContextReq; - -#define sz_xXF86DRIDestroyContextReq 12 - -typedef struct _XF86DRICreateDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICreateDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICreateDrawableReq; - -#define sz_xXF86DRICreateDrawableReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hHWDrawable B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRICreateDrawableReply; - -#define sz_xXF86DRICreateDrawableReply 32 - -typedef struct _XF86DRIDestroyDrawable -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIDestroyDrawable */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIDestroyDrawableReq; - -#define sz_xXF86DRIDestroyDrawableReq 12 - -typedef struct _XF86DRIGetDrawableInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDrawableInfo */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIGetDrawableInfoReq; - -#define sz_xXF86DRIGetDrawableInfoReq 12 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 drawableTableIndex B32; - CARD32 drawableTableStamp B32; - INT16 drawableX B16; - INT16 drawableY B16; - INT16 drawableWidth B16; - INT16 drawableHeight B16; - CARD32 numClipRects B32; - INT16 backX B16; - INT16 backY B16; - CARD32 numBackClipRects B32; -} xXF86DRIGetDrawableInfoReply; - -#define sz_xXF86DRIGetDrawableInfoReply 36 - -typedef struct _XF86DRIGetDeviceInfo -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIGetDeviceInfo */ - CARD16 length B16; - CARD32 screen B32; -} xXF86DRIGetDeviceInfoReq; - -#define sz_xXF86DRIGetDeviceInfoReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 hFrameBufferLow B32; - CARD32 hFrameBufferHigh B32; - CARD32 framebufferOrigin B32; - CARD32 framebufferSize B32; - CARD32 framebufferStride B32; - CARD32 devPrivateSize B32; -} xXF86DRIGetDeviceInfoReply; - -#define sz_xXF86DRIGetDeviceInfoReply 32 - -typedef struct _XF86DRIOpenFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRIOpenFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRIOpenFullScreenReq; - -#define sz_xXF86DRIOpenFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 isFullScreen B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DRIOpenFullScreenReply; - -#define sz_xXF86DRIOpenFullScreenReply 32 - -typedef struct _XF86DRICloseFullScreen -{ - CARD8 reqType; /* always DRIReqCode */ - CARD8 driReqType; /* always X_DRICloseFullScreen */ - CARD16 length B16; - CARD32 screen B32; - CARD32 drawable B32; -} xXF86DRICloseFullScreenReq; - -#define sz_xXF86DRICloseFullScreenReq 12 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xXF86DRICloseFullScreenReply; - -#define sz_xXF86DRICloseFullScreenReply 32 - -#endif /* _XF86DRISTR_H_ */ -- cgit v1.2.3 From 601bfb5951ae303b54b4dd8a50bf0558017bf549 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 10:34:29 +0000 Subject: python: Fix up state tracker for sw api. --- SConstruct | 1 + src/gallium/state_trackers/python/SConscript | 29 ++--- src/gallium/state_trackers/python/st_device.c | 52 +++----- src/gallium/state_trackers/python/st_device.h | 9 +- .../state_trackers/python/st_hardpipe_winsys.c | 11 +- .../state_trackers/python/st_llvmpipe_winsys.c | 141 --------------------- .../state_trackers/python/st_softpipe_winsys.c | 53 ++++++-- src/gallium/state_trackers/python/st_winsys.h | 14 +- 8 files changed, 85 insertions(+), 225 deletions(-) delete mode 100644 src/gallium/state_trackers/python/st_llvmpipe_winsys.c (limited to 'src/gallium') diff --git a/SConstruct b/SConstruct index 5e171ea2e1..606be015c0 100644 --- a/SConstruct +++ b/SConstruct @@ -124,6 +124,7 @@ env.Append(CPPPATH = [ '#/src/gallium/include', '#/src/gallium/auxiliary', '#/src/gallium/drivers', + '#/src/gallium/winsys', ]) if env['msvc']: diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 527e065cd9..8010f122b7 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -33,31 +33,26 @@ if 'python' in env['statetrackers']: 'gallium.i', 'st_device.c', 'st_sample.c', + 'st_hardpipe_winsys.c', + 'st_softpipe_winsys.c', ] - drivers = [ - trace - ] + env.Prepend(LIBS = [ + trace, + gallium + ]) if 'llvmpipe' in env['drivers']: + env.Append(CPPDEFINES = ['HAVE_LLVMPIPE']) env.Tool('llvm') - sources += ['st_llvmpipe_winsys.c'] - drivers += [llvmpipe] - else: - sources += ['st_softpipe_winsys.c'] - drivers += [softpipe] - - pyst = env.ConvenienceLibrary( - target = 'pyst', - source = sources, - ) + env.Prepend(LIBS = [llvmpipe]) + if 'softpipe' in env['drivers']: + env.Append(CPPDEFINES = ['HAVE_SOFTPIPE']) + env.Prepend(LIBS = [softpipe]) env['no_import_lib'] = 1 env.SharedLibrary( target = '_gallium', - source = [ - 'st_hardpipe_winsys.c', - ], - LIBS = [pyst] + drivers + gallium + env['LIBS'], + source = sources, ) diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 45e7841750..335e8e7f0d 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -34,8 +34,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_simple_shaders.h" -#include "trace/tr_screen.h" -#include "trace/tr_context.h" +#include "trace/tr_public.h" #include "st_device.h" #include "st_winsys.h" @@ -75,43 +74,34 @@ st_device_destroy(struct st_device *st_dev) } -static struct st_device * -st_device_create_from_st_winsys(const struct st_winsys *st_ws) +struct st_device * +st_device_create(boolean hardware) { + struct pipe_screen *screen; struct st_device *st_dev; - - if(!st_ws->screen_create) - return NULL; - + + if (hardware) + screen = st_hardware_screen_create(); + else + screen = st_software_screen_create(); + + screen = trace_screen_create(screen); + if (!screen) + goto no_screen; + st_dev = CALLOC_STRUCT(st_device); - if(!st_dev) - return NULL; + if (!st_dev) + goto no_device; pipe_reference_init(&st_dev->reference, 1); - st_dev->st_ws = st_ws; - - st_dev->real_screen = st_ws->screen_create(); - if(!st_dev->real_screen) { - st_device_destroy(st_dev); - return NULL; - } - - st_dev->screen = trace_screen_create(st_dev->real_screen); - if(!st_dev->screen) { - st_device_destroy(st_dev); - return NULL; - } + st_dev->screen = screen; return st_dev; -} - -struct st_device * -st_device_create(boolean hardware) { - if(hardware) - return st_device_create_from_st_winsys(&st_hardpipe_winsys); - else - return st_device_create_from_st_winsys(&st_softpipe_winsys); +no_device: + screen->destroy(screen); +no_screen: + return NULL; } diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h index de9e0215d8..6ec7409b11 100644 --- a/src/gallium/state_trackers/python/st_device.h +++ b/src/gallium/state_trackers/python/st_device.h @@ -47,7 +47,8 @@ struct st_surface }; -struct st_context { +struct st_context +{ struct st_device *st_dev; struct pipe_context *pipe; @@ -72,13 +73,11 @@ struct st_context { }; -struct st_device { +struct st_device +{ /* FIXME: we also need to refcount for textures and surfaces... */ struct pipe_reference reference; - const struct st_winsys *st_ws; - - struct pipe_screen *real_screen; struct pipe_screen *screen; }; diff --git a/src/gallium/state_trackers/python/st_hardpipe_winsys.c b/src/gallium/state_trackers/python/st_hardpipe_winsys.c index a3110a19d5..0bf7c51613 100644 --- a/src/gallium/state_trackers/python/st_hardpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_hardpipe_winsys.c @@ -207,16 +207,11 @@ st_hardpipe_load(void) #endif -static struct pipe_screen * -st_hardpipe_screen_create(void) +struct pipe_screen * +st_hardware_screen_create(void) { if(st_hardpipe_load()) return pfnGetGalliumScreenMESA(); else - return st_softpipe_winsys.screen_create(); + return st_software_screen_create(); } - - -const struct st_winsys st_hardpipe_winsys = { - &st_hardpipe_screen_create -}; diff --git a/src/gallium/state_trackers/python/st_llvmpipe_winsys.c b/src/gallium/state_trackers/python/st_llvmpipe_winsys.c deleted file mode 100644 index 5d83b5a9e1..0000000000 --- a/src/gallium/state_trackers/python/st_llvmpipe_winsys.c +++ /dev/null @@ -1,141 +0,0 @@ -/************************************************************************** - * - * Copyright 2010 VMware, Inc. - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/** - * @file - * Llvmpipe support. - * - * @author Jose Fonseca - */ - - -#include "pipe/p_format.h" -#include "pipe/p_context.h" -#include "util/u_inlines.h" -#include "util/u_math.h" -#include "util/u_memory.h" -#include "llvmpipe/lp_winsys.h" -#include "st_winsys.h" - - -static boolean -llvmpipe_ws_is_displaytarget_format_supported( struct llvmpipe_winsys *ws, - enum pipe_format format ) -{ - return FALSE; -} - - -static void * -llvmpipe_ws_displaytarget_map(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt, - unsigned flags ) -{ - assert(0); - return NULL; -} - - -static void -llvmpipe_ws_displaytarget_unmap(struct llvmpipe_winsys *ws, - struct llvmpipe_displaytarget *dt ) -{ - assert(0); -} - - -static void -llvmpipe_ws_displaytarget_destroy(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt) -{ - assert(0); -} - - -static struct llvmpipe_displaytarget * -llvmpipe_ws_displaytarget_create(struct llvmpipe_winsys *winsys, - enum pipe_format format, - unsigned width, unsigned height, - unsigned alignment, - unsigned *stride) -{ - return NULL; -} - - -static void -llvmpipe_ws_displaytarget_display(struct llvmpipe_winsys *winsys, - struct llvmpipe_displaytarget *dt, - void *context_private) -{ - assert(0); -} - - -static void -llvmpipe_ws_destroy(struct llvmpipe_winsys *winsys) -{ - FREE(winsys); -} - - -static struct pipe_screen * -st_llvmpipe_screen_create(void) -{ - static struct llvmpipe_winsys *winsys; - struct pipe_screen *screen; - - winsys = CALLOC_STRUCT(llvmpipe_winsys); - if (!winsys) - goto no_winsys; - - winsys->destroy = llvmpipe_ws_destroy; - winsys->is_displaytarget_format_supported = llvmpipe_ws_is_displaytarget_format_supported; - winsys->displaytarget_create = llvmpipe_ws_displaytarget_create; - winsys->displaytarget_map = llvmpipe_ws_displaytarget_map; - winsys->displaytarget_unmap = llvmpipe_ws_displaytarget_unmap; - winsys->displaytarget_display = llvmpipe_ws_displaytarget_display; - winsys->displaytarget_destroy = llvmpipe_ws_displaytarget_destroy; - - screen = llvmpipe_create_screen(winsys); - if (!screen) - goto no_screen; - - return screen; - -no_screen: - FREE(winsys); -no_winsys: - return NULL; -} - - - -const struct st_winsys st_softpipe_winsys = { - &st_llvmpipe_screen_create -}; diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index 81676bc3a4..cd3e786f1a 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -26,18 +26,45 @@ * **************************************************************************/ -/** - * @file - * Softpipe support. - * - * @author Keith Whitwell - * @author Brian Paul - * @author Jose Fonseca - */ - -#include "softpipe/sp_winsys.h" +#include "util/u_debug.h" +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "state_tracker/sw_winsys.h" +#include "null/null_sw_winsys.h" #include "st_winsys.h" -const struct st_winsys st_softpipe_winsys = { - &softpipe_create_screen_malloc -}; + +struct pipe_screen * +st_software_screen_create(void) +{ + struct sw_winsys *ws; + const char *default_driver; + const char *driver; + struct pipe_screen *screen = NULL; + +#if defined(HAVE_LLVMPIPE) + default_driver = "llvmpipe"; +#elif defined(HAVE_SOFTPIPE) + default_driver = "softpipe"; +#endif + + ws = null_sw_create(); + if(!ws) + return NULL; + + driver = debug_get_option("GALLIUM_DRIVER", default_driver); + +#ifdef HAVE_LLVMPIPE + if (strcmp(driver, "llvmpipe") == 0) { + screen = llvmpipe_create_screen(ws); + } +#endif + +#ifdef HAVE_SOFTPIPE + if (strcmp(driver, "softpipe") == 0) { + screen = softpipe_create_screen(ws); + } +#endif + + return screen; +} diff --git a/src/gallium/state_trackers/python/st_winsys.h b/src/gallium/state_trackers/python/st_winsys.h index 0c7b6a200e..e1a99383a4 100644 --- a/src/gallium/state_trackers/python/st_winsys.h +++ b/src/gallium/state_trackers/python/st_winsys.h @@ -31,19 +31,13 @@ struct pipe_screen; -struct pipe_context; -struct st_winsys -{ - struct pipe_screen * - (*screen_create)(void); -}; +struct pipe_screen * +st_hardware_screen_create(void); - -extern const struct st_winsys st_softpipe_winsys; - -extern const struct st_winsys st_hardpipe_winsys; +struct pipe_screen * +st_software_screen_create(void); #endif /* ST_WINSYS_H_ */ -- cgit v1.2.3 From 431a2f99bc9d4ab567c1feaac9360c09c1dcdfde Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 10:32:16 +0000 Subject: target-helpers: helper for injecting common debug layers Add a helper gallium_wrap_screen() for injecting the commonly used extra layers into a gallium stack. Currently that's just the trace module and identity layer, but there could be more in the future, eg. a validation layer. --- src/gallium/auxiliary/Makefile | 1 + src/gallium/auxiliary/SConscript | 1 + src/gallium/auxiliary/target-helpers/swrast_xlib.c | 13 +---- src/gallium/auxiliary/target-helpers/wrap_screen.c | 65 ++++++++++++++++++++++ src/gallium/auxiliary/target-helpers/wrap_screen.h | 16 ++++++ 5 files changed, 85 insertions(+), 11 deletions(-) create mode 100644 src/gallium/auxiliary/target-helpers/wrap_screen.c create mode 100644 src/gallium/auxiliary/target-helpers/wrap_screen.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index c84e8d781d..89b15d41b7 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -133,6 +133,7 @@ C_SOURCES = \ vl/vl_csc.c \ vl/vl_shader_build.c \ target-helpers/swrast_xlib.c + target-helpers/wrap_screen.c GALLIVM_SOURCES = \ gallivm/lp_bld_alpha.c \ diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript index d6185bcb5e..2be16776fb 100644 --- a/src/gallium/auxiliary/SConscript +++ b/src/gallium/auxiliary/SConscript @@ -175,6 +175,7 @@ source = [ 'vl/vl_compositor.c', 'vl/vl_csc.c', 'vl/vl_shader_build.c', + 'target-helpers/wrap_screen.c', ] if drawllvm: diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.c b/src/gallium/auxiliary/target-helpers/swrast_xlib.c index bf30ff68c1..3cab901272 100644 --- a/src/gallium/auxiliary/target-helpers/swrast_xlib.c +++ b/src/gallium/auxiliary/target-helpers/swrast_xlib.c @@ -37,9 +37,8 @@ #include "util/u_debug.h" #include "softpipe/sp_public.h" #include "llvmpipe/lp_public.h" -#include "identity/id_public.h" -#include "trace/tr_public.h" #include "cell/ppu/cell_public.h" +#include "wrap_screen.h" /* Helper function to build a subset of a driver stack consisting of @@ -84,15 +83,7 @@ swrast_xlib_create_screen( Display *display ) /* Inject any wrapping layers we want to here: */ - if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { - screen = identity_screen_create(screen); - } - - if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { - screen = trace_screen_create( screen ); - } - - return screen; + return gallium_wrap_screen( screen ); fail: if (winsys) diff --git a/src/gallium/auxiliary/target-helpers/wrap_screen.c b/src/gallium/auxiliary/target-helpers/wrap_screen.c new file mode 100644 index 0000000000..5fe3013938 --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/wrap_screen.c @@ -0,0 +1,65 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * + **************************************************************************/ + +/* + * Authors: + * Keith Whitwell + */ + +#include "target-helpers/wrap_screen.h" +#include "trace/tr_public.h" +#include "identity/id_public.h" +#include "util/u_debug.h" + + +/* Centralized code to inject common wrapping layers: + */ +struct pipe_screen * +gallium_wrap_screen( struct pipe_screen *screen ) +{ + /* Screen wrapping functions are required not to fail. If it is + * impossible to wrap a screen, the unwrapped screen should be + * returned instead. Any failure condition should be returned in + * an OUT argument. + * + * Otherwise it is really messy trying to clean up in this code. + */ + if (debug_get_bool_option("GALLIUM_WRAP", FALSE)) { + screen = identity_screen_create(screen); + } + + if (debug_get_bool_option("GALLIUM_TRACE", FALSE)) { + screen = trace_screen_create( screen ); + } + + return screen; +} + + + + diff --git a/src/gallium/auxiliary/target-helpers/wrap_screen.h b/src/gallium/auxiliary/target-helpers/wrap_screen.h new file mode 100644 index 0000000000..7e76beb7c5 --- /dev/null +++ b/src/gallium/auxiliary/target-helpers/wrap_screen.h @@ -0,0 +1,16 @@ +#ifndef WRAP_SCREEN_HELPER_H +#define WRAP_SCREEN_HELPER_H + +#include "pipe/p_compiler.h" + +struct pipe_screen; + +/* Centralized code to inject common wrapping layers. Other layers + * can be introduced by specific targets, but these are the generally + * helpful ones we probably want everywhere. + */ +struct pipe_screen * +gallium_wrap_screen( struct pipe_screen *screen ); + + +#endif -- cgit v1.2.3 From 7e29bef7dc7669bdf44f97e235c7a7aed8c52be8 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 10:37:41 +0000 Subject: ws/gdi: add include --- src/gallium/winsys/gdi/gdi_sw_winsys.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/winsys/gdi/gdi_sw_winsys.h b/src/gallium/winsys/gdi/gdi_sw_winsys.h index 8ecca7bbc3..4bbcb47848 100644 --- a/src/gallium/winsys/gdi/gdi_sw_winsys.h +++ b/src/gallium/winsys/gdi/gdi_sw_winsys.h @@ -1,6 +1,8 @@ #ifndef GDI_SW_WINSYS_H #define GDI_SW_WINSYS_H +#include + #include "pipe/p_compiler.h" #include "state_tracker/sw_winsys.h" -- cgit v1.2.3 From de27e272f42f8f453588edbcb98f3e510dad869b Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 10:43:00 +0000 Subject: gallium: remove trace module injection from various state trackers Components such as state trackers, drivers, etc, should be free to be recombined in arbtrary ways to build driver stacks. They should not be reaching out and trying to build the stack themselves - this is now expected to be handled by the "target" abstraction. --- src/gallium/state_trackers/python/st_device.c | 5 ----- src/gallium/state_trackers/wgl/stw_device.c | 14 +++----------- src/gallium/state_trackers/wgl/stw_device.h | 4 ---- src/gallium/state_trackers/wgl/stw_ext_gallium.c | 5 ----- src/gallium/state_trackers/wgl/stw_framebuffer.c | 19 ------------------- 5 files changed, 3 insertions(+), 44 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 335e8e7f0d..3aeb6226d0 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -34,7 +34,6 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_simple_shaders.h" -#include "trace/tr_public.h" #include "st_device.h" #include "st_winsys.h" @@ -85,10 +84,6 @@ st_device_create(boolean hardware) else screen = st_software_screen_create(); - screen = trace_screen_create(screen); - if (!screen) - goto no_screen; - st_dev = CALLOC_STRUCT(st_device); if (!st_dev) goto no_device; diff --git a/src/gallium/state_trackers/wgl/stw_device.c b/src/gallium/state_trackers/wgl/stw_device.c index 472a2a5379..ea300f27cb 100644 --- a/src/gallium/state_trackers/wgl/stw_device.c +++ b/src/gallium/state_trackers/wgl/stw_device.c @@ -33,11 +33,6 @@ #include "pipe/p_screen.h" #include "state_tracker/st_public.h" -#ifdef DEBUG -#include "trace/tr_screen.h" -#include "trace/tr_texture.h" -#endif - #include "stw_device.h" #include "stw_winsys.h" #include "stw_pixelformat.h" @@ -107,13 +102,10 @@ stw_init(const struct stw_winsys *stw_winsys) if(stw_winsys->get_adapter_luid) stw_winsys->get_adapter_luid(screen, &stw_dev->AdapterLuid); -#ifdef DEBUG - stw_dev->screen = trace_screen_create(screen); - stw_dev->trace_running = stw_dev->screen != screen ? TRUE : FALSE; -#else stw_dev->screen = screen; -#endif - + + /* XXX + */ stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer; pipe_mutex_init( stw_dev->ctx_mutex ); diff --git a/src/gallium/state_trackers/wgl/stw_device.h b/src/gallium/state_trackers/wgl/stw_device.h index a83841f6b7..2e9ba197df 100644 --- a/src/gallium/state_trackers/wgl/stw_device.h +++ b/src/gallium/state_trackers/wgl/stw_device.h @@ -48,10 +48,6 @@ struct stw_device struct pipe_screen *screen; -#ifdef DEBUG - boolean trace_running; -#endif - LUID AdapterLuid; struct stw_pixelformat_info pixelformats[STW_MAX_PIXELFORMATS]; diff --git a/src/gallium/state_trackers/wgl/stw_ext_gallium.c b/src/gallium/state_trackers/wgl/stw_ext_gallium.c index 8dd63f124a..5ecbd8048d 100644 --- a/src/gallium/state_trackers/wgl/stw_ext_gallium.c +++ b/src/gallium/state_trackers/wgl/stw_ext_gallium.c @@ -31,11 +31,6 @@ #include "stw_winsys.h" #include "stw_ext_gallium.h" -#ifdef DEBUG -#include "trace/tr_screen.h" -#include "trace/tr_context.h" -#endif - struct pipe_screen * APIENTRY wglGetGalliumScreenMESA(void) diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.c b/src/gallium/state_trackers/wgl/stw_framebuffer.c index 02de21ccb2..4f1629de2f 100644 --- a/src/gallium/state_trackers/wgl/stw_framebuffer.c +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.c @@ -34,11 +34,6 @@ #include "state_tracker/st_context.h" #include "state_tracker/st_public.h" -#ifdef DEBUG -#include "trace/tr_screen.h" -#include "trace/tr_texture.h" -#endif - #include "stw_icd.h" #include "stw_framebuffer.h" #include "stw_device.h" @@ -495,13 +490,6 @@ DrvPresentBuffers(HDC hdc, PGLPRESENTBUFFERSDATA data) surface = (struct pipe_surface *)data->pPrivateData; -#ifdef DEBUG - if(stw_dev->trace_running) { - screen = trace_screen(screen)->screen; - surface = trace_surface(surface)->surface; - } -#endif - if(data->hSharedSurface != fb->hSharedSurface) { if(fb->shared_surface) { stw_dev->stw_winsys->shared_surface_close(screen, fb->shared_surface); @@ -563,13 +551,6 @@ stw_framebuffer_present_locked(HDC hdc, else { struct pipe_screen *screen = stw_dev->screen; -#ifdef DEBUG - if(stw_dev->trace_running) { - screen = trace_screen(screen)->screen; - surface = trace_surface(surface)->surface; - } -#endif - stw_dev->stw_winsys->present( screen, surface, hdc ); stw_framebuffer_update(fb); -- cgit v1.2.3 From 6b707667c853c6c0ded3715050a01cfdbd4883c2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 10:56:51 +0000 Subject: python: Handle the possibility that no driver is selected. --- src/gallium/state_trackers/python/st_softpipe_winsys.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/st_softpipe_winsys.c b/src/gallium/state_trackers/python/st_softpipe_winsys.c index cd3e786f1a..985374190c 100644 --- a/src/gallium/state_trackers/python/st_softpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_softpipe_winsys.c @@ -46,6 +46,8 @@ st_software_screen_create(void) default_driver = "llvmpipe"; #elif defined(HAVE_SOFTPIPE) default_driver = "softpipe"; +#else + default_driver = ""; #endif ws = null_sw_create(); -- cgit v1.2.3 From e8d884eab9b96f2db647363f17649ff35570c710 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 11:34:09 +0000 Subject: scons: Fixup the libgl-gdi build. --- SConstruct | 2 -- src/gallium/targets/SConscript | 10 +++++----- src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c | 3 ++- src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c | 3 ++- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/SConstruct b/SConstruct index 606be015c0..6ed44ddd06 100644 --- a/SConstruct +++ b/SConstruct @@ -53,8 +53,6 @@ opts.Add(ListVariable('drivers', 'pipe drivers to build', default_drivers, ['softpipe', 'failover', 'svga', 'i915', 'i965', 'trace', 'r300', 'identity', 'llvmpipe'])) opts.Add(ListVariable('winsys', 'winsys drivers to build', default_winsys, ['xlib', 'vmware', 'intel', 'i965', 'gdi', 'radeon'])) -opts.Add(ListVariable('targets', 'target drivers to build', 'all', - ['xlib'])) opts.Add(EnumVariable('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0'))) diff --git a/src/gallium/targets/SConscript b/src/gallium/targets/SConscript index 266d705f89..df62fc65fb 100644 --- a/src/gallium/targets/SConscript +++ b/src/gallium/targets/SConscript @@ -5,12 +5,12 @@ Import('*') # 'drm/SConscript', # ]) -if 'xlib' in env['targets']: +if 'xlib' in env['winsys']: SConscript([ 'libgl-xlib/SConscript', ]) -#if 'gdi' in env['winsys']: -# SConscript([ -# 'gdi/SConscript', -# ]) +if 'gdi' in env['winsys']: + SConscript([ + 'libgl-gdi/SConscript', + ]) diff --git a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c index f20c2614e2..29316a1ce2 100644 --- a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c +++ b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c @@ -37,9 +37,10 @@ #include #include "stw_winsys.h" -#include "gdi_sw_winsys.h" +#include "gdi/gdi_sw_winsys.h" #include "llvmpipe/lp_texture.h" #include "llvmpipe/lp_screen.h" +#include "llvmpipe/lp_public.h" static struct pipe_screen * diff --git a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c index 5c5c154c7f..dfe60195d9 100644 --- a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c +++ b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c @@ -37,9 +37,10 @@ #include #include "stw_winsys.h" -#include "gdi_sw_winsys.h" +#include "gdi/gdi_sw_winsys.h" #include "softpipe/sp_texture.h" #include "softpipe/sp_screen.h" +#include "softpipe/sp_public.h" static struct pipe_screen * -- cgit v1.2.3 From e47a619ea262ba1c49f86525b2855a64a5e36a42 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 11:13:03 +0000 Subject: ws/xlib: remove dead lines --- src/gallium/winsys/xlib/xlib_sw_winsys.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 0ee589943e..29c642706a 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -32,12 +32,6 @@ * Brian Paul */ - - - -#undef ASSERT -#undef Elements - #include "pipe/p_format.h" #include "pipe/p_context.h" #include "util/u_inlines.h" -- cgit v1.2.3 From 0731d14a43191233e91fbebe5b47b13faa655f9f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 10 Mar 2010 11:49:11 +0000 Subject: target-helpers: remove swrast_xlib.c helper This was a good idea, but ended up tying the build systems in knots. We can revisit this later, in particular if we can put in place dummy implementations of cell_create_screen(), llvmpipe_create_screen() which just return NULL if the driver isn't available. In the meantime, just duplicate this smallish function in the two places it was being called. --- src/gallium/auxiliary/Makefile | 1 - src/gallium/auxiliary/target-helpers/swrast_xlib.c | 97 ---------------------- src/gallium/auxiliary/target-helpers/swrast_xlib.h | 15 ---- src/gallium/state_trackers/egl/x11/native_ximage.c | 60 ++++++++++++- src/gallium/targets/libgl-xlib/xlib.c | 63 +++++++++++++- 5 files changed, 121 insertions(+), 115 deletions(-) delete mode 100644 src/gallium/auxiliary/target-helpers/swrast_xlib.c delete mode 100644 src/gallium/auxiliary/target-helpers/swrast_xlib.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile index 89b15d41b7..0ac18426d9 100644 --- a/src/gallium/auxiliary/Makefile +++ b/src/gallium/auxiliary/Makefile @@ -132,7 +132,6 @@ C_SOURCES = \ vl/vl_compositor.c \ vl/vl_csc.c \ vl/vl_shader_build.c \ - target-helpers/swrast_xlib.c target-helpers/wrap_screen.c GALLIVM_SOURCES = \ diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.c b/src/gallium/auxiliary/target-helpers/swrast_xlib.c deleted file mode 100644 index 3cab901272..0000000000 --- a/src/gallium/auxiliary/target-helpers/swrast_xlib.c +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Bismarck, ND., USA - * 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * - **************************************************************************/ - -/* - * Authors: - * Keith Whitwell - */ - -#include "swrast_xlib.h" - -#include "state_tracker/xlib_sw_winsys.h" -#include "util/u_debug.h" -#include "softpipe/sp_public.h" -#include "llvmpipe/lp_public.h" -#include "cell/ppu/cell_public.h" -#include "wrap_screen.h" - - -/* Helper function to build a subset of a driver stack consisting of - * one of the software rasterizers (cell, llvmpipe, softpipe) and the - * xlib winsys. - * - * This can be called by any target that builds on top of this - * combination. - */ -struct pipe_screen * -swrast_xlib_create_screen( Display *display ) -{ - struct sw_winsys *winsys; - struct pipe_screen *screen = NULL; - - /* Create the underlying winsys, which performs presents to Xlib - * drawables: - */ - winsys = xlib_create_sw_winsys( display ); - if (winsys == NULL) - return NULL; - - /* Create a software rasterizer on top of that winsys: - */ -#if defined(GALLIUM_CELL) - if (screen == NULL && - !debug_get_bool_option("GALLIUM_NO_CELL", FALSE)) - screen = cell_create_screen( winsys ); -#endif - -#if defined(GALLIUM_LLVMPIPE) - if (screen == NULL && - !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) - screen = llvmpipe_create_screen( winsys ); -#endif - - if (screen == NULL) - screen = softpipe_create_screen( winsys ); - - if (screen == NULL) - goto fail; - - /* Inject any wrapping layers we want to here: - */ - return gallium_wrap_screen( screen ); - -fail: - if (winsys) - winsys->destroy( winsys ); - - return NULL; -} - - - - diff --git a/src/gallium/auxiliary/target-helpers/swrast_xlib.h b/src/gallium/auxiliary/target-helpers/swrast_xlib.h deleted file mode 100644 index 3a0f713d54..0000000000 --- a/src/gallium/auxiliary/target-helpers/swrast_xlib.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef SWRAST_XLIB_HELPER_H -#define SWRAST_XLIB_HELPER_H - -#include -#include "pipe/p_compiler.h" - -/* Helper to build the xlib winsys, choose between the software - * rasterizers and construct the lower part of a driver stack. - * - * Just add a state tracker. - */ -struct pipe_screen *swrast_xlib_create_screen( Display *display ); - - -#endif diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c index 544b3b4276..e0d12acabe 100644 --- a/src/gallium/state_trackers/egl/x11/native_ximage.c +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c @@ -34,7 +34,11 @@ #include "pipe/p_compiler.h" #include "util/u_inlines.h" #include "state_tracker/xlib_sw_winsys.h" -#include "target-helpers/swrast_xlib.h" +#include "target-helpers/wrap_screen.h" +#include "util/u_debug.h" +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "cell/ppu/cell_public.h" #include "egllog.h" #include "native_x11.h" @@ -614,6 +618,60 @@ ximage_display_destroy(struct native_display *ndpy) free(xdpy); } + +/* Helper function to build a subset of a driver stack consisting of + * one of the software rasterizers (cell, llvmpipe, softpipe) and the + * xlib winsys. + * + * This function could be shared, but currently causes headaches for + * the build systems, particularly scons if we try. + * + * Long term, want to avoid having global #defines for things like + * GALLIUM_LLVMPIPE, GALLIUM_CELL, etc. Scons already eliminates + * those #defines, so things that are painful for it now are likely to + * be painful for other build systems in the future. + */ +static struct pipe_screen * +swrast_xlib_create_screen( Display *display ) +{ + struct sw_winsys *winsys; + struct pipe_screen *screen = NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = xlib_create_sw_winsys( display ); + if (winsys == NULL) + return NULL; + + /* Create a software rasterizer on top of that winsys. Use + * llvmpipe if it is available. + */ +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && + !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) + screen = llvmpipe_create_screen( winsys ); +#endif + + if (screen == NULL) + screen = softpipe_create_screen( winsys ); + + if (screen == NULL) + goto fail; + + /* Inject any wrapping layers we want to here: + */ + return gallium_wrap_screen( screen ); + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + + + struct native_display * x11_create_ximage_display(EGLNativeDisplayType dpy, struct native_event_handler *event_handler) diff --git a/src/gallium/targets/libgl-xlib/xlib.c b/src/gallium/targets/libgl-xlib/xlib.c index 54764440e7..05dc8db57d 100644 --- a/src/gallium/targets/libgl-xlib/xlib.c +++ b/src/gallium/targets/libgl-xlib/xlib.c @@ -31,12 +31,73 @@ * Keith Whitwell */ #include "pipe/p_compiler.h" -#include "target-helpers/swrast_xlib.h" +#include "state_tracker/xlib_sw_winsys.h" +#include "util/u_debug.h" +#include "softpipe/sp_public.h" +#include "llvmpipe/lp_public.h" +#include "cell/ppu/cell_public.h" +#include "target-helpers/wrap_screen.h" #include "xm_public.h" /* advertise OpenGL support */ PUBLIC const int st_api_OpenGL = 1; + +/* Helper function to build a subset of a driver stack consisting of + * one of the software rasterizers (cell, llvmpipe, softpipe) and the + * xlib winsys. + * + * This function could be shared, but currently causes headaches for + * the build systems, particularly scons if we try. Long term, want + * to avoid having global #defines for things like GALLIUM_LLVMPIPE, + * GALLIUM_CELL, etc. Scons already eliminates those #defines, so + * things that are painful for it now are likely to be painful for + * other build systems in the future. + */ +static struct pipe_screen * +swrast_xlib_create_screen( Display *display ) +{ + struct sw_winsys *winsys; + struct pipe_screen *screen = NULL; + + /* Create the underlying winsys, which performs presents to Xlib + * drawables: + */ + winsys = xlib_create_sw_winsys( display ); + if (winsys == NULL) + return NULL; + + /* Create a software rasterizer on top of that winsys: + */ +#if defined(GALLIUM_CELL) + if (screen == NULL && + !debug_get_bool_option("GALLIUM_NO_CELL", FALSE)) + screen = cell_create_screen( winsys ); +#endif + +#if defined(GALLIUM_LLVMPIPE) + if (screen == NULL && + !debug_get_bool_option("GALLIUM_NO_LLVM", FALSE)) + screen = llvmpipe_create_screen( winsys ); +#endif + + if (screen == NULL) + screen = softpipe_create_screen( winsys ); + + if (screen == NULL) + goto fail; + + /* Inject any wrapping layers we want to here: + */ + return gallium_wrap_screen( screen ); + +fail: + if (winsys) + winsys->destroy( winsys ); + + return NULL; +} + struct xm_driver xlib_driver = { .create_pipe_screen = swrast_xlib_create_screen, -- cgit v1.2.3 From fc08d13fdcfe637064e92f962b1704fde193e70b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 11:52:20 +0000 Subject: trace: Make tr_public.h c++ friendly. --- src/gallium/drivers/trace/tr_public.h | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/trace/tr_public.h b/src/gallium/drivers/trace/tr_public.h index da31c24e64..62e217097d 100644 --- a/src/gallium/drivers/trace/tr_public.h +++ b/src/gallium/drivers/trace/tr_public.h @@ -1,6 +1,6 @@ /************************************************************************** * - * Copyright 2009 VMware, Inc. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -11,27 +11,35 @@ * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * + * 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * * 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 VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * **************************************************************************/ #ifndef TR_PUBLIC_H #define TR_PUBLIC_H +#ifdef __cplusplus +extern "C" { +#endif + struct pipe_screen; struct pipe_context; struct pipe_screen * trace_screen_create(struct pipe_screen *screen); +#ifdef __cplusplus +} +#endif + #endif /* TR_PUBLIC_H */ -- cgit v1.2.3 From 7b8641bbba995bc3fc299b1018720caa1e91cb9f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 12:00:13 +0000 Subject: python: More build fixes. --- src/gallium/SConscript | 3 +++ src/gallium/state_trackers/python/SConscript | 3 ++- src/gallium/state_trackers/python/st_device.c | 5 +++++ src/gallium/winsys/SConscript | 4 ---- 4 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/SConscript b/src/gallium/SConscript index ba541f9636..c833d83e65 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -7,6 +7,9 @@ SConscript('auxiliary/SConscript') for driver in env['drivers']: SConscript(os.path.join('drivers', driver, 'SConscript')) +# Needed by some state trackers +SConscript('winsys/null/SConscript') + SConscript('state_trackers/python/SConscript') if platform != 'embedded': SConscript('state_trackers/glx/xlib/SConscript') diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 8010f122b7..2b44c13737 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -38,8 +38,9 @@ if 'python' in env['statetrackers']: ] env.Prepend(LIBS = [ + ws_null, trace, - gallium + gallium, ]) if 'llvmpipe' in env['drivers']: diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c index 3aeb6226d0..335e8e7f0d 100644 --- a/src/gallium/state_trackers/python/st_device.c +++ b/src/gallium/state_trackers/python/st_device.c @@ -34,6 +34,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_simple_shaders.h" +#include "trace/tr_public.h" #include "st_device.h" #include "st_winsys.h" @@ -84,6 +85,10 @@ st_device_create(boolean hardware) else screen = st_software_screen_create(); + screen = trace_screen_create(screen); + if (!screen) + goto no_screen; + st_dev = CALLOC_STRUCT(st_device); if (!st_dev) goto no_device; diff --git a/src/gallium/winsys/SConscript b/src/gallium/winsys/SConscript index 4567d17447..30c3378dff 100644 --- a/src/gallium/winsys/SConscript +++ b/src/gallium/winsys/SConscript @@ -1,9 +1,5 @@ Import('*') -SConscript([ - 'null/SConscript', -]) - if env['dri']: SConscript([ 'drm/SConscript', -- cgit v1.2.3 From 986ce8f1c118007062cacd4b4bad54657cd09a65 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 12:05:10 +0000 Subject: python: Remove broken link hack. --- src/gallium/state_trackers/python/SConscript | 1 + src/gallium/state_trackers/python/st_hardpipe_winsys.c | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript index 2b44c13737..781f54bf2b 100644 --- a/src/gallium/state_trackers/python/SConscript +++ b/src/gallium/state_trackers/python/SConscript @@ -24,6 +24,7 @@ if 'python' in env['statetrackers']: 'ws2_32', ]) else: + env.Append(CPPDEFINES = ['GCC_HASCLASSVISIBILITY']) env.Append(LIBS = [ 'GL', 'X11', diff --git a/src/gallium/state_trackers/python/st_hardpipe_winsys.c b/src/gallium/state_trackers/python/st_hardpipe_winsys.c index 0bf7c51613..b141177b79 100644 --- a/src/gallium/state_trackers/python/st_hardpipe_winsys.c +++ b/src/gallium/state_trackers/python/st_hardpipe_winsys.c @@ -54,11 +54,6 @@ static PFNGETGALLIUMSCREENMESAPROC pfnGetGalliumScreenMESA = NULL; static PFNCREATEGALLIUMCONTEXTMESAPROC pfnCreateGalliumContextMESA = NULL; -/* XXX: Force init_gallium symbol to be linked */ -extern void init_gallium(void); -void (*force_init_gallium_linkage)(void) = &init_gallium; - - #ifdef PIPE_OS_WINDOWS static INLINE boolean -- cgit v1.2.3 From c282c0b6e40f9ed3cbf9d4c4eeb01d1896763246 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 12:24:03 +0000 Subject: softpipe: Prevent NULL dereference. --- src/gallium/drivers/softpipe/sp_state_vertex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_state_vertex.c b/src/gallium/drivers/softpipe/sp_state_vertex.c index a151758ddc..462f4d2655 100644 --- a/src/gallium/drivers/softpipe/sp_state_vertex.c +++ b/src/gallium/drivers/softpipe/sp_state_vertex.c @@ -62,7 +62,8 @@ softpipe_bind_vertex_elements_state(struct pipe_context *pipe, softpipe->dirty |= SP_NEW_VERTEX; - draw_set_vertex_elements(softpipe->draw, sp_velems->count, sp_velems->velem); + if (sp_velems) + draw_set_vertex_elements(softpipe->draw, sp_velems->count, sp_velems->velem); } void -- cgit v1.2.3 From 504ad3606dfd5891ee04d85d3af2c233fd362c51 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 10 Mar 2010 12:04:00 +0100 Subject: svga: Check if vertex elements has been bound before using it. --- src/gallium/drivers/svga/svga_state_need_swtnl.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c index 10d473584d..dfaab53aef 100644 --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c @@ -76,6 +76,11 @@ static int update_need_swvfetch( struct svga_context *svga, unsigned i; boolean need_swvfetch = FALSE; + if (!svga->curr.velems) { + /* No vertex elements bound. */ + return 0; + } + for (i = 0; i < svga->curr.velems->count; i++) { svga->state.sw.ve_format[i] = svga_translate_vertex_format(svga->curr.velems->velem[i].src_format); if (svga->state.sw.ve_format[i] == SVGA3D_DECLTYPE_MAX) { -- cgit v1.2.3 From 9b348d0ed125a22be3f318ac60cef6f201edfdab Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 10 Mar 2010 12:05:25 +0100 Subject: svga: Disable debug message. --- src/gallium/drivers/svga/svga_pipe_sampler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c index acba2b8f9d..1a8ef296ca 100644 --- a/src/gallium/drivers/svga/svga_pipe_sampler.c +++ b/src/gallium/drivers/svga/svga_pipe_sampler.c @@ -155,7 +155,7 @@ static void svga_bind_sampler_states(struct pipe_context *pipe, /* Check for no-op */ if (num == svga->curr.num_samplers && !memcmp(svga->curr.sampler, sampler, num * sizeof(void *))) { - debug_printf("sampler noop\n"); + if (0) debug_printf("sampler noop\n"); return; } -- cgit v1.2.3 From e4848d21e8f384f4157076d5e7c7c9d38da6598e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 10 Mar 2010 22:20:15 +0800 Subject: gallium: Do not mix winsys-drawable-handle and context-private. update_buffer should be called with context-private, not winsys-drawable-handle. --- src/gallium/include/pipe/p_screen.h | 5 ++++- src/gallium/state_trackers/vega/vg_tracker.c | 10 +--------- src/mesa/state_tracker/st_cb_flush.c | 2 +- src/mesa/state_tracker/st_context.c | 2 +- src/mesa/state_tracker/st_context.h | 1 + 5 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 690455f722..b771bfe85e 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -265,6 +265,7 @@ struct pipe_screen { /** * Do any special operations to ensure buffer size is correct + * \param context_private the private data of the calling context */ void (*update_buffer)( struct pipe_screen *ws, void *context_private ); @@ -272,10 +273,12 @@ struct pipe_screen { /** * Do any special operations to ensure frontbuffer contents are * displayed, eg copy fake frontbuffer. + * \param winsys_drawable_handle an opaque handle that the calling context + * gets out-of-band */ void (*flush_frontbuffer)( struct pipe_screen *screen, struct pipe_surface *surf, - void *context_private ); + void *winsys_drawable_handle ); diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index a002e50faf..ea5c2ce41f 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -380,16 +380,8 @@ boolean st_make_current(struct vg_context *st, void *winsys_drawable_handle) { vg_set_current_context(st); - if (st) { + if (st) st->draw_buffer = draw; - - /* VG state tracker doesn't seem to do front-buffer rendering - * (no calls to flush_frontbuffer). If it ever did start doing - * that, it would need to pass this value down in the - * flush_frontbuffer call: - */ - st->pipe->priv = winsys_drawable_handle; - } return VG_TRUE; } diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 1329f807bc..28a384ba49 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -79,7 +79,7 @@ display_front_buffer(struct st_context *st) /* Hook for copying "fake" frontbuffer if necessary: */ st->pipe->screen->flush_frontbuffer( st->pipe->screen, front_surf, - st->pipe->priv ); + st->winsys_drawable_handle ); /* st->frontbuffer_status = FRONT_STATUS_UNDEFINED; diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 09f891d691..ca6d4dfb06 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -287,7 +287,7 @@ st_make_current(struct st_context *st, } _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); - st->pipe->priv = winsys_drawable_handle; + st->winsys_drawable_handle = winsys_drawable_handle; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 6622361a7e..e2d34fb3d1 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -185,6 +185,7 @@ struct st_context struct cso_context *cso_context; int force_msaa; + void *winsys_drawable_handle; }; -- cgit v1.2.3 From c47c73293d359c00abb34c39d1163b4c55f531de Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 10 Mar 2010 22:58:51 +0800 Subject: i915g: Prevent NULL dereference. bind_vertex_elements_state may be called with NULL velems. Do nothing if that is the case. --- src/gallium/drivers/i915/i915_state.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c index 8927dfc33d..377d8425a5 100644 --- a/src/gallium/drivers/i915/i915_state.c +++ b/src/gallium/drivers/i915/i915_state.c @@ -770,7 +770,10 @@ i915_bind_vertex_elements_state(struct pipe_context *pipe, draw_flush(i915->draw); /* pass-through to draw module */ - draw_set_vertex_elements(i915->draw, i915_velems->count, i915_velems->velem); + if (i915_velems) { + draw_set_vertex_elements(i915->draw, + i915_velems->count, i915_velems->velem); + } } static void -- cgit v1.2.3 From 8c34437deda2ff8659fecdf3ea687820c9e57261 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Wed, 10 Mar 2010 16:53:07 +0100 Subject: cell: handle NULL cso vertex_elements state object on bind drivers need to handle NULL cso vertex elements (and others) objects. It is possible the cso code saves/restores NULL objects (if no normal cso object was bound before this was invoked). This led to segfaults (for example demos/cubemap) for apps which were using things like creating mipmaps before drawing anything. --- src/gallium/drivers/cell/ppu/cell_state_vertex.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c index d3efb8ecea..9510ea9ac2 100644 --- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c +++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c @@ -62,7 +62,8 @@ cell_bind_vertex_elements_state(struct pipe_context *pipe, cell->dirty |= CELL_NEW_VERTEX; - draw_set_vertex_elements(cell->draw, cell_velems->count, cell_velems->velem); + if (cell_velems) + draw_set_vertex_elements(cell->draw, cell_velems->count, cell_velems->velem); } void -- cgit v1.2.3 From 766d90f1a201d8fd19e49df14d712efbb82223b4 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Wed, 10 Mar 2010 18:26:25 +0100 Subject: st/xorg: Work around cursor reference counting bugs in older X servers. Could result in use of freed memory and consequently random crashes, e.g. on screen resize. (cherry picked from commit 21c91b410a2a2cbf8eb677e59e3322f86320f2b0) Conflicts: src/gallium/state_trackers/xorg/xorg_tracker.h --- src/gallium/state_trackers/xorg/xorg_crtc.c | 14 ++++++++++++++ src/gallium/state_trackers/xorg/xorg_driver.c | 5 +++++ src/gallium/state_trackers/xorg/xorg_tracker.h | 1 + 3 files changed, 20 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 000ec9048f..53a3c5c2b7 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -275,7 +275,21 @@ err_bo_destroy: static void crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) { + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); modesettingPtr ms = modesettingPTR(crtc->scrn); + + /* Older X servers have cursor reference counting bugs leading to use of + * freed memory and consequently random crashes. Should be fixed as of + * xserver 1.8, but this workaround shouldn't hurt anyway. + */ + if (config->cursor) + config->cursor->refcnt++; + + if (ms->cursor) + FreeCursor(ms->cursor, None); + + ms->cursor = config->cursor; + if (ms->screen) crtc_load_cursor_argb_ga3d(crtc, image); #ifdef HAVE_LIBKMS diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 8fb6e5a96d..d7c67463d2 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -922,6 +922,11 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen) drv_leave_vt(scrnIndex, 0); } + if (ms->cursor) { + FreeCursor(ms->cursor, None); + ms->cursor = NULL; + } + if (cust && cust->winsys_screen_close) cust->winsys_screen_close(cust); diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index 2f5cc64d9c..c1884ebd11 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -90,6 +90,7 @@ typedef struct _modesettingRec Bool noAccel; Bool SWCursor; + CursorPtr cursor; CloseScreenProcPtr CloseScreen; /* Broken-out options. */ -- cgit v1.2.3 From 7069dff80f25d0ac532c9f76634d1cd382d4fac1 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 13:09:00 -0700 Subject: softpipe: fix memcpy params to avoid static analysis warnings See fd.o bug 26970. Also added sanity check assertions. --- src/gallium/drivers/softpipe/sp_fs_exec.c | 7 ++++++- src/gallium/drivers/softpipe/sp_fs_sse.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c index 27fa126b7c..67e2c8f8bc 100644 --- a/src/gallium/drivers/softpipe/sp_fs_exec.c +++ b/src/gallium/drivers/softpipe/sp_fs_exec.c @@ -145,8 +145,13 @@ exec_run( const struct sp_fragment_shader *base, case TGSI_SEMANTIC_COLOR: { uint cbuf = sem_index[i]; + + assert(sizeof(quad->output.color[cbuf]) == + sizeof(machine->Outputs[i])); + + /* copy float[4][4] result */ memcpy(quad->output.color[cbuf], - &machine->Outputs[i].xyzw[0].f[0], + &machine->Outputs[i], sizeof(quad->output.color[0]) ); } break; diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c index acee213670..daa158df7c 100644 --- a/src/gallium/drivers/softpipe/sp_fs_sse.c +++ b/src/gallium/drivers/softpipe/sp_fs_sse.c @@ -156,8 +156,13 @@ fs_sse_run( const struct sp_fragment_shader *base, case TGSI_SEMANTIC_COLOR: { uint cbuf = sem_index[i]; + + assert(sizeof(quad->output.color[cbuf]) == + sizeof(machine->Outputs[i])); + + /* copy float[4][4] result */ memcpy(quad->output.color[cbuf], - &machine->Outputs[i].xyzw[0].f[0], + &machine->Outputs[i], sizeof(quad->output.color[0]) ); } break; -- cgit v1.2.3 From a75519cb43c85b99cd54bc46dd83accda0cbd6cd Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 10 Mar 2010 20:36:42 +0000 Subject: llvmpipe: Finally found a way to do vector comparisons without using intrinsics. Only works well with LLVM >= 2.7 --- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 32 ++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index 7c585fda78..fa65895367 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -42,6 +42,26 @@ #include "lp_bld_logic.h" +/* + * XXX + * + * Selection with vector conditional like + * + * select <4 x i1> %C, %A, %B + * + * is valid IR (e.g. llvm/test/Assembler/vector-select.ll), but it is not + * supported on any backend. + * + * Expanding the boolean vector to full SIMD register width, as in + * + * sext <4 x i1> %C to <4 x i32> + * + * is valid and supported (e.g., llvm/test/CodeGen/X86/vec_compare.ll), but + * it causes assertion failures in LLVM 2.6. It appears to work correctly on + * LLVM 2.7. + */ + + /** * Build code to compare two values 'a' and 'b' of 'type' using the given func. * \param func one of PIPE_FUNC_x @@ -74,6 +94,7 @@ lp_build_compare(LLVMBuilderRef builder, /* XXX: It is not clear if we should use the ordered or unordered operators */ +#if !defined(HAVE_LLVM) || HAVE_LLVM < 0x0207 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) if(type.width * type.length == 128) { if(type.floating && util_cpu_caps.has_sse) { @@ -200,6 +221,7 @@ lp_build_compare(LLVMBuilderRef builder, } } /* if (type.width * type.length == 128) */ #endif +#endif /* HAVE_LLVM < 0x0207 */ if(type.floating) { LLVMRealPredicate op; @@ -233,10 +255,9 @@ lp_build_compare(LLVMBuilderRef builder, return lp_build_undef(type); } -#if 0 - /* XXX: Although valid IR, no LLVM target currently support this */ +#if HAVE_LLVM >= 0x0207 cond = LLVMBuildFCmp(builder, op, a, b, ""); - res = LLVMBuildSelect(builder, cond, ones, zeros, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else res = LLVMGetUndef(int_vec_type); if (type.length == 1) { @@ -286,10 +307,9 @@ lp_build_compare(LLVMBuilderRef builder, return lp_build_undef(type); } -#if 0 - /* XXX: Although valid IR, no LLVM target currently support this */ +#if HAVE_LLVM >= 0x0207 cond = LLVMBuildICmp(builder, op, a, b, ""); - res = LLVMBuildSelect(builder, cond, ones, zeros, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else res = LLVMGetUndef(int_vec_type); if (type.length == 1) { -- cgit v1.2.3 From 18d406e8a8a838c82ee4ec5dbf244ab8bba0855e Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 9 Mar 2010 15:09:15 -0500 Subject: gallivm: implement loops --- src/gallium/auxiliary/gallivm/lp_bld_flow.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_flow.h | 4 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 157 ++++++++++++++++++++++-- 3 files changed, 153 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c index bc83138908..c2f35419ec 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c @@ -308,7 +308,7 @@ lp_build_flow_scope_end(struct lp_build_flow_context *flow) * Note: this function has no dependencies on the flow code and could * be used elsewhere. */ -static LLVMBasicBlockRef +LLVMBasicBlockRef lp_build_insert_new_block(LLVMBuilderRef builder, const char *name) { LLVMBasicBlockRef current_block; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h index 4c225a0d4f..8bb22543ee 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h @@ -145,7 +145,9 @@ lp_build_else(struct lp_build_if_state *ctx); void lp_build_endif(struct lp_build_if_state *ctx); - + +LLVMBasicBlockRef +lp_build_insert_new_block(LLVMBuilderRef builder, const char *name); #endif /* !LP_BLD_FLOW_H */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index fbb664d43a..085afe33de 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -95,6 +95,19 @@ struct lp_exec_mask { int cond_stack_size; LLVMValueRef cond_mask; + LLVMValueRef break_stack[LP_TGSI_MAX_NESTING]; + int break_stack_size; + LLVMValueRef break_mask; + + LLVMValueRef cont_stack[LP_TGSI_MAX_NESTING]; + int cont_stack_size; + LLVMValueRef cont_mask; + + LLVMBasicBlockRef loop_stack[LP_TGSI_MAX_NESTING]; + int loop_stack_size; + LLVMBasicBlockRef loop_block; + + LLVMValueRef exec_mask; }; @@ -145,14 +158,33 @@ static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context mask->bld = bld; mask->has_mask = FALSE; mask->cond_stack_size = 0; + mask->loop_stack_size = 0; + mask->break_stack_size = 0; + mask->cont_stack_size = 0; mask->int_vec_type = lp_build_int_vec_type(mask->bld->type); } static void lp_exec_mask_update(struct lp_exec_mask *mask) { - mask->exec_mask = mask->cond_mask; - mask->has_mask = (mask->cond_stack_size > 0); + if (mask->loop_stack_size) { + /*for loops we need to update the entire mask at + * runtime */ + LLVMValueRef tmp; + tmp = LLVMBuildAnd(mask->bld->builder, + mask->cont_mask, + mask->break_mask, + "maskcb"); + mask->exec_mask = LLVMBuildAnd(mask->bld->builder, + mask->cond_mask, + tmp, + "maskfull"); + } else + mask->exec_mask = mask->cond_mask; + + + mask->has_mask = (mask->cond_stack_size > 0 || + mask->loop_stack_size > 0); } static void lp_exec_mask_cond_push(struct lp_exec_mask *mask, @@ -189,6 +221,102 @@ static void lp_exec_mask_cond_pop(struct lp_exec_mask *mask) lp_exec_mask_update(mask); } +static void lp_exec_bgnloop(struct lp_exec_mask *mask) +{ + + if (mask->cont_stack_size == 0) + mask->cont_mask = LLVMConstAllOnes(mask->int_vec_type); + if (mask->cont_stack_size == 0) + mask->break_mask = LLVMConstAllOnes(mask->int_vec_type); + if (mask->cond_stack_size == 0) + mask->cond_mask = LLVMConstAllOnes(mask->int_vec_type); + mask->loop_stack[mask->loop_stack_size++] = mask->loop_block; + mask->loop_block = lp_build_insert_new_block(mask->bld->builder, "bgnloop"); + LLVMBuildBr(mask->bld->builder, mask->loop_block); + LLVMPositionBuilderAtEnd(mask->bld->builder, mask->loop_block); + + lp_exec_mask_update(mask); +} + +static void lp_exec_break(struct lp_exec_mask *mask) +{ + LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder, + mask->exec_mask, + "break"); + + mask->break_stack[mask->break_stack_size++] = mask->break_mask; + if (mask->break_stack_size > 1) { + mask->break_mask = LLVMBuildAnd(mask->bld->builder, + mask->break_mask, + exec_mask, "break_full"); + } else + mask->break_mask = exec_mask; + + lp_exec_mask_update(mask); +} + +static void lp_exec_continue(struct lp_exec_mask *mask) +{ + LLVMValueRef exec_mask = LLVMBuildNot(mask->bld->builder, + mask->exec_mask, + ""); + + mask->cont_stack[mask->cont_stack_size++] = mask->cont_mask; + if (mask->cont_stack_size > 1) { + mask->cont_mask = LLVMBuildAnd(mask->bld->builder, + mask->cont_mask, + exec_mask, ""); + } else + mask->cont_mask = exec_mask; + + lp_exec_mask_update(mask); +} + + +static void lp_exec_endloop(struct lp_exec_mask *mask) +{ + LLVMBasicBlockRef endloop; + LLVMValueRef i1cond; + + { /* convert our soa vector into i1 */ + int i; + LLVMValueRef packed = 0; + for (i = 0; i < mask->bld->type.length; ++i) { + LLVMValueRef component = LLVMBuildExtractElement( + mask->bld->builder, + mask->break_mask, + LLVMConstInt(LLVMInt32Type(), i, 0), ""); + if (packed) + packed = LLVMBuildOr(mask->bld->builder, + packed, component, ""); + else + packed = component; + } + i1cond = LLVMBuildICmp(mask->bld->builder, LLVMIntNE, + packed, + LLVMConstNull(LLVMTypeOf(packed)), + ""); + } + + endloop = lp_build_insert_new_block(mask->bld->builder, "endloop"); + + LLVMBuildCondBr(mask->bld->builder, + i1cond, endloop, mask->loop_block); + + LLVMPositionBuilderAtEnd(mask->bld->builder, endloop); + + mask->loop_block = mask->loop_stack[--mask->loop_stack_size]; + /* pop the break mask */ + if (mask->cont_stack_size) { + mask->cont_mask = mask->cont_stack[--mask->cont_stack_size]; + } + if (mask->break_stack_size) { + mask->break_mask = mask->cont_stack[--mask->break_stack_size]; + } + + lp_exec_mask_update(mask); +} + static void lp_exec_mask_store(struct lp_exec_mask *mask, LLVMValueRef val, LLVMValueRef dst) @@ -1363,10 +1491,9 @@ emit_instruction( case TGSI_OPCODE_TXP: emit_tex( bld, inst, FALSE, TRUE, dst0 ); break; - + case TGSI_OPCODE_BRK: - /* FIXME */ - return 0; + lp_exec_break(&bld->exec_mask); break; case TGSI_OPCODE_IF: @@ -1380,6 +1507,10 @@ emit_instruction( return 0; break; + case TGSI_OPCODE_BGNLOOP: + lp_exec_bgnloop(&bld->exec_mask); + break; + case TGSI_OPCODE_REP: /* deprecated */ assert(0); @@ -1400,6 +1531,10 @@ emit_instruction( return 0; break; + case TGSI_OPCODE_ENDLOOP: + lp_exec_endloop(&bld->exec_mask); + break; + case TGSI_OPCODE_ENDREP: /* deprecated */ assert(0); @@ -1499,8 +1634,7 @@ emit_instruction( break; case TGSI_OPCODE_CONT: - /* FIXME */ - return 0; + lp_exec_continue(&bld->exec_mask); break; case TGSI_OPCODE_EMIT: @@ -1603,7 +1737,14 @@ lp_build_tgsi_soa(LLVMBuilderRef builder, assert( 0 ); } } - + if (0) { + LLVMBasicBlockRef block = LLVMGetInsertBlock(builder); + LLVMValueRef function = LLVMGetBasicBlockParent(block); + debug_printf("11111111111111111111111111111 \n"); + tgsi_dump(tokens, 0); + LLVMDumpValue(function); + debug_printf("2222222222222222222222222222 \n"); + } tgsi_parse_free( &parse ); } -- cgit v1.2.3 From ac33e7752d22f03db84e6a4c822b3a3f41d05f77 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 10 Mar 2010 16:36:20 -0500 Subject: gallivm: properly test the if condition and branch to the proper label makes loops work --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 085afe33de..aa57289395 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -301,7 +301,7 @@ static void lp_exec_endloop(struct lp_exec_mask *mask) endloop = lp_build_insert_new_block(mask->bld->builder, "endloop"); LLVMBuildCondBr(mask->bld->builder, - i1cond, endloop, mask->loop_block); + i1cond, mask->loop_block, endloop); LLVMPositionBuilderAtEnd(mask->bld->builder, endloop); @@ -1498,6 +1498,8 @@ emit_instruction( case TGSI_OPCODE_IF: tmp0 = emit_fetch(bld, inst, 0, CHAN_X); + tmp0 = lp_build_cmp(&bld->base, PIPE_FUNC_NOTEQUAL, + tmp0, bld->base.zero); lp_exec_mask_cond_push(&bld->exec_mask, tmp0); break; -- cgit v1.2.3 From d42229707ad4be9be5a8e122354be7102d6ec348 Mon Sep 17 00:00:00 2001 From: Jose Fonseca Date: Wed, 10 Mar 2010 17:22:30 -0500 Subject: gallivm: simplify conditional branching Instead of testing each component individually, we can test the entire vector at once. --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 29 +++++++------------------ 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index aa57289395..b3a0fe7d9b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -276,27 +276,14 @@ static void lp_exec_continue(struct lp_exec_mask *mask) static void lp_exec_endloop(struct lp_exec_mask *mask) { LLVMBasicBlockRef endloop; - LLVMValueRef i1cond; - - { /* convert our soa vector into i1 */ - int i; - LLVMValueRef packed = 0; - for (i = 0; i < mask->bld->type.length; ++i) { - LLVMValueRef component = LLVMBuildExtractElement( - mask->bld->builder, - mask->break_mask, - LLVMConstInt(LLVMInt32Type(), i, 0), ""); - if (packed) - packed = LLVMBuildOr(mask->bld->builder, - packed, component, ""); - else - packed = component; - } - i1cond = LLVMBuildICmp(mask->bld->builder, LLVMIntNE, - packed, - LLVMConstNull(LLVMTypeOf(packed)), - ""); - } + LLVMTypeRef reg_type = LLVMIntType(mask->bld->type.width* + mask->bld->type.length); + /* i1cond = (mask == 0) */ + LLVMValueRef i1cond = LLVMBuildICmp( + mask->bld->builder, + LLVMIntNE, + LLVMBuildBitCast(mask->bld->builder, mask->break_mask, reg_type, ""), + LLVMConstNull(reg_type), ""); endloop = lp_build_insert_new_block(mask->bld->builder, "endloop"); -- cgit v1.2.3 From 54af54277a7a469ed2b9821ef6ed7ed464381f91 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 6 Feb 2010 16:58:32 +0000 Subject: st/xorg: Include cursorstr.h --- src/gallium/state_trackers/xorg/xorg_crtc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 53a3c5c2b7..a428fa8d94 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "xorg_tracker.h" #include "xf86Modes.h" -- cgit v1.2.3 From 19371fb60da8ec27a6024d0bf38b82cf3ca787e4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 15:11:49 -0700 Subject: llvmpipe: fix loop over mipmap levels --- src/gallium/drivers/llvmpipe/lp_setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index fbe14924cb..d6d37c4809 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -475,7 +475,7 @@ lp_setup_set_sampler_textures( struct setup_context *setup, if (!lp_tex->dt) { /* regular texture - setup array of mipmap level pointers */ int j; - for (j = 0; j < LP_MAX_TEXTURE_2D_LEVELS; j++) { + for (j = 0; j <= tex->last_level; j++) { jit_tex->data[j] = (ubyte *) lp_tex->data + lp_tex->level_offset[j]; } -- cgit v1.2.3 From dd67103d867dcce108848ac5fa2d48175362bf97 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 15:12:19 -0700 Subject: gallivm: remove debug code. nearest minification works now. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index a965d394f4..f1371d909e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -794,7 +794,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, { const int dims = texture_dims(bld->static_state->target); - struct lp_build_context *coord_bld = &bld->coord_bld; struct lp_build_context *float_bld = &bld->float_bld; LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(), bld->static_state->lod_bias); LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod); @@ -1021,12 +1020,10 @@ lp_build_sample_2d_nearest_mip_nearest_soa(struct lp_build_sample_context *bld, lp_build_name(y, "tex.y.wrapped"); /* get pointer to mipmap level [ilevel] data */ - if (0) - data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); - else - data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); + data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); - lp_build_sample_texel_soa(bld, width_vec, height_vec, x, y, stride, data_ptr, texel); + lp_build_sample_texel_soa(bld, width_vec, height_vec, x, y, + stride, data_ptr, texel); } -- cgit v1.2.3 From a75254dda98419b92f4656fcc00973426cb68cf7 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 15:38:17 -0700 Subject: gallivm: implement bilinear sampling with nearest mipmapping Time to start consolidating some code... --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index f1371d909e..2e6865a67b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1027,6 +1027,76 @@ lp_build_sample_2d_nearest_mip_nearest_soa(struct lp_build_sample_context *bld, } +/** + * Sample 2D texture with linear filtering, nearest mipmap. + */ +static void +lp_build_sample_2d_linear_mip_nearest_soa(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef width, + LLVMValueRef height, + LLVMValueRef width_vec, + LLVMValueRef height_vec, + LLVMValueRef stride, + LLVMValueRef data_array, + LLVMValueRef *texel) +{ + LLVMValueRef x0, y0, x1, y1, s_fpart, t_fpart; + LLVMValueRef lod, ilevel, ilevel_vec; + LLVMValueRef neighbors[2][2][4]; + LLVMValueRef data_ptr; + int chan; + + /* compute float LOD */ + lod = lp_build_lod_selector(bld, s, t, NULL, width, height, NULL); + + /* convert LOD to int */ + lp_build_nearest_mip_level(bld, unit, lod, &ilevel); + + ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel); + + /* compute width_vec, height at mipmap level 'ilevel' */ + width_vec = lp_build_minify(bld, width_vec, ilevel_vec); + height_vec = lp_build_minify(bld, height_vec, ilevel_vec); + stride = lp_build_minify(bld, stride, ilevel_vec); + + lp_build_sample_wrap_linear(bld, s, width_vec, + bld->static_state->pot_width, + bld->static_state->wrap_s, &x0, &x1, &s_fpart); + lp_build_sample_wrap_linear(bld, t, height_vec, + bld->static_state->pot_height, + bld->static_state->wrap_t, &y0, &y1, &t_fpart); + + lp_build_name(x0, "tex.x0.wrapped"); + lp_build_name(y0, "tex.y0.wrapped"); + lp_build_name(x1, "tex.x1.wrapped"); + lp_build_name(y1, "tex.y1.wrapped"); + + /* get pointer to mipmap level [ilevel] data */ + data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); + + lp_build_sample_texel_soa(bld, width_vec, height_vec, x0, y0, + stride, data_ptr, neighbors[0][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, x1, y0, + stride, data_ptr, neighbors[0][1]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, x0, y1, + stride, data_ptr, neighbors[1][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, x1, y1, + stride, data_ptr, neighbors[1][1]); + + for(chan = 0; chan < 4; ++chan) { + texel[chan] = lp_build_lerp_2d(&bld->texel_bld, + s_fpart, t_fpart, + neighbors[0][0][chan], + neighbors[0][1][chan], + neighbors[1][0][chan], + neighbors[1][1][chan]); + } +} + + /** * Sample 2D texture with bilinear filtering. */ @@ -1413,6 +1483,15 @@ lp_build_sample_soa(LLVMBuilderRef builder, case PIPE_TEX_MIPFILTER_NEAREST: switch (static_state->min_img_filter) { + case PIPE_TEX_FILTER_LINEAR: + lp_build_sample_2d_linear_mip_nearest_soa(&bld, unit, + s, t, + width, height, + width_vec, height_vec, + stride_vec, + data_array, texel); + done = TRUE; + break; case PIPE_TEX_FILTER_NEAREST: lp_build_sample_2d_nearest_mip_nearest_soa(&bld, unit, s, t, -- cgit v1.2.3 From 22bb7ffd04ca9296bcafa929f448203880cbcb2b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 18:06:02 -0700 Subject: gallivm: constant building for scalar zero --- src/gallium/auxiliary/gallivm/lp_bld_const.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.c b/src/gallium/auxiliary/gallivm/lp_bld_const.c index 53447757e8..8a275fa72f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.c @@ -221,8 +221,16 @@ lp_build_undef(struct lp_type type) LLVMValueRef lp_build_zero(struct lp_type type) { - LLVMTypeRef vec_type = lp_build_vec_type(type); - return LLVMConstNull(vec_type); + if (type.length == 1) { + if (type.floating) + return LLVMConstReal(LLVMFloatType(), 0.0); + else + return LLVMConstInt(LLVMIntType(type.width), 0, 0); + } + else { + LLVMTypeRef vec_type = lp_build_vec_type(type); + return LLVMConstNull(vec_type); + } } -- cgit v1.2.3 From a599f552f2ee86004216fe062bf4885de9c9ae96 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 18:07:13 -0700 Subject: gallivm: handle scalar floats in lp_build_floor() and lp_build_iround() --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index e2c6788397..f55d2b6d15 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -883,6 +883,10 @@ lp_build_floor(struct lp_build_context *bld, assert(type.floating); + if (type.length == 1) { + return LLVMBuildFPTrunc(bld->builder, a, LLVMFloatType(), ""); + } + if(util_cpu_caps.has_sse4_1) return lp_build_round_sse41(bld, a, LP_BUILD_ROUND_SSE41_FLOOR); else { @@ -953,6 +957,9 @@ lp_build_itrunc(struct lp_build_context *bld, } +/** + * Convert float[] to int[] with round(). + */ LLVMValueRef lp_build_iround(struct lp_build_context *bld, LLVMValueRef a) @@ -1013,6 +1020,14 @@ lp_build_ifloor(struct lp_build_context *bld, LLVMValueRef res; assert(type.floating); + + if (type.length == 1) { + /* scalar float to int */ + LLVMTypeRef int_type = LLVMIntType(type.width); + res = LLVMBuildFPToSI(bld->builder, a, int_type, ""); + return res; + } + assert(lp_check_value(type, a)); if(util_cpu_caps.has_sse4_1) { -- cgit v1.2.3 From 67a2f98be79b368c316ebe6731112734d306b3f6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Mar 2010 18:07:52 -0700 Subject: gallivm: overhaul of texture sampling code The new lp_build_sample_general() function will handle all sampling modes for all texture types. Still incomplete, but a few additional sampling modes are now supported. 1D textures should work and most of the code for 3D textures is in place. No support for cube maps yet. No support for different min/mag filters. --- src/gallium/auxiliary/gallivm/lp_bld_sample.c | 24 +- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 4 +- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 642 ++++++++++++++-------- 3 files changed, 420 insertions(+), 250 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c index 311c9f1b9e..543fd5fea3 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c @@ -155,14 +155,16 @@ lp_build_gather(LLVMBuilderRef builder, /** * Compute the offset of a pixel. * - * x, y, y_stride are vectors + * x, y, z, y_stride, z_stride are vectors */ LLVMValueRef lp_build_sample_offset(struct lp_build_context *bld, const struct util_format_description *format_desc, LLVMValueRef x, LLVMValueRef y, - LLVMValueRef y_stride) + LLVMValueRef z, + LLVMValueRef y_stride, + LLVMValueRef z_stride) { LLVMValueRef x_stride; LLVMValueRef offset; @@ -178,6 +180,10 @@ lp_build_sample_offset(struct lp_build_context *bld, LLVMValueRef y_offset_lo, y_offset_hi; LLVMValueRef offset_lo, offset_hi; + /* XXX 1D & 3D addressing not done yet */ + assert(!z); + assert(!z_stride); + x_lo = LLVMBuildAnd(bld->builder, x, bld->one, ""); y_lo = LLVMBuildAnd(bld->builder, y, bld->one, ""); @@ -201,13 +207,17 @@ lp_build_sample_offset(struct lp_build_context *bld, offset = lp_build_add(bld, offset_hi, offset_lo); } else { - LLVMValueRef x_offset; - LLVMValueRef y_offset; + offset = lp_build_mul(bld, x, x_stride); - x_offset = lp_build_mul(bld, x, x_stride); - y_offset = lp_build_mul(bld, y, y_stride); + if (y && y_stride) { + LLVMValueRef y_offset = lp_build_mul(bld, y, y_stride); + offset = lp_build_add(bld, offset, y_offset); + } - offset = lp_build_add(bld, x_offset, y_offset); + if (z && z_stride) { + LLVMValueRef z_offset = lp_build_mul(bld, z, z_stride); + offset = lp_build_add(bld, offset, z_offset); + } } return offset; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 68db91d6fd..5b8da5dbf2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -148,7 +148,9 @@ lp_build_sample_offset(struct lp_build_context *bld, const struct util_format_description *format_desc, LLVMValueRef x, LLVMValueRef y, - LLVMValueRef y_stride); + LLVMValueRef z, + LLVMValueRef y_stride, + LLVMValueRef z_stride); void diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 2e6865a67b..dadae61115 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -138,8 +138,28 @@ lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld, } +static int +texture_dims(enum pipe_texture_target tex) +{ + switch (tex) { + case PIPE_TEXTURE_1D: + return 1; + case PIPE_TEXTURE_2D: + case PIPE_TEXTURE_CUBE: + return 2; + case PIPE_TEXTURE_3D: + return 3; + default: + assert(0 && "bad texture target in texture_dims()"); + return 2; + } +} + + + /** - * Gen code to fetch a texel from a texture at int coords (x, y). + * Generate code to fetch a texel from a texture at int coords (x, y, z). + * The computation depends on whether the texture is 1D, 2D or 3D. * The result, texel, will be: * texel[0] = red values * texel[1] = green values @@ -150,12 +170,16 @@ static void lp_build_sample_texel_soa(struct lp_build_sample_context *bld, LLVMValueRef width, LLVMValueRef height, + LLVMValueRef depth, LLVMValueRef x, LLVMValueRef y, + LLVMValueRef z, LLVMValueRef y_stride, + LLVMValueRef z_stride, LLVMValueRef data_ptr, LLVMValueRef *texel) { + const int dims = texture_dims(bld->static_state->target); struct lp_build_context *int_coord_bld = &bld->int_coord_bld; LLVMValueRef offset; LLVMValueRef packed; @@ -169,7 +193,7 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2"); } - if (wrap_mode_uses_border_color(bld->static_state->wrap_t)) { + if (dims >= 2 && wrap_mode_uses_border_color(bld->static_state->wrap_t)) { LLVMValueRef b1, b2; b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, y, int_coord_bld->zero); b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, y, height); @@ -182,6 +206,19 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, } } + if (dims == 3 && wrap_mode_uses_border_color(bld->static_state->wrap_r)) { + LLVMValueRef b1, b2; + b1 = lp_build_cmp(int_coord_bld, PIPE_FUNC_LESS, z, int_coord_bld->zero); + b2 = lp_build_cmp(int_coord_bld, PIPE_FUNC_GEQUAL, z, depth); + if (use_border) { + use_border = LLVMBuildOr(bld->builder, use_border, b1, "ub_or_b1"); + use_border = LLVMBuildOr(bld->builder, use_border, b2, "ub_or_b2"); + } + else { + use_border = LLVMBuildOr(bld->builder, b1, b2, "b1_or_b2"); + } + } + /* * Note: if we find an app which frequently samples the texture border * we might want to implement a true conditional here to avoid sampling @@ -197,10 +234,10 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, * the texel color results with the border color. */ - /* convert x,y coords to linear offset from start of texture, in bytes */ + /* convert x,y,z coords to linear offset from start of texture, in bytes */ offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, - x, y, y_stride); + x, y, z, y_stride, z_stride); assert(bld->format_desc->block.width == 1); assert(bld->format_desc->block.height == 1); @@ -213,6 +250,8 @@ lp_build_sample_texel_soa(struct lp_build_sample_context *bld, bld->texel_type.width, data_ptr, offset); + texel[0] = texel[1] = texel[2] = texel[3] = NULL; + /* convert texels to float rgba */ lp_build_unpack_rgba_soa(bld->builder, bld->format_desc, @@ -245,7 +284,7 @@ lp_build_sample_packed(struct lp_build_sample_context *bld, offset = lp_build_sample_offset(&bld->uint_coord_bld, bld->format_desc, - x, y, y_stride); + x, y, NULL, y_stride, NULL); assert(bld->format_desc->block.width == 1); assert(bld->format_desc->block.height == 1); @@ -756,24 +795,6 @@ lp_build_minify(struct lp_build_sample_context *bld, } -static int -texture_dims(enum pipe_texture_target tex) -{ - switch (tex) { - case PIPE_TEXTURE_1D: - return 1; - case PIPE_TEXTURE_2D: - case PIPE_TEXTURE_CUBE: - return 2; - case PIPE_TEXTURE_3D: - return 3; - default: - assert(0 && "bad texture target in texture_dims()"); - return 2; - } -} - - /** * Generate code to compute texture level of detail (lambda). * \param s vector of texcoord s values @@ -920,229 +941,406 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld, LLVMValueRef *level1_out, LLVMValueRef *weight_out) { - struct lp_build_context *coord_bld = &bld->coord_bld; - struct lp_build_context *int_coord_bld = &bld->int_coord_bld; + struct lp_build_context *float_bld = &bld->float_bld; + struct lp_build_context *int_bld = &bld->int_bld; LLVMValueRef last_level, level; last_level = bld->dynamic_state->last_level(bld->dynamic_state, bld->builder, unit); /* convert float lod to integer */ - level = lp_build_ifloor(coord_bld, lod); + level = lp_build_ifloor(float_bld, lod); /* compute level 0 and clamp to legal range of levels */ - *level0_out = lp_build_clamp(int_coord_bld, level, - int_coord_bld->zero, + *level0_out = lp_build_clamp(int_bld, level, + int_bld->zero, last_level); /* compute level 1 and clamp to legal range of levels */ - *level1_out = lp_build_add(int_coord_bld, *level0_out, int_coord_bld->one); - *level1_out = lp_build_min(int_coord_bld, *level1_out, int_coord_bld->zero); + *level1_out = lp_build_add(int_bld, *level0_out, int_bld->one); + *level1_out = lp_build_min(int_bld, *level1_out, int_bld->zero); - *weight_out = lp_build_fract(coord_bld, lod); + *weight_out = lp_build_fract(float_bld, lod); } - /** - * Sample 2D texture with nearest filtering, no mipmapping. + * Generate code to sample a mipmap level with nearest filtering. */ static void -lp_build_sample_2d_nearest_soa(struct lp_build_sample_context *bld, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef width, - LLVMValueRef height, - LLVMValueRef stride, - LLVMValueRef data_array, - LLVMValueRef *texel) +lp_build_sample_image_nearest(struct lp_build_sample_context *bld, + LLVMValueRef width_vec, + LLVMValueRef height_vec, + LLVMValueRef depth_vec, + LLVMValueRef row_stride_vec, + LLVMValueRef img_stride_vec, + LLVMValueRef data_ptr, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef colors_out[4]) { - LLVMValueRef x, y; - LLVMValueRef data_ptr; + const int dims = texture_dims(bld->static_state->target); + LLVMValueRef x, y, z; - x = lp_build_sample_wrap_nearest(bld, s, width, + /* + * Compute integer texcoords. + */ + x = lp_build_sample_wrap_nearest(bld, s, width_vec, bld->static_state->pot_width, bld->static_state->wrap_s); - y = lp_build_sample_wrap_nearest(bld, t, height, - bld->static_state->pot_height, - bld->static_state->wrap_t); - lp_build_name(x, "tex.x.wrapped"); - lp_build_name(y, "tex.y.wrapped"); - /* get pointer to mipmap level 0 data */ - data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); + if (dims >= 2) { + y = lp_build_sample_wrap_nearest(bld, t, height_vec, + bld->static_state->pot_height, + bld->static_state->wrap_t); + lp_build_name(y, "tex.y.wrapped"); + + if (dims == 3) { + z = lp_build_sample_wrap_nearest(bld, r, depth_vec, + bld->static_state->pot_height, + bld->static_state->wrap_r); + lp_build_name(z, "tex.z.wrapped"); + } + else { + z = NULL; + } + } + else { + y = NULL; + } - lp_build_sample_texel_soa(bld, width, height, x, y, stride, data_ptr, texel); + /* + * Get texture colors. + */ + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x, y, z, + row_stride_vec, img_stride_vec, + data_ptr, colors_out); } /** - * Sample 2D texture with nearest filtering, nearest mipmap. + * Generate code to sample a mipmap level with linear filtering. + * 1D, 2D and 3D images are suppored. */ static void -lp_build_sample_2d_nearest_mip_nearest_soa(struct lp_build_sample_context *bld, - unsigned unit, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef width, - LLVMValueRef height, - LLVMValueRef width_vec, - LLVMValueRef height_vec, - LLVMValueRef stride, - LLVMValueRef data_array, - LLVMValueRef *texel) +lp_build_sample_image_linear(struct lp_build_sample_context *bld, + LLVMValueRef width_vec, + LLVMValueRef height_vec, + LLVMValueRef depth_vec, + LLVMValueRef row_stride_vec, + LLVMValueRef img_stride_vec, + LLVMValueRef data_ptr, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef colors_out[4]) { - LLVMValueRef x, y; - LLVMValueRef lod, ilevel, ilevel_vec; - LLVMValueRef data_ptr; - - /* compute float LOD */ - lod = lp_build_lod_selector(bld, s, t, NULL, width, height, NULL); - - /* convert LOD to int */ - lp_build_nearest_mip_level(bld, unit, lod, &ilevel); - - ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel); + const int dims = texture_dims(bld->static_state->target); + LLVMValueRef x0, y0, z0, x1, y1, z1; + LLVMValueRef s_fpart, t_fpart, r_fpart; + LLVMValueRef neighbors[2][2][4]; + int chan; - /* compute width_vec, height at mipmap level 'ilevel' */ - width_vec = lp_build_minify(bld, width_vec, ilevel_vec); - height_vec = lp_build_minify(bld, height_vec, ilevel_vec); - stride = lp_build_minify(bld, stride, ilevel_vec); + /* + * Compute integer texcoords. + */ + lp_build_sample_wrap_linear(bld, s, width_vec, + bld->static_state->pot_width, + bld->static_state->wrap_s, + &x0, &x1, &s_fpart); + lp_build_name(x0, "tex.x0.wrapped"); + lp_build_name(x1, "tex.x1.wrapped"); - x = lp_build_sample_wrap_nearest(bld, s, width_vec, - bld->static_state->pot_width, - bld->static_state->wrap_s); - y = lp_build_sample_wrap_nearest(bld, t, height_vec, - bld->static_state->pot_height, - bld->static_state->wrap_t); + if (dims >= 2) { + lp_build_sample_wrap_linear(bld, t, height_vec, + bld->static_state->pot_height, + bld->static_state->wrap_t, + &y0, &y1, &t_fpart); + lp_build_name(y0, "tex.y0.wrapped"); + lp_build_name(y1, "tex.y1.wrapped"); + + if (dims == 3) { + lp_build_sample_wrap_linear(bld, r, depth_vec, + bld->static_state->pot_depth, + bld->static_state->wrap_r, + &z0, &z1, &r_fpart); + lp_build_name(z0, "tex.z0.wrapped"); + lp_build_name(z1, "tex.z1.wrapped"); + } + else { + z0 = z1 = r_fpart = NULL; + } + } + else { + y0 = y1 = t_fpart = NULL; + } - lp_build_name(x, "tex.x.wrapped"); - lp_build_name(y, "tex.y.wrapped"); + /* + * Get texture colors. + */ + /* get x0/x1 texels */ + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x0, y0, z0, + row_stride_vec, img_stride_vec, + data_ptr, neighbors[0][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x1, y0, z0, + row_stride_vec, img_stride_vec, + data_ptr, neighbors[0][1]); + + if (dims == 1) { + /* Interpolate two samples from 1D image to produce one color */ + colors_out[chan] = lp_build_lerp(&bld->texel_bld, s_fpart, + neighbors[0][0][chan], + neighbors[0][1][chan]); + } + else { + /* 2D/3D texture */ + LLVMValueRef colors0[4]; + + /* get x0/x1 texels at y1 */ + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x0, y1, z0, + row_stride_vec, img_stride_vec, + data_ptr, neighbors[1][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x1, y1, z0, + row_stride_vec, img_stride_vec, + data_ptr, neighbors[1][1]); + + /* Bilinear interpolate the four samples from the 2D image / 3D slice */ + for (chan = 0; chan < 4; chan++) { + colors0[chan] = lp_build_lerp_2d(&bld->texel_bld, + s_fpart, t_fpart, + neighbors[0][0][chan], + neighbors[0][1][chan], + neighbors[1][0][chan], + neighbors[1][1][chan]); + } - /* get pointer to mipmap level [ilevel] data */ - data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); + if (dims == 3) { + LLVMValueRef neighbors1[2][2][4]; + LLVMValueRef colors1[4]; + + /* get x0/x1/y0/y1 texels at z1 */ + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x0, y0, z1, + row_stride_vec, img_stride_vec, + data_ptr, neighbors1[0][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x1, y0, z1, + row_stride_vec, img_stride_vec, + data_ptr, neighbors1[0][1]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x0, y1, z1, + row_stride_vec, img_stride_vec, + data_ptr, neighbors1[1][0]); + lp_build_sample_texel_soa(bld, width_vec, height_vec, depth_vec, + x1, y1, z1, + row_stride_vec, img_stride_vec, + data_ptr, neighbors1[1][1]); + + /* Bilinear interpolate the four samples from the second Z slice */ + for (chan = 0; chan < 4; chan++) { + colors1[chan] = lp_build_lerp_2d(&bld->texel_bld, + s_fpart, t_fpart, + neighbors1[0][0][chan], + neighbors1[0][1][chan], + neighbors1[1][0][chan], + neighbors1[1][1][chan]); + } - lp_build_sample_texel_soa(bld, width_vec, height_vec, x, y, - stride, data_ptr, texel); + /* Linearly interpolate the two samples from the two 3D slices */ + for (chan = 0; chan < 4; chan++) { + colors_out[chan] = lp_build_lerp(&bld->texel_bld, + r_fpart, + colors0[chan], colors1[chan]); + } + } + else { + /* 2D tex */ + for (chan = 0; chan < 4; chan++) { + colors_out[chan] = colors0[chan]; + } + } + } } + /** - * Sample 2D texture with linear filtering, nearest mipmap. + * General texture sampling codegen. + * This function handles texture sampling for all texture targets (1D, + * 2D, 3D, cube) and all filtering modes. */ static void -lp_build_sample_2d_linear_mip_nearest_soa(struct lp_build_sample_context *bld, - unsigned unit, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef width, - LLVMValueRef height, - LLVMValueRef width_vec, - LLVMValueRef height_vec, - LLVMValueRef stride, - LLVMValueRef data_array, - LLVMValueRef *texel) +lp_build_sample_general(struct lp_build_sample_context *bld, + unsigned unit, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef width, + LLVMValueRef height, + LLVMValueRef depth, + LLVMValueRef width_vec, + LLVMValueRef height_vec, + LLVMValueRef depth_vec, + LLVMValueRef row_stride_vec, + LLVMValueRef img_stride_vec, + LLVMValueRef data_array, + LLVMValueRef *colors_out) { - LLVMValueRef x0, y0, x1, y1, s_fpart, t_fpart; - LLVMValueRef lod, ilevel, ilevel_vec; - LLVMValueRef neighbors[2][2][4]; - LLVMValueRef data_ptr; + const unsigned mip_filter = bld->static_state->min_mip_filter; + const unsigned min_filter = bld->static_state->min_img_filter; + const unsigned mag_filter = bld->static_state->mag_img_filter; + const int dims = texture_dims(bld->static_state->target); + LLVMValueRef lod, lod_fpart; + LLVMValueRef ilevel0, ilevel1, ilevel0_vec, ilevel1_vec; + LLVMValueRef width0_vec, height0_vec, depth0_vec; + LLVMValueRef width1_vec, height1_vec, depth1_vec; + LLVMValueRef row_stride0_vec, row_stride1_vec; + LLVMValueRef img_stride0_vec, img_stride1_vec; + LLVMValueRef data_ptr0, data_ptr1; int chan; - /* compute float LOD */ - lod = lp_build_lod_selector(bld, s, t, NULL, width, height, NULL); - - /* convert LOD to int */ - lp_build_nearest_mip_level(bld, unit, lod, &ilevel); - - ilevel_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel); + /* + printf("%s mip %d min %d mag %d\n", __FUNCTION__, + mip_filter, min_filter, mag_filter); + */ - /* compute width_vec, height at mipmap level 'ilevel' */ - width_vec = lp_build_minify(bld, width_vec, ilevel_vec); - height_vec = lp_build_minify(bld, height_vec, ilevel_vec); - stride = lp_build_minify(bld, stride, ilevel_vec); + /* + * Compute the level of detail (mipmap level index(es)). + */ + if (mip_filter == PIPE_TEX_MIPFILTER_NONE) { + /* always use mip level 0 */ + ilevel0 = LLVMConstInt(LLVMInt32Type(), 0, 0); + } + else { + /* compute float LOD */ + lod = lp_build_lod_selector(bld, s, t, r, width, height, depth); - lp_build_sample_wrap_linear(bld, s, width_vec, - bld->static_state->pot_width, - bld->static_state->wrap_s, &x0, &x1, &s_fpart); - lp_build_sample_wrap_linear(bld, t, height_vec, - bld->static_state->pot_height, - bld->static_state->wrap_t, &y0, &y1, &t_fpart); + if (mip_filter == PIPE_TEX_MIPFILTER_NEAREST) { + lp_build_nearest_mip_level(bld, unit, lod, &ilevel0); + } + else { + assert(mip_filter == PIPE_TEX_MIPFILTER_LINEAR); + lp_build_linear_mip_levels(bld, unit, lod, &ilevel0, &ilevel1, + &lod_fpart); + lod_fpart = lp_build_broadcast_scalar(&bld->coord_bld, lod_fpart); + } + } - lp_build_name(x0, "tex.x0.wrapped"); - lp_build_name(y0, "tex.y0.wrapped"); - lp_build_name(x1, "tex.x1.wrapped"); - lp_build_name(y1, "tex.y1.wrapped"); + /* + * Convert scalar integer mipmap levels into vectors. + */ + ilevel0_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel0); + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) + ilevel1_vec = lp_build_broadcast_scalar(&bld->int_coord_bld, ilevel1); - /* get pointer to mipmap level [ilevel] data */ - data_ptr = lp_build_get_mipmap_level(bld, data_array, ilevel); + /* + * Compute width, height at mipmap level 'ilevel0' + */ + width0_vec = lp_build_minify(bld, width_vec, ilevel0_vec); + if (dims >= 2) { + height0_vec = lp_build_minify(bld, height_vec, ilevel0_vec); + row_stride0_vec = lp_build_minify(bld, row_stride_vec, ilevel0_vec); + if (dims == 3) { + depth0_vec = lp_build_minify(bld, depth_vec, ilevel0_vec); + } + } + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { + /* compute width, height, depth for second mipmap level at ilevel1 */ + width1_vec = lp_build_minify(bld, width_vec, ilevel1_vec); + if (dims >= 2) { + height1_vec = lp_build_minify(bld, height_vec, ilevel1_vec); + row_stride1_vec = lp_build_minify(bld, row_stride_vec, ilevel1_vec); + if (dims == 3) { + depth1_vec = lp_build_minify(bld, depth_vec, ilevel1_vec); + } + } + } - lp_build_sample_texel_soa(bld, width_vec, height_vec, x0, y0, - stride, data_ptr, neighbors[0][0]); - lp_build_sample_texel_soa(bld, width_vec, height_vec, x1, y0, - stride, data_ptr, neighbors[0][1]); - lp_build_sample_texel_soa(bld, width_vec, height_vec, x0, y1, - stride, data_ptr, neighbors[1][0]); - lp_build_sample_texel_soa(bld, width_vec, height_vec, x1, y1, - stride, data_ptr, neighbors[1][1]); + /* + * Choose cube face, recompute texcoords. + */ + if (bld->static_state->target == PIPE_TEXTURE_CUBE) { - for(chan = 0; chan < 4; ++chan) { - texel[chan] = lp_build_lerp_2d(&bld->texel_bld, - s_fpart, t_fpart, - neighbors[0][0][chan], - neighbors[0][1][chan], - neighbors[1][0][chan], - neighbors[1][1][chan]); } -} + /* + * Get pointer(s) to image data for mipmap level(s). + */ + data_ptr0 = lp_build_get_mipmap_level(bld, data_array, ilevel0); + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { + data_ptr1 = lp_build_get_mipmap_level(bld, data_array, ilevel1); + } -/** - * Sample 2D texture with bilinear filtering. - */ -static void -lp_build_sample_2d_linear_soa(struct lp_build_sample_context *bld, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef width, - LLVMValueRef height, - LLVMValueRef stride, - LLVMValueRef data_array, - LLVMValueRef *texel) -{ - LLVMValueRef s_fpart; - LLVMValueRef t_fpart; - LLVMValueRef x0, x1; - LLVMValueRef y0, y1; - LLVMValueRef neighbors[2][2][4]; - LLVMValueRef data_ptr; - unsigned chan; + /* + * Get/interpolate texture colors. + */ + /* XXX temporarily force this path: */ + if (1 /*min_filter == mag_filter*/) { + /* same filter for minification or magnification */ + LLVMValueRef colors0[4], colors1[4]; + + if (min_filter == PIPE_TEX_FILTER_NEAREST) { + lp_build_sample_image_nearest(bld, + width0_vec, height0_vec, depth0_vec, + row_stride0_vec, img_stride0_vec, + data_ptr0, s, t, r, colors0); + + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { + /* sample the second mipmap level, and interp */ + lp_build_sample_image_nearest(bld, + width1_vec, height1_vec, depth1_vec, + row_stride1_vec, img_stride1_vec, + data_ptr1, s, t, r, colors1); + } + } + else { + assert(min_filter == PIPE_TEX_FILTER_LINEAR); - lp_build_sample_wrap_linear(bld, s, width, bld->static_state->pot_width, - bld->static_state->wrap_s, &x0, &x1, &s_fpart); - lp_build_sample_wrap_linear(bld, t, height, bld->static_state->pot_height, - bld->static_state->wrap_t, &y0, &y1, &t_fpart); + lp_build_sample_image_linear(bld, + width0_vec, height0_vec, depth0_vec, + row_stride0_vec, img_stride0_vec, + data_ptr0, s, t, r, colors0); - /* get pointer to mipmap level 0 data */ - data_ptr = lp_build_get_const_mipmap_level(bld, data_array, 0); - lp_build_sample_texel_soa(bld, width, height, x0, y0, stride, data_ptr, neighbors[0][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y0, stride, data_ptr, neighbors[0][1]); - lp_build_sample_texel_soa(bld, width, height, x0, y1, stride, data_ptr, neighbors[1][0]); - lp_build_sample_texel_soa(bld, width, height, x1, y1, stride, data_ptr, neighbors[1][1]); + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { + /* sample the second mipmap level, and interp */ + lp_build_sample_image_linear(bld, + width1_vec, height1_vec, depth1_vec, + row_stride1_vec, img_stride1_vec, + data_ptr1, s, t, r, colors1); + } + } - /* TODO: Don't interpolate missing channels */ - for(chan = 0; chan < 4; ++chan) { - texel[chan] = lp_build_lerp_2d(&bld->texel_bld, - s_fpart, t_fpart, - neighbors[0][0][chan], - neighbors[0][1][chan], - neighbors[1][0][chan], - neighbors[1][1][chan]); + if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { + /* interpolate samples from the two mipmap levels */ + for (chan = 0; chan < 4; chan++) { + colors_out[chan] = lp_build_lerp(&bld->texel_bld, lod_fpart, + colors0[chan], colors1[chan]); + } + } + else { + /* use first/only level's colors */ + for (chan = 0; chan < 4; chan++) { + colors_out[chan] = colors0[chan]; + } + } + } + else { + /* emit conditional to choose min image filter or mag image filter + * depending on the lod being >0 or <= 0, respectively. + */ + abort(); } } + static void lp_build_rgba8_to_f32_soa(LLVMBuilderRef builder, struct lp_type dst_type, @@ -1426,12 +1624,12 @@ lp_build_sample_soa(LLVMBuilderRef builder, struct lp_build_sample_context bld; LLVMValueRef width, width_vec; LLVMValueRef height, height_vec; + LLVMValueRef depth, depth_vec; LLVMValueRef stride, stride_vec; LLVMValueRef data_array; LLVMValueRef s; LLVMValueRef t; LLVMValueRef r; - boolean done = FALSE; (void) lp_build_lod_selector; /* temporary to silence warning */ (void) lp_build_nearest_mip_level; @@ -1462,6 +1660,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, /* Get the dynamic state */ width = dynamic_state->width(dynamic_state, builder, unit); height = dynamic_state->height(dynamic_state, builder, unit); + depth = dynamic_state->depth(dynamic_state, builder, unit); stride = dynamic_state->stride(dynamic_state, builder, unit); data_array = dynamic_state->data_ptr(dynamic_state, builder, unit); /* Note that data_array is an array[level] of pointers to texture images */ @@ -1472,67 +1671,26 @@ lp_build_sample_soa(LLVMBuilderRef builder, width_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); + depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth); stride_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride); - if(static_state->target == PIPE_TEXTURE_1D) - t = bld.coord_bld.zero; - - switch (static_state->min_mip_filter) { - case PIPE_TEX_MIPFILTER_NONE: - break; - case PIPE_TEX_MIPFILTER_NEAREST: - - switch (static_state->min_img_filter) { - case PIPE_TEX_FILTER_LINEAR: - lp_build_sample_2d_linear_mip_nearest_soa(&bld, unit, - s, t, - width, height, - width_vec, height_vec, - stride_vec, - data_array, texel); - done = TRUE; - break; - case PIPE_TEX_FILTER_NEAREST: - lp_build_sample_2d_nearest_mip_nearest_soa(&bld, unit, - s, t, - width, height, - width_vec, height_vec, - stride_vec, - data_array, texel); - done = TRUE; - break; - } - - break; - case PIPE_TEX_MIPFILTER_LINEAR: - break; - default: - assert(0 && "invalid mip filter"); + if (lp_format_is_rgba8(bld.format_desc) && + static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && + static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR && + static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE && + is_simple_wrap_mode(static_state->wrap_s) && + is_simple_wrap_mode(static_state->wrap_t)) { + /* special case */ + lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, + stride_vec, data_array, texel); } - - if (!done) { - switch (static_state->min_img_filter) { - case PIPE_TEX_FILTER_NEAREST: - lp_build_sample_2d_nearest_soa(&bld, s, t, width_vec, height_vec, - stride_vec, data_array, texel); - break; - case PIPE_TEX_FILTER_LINEAR: - if(lp_format_is_rgba8(bld.format_desc) && - is_simple_wrap_mode(static_state->wrap_s) && - is_simple_wrap_mode(static_state->wrap_t)) - lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, - stride_vec, data_array, texel); - else - lp_build_sample_2d_linear_soa(&bld, s, t, width_vec, height_vec, - stride_vec, data_array, texel); - break; - default: - assert(0); - } + else { + lp_build_sample_general(&bld, unit, s, t, r, + width, height, depth, + width_vec, height_vec, depth_vec, + stride_vec, NULL, data_array, + texel); } - /* FIXME: respect static_state->min_mip_filter */; - /* FIXME: respect static_state->mag_img_filter */; - lp_build_sample_compare(&bld, r, texel); } -- cgit v1.2.3 From aa311ae61680f0fc300e33e8955c6c58cafd5fb4 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 11 Mar 2010 00:18:09 -0800 Subject: winsys/xlib: Fix memory leak. Memory for xm_dt was allocated twice. --- src/gallium/winsys/xlib/xlib_sw_winsys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 29c642706a..cecfa4a53d 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -363,7 +363,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, unsigned alignment, unsigned *stride) { - struct xm_displaytarget *xm_dt = CALLOC_STRUCT(xm_displaytarget); + struct xm_displaytarget *xm_dt; unsigned nblocksy, size; xm_dt = CALLOC_STRUCT(xm_displaytarget); -- cgit v1.2.3 From a0ae2ca033ec2024da1e01d1c11c0437837c031b Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Sat, 6 Mar 2010 17:36:44 +0100 Subject: st/dri: move extension initilization to st/mesa completely Extensions were enabled in both st/mesa and st/dri, with st/dri completely overriding the decisions of st/mesa and exposing even the extensions claimed to be unsupported by a pipe driver. This commit moves the differences between the two to st/mesa and removes the responsibilty of advertising extensions from st/dri. --- src/gallium/state_trackers/dri/dri_extensions.c | 102 +----------------------- src/mesa/state_tracker/st_extensions.c | 9 +++ 2 files changed, 12 insertions(+), 99 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index 1259813a41..d98fe3b47b 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -33,110 +33,14 @@ #include "dri_context.h" #include "state_tracker/st_context.h" -#define need_GL_ARB_map_buffer_range -#define need_GL_ARB_multisample -#define need_GL_ARB_occlusion_query -#define need_GL_ARB_point_parameters -#define need_GL_ARB_provoking_vertex -#define need_GL_ARB_shader_objects -#define need_GL_ARB_texture_compression -#define need_GL_ARB_vertex_array_object -#define need_GL_ARB_vertex_buffer_object -#define need_GL_ARB_vertex_program -#define need_GL_ARB_vertex_shader -#define need_GL_ARB_window_pos -#define need_GL_EXT_blend_color -#define need_GL_EXT_blend_equation_separate -#define need_GL_EXT_blend_func_separate -#define need_GL_EXT_blend_minmax -#define need_GL_EXT_cull_vertex -#define need_GL_EXT_draw_buffers2 -#define need_GL_EXT_fog_coord -#define need_GL_EXT_framebuffer_object -#define need_GL_EXT_multi_draw_arrays -#define need_GL_EXT_provoking_vertex -#define need_GL_EXT_secondary_color -#define need_GL_EXT_stencil_two_side -#define need_GL_APPLE_vertex_array_object -#define need_GL_NV_vertex_program -#define need_GL_VERSION_2_0 -#define need_GL_VERSION_2_1 -#include "main/remap_helper.h" #include "utils.h" -/** - * Extension strings exported by the driver. - */ -static const struct dri_extension card_extensions[] = { - {"GL_ARB_fragment_shader", NULL}, - {"GL_ARB_map_buffer_range", GL_ARB_map_buffer_range_functions}, - {"GL_ARB_multisample", GL_ARB_multisample_functions}, - {"GL_ARB_multitexture", NULL}, - {"GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions}, - {"GL_ARB_pixel_buffer_object", NULL}, - {"GL_ARB_provoking_vertex", GL_ARB_provoking_vertex_functions}, - {"GL_ARB_point_parameters", GL_ARB_point_parameters_functions}, - {"GL_ARB_shading_language_100", GL_VERSION_2_0_functions }, - {"GL_ARB_shading_language_120", GL_VERSION_2_1_functions }, - {"GL_ARB_shader_objects", GL_ARB_shader_objects_functions}, - {"GL_ARB_texture_border_clamp", NULL}, - {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions}, - {"GL_ARB_texture_cube_map", NULL}, - {"GL_ARB_texture_env_add", NULL}, - {"GL_ARB_texture_env_combine", NULL}, - {"GL_ARB_texture_env_dot3", NULL}, - {"GL_ARB_texture_mirrored_repeat", NULL}, - {"GL_ARB_texture_non_power_of_two", NULL}, - {"GL_ARB_texture_rectangle", NULL}, - {"GL_ARB_vertex_array_object", GL_ARB_vertex_array_object_functions}, - {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, - {"GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions}, - {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions}, - {"GL_ARB_window_pos", GL_ARB_window_pos_functions}, - {"GL_EXT_blend_color", GL_EXT_blend_color_functions}, - {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions}, - {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, - {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, - {"GL_EXT_blend_subtract", NULL}, - {"GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions}, - {"GL_EXT_draw_buffers2", GL_EXT_draw_buffers2_functions}, - {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions}, - {"GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions}, - {"GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions}, - {"GL_EXT_packed_depth_stencil", NULL}, - {"GL_EXT_pixel_buffer_object", NULL}, - {"GL_EXT_provoking_vertex", GL_EXT_provoking_vertex_functions}, - {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, - {"GL_EXT_stencil_two_side", GL_EXT_stencil_two_side_functions}, - {"GL_EXT_stencil_wrap", NULL}, - {"GL_EXT_texture_edge_clamp", NULL}, - {"GL_EXT_texture_env_combine", NULL}, - {"GL_EXT_texture_env_dot3", NULL}, - {"GL_EXT_texture_filter_anisotropic", NULL}, - {"GL_EXT_texture_lod_bias", NULL}, - {"GL_3DFX_texture_compression_FXT1", NULL}, - {"GL_APPLE_client_storage", NULL}, - {"GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions}, - {"GL_MESA_pack_invert", NULL}, - {"GL_MESA_ycbcr_texture", NULL}, - {"GL_NV_blend_square", NULL}, - {"GL_NV_vertex_program", GL_NV_vertex_program_functions}, - {"GL_NV_vertex_program1_1", NULL}, - {"GL_SGIS_generate_mipmap", NULL}, - {NULL, NULL} -}; - void dri_init_extensions(struct dri_context *ctx) { - /* The card_extensions list should be pruned according to the - * capabilities of the pipe_screen. This is actually something - * that can/should be done inside st_create_context(). - * XXX Not pruning is very bogus. Always all these extensions above - * will be advertized, regardless what st_init_extensions - * (which depends on the pipe cap bits) does. - */ - driInitExtensions(ctx->st->ctx, card_extensions, GL_TRUE); + /* New extensions should be added in mesa/state_tracker/st_extensions.c + * and not in this file. */ + driInitExtensions(ctx->st->ctx, NULL, GL_TRUE); } /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index bc240e0893..e837924dbd 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -172,12 +172,14 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ARB_vertex_array_object = GL_TRUE; ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE; ctx->Extensions.ARB_vertex_program = GL_TRUE; + ctx->Extensions.ARB_window_pos = GL_TRUE; ctx->Extensions.EXT_blend_color = GL_TRUE; ctx->Extensions.EXT_blend_func_separate = GL_TRUE; ctx->Extensions.EXT_blend_logic_op = GL_TRUE; ctx->Extensions.EXT_blend_minmax = GL_TRUE; ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_cull_vertex = GL_TRUE; ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; ctx->Extensions.EXT_framebuffer_object = GL_TRUE; ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; @@ -194,12 +196,19 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; + ctx->Extensions.TDFX_texture_compression_FXT1 = GL_TRUE; + + ctx->Extensions.APPLE_client_storage = GL_TRUE; ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; + ctx->Extensions.MESA_pack_invert = GL_TRUE; + ctx->Extensions.NV_blend_square = GL_TRUE; ctx->Extensions.NV_texgen_reflection = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; ctx->Extensions.NV_texture_rectangle = GL_TRUE; + ctx->Extensions.NV_vertex_program = GL_TRUE; + ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; #if FEATURE_OES_draw_texture ctx->Extensions.OES_draw_texture = GL_TRUE; -- cgit v1.2.3 From 4c5c442f127419d4ea780fbc60bf58f4ed17d71e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Mar 2010 11:43:04 +0000 Subject: softpipe: Dummy fence functions. --- src/gallium/drivers/softpipe/Makefile | 1 + src/gallium/drivers/softpipe/SConscript | 1 + src/gallium/drivers/softpipe/sp_fence.c | 70 ++++++++++++++++++++++++++++++++ src/gallium/drivers/softpipe/sp_fence.h | 40 ++++++++++++++++++ src/gallium/drivers/softpipe/sp_screen.c | 2 + 5 files changed, 114 insertions(+) create mode 100644 src/gallium/drivers/softpipe/sp_fence.c create mode 100644 src/gallium/drivers/softpipe/sp_fence.h (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile index 1c6e4ae076..239655d628 100644 --- a/src/gallium/drivers/softpipe/Makefile +++ b/src/gallium/drivers/softpipe/Makefile @@ -8,6 +8,7 @@ C_SOURCES = \ sp_fs_sse.c \ sp_buffer.c \ sp_clear.c \ + sp_fence.c \ sp_flush.c \ sp_query.c \ sp_context.c \ diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript index 27ab00b036..9949a53adf 100644 --- a/src/gallium/drivers/softpipe/SConscript +++ b/src/gallium/drivers/softpipe/SConscript @@ -11,6 +11,7 @@ softpipe = env.ConvenienceLibrary( 'sp_clear.c', 'sp_context.c', 'sp_draw_arrays.c', + 'sp_fence.c', 'sp_flush.c', 'sp_prim_vbuf.c', 'sp_setup.c', diff --git a/src/gallium/drivers/softpipe/sp_fence.c b/src/gallium/drivers/softpipe/sp_fence.c new file mode 100644 index 0000000000..66c5214113 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_fence.c @@ -0,0 +1,70 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#include "pipe/p_screen.h" +#include "util/u_debug.h" +#include "sp_fence.h" + + +static void +softpipe_fence_reference(struct pipe_screen *screen, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence) +{ + assert(!*ptr); + assert(!fence); +} + + +static int +softpipe_fence_signalled(struct pipe_screen *screen, + struct pipe_fence_handle *fence, + unsigned flags) +{ + assert(!fence); + return 0; +} + + +static int +softpipe_fence_finish(struct pipe_screen *screen, + struct pipe_fence_handle *fence, + unsigned flags) +{ + assert(!fence); + return 0; +} + + +void +softpipe_init_screen_fence_funcs(struct pipe_screen *screen) +{ + screen->fence_reference = softpipe_fence_reference; + screen->fence_finish = softpipe_fence_finish; + screen->fence_signalled = softpipe_fence_signalled; +} diff --git a/src/gallium/drivers/softpipe/sp_fence.h b/src/gallium/drivers/softpipe/sp_fence.h new file mode 100644 index 0000000000..39c33243bd --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_fence.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + + +#ifndef SP_FENCE_H_ +#define SP_FENCE_H_ + + +struct pipe_screen; + + +void +softpipe_init_screen_fence_funcs(struct pipe_screen *screen); + + +#endif /* SP_FENCE_H_ */ diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c index e0a2ef604e..d62bfa3d63 100644 --- a/src/gallium/drivers/softpipe/sp_screen.c +++ b/src/gallium/drivers/softpipe/sp_screen.c @@ -36,6 +36,7 @@ #include "sp_screen.h" #include "sp_context.h" #include "sp_buffer.h" +#include "sp_fence.h" #include "sp_public.h" @@ -239,6 +240,7 @@ softpipe_create_screen(struct sw_winsys *winsys) softpipe_init_screen_texture_funcs(&screen->base); softpipe_init_screen_buffer_funcs(&screen->base); + softpipe_init_screen_fence_funcs(&screen->base); return &screen->base; } -- cgit v1.2.3 From b43c182f19c6291c88420fa12714f952c2b461fb Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 11 Mar 2010 15:23:16 +0000 Subject: Squashed commit of gallium-context-transfers: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit 7a2ee04629681e59ea147b440856c4f9a33ae9f8 Author: Keith Whitwell Date: Thu Mar 11 14:19:17 2010 +0000 nv: convert to context transfers commit 188a3f5331c8e5966729fd59d02975afb7324adc Author: Keith Whitwell Date: Thu Mar 11 14:11:10 2010 +0000 nouveau: remove unused variable commit 5c8e880ab4dc020358c08728b8adb1637d2dc5bc Author: Keith Whitwell Date: Thu Mar 11 12:31:21 2010 +0000 mesa/st: fix compilation after merge commit c552595333f860c2a4807e195596acdf5d6a5ef8 Author: Keith Whitwell Date: Thu Mar 11 12:31:06 2010 +0000 util: fix compilation after merge commit e80836878a3617b0e350d2a8f92311832a1476cb Author: Keith Whitwell Date: Thu Mar 11 12:30:47 2010 +0000 r300g: fix compilation after merge commit 0e4883e9511b9db4e75a4dbc78d7bb970badc15d Author: Keith Whitwell Date: Thu Mar 11 12:18:45 2010 +0000 i965g: fix incorrect merge commit 17d74133d8168eebf93bf1390de79930fc8da231 Merge: cb81c79 aa311ae Author: Keith Whitwell Date: Thu Mar 11 12:08:32 2010 +0000 Merge commit 'origin/master' into gallium-context-transfers Conflicts: src/gallium/drivers/i965/brw_screen_texture.c src/gallium/drivers/r300/r300_screen.c src/gallium/drivers/softpipe/sp_texture.c src/gallium/drivers/svga/svga_screen_texture.c src/gallium/state_trackers/egl/x11/native_ximage.c commit cb81c79098bc3a92a4d2a3dcc0edc972dfb407be Author: Keith Whitwell Date: Tue Mar 2 16:04:01 2010 +0000 egl/x11: hack for context transfers There is a better approach to this in the winsys-handle branch, but for now avoid using transfers at all by always allocating our own backing store directly. commit f44a24e1d4ad7563f3eedd6b3a5688f53a36265c Author: Keith Whitwell Date: Tue Mar 2 16:03:16 2010 +0000 llvmpipe: context transfers commit 4d7475ef8104b3b478c7c6ce77cd3506c57e25d1 Author: Keith Whitwell Date: Tue Mar 2 16:02:50 2010 +0000 llvmpipe: disable testprogs build Not working. commit a9bf98c4d36bd92a76f81e83747eb9b8f0a0515f Merge: ee0f97e 0c616da Author: Keith Whitwell Date: Tue Mar 2 15:28:25 2010 +0000 Merge commit 'origin/master' into gallium-context-transfers Conflicts: src/mesa/state_tracker/st_cb_accum.c src/mesa/state_tracker/st_cb_bitmap.c commit ee0f97e8d9fd5ef57211a8e1268f505c9829e246 Merge: a7f078e 828f545 Author: Keith Whitwell Date: Fri Feb 19 13:00:29 2010 +0000 Merge commit 'origin/master' into gallium-context-transfers Conflicts: src/gallium/auxiliary/util/u_debug.h src/gallium/drivers/i915/i915_context.h src/gallium/drivers/llvmpipe/lp_flush.c src/gallium/drivers/nv30/nv30_screen.h src/gallium/drivers/nv40/nv40_context.h src/gallium/drivers/nv40/nv40_screen.h src/gallium/drivers/nv50/nv50_context.h src/gallium/drivers/r300/r300_screen.c src/gallium/drivers/r300/r300_winsys.h src/gallium/drivers/softpipe/sp_context.c src/gallium/drivers/trace/tr_context.c src/gallium/state_trackers/dri/dri_context.c src/gallium/state_trackers/egl/common/egl_g3d.c src/gallium/state_trackers/python/st_device.c src/gallium/winsys/drm/radeon/core/radeon_drm.c commit a7f078e16d851b53ef316066dcced46eb39ebe24 Author: Keith Whitwell Date: Fri Feb 5 14:16:11 2010 +0000 gallium: move texture transfers to pipe_context commit 7b2ffc2019d72e833afea7eebf3e80121187375d Merge: 51e190e c036d13 Author: Keith Whitwell Date: Fri Feb 5 09:55:02 2010 +0000 Merge commit 'origin/master' into gallium-screen-context Conflicts: src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c This branch has got a pretty tortured history now, I expect a squash merge will be appropriate when it is done. commit 51e190e95acf120f72768fafb29e9721e358df1b Author: Keith Whitwell Date: Thu Feb 4 17:58:02 2010 +0000 gallium: fix some build issues commit f524bdaa723fb181637ad30c6ad708aeedabe25b Merge: f906212 3aba0a2 Author: Keith Whitwell Date: Thu Feb 4 17:51:32 2010 +0000 Merge commit 'origin/master' into gallium-screen-context commit f9062126883199eabf045714c717cd35f4b7b313 Author: Keith Whitwell Date: Thu Feb 4 17:17:12 2010 +0000 gallium/docs: small description of screen::create_context commit efcb37bd3d5ed37f06c6105bd2d750b374ec0927 Author: Keith Whitwell Date: Thu Feb 4 16:42:42 2010 +0000 drm/radeon: more dead create_context wrapper removal commit 6badc0dd9e06cf2ec936940bcf12b9ef5324b301 Author: Keith Whitwell Date: Thu Feb 4 16:42:30 2010 +0000 drm/i965: more dead create_context wrapper removal commit cf04ebd5a54b18b2d894cfdab2b0f2fd55626ffc Author: Keith Whitwell Date: Thu Feb 4 16:42:05 2010 +0000 st/python: more dead create_context wrapper removal commit 444f114c3516abf71c430e6e9d0d2ae3b80679d3 Author: Keith Whitwell Date: Thu Feb 4 16:37:58 2010 +0000 idenity: wrapped context creation commit 5a6d09cb9e468d1ee6c8d54b887618819d8d94f2 Author: Keith Whitwell Date: Thu Feb 4 16:28:47 2010 +0000 ws/gdi: remove dead context_create wrapper commit 132b55f4bec39386ac625f09aaa11f609664024c Author: Keith Whitwell Date: Thu Feb 4 16:27:52 2010 +0000 ws/gdi: remove dead context_create wrapper commit 56d2d21a0cdcb197a364049d354c2f15a4fc026a Author: Keith Whitwell Date: Thu Feb 4 16:25:38 2010 +0000 st/xorg: use screen::context_create commit 838c5cfe56b2af6c644909bed3c5e7cdd64c336a Author: Keith Whitwell Date: Thu Feb 4 16:23:20 2010 +0000 glx/xlib: simplify creation of trace-wrapped contexts Trace screen knows how to properly wrap context creation in the wrapped screen, so nothing special to do here. commit c99404c03ebaec4175f08a2f363e43c9085f2635 Author: Keith Whitwell Date: Thu Feb 4 16:18:24 2010 +0000 st/python: no need to special case context creation for trace commit 193a527a682b6877bb1faecd8092df4dfd055a18 Author: Keith Whitwell Date: Thu Feb 4 16:15:30 2010 +0000 drm/radeon: remove dead create_context declaration commit bb984eecc25cf23bc77e1c818b81165ba1a07c9a Author: Keith Whitwell Date: Thu Feb 4 16:14:58 2010 +0000 nv/drm: remove dead create_context ref commit e809313a44287dc4e16c28e9e74ef3b2b5271aa1 Author: Keith Whitwell Date: Thu Feb 4 16:12:51 2010 +0000 st/egl: remove a layer of wrappers around screen::create_context commit 39caa6672a04122f185c22e17aab86d1c40938bf Author: Keith Whitwell Date: Thu Feb 4 16:05:28 2010 +0000 r300g: fill in screen::context_create commit 407f12556d16ba0656774d8a1d9ebda22f82f473 Author: Keith Whitwell Date: Thu Feb 4 16:04:04 2010 +0000 cell: adapt for screen::create_context, untested commit d02b0c6ce321a04c76fdabb09e0e4380ce1c1376 Author: Keith Whitwell Date: Thu Feb 4 15:50:24 2010 +0000 drm/nv: adapt for screen::create_context All contexts now created directly through the screen, so remove equivalent code here. Remove apparently un-needed array of contexts in the winsys. commit 53eec5b1349aa1b6892a75a7bff7e7530957aeae Author: Keith Whitwell Date: Thu Feb 4 15:50:08 2010 +0000 stw: adapt for screen::create_context, untested commit c6a64de3eb381bc9a88e9fbdecbf87d77925aaf5 Author: Keith Whitwell Date: Thu Feb 4 15:49:20 2010 +0000 trace: expose the wrapped context's priv data If we are going to keep this priv idea, really want an accessor function for it so that trace and other drivers can wrap that. commit 75d6104e11d86ec2b0749627ed58e35f856ee6eb Author: Keith Whitwell Date: Thu Feb 4 15:47:55 2010 +0000 nv30: adapt to screen::context_create commit 12f5deb6ed9723e9b5d34577052b8365813ca14e Author: Keith Whitwell Date: Thu Feb 4 15:44:47 2010 +0000 nv40: adapt to screen::context_create commit 14baccaa3b6bbb3b91056126f6521828e786dc62 Author: Keith Whitwell Date: Thu Feb 4 15:35:27 2010 +0000 nv50: adapt to screen::create_context Not build tested. Need to figure out how to build nouveau. commit a0e94505ccd2d7f3e604465a2ac302f1286b73b6 Author: Keith Whitwell Date: Thu Feb 4 15:22:27 2010 +0000 llvmpipe: update for screen::create_context, untested commit 0eae17107c950346030e4f7e0ec232f868d3893d Author: Keith Whitwell Date: Thu Feb 4 15:16:57 2010 +0000 xlib/llvmpipe: remove dead winsys context creation path commit 2f69f9ffaa7e2a01d2483277246ed13051ae4ca3 Author: Keith Whitwell Date: Thu Feb 4 14:58:27 2010 +0000 gallium: convert most code to use screen::create_context I wish I could build all of gallium at once to find breakages. commit d7b57f4061b82322cbcae176125913d9f0dea6c1 Author: Keith Whitwell Date: Thu Feb 4 12:46:21 2010 +0000 glx: permit building with older protocol headers I'd like to be able to build mesa on current distro releases without having to upgrade from the standard dri2proto and glproto headers. With this change I'm able to build on ancient releases such as Ubuntu 9-10... In general, it would be nice to be able to build-test mesa to check for unintended breakages without having to follow the external dependencies of every group working on the codebase. commit 57adedd6fb06c98572ed8d4aef19203df4c4eea2 Merge: da71847 e1906ae Author: Keith Whitwell Date: Thu Feb 4 11:38:15 2010 +0000 Merge commit 'origin/master' into gallium-screen-context Conflicts: src/gallium/drivers/softpipe/sp_video_context.h src/gallium/drivers/trace/tr_context.c src/gallium/state_trackers/wgl/shared/stw_context.c src/gallium/winsys/gdi/gdi_softpipe_winsys.c commit da71847ea6414d7e352c6094f8963bb4eda344dc Author: José Fonseca Date: Sat May 2 08:57:39 2009 +0100 wgl: Use pipe_screen::context_create. commit 2595a188f93fd903600ef5d8517737ee0592035d Author: José Fonseca Date: Sat May 2 08:56:47 2009 +0100 trace: Implement pipe_screen::context_create. commit f3640e4ae37a5260cbfba999d079f827de0a313a Author: José Fonseca Date: Sat May 2 08:56:17 2009 +0100 softpipe: Implement pipe_screen::context_create. commit 347266bddc8bd39c711bacb2193793759d0f3696 Author: José Fonseca Date: Sat May 2 08:55:31 2009 +0100 gallium: New pipe_screen::context_create callback. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 8 +- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 14 ++- src/gallium/auxiliary/util/u_debug.c | 44 ++++---- src/gallium/auxiliary/util/u_debug.h | 14 ++- src/gallium/auxiliary/util/u_gen_mipmap.c | 50 ++++----- src/gallium/auxiliary/util/u_inlines.h | 12 +- src/gallium/auxiliary/util/u_rect.c | 26 ++--- src/gallium/auxiliary/util/u_tile.c | 24 ++-- src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 10 +- src/gallium/drivers/i915/i915_context.c | 1 + src/gallium/drivers/i915/i915_context.h | 6 + src/gallium/drivers/i915/i915_texture.c | 23 ++-- src/gallium/drivers/i965/brw_screen.h | 5 +- src/gallium/drivers/i965/brw_screen_texture.c | 25 +++-- src/gallium/drivers/identity/id_context.c | 72 ++++++++++++ src/gallium/drivers/identity/id_objects.c | 10 +- src/gallium/drivers/identity/id_objects.h | 4 +- src/gallium/drivers/identity/id_screen.c | 69 ------------ src/gallium/drivers/llvmpipe/Makefile | 6 +- src/gallium/drivers/llvmpipe/lp_context.c | 1 + src/gallium/drivers/llvmpipe/lp_flush.c | 4 +- src/gallium/drivers/llvmpipe/lp_scene.c | 20 ++-- src/gallium/drivers/llvmpipe/lp_texture.c | 25 +++-- src/gallium/drivers/llvmpipe/lp_texture.h | 2 + src/gallium/drivers/nouveau/nv04_surface_2d.c | 1 - src/gallium/drivers/nv30/nv30_context.c | 1 + src/gallium/drivers/nv30/nv30_context.h | 1 + src/gallium/drivers/nv30/nv30_screen.c | 1 - src/gallium/drivers/nv30/nv30_screen.h | 3 - src/gallium/drivers/nv30/nv30_transfer.c | 19 ++-- src/gallium/drivers/nv40/nv40_context.c | 1 + src/gallium/drivers/nv40/nv40_context.h | 1 + src/gallium/drivers/nv40/nv40_screen.c | 1 - src/gallium/drivers/nv40/nv40_screen.h | 3 - src/gallium/drivers/nv40/nv40_transfer.c | 19 ++-- src/gallium/drivers/nv50/nv50_context.c | 1 + src/gallium/drivers/nv50/nv50_context.h | 1 + src/gallium/drivers/nv50/nv50_transfer.c | 17 +-- src/gallium/drivers/r300/r300_context.c | 3 + src/gallium/drivers/r300/r300_context.h | 1 + src/gallium/drivers/r300/r300_screen.c | 4 +- src/gallium/drivers/r300/r300_transfer.c | 39 ++++--- src/gallium/drivers/r300/r300_transfer.h | 4 +- src/gallium/drivers/softpipe/sp_context.c | 10 +- src/gallium/drivers/softpipe/sp_flush.c | 4 +- src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 30 ++--- src/gallium/drivers/softpipe/sp_tex_tile_cache.h | 4 +- src/gallium/drivers/softpipe/sp_texture.c | 27 +++-- src/gallium/drivers/softpipe/sp_texture.h | 3 + src/gallium/drivers/softpipe/sp_tile_cache.c | 26 ++--- src/gallium/drivers/softpipe/sp_tile_cache.h | 4 +- src/gallium/drivers/svga/svga_screen_texture.c | 45 +++++--- src/gallium/drivers/svga/svga_screen_texture.h | 3 + src/gallium/drivers/trace/tr_context.c | 136 +++++++++++++++++++++++ src/gallium/drivers/trace/tr_rbug.c | 16 +-- src/gallium/drivers/trace/tr_screen.c | 136 +---------------------- src/gallium/drivers/trace/tr_screen.h | 1 + src/gallium/drivers/trace/tr_texture.c | 13 ++- src/gallium/drivers/trace/tr_texture.h | 6 +- src/gallium/include/pipe/p_context.h | 26 +++++ src/gallium/include/pipe/p_screen.h | 17 --- src/gallium/include/pipe/p_state.h | 2 + src/gallium/state_trackers/vega/api_filters.c | 14 +-- src/gallium/state_trackers/vega/api_images.c | 5 +- src/gallium/state_trackers/vega/image.c | 13 +-- src/gallium/state_trackers/vega/paint.c | 6 +- src/gallium/state_trackers/vega/st_inlines.h | 9 +- src/mesa/state_tracker/st_atom_pixeltransfer.c | 7 +- src/mesa/state_tracker/st_cb_accum.c | 9 +- src/mesa/state_tracker/st_cb_bitmap.c | 23 ++-- src/mesa/state_tracker/st_cb_drawpixels.c | 30 +++-- src/mesa/state_tracker/st_cb_readpixels.c | 20 ++-- src/mesa/state_tracker/st_cb_texture.c | 19 ++-- src/mesa/state_tracker/st_gen_mipmap.c | 13 +-- src/mesa/state_tracker/st_inlines.h | 10 +- src/mesa/state_tracker/st_texture.c | 17 ++- 76 files changed, 690 insertions(+), 610 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 8f6ca15dfa..2cb76b25ae 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -422,9 +422,9 @@ aaline_create_texture(struct aaline_stage *aaline) /* This texture is new, no need to flush. */ - transfer = screen->get_tex_transfer(screen, aaline->texture, 0, level, 0, + transfer = pipe->get_tex_transfer(pipe, aaline->texture, 0, level, 0, PIPE_TRANSFER_WRITE, 0, 0, size, size); - data = screen->transfer_map(screen, transfer); + data = pipe->transfer_map(pipe, transfer); if (data == NULL) return FALSE; @@ -448,8 +448,8 @@ aaline_create_texture(struct aaline_stage *aaline) } /* unmap */ - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); } return TRUE; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index d0d99aa331..479777e807 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -374,19 +374,21 @@ pstip_update_texture(struct pstip_stage *pstip) { static const uint bit31 = 1 << 31; struct pipe_context *pipe = pstip->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *transfer; const uint *stipple = pstip->state.stipple->stipple; uint i, j; ubyte *data; /* XXX: want to avoid flushing just because we use stipple: + * + * Flush should no longer be necessary if driver is properly + * interleaving drawing and transfers on a given context: */ pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL ); - transfer = screen->get_tex_transfer(screen, pstip->texture, 0, 0, 0, - PIPE_TRANSFER_WRITE, 0, 0, 32, 32); - data = screen->transfer_map(screen, transfer); + transfer = pipe->get_tex_transfer(pipe, pstip->texture, 0, 0, 0, + PIPE_TRANSFER_WRITE, 0, 0, 32, 32); + data = pipe->transfer_map(pipe, transfer); /* * Load alpha texture. @@ -408,8 +410,8 @@ pstip_update_texture(struct pstip_stage *pstip) } /* unmap */ - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); } diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 94be682c4b..de775a2dbc 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -421,26 +421,31 @@ void debug_dump_image(const char *prefix, #endif } -void debug_dump_surface(const char *prefix, +void debug_dump_surface(struct pipe_context *pipe, + const char *prefix, struct pipe_surface *surface) { struct pipe_texture *texture; - struct pipe_screen *screen; struct pipe_transfer *transfer; void *data; if (!surface) return; + /* XXX: this doesn't necessarily work, as the driver may be using + * temporary storage for the surface which hasn't been propagated + * back into the texture. Need to nail down the semantics of views + * and transfers a bit better before we can say if extra work needs + * to be done here: + */ texture = surface->texture; - screen = texture->screen; - transfer = screen->get_tex_transfer(screen, texture, surface->face, - surface->level, surface->zslice, - PIPE_TRANSFER_READ, 0, 0, surface->width, - surface->height); + transfer = pipe->get_tex_transfer(pipe, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); - data = screen->transfer_map(screen, transfer); + data = pipe->transfer_map(pipe, transfer); if(!data) goto error; @@ -452,13 +457,14 @@ void debug_dump_surface(const char *prefix, transfer->stride, data); - screen->transfer_unmap(screen, transfer); + pipe->transfer_unmap(pipe, transfer); error: - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(transfer); } -void debug_dump_texture(const char *prefix, +void debug_dump_texture(struct pipe_context *pipe, + const char *prefix, struct pipe_texture *texture) { struct pipe_surface *surface; @@ -473,7 +479,7 @@ void debug_dump_texture(const char *prefix, surface = screen->get_tex_surface(screen, texture, 0, 0, 0, PIPE_TEXTURE_USAGE_SAMPLER); if (surface) { - debug_dump_surface(prefix, surface); + debug_dump_surface(pipe, prefix, surface); screen->tex_surface_destroy(surface); } } @@ -511,22 +517,22 @@ struct bmp_rgb_quad { }; void -debug_dump_surface_bmp(const char *filename, +debug_dump_surface_bmp(struct pipe_context *pipe, + const char *filename, struct pipe_surface *surface) { #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT struct pipe_transfer *transfer; struct pipe_texture *texture = surface->texture; - struct pipe_screen *screen = texture->screen; - transfer = screen->get_tex_transfer(screen, texture, surface->face, - surface->level, surface->zslice, - PIPE_TRANSFER_READ, 0, 0, surface->width, - surface->height); + transfer = pipe->get_tex_transfer(pipe, texture, surface->face, + surface->level, surface->zslice, + PIPE_TRANSFER_READ, 0, 0, surface->width, + surface->height); debug_dump_transfer_bmp(filename, transfer); - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(transfer); #endif } diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index 0f4768f344..a383837743 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -312,6 +312,7 @@ debug_memory_end(unsigned long beginning); #ifdef DEBUG +struct pipe_context; struct pipe_surface; struct pipe_transfer; struct pipe_texture; @@ -321,11 +322,14 @@ void debug_dump_image(const char *prefix, unsigned width, unsigned height, unsigned stride, const void *data); -void debug_dump_surface(const char *prefix, +void debug_dump_surface(struct pipe_context *pipe, + const char *prefix, struct pipe_surface *surface); -void debug_dump_texture(const char *prefix, +void debug_dump_texture(struct pipe_context *pipe, + const char *prefix, struct pipe_texture *texture); -void debug_dump_surface_bmp(const char *filename, +void debug_dump_surface_bmp(struct pipe_context *pipe, + const char *filename, struct pipe_surface *surface); void debug_dump_transfer_bmp(const char *filename, struct pipe_transfer *transfer); @@ -334,8 +338,8 @@ void debug_dump_float_rgba_bmp(const char *filename, float *rgba, unsigned stride); #else #define debug_dump_image(prefix, format, cpp, width, height, stride, data) ((void)0) -#define debug_dump_surface(prefix, surface) ((void)0) -#define debug_dump_surface_bmp(filename, surface) ((void)0) +#define debug_dump_surface(pipe, prefix, surface) ((void)0) +#define debug_dump_surface_bmp(pipe, filename, surface) ((void)0) #define debug_dump_transfer_bmp(filename, transfer) ((void)0) #define debug_dump_float_rgba_bmp(filename, width, height, rgba, stride) ((void)0) #endif diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index d421bee8ef..46fbde3f4a 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1119,7 +1119,6 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, uint face, uint baseLevel, uint lastLevel) { struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; const uint zslice = 0; uint dstLevel; @@ -1128,27 +1127,27 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; void *srcMap, *dstMap; - srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice, + srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, u_minify(pt->width0, srcLevel), u_minify(pt->height0, srcLevel)); - dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice, + dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); - srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); - dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); + srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); + dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); reduce_1d(pt->format, srcTrans->width, srcMap, dstTrans->width, dstMap); - screen->transfer_unmap(screen, srcTrans); - screen->transfer_unmap(screen, dstTrans); + pipe->transfer_unmap(pipe, srcTrans); + pipe->transfer_unmap(pipe, dstTrans); - screen->tex_transfer_destroy(srcTrans); - screen->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(srcTrans); + pipe->tex_transfer_destroy(dstTrans); } } @@ -1159,7 +1158,6 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, uint face, uint baseLevel, uint lastLevel) { struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; const uint zslice = 0; uint dstLevel; @@ -1171,17 +1169,17 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice, + srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, u_minify(pt->width0, srcLevel), u_minify(pt->height0, srcLevel)); - dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice, + dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); - srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); - dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); + srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); + dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); reduce_2d(pt->format, srcTrans->width, srcTrans->height, @@ -1189,11 +1187,11 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, dstTrans->width, dstTrans->height, dstTrans->stride, dstMap); - screen->transfer_unmap(screen, srcTrans); - screen->transfer_unmap(screen, dstTrans); + pipe->transfer_unmap(pipe, srcTrans); + pipe->transfer_unmap(pipe, dstTrans); - screen->tex_transfer_destroy(srcTrans); - screen->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(srcTrans); + pipe->tex_transfer_destroy(dstTrans); } } @@ -1216,17 +1214,17 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, struct pipe_transfer *srcTrans, *dstTrans; ubyte *srcMap, *dstMap; - srcTrans = screen->get_tex_transfer(screen, pt, face, srcLevel, zslice, + srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice, PIPE_TRANSFER_READ, 0, 0, u_minify(pt->width0, srcLevel), u_minify(pt->height0, srcLevel)); - dstTrans = screen->get_tex_transfer(screen, pt, face, dstLevel, zslice, + dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice, PIPE_TRANSFER_WRITE, 0, 0, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); - srcMap = (ubyte *) screen->transfer_map(screen, srcTrans); - dstMap = (ubyte *) screen->transfer_map(screen, dstTrans); + srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans); + dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans); reduce_3d(pt->format, srcTrans->width, srcTrans->height, @@ -1234,11 +1232,11 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, dstTrans->width, dstTrans->height, dstTrans->stride, dstMap); - screen->transfer_unmap(screen, srcTrans); - screen->transfer_unmap(screen, dstTrans); + pipe->transfer_unmap(pipe, srcTrans); + pipe->transfer_unmap(pipe, dstTrans); - screen->tex_transfer_destroy(srcTrans); - screen->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(srcTrans); + pipe->tex_transfer_destroy(dstTrans); } #else (void) reduce_3d; diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 0cb3432c6e..ada31b8182 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -266,22 +266,22 @@ pipe_buffer_read(struct pipe_screen *screen, static INLINE void * pipe_transfer_map( struct pipe_transfer *transf ) { - struct pipe_screen *screen = transf->texture->screen; - return screen->transfer_map(screen, transf); + struct pipe_context *context = transf->pipe; + return context->transfer_map(context, transf); } static INLINE void pipe_transfer_unmap( struct pipe_transfer *transf ) { - struct pipe_screen *screen = transf->texture->screen; - screen->transfer_unmap(screen, transf); + struct pipe_context *context = transf->pipe; + context->transfer_unmap(context, transf); } static INLINE void pipe_transfer_destroy( struct pipe_transfer *transf ) { - struct pipe_screen *screen = transf->texture->screen; - screen->tex_transfer_destroy(transf); + struct pipe_context *context = transf->pipe; + context->tex_transfer_destroy(transf); } static INLINE unsigned diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 8479161c74..0b8405d01f 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -169,7 +169,6 @@ util_surface_copy(struct pipe_context *pipe, unsigned src_x, unsigned src_y, unsigned w, unsigned h) { - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *src_trans, *dst_trans; void *dst_map; const void *src_map; @@ -182,7 +181,7 @@ util_surface_copy(struct pipe_context *pipe, src_format = src->texture->format; dst_format = dst->texture->format; - src_trans = screen->get_tex_transfer(screen, + src_trans = pipe->get_tex_transfer(pipe, src->texture, src->face, src->level, @@ -190,7 +189,7 @@ util_surface_copy(struct pipe_context *pipe, PIPE_TRANSFER_READ, src_x, src_y, w, h); - dst_trans = screen->get_tex_transfer(screen, + dst_trans = pipe->get_tex_transfer(pipe, dst->texture, dst->face, dst->level, @@ -202,8 +201,8 @@ util_surface_copy(struct pipe_context *pipe, assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format)); assert(util_format_get_blockheight(dst_format) == util_format_get_blockheight(src_format)); - src_map = pipe->screen->transfer_map(screen, src_trans); - dst_map = pipe->screen->transfer_map(screen, dst_trans); + src_map = pipe->transfer_map(pipe, src_trans); + dst_map = pipe->transfer_map(pipe, dst_trans); assert(src_map); assert(dst_map); @@ -221,11 +220,11 @@ util_surface_copy(struct pipe_context *pipe, do_flip ? h - 1 : 0); } - pipe->screen->transfer_unmap(pipe->screen, src_trans); - pipe->screen->transfer_unmap(pipe->screen, dst_trans); + pipe->transfer_unmap(pipe, src_trans); + pipe->transfer_unmap(pipe, dst_trans); - screen->tex_transfer_destroy(src_trans); - screen->tex_transfer_destroy(dst_trans); + pipe->tex_transfer_destroy(src_trans); + pipe->tex_transfer_destroy(dst_trans); } @@ -243,14 +242,13 @@ util_surface_fill(struct pipe_context *pipe, unsigned dstx, unsigned dsty, unsigned width, unsigned height, unsigned value) { - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *dst_trans; void *dst_map; assert(dst->texture); if (!dst->texture) return; - dst_trans = screen->get_tex_transfer(screen, + dst_trans = pipe->get_tex_transfer(pipe, dst->texture, dst->face, dst->level, @@ -258,7 +256,7 @@ util_surface_fill(struct pipe_context *pipe, PIPE_TRANSFER_WRITE, dstx, dsty, width, height); - dst_map = pipe->screen->transfer_map(screen, dst_trans); + dst_map = pipe->transfer_map(pipe, dst_trans); assert(dst_map); @@ -302,6 +300,6 @@ util_surface_fill(struct pipe_context *pipe, } } - pipe->screen->transfer_unmap(pipe->screen, dst_trans); - screen->tex_transfer_destroy(dst_trans); + pipe->transfer_unmap(pipe, dst_trans); + pipe->tex_transfer_destroy(dst_trans); } diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 79481b710b..70a6d97385 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -49,7 +49,7 @@ pipe_get_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, void *dst, int dst_stride) { - struct pipe_screen *screen = pt->texture->screen; + struct pipe_context *pipe = pt->pipe; const void *src; if (dst_stride == 0) @@ -58,14 +58,14 @@ pipe_get_tile_raw(struct pipe_transfer *pt, if (pipe_clip_tile(x, y, &w, &h, pt)) return; - src = screen->transfer_map(screen, pt); + src = pipe->transfer_map(pipe, pt); assert(src); if(!src) return; util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y); - screen->transfer_unmap(screen, pt); + pipe->transfer_unmap(pipe, pt); } @@ -77,7 +77,7 @@ pipe_put_tile_raw(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const void *src, int src_stride) { - struct pipe_screen *screen = pt->texture->screen; + struct pipe_context *pipe = pt->pipe; void *dst; enum pipe_format format = pt->texture->format; @@ -87,14 +87,14 @@ pipe_put_tile_raw(struct pipe_transfer *pt, if (pipe_clip_tile(x, y, &w, &h, pt)) return; - dst = screen->transfer_map(screen, pt); + dst = pipe->transfer_map(pipe, pt); assert(dst); if(!dst) return; util_copy_rect(dst, format, pt->stride, x, y, w, h, src, src_stride, 0, 0); - screen->transfer_unmap(screen, pt); + pipe->transfer_unmap(pipe, pt); } @@ -1377,7 +1377,7 @@ pipe_get_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, uint *z) { - struct pipe_screen *screen = pt->texture->screen; + struct pipe_context *pipe = pt->pipe; const uint dstStride = w; ubyte *map; uint *pDest = z; @@ -1387,7 +1387,7 @@ pipe_get_tile_z(struct pipe_transfer *pt, if (pipe_clip_tile(x, y, &w, &h, pt)) return; - map = (ubyte *)screen->transfer_map(screen, pt); + map = (ubyte *)pipe->transfer_map(pipe, pt); if (!map) { assert(0); return; @@ -1453,7 +1453,7 @@ pipe_get_tile_z(struct pipe_transfer *pt, assert(0); } - screen->transfer_unmap(screen, pt); + pipe->transfer_unmap(pipe, pt); } @@ -1462,7 +1462,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const uint *zSrc) { - struct pipe_screen *screen = pt->texture->screen; + struct pipe_context *pipe = pt->pipe; const uint srcStride = w; const uint *ptrc = zSrc; ubyte *map; @@ -1472,7 +1472,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, if (pipe_clip_tile(x, y, &w, &h, pt)) return; - map = (ubyte *)screen->transfer_map(screen, pt); + map = (ubyte *)pipe->transfer_map(pipe, pt); if (!map) { assert(0); return; @@ -1560,7 +1560,7 @@ pipe_put_tile_z(struct pipe_transfer *pt, assert(0); } - screen->transfer_unmap(screen, pt); + pipe->transfer_unmap(pipe, pt); } diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index 0763b5bb0e..dcc0014479 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -680,14 +680,14 @@ xfer_buffers_map(struct vl_mpeg12_mc_renderer *r) assert(r); for (i = 0; i < 3; ++i) { - r->tex_transfer[i] = r->pipe->screen->get_tex_transfer + r->tex_transfer[i] = r->pipe->get_tex_transfer ( - r->pipe->screen, r->textures.all[i], + r->pipe, r->textures.all[i], 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, r->textures.all[i]->width0, r->textures.all[i]->height0 ); - r->texels[i] = r->pipe->screen->transfer_map(r->pipe->screen, r->tex_transfer[i]); + r->texels[i] = r->pipe->transfer_map(r->pipe, r->tex_transfer[i]); } } @@ -699,8 +699,8 @@ xfer_buffers_unmap(struct vl_mpeg12_mc_renderer *r) assert(r); for (i = 0; i < 3; ++i) { - r->pipe->screen->transfer_unmap(r->pipe->screen, r->tex_transfer[i]); - r->pipe->screen->tex_transfer_destroy(r->tex_transfer[i]); + r->pipe->transfer_unmap(r->pipe, r->tex_transfer[i]); + r->pipe->tex_transfer_destroy(r->tex_transfer[i]); } } diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c index 3d45a22b7e..130519ffa5 100644 --- a/src/gallium/drivers/i915/i915_context.c +++ b/src/gallium/drivers/i915/i915_context.c @@ -221,6 +221,7 @@ i915_create_context(struct pipe_screen *screen, void *priv) i915_init_surface_functions(i915); i915_init_state_functions(i915); i915_init_flush_functions(i915); + i915_init_texture_functions(i915); draw_install_aaline_stage(i915->draw, &i915->base); draw_install_aapoint_stage(i915->draw, &i915->base); diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h index 4994537683..039165b63f 100644 --- a/src/gallium/drivers/i915/i915_context.h +++ b/src/gallium/drivers/i915/i915_context.h @@ -349,6 +349,12 @@ struct pipe_context *i915_create_context(struct pipe_screen *screen, void *priv); +/*********************************************************************** + * i915_texture.c + */ +void i915_init_texture_functions(struct i915_context *i915 ); + + /*********************************************************************** * Inline conversion functions. These are better-typed than the * macros used previously: diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 3ce52cdcdb..3435f7797f 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -795,12 +795,12 @@ i915_tex_surface_destroy(struct pipe_surface *surf) /* - * Screen transfer functions + * Texture transfer functions */ -static struct pipe_transfer* -i915_get_tex_transfer(struct pipe_screen *screen, +static struct pipe_transfer * +i915_get_tex_transfer(struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, @@ -825,6 +825,7 @@ i915_get_tex_transfer(struct pipe_screen *screen, trans = CALLOC_STRUCT(i915_transfer); if (trans) { pipe_texture_reference(&trans->base.texture, texture); + trans->base.pipe = pipe; trans->base.x = x; trans->base.y = y; trans->base.width = w; @@ -837,7 +838,7 @@ i915_get_tex_transfer(struct pipe_screen *screen, } static void * -i915_transfer_map(struct pipe_screen *screen, +i915_transfer_map(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct i915_texture *tex = (struct i915_texture *)transfer->texture; @@ -859,7 +860,7 @@ i915_transfer_map(struct pipe_screen *screen, } static void -i915_transfer_unmap(struct pipe_screen *screen, +i915_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct i915_texture *tex = (struct i915_texture *)transfer->texture; @@ -879,6 +880,14 @@ i915_tex_transfer_destroy(struct pipe_transfer *trans) * Other texture functions */ +void +i915_init_texture_functions(struct i915_context *i915 ) +{ + i915->base.get_tex_transfer = i915_get_tex_transfer; + i915->base.transfer_map = i915_transfer_map; + i915->base.transfer_unmap = i915_transfer_unmap; + i915->base.tex_transfer_destroy = i915_tex_transfer_destroy; +} void i915_init_screen_texture_functions(struct i915_screen *is) @@ -889,8 +898,4 @@ i915_init_screen_texture_functions(struct i915_screen *is) is->base.texture_destroy = i915_texture_destroy; is->base.get_tex_surface = i915_get_tex_surface; is->base.tex_surface_destroy = i915_tex_surface_destroy; - is->base.get_tex_transfer = i915_get_tex_transfer; - is->base.transfer_map = i915_transfer_map; - is->base.transfer_unmap = i915_transfer_unmap; - is->base.tex_transfer_destroy = i915_tex_transfer_destroy; } diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h index e0f3cd2a9f..23e052d0b9 100644 --- a/src/gallium/drivers/i965/brw_screen.h +++ b/src/gallium/drivers/i965/brw_screen.h @@ -181,6 +181,10 @@ void brw_update_texture( struct brw_screen *brw_screen, struct brw_texture *tex ); +/* brw_screen_texture.h + */ +struct brw_context; +void brw_tex_init( struct brw_context *brw ); void brw_screen_tex_init( struct brw_screen *brw_screen ); void brw_screen_tex_surface_init( struct brw_screen *brw_screen ); @@ -198,5 +202,4 @@ boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen, struct brw_winsys_buffer *bo ); - #endif /* BRW_SCREEN_H */ diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index cc79bfc771..52bf9b3c1c 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -37,6 +37,8 @@ #include "brw_defines.h" #include "brw_structs.h" #include "brw_winsys.h" +#include "brw_context.h" + @@ -479,7 +481,7 @@ boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen, */ static struct pipe_transfer* -brw_get_tex_transfer(struct pipe_screen *screen, +brw_get_tex_transfer(struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, @@ -502,6 +504,7 @@ brw_get_tex_transfer(struct pipe_screen *screen, trans = CALLOC_STRUCT(brw_transfer); if (trans) { pipe_texture_reference(&trans->base.texture, texture); + trans->base.pipe = pipe; trans->base.x = x; trans->base.y = y; trans->base.width = w; @@ -514,11 +517,11 @@ brw_get_tex_transfer(struct pipe_screen *screen, } static void * -brw_transfer_map(struct pipe_screen *screen, +brw_transfer_map(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct brw_texture *tex = brw_texture(transfer->texture); - struct brw_winsys_screen *sws = brw_screen(screen)->sws; + struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws; char *map; unsigned usage = transfer->usage; @@ -541,11 +544,11 @@ brw_transfer_map(struct pipe_screen *screen, } static void -brw_transfer_unmap(struct pipe_screen *screen, +brw_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct brw_texture *tex = brw_texture(transfer->texture); - struct brw_winsys_screen *sws = brw_screen(screen)->sws; + struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws; sws->bo_unmap(tex->bo); } @@ -558,6 +561,14 @@ brw_tex_transfer_destroy(struct pipe_transfer *trans) } +void brw_tex_init( struct brw_context *brw ) +{ + brw->base.get_tex_transfer = brw_get_tex_transfer; + brw->base.transfer_map = brw_transfer_map; + brw->base.transfer_unmap = brw_transfer_unmap; + brw->base.tex_transfer_destroy = brw_tex_transfer_destroy; +} + void brw_screen_tex_init( struct brw_screen *brw_screen ) { brw_screen->base.is_format_supported = brw_is_format_supported; @@ -565,8 +576,4 @@ void brw_screen_tex_init( struct brw_screen *brw_screen ) brw_screen->base.texture_from_handle = brw_texture_from_handle; brw_screen->base.texture_get_handle = brw_texture_get_handle; brw_screen->base.texture_destroy = brw_texture_destroy; - brw_screen->base.get_tex_transfer = brw_get_tex_transfer; - brw_screen->base.transfer_map = brw_transfer_map; - brw_screen->base.transfer_unmap = brw_transfer_unmap; - brw_screen->base.tex_transfer_destroy = brw_tex_transfer_destroy; } diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index baf0ae4401..5e371c47c8 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -711,6 +711,74 @@ identity_is_buffer_referenced(struct pipe_context *_pipe, buffer); } + + +static struct pipe_transfer * +identity_context_get_tex_transfer(struct pipe_context *_context, + struct pipe_texture *_texture, + unsigned face, + unsigned level, + unsigned zslice, + enum pipe_transfer_usage usage, + unsigned x, + unsigned y, + unsigned w, + unsigned h) +{ + struct identity_context *id_context = identity_context(_context); + struct identity_texture *id_texture = identity_texture(_texture); + struct pipe_context *context = id_context->pipe; + struct pipe_texture *texture = id_texture->texture; + struct pipe_transfer *result; + + result = context->get_tex_transfer(context, + texture, + face, + level, + zslice, + usage, + x, + y, + w, + h); + + if (result) + return identity_transfer_create(id_context, id_texture, result); + return NULL; +} + +static void +identity_context_tex_transfer_destroy(struct pipe_transfer *_transfer) +{ + identity_transfer_destroy(identity_transfer(_transfer)); +} + +static void * +identity_context_transfer_map(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct identity_context *id_context = identity_context(_context); + struct identity_transfer *id_transfer = identity_transfer(_transfer); + struct pipe_context *context = id_context->pipe; + struct pipe_transfer *transfer = id_transfer->transfer; + + return context->transfer_map(context, + transfer); +} + +static void +identity_context_transfer_unmap(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct identity_context *id_context = identity_context(_context); + struct identity_transfer *id_transfer = identity_transfer(_transfer); + struct pipe_context *context = id_context->pipe; + struct pipe_transfer *transfer = id_transfer->transfer; + + context->transfer_unmap(context, + transfer); +} + struct pipe_context * identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) { @@ -775,6 +843,10 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe) id_pipe->base.flush = identity_flush; id_pipe->base.is_texture_referenced = identity_is_texture_referenced; id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced; + id_pipe->base.get_tex_transfer = identity_context_get_tex_transfer; + id_pipe->base.tex_transfer_destroy = identity_context_tex_transfer_destroy; + id_pipe->base.transfer_map = identity_context_transfer_map; + id_pipe->base.transfer_unmap = identity_context_transfer_unmap; id_pipe->pipe = pipe; diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index 2b1a60c1bf..91831404b8 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -142,7 +142,8 @@ identity_surface_destroy(struct identity_surface *id_surface) struct pipe_transfer * -identity_transfer_create(struct identity_texture *id_texture, +identity_transfer_create(struct identity_context *id_context, + struct identity_texture *id_texture, struct pipe_transfer *transfer) { struct identity_transfer *id_transfer; @@ -166,18 +167,15 @@ identity_transfer_create(struct identity_texture *id_texture, return &id_transfer->base; error: - transfer->texture->screen->tex_transfer_destroy(transfer); + transfer->pipe->tex_transfer_destroy(transfer); return NULL; } void identity_transfer_destroy(struct identity_transfer *id_transfer) { - struct identity_screen *id_screen = identity_screen(id_transfer->base.texture->screen); - struct pipe_screen *screen = id_screen->screen; - pipe_texture_reference(&id_transfer->base.texture, NULL); - screen->tex_transfer_destroy(id_transfer->transfer); + id_transfer->transfer->pipe->tex_transfer_destroy(id_transfer->transfer); FREE(id_transfer); } diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 77cc719079..3c4e6d3f8c 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -35,6 +35,7 @@ #include "id_screen.h" +struct identity_context; struct identity_buffer { @@ -177,7 +178,8 @@ void identity_surface_destroy(struct identity_surface *id_surface); struct pipe_transfer * -identity_transfer_create(struct identity_texture *id_texture, +identity_transfer_create(struct identity_context *id_context, + struct identity_texture *id_texture, struct pipe_transfer *transfer); void diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c index b9d0f003d7..419b146578 100644 --- a/src/gallium/drivers/identity/id_screen.c +++ b/src/gallium/drivers/identity/id_screen.c @@ -207,71 +207,6 @@ identity_screen_tex_surface_destroy(struct pipe_surface *_surface) identity_surface_destroy(identity_surface(_surface)); } -static struct pipe_transfer * -identity_screen_get_tex_transfer(struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned face, - unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, - unsigned y, - unsigned w, - unsigned h) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_texture *id_texture = identity_texture(_texture); - struct pipe_screen *screen = id_screen->screen; - struct pipe_texture *texture = id_texture->texture; - struct pipe_transfer *result; - - result = screen->get_tex_transfer(screen, - texture, - face, - level, - zslice, - usage, - x, - y, - w, - h); - - if (result) - return identity_transfer_create(id_texture, result); - return NULL; -} - -static void -identity_screen_tex_transfer_destroy(struct pipe_transfer *_transfer) -{ - identity_transfer_destroy(identity_transfer(_transfer)); -} - -static void * -identity_screen_transfer_map(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_transfer *id_transfer = identity_transfer(_transfer); - struct pipe_screen *screen = id_screen->screen; - struct pipe_transfer *transfer = id_transfer->transfer; - - return screen->transfer_map(screen, - transfer); -} - -static void -identity_screen_transfer_unmap(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct identity_screen *id_screen = identity_screen(_screen); - struct identity_transfer *id_transfer = identity_transfer(_transfer); - struct pipe_screen *screen = id_screen->screen; - struct pipe_transfer *transfer = id_transfer->transfer; - - screen->transfer_unmap(screen, - transfer); -} static struct pipe_buffer * identity_screen_buffer_create(struct pipe_screen *_screen, @@ -488,10 +423,6 @@ identity_screen_create(struct pipe_screen *screen) id_screen->base.texture_destroy = identity_screen_texture_destroy; id_screen->base.get_tex_surface = identity_screen_get_tex_surface; id_screen->base.tex_surface_destroy = identity_screen_tex_surface_destroy; - id_screen->base.get_tex_transfer = identity_screen_get_tex_transfer; - id_screen->base.tex_transfer_destroy = identity_screen_tex_transfer_destroy; - id_screen->base.transfer_map = identity_screen_transfer_map; - id_screen->base.transfer_unmap = identity_screen_transfer_unmap; id_screen->base.buffer_create = identity_screen_buffer_create; id_screen->base.user_buffer_create = identity_screen_user_buffer_create; if (screen->buffer_map) diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 41ac1cee72..89c06ea3ad 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -55,7 +55,7 @@ testprogs := lp_test_format \ LIBS += $(GL_LIB_DEPS) -L. -lllvmpipe -L../../auxiliary/ -lgallium -$(testprogs): lp_test_% : lp_test_%.o lp_test_main.o libllvmpipe.a - $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group +#$(testprogs): lp_test_% : lp_test_%.o lp_test_main.o libllvmpipe.a +# $(LD) $(filter %.o,$^) -o $@ -Wl,--start-group $(LIBS) -Wl,--end-group -default: $(testprogs) +#default: $(testprogs) diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c index d94efec16a..945e3e0558 100644 --- a/src/gallium/drivers/llvmpipe/lp_context.c +++ b/src/gallium/drivers/llvmpipe/lp_context.c @@ -173,6 +173,7 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv ) llvmpipe->pipe.is_buffer_referenced = llvmpipe_is_buffer_referenced; llvmpipe_init_query_funcs( llvmpipe ); + llvmpipe_init_context_texture_funcs( &llvmpipe->pipe ); /* * Create drawing context and plug our rendering stage into it. diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index bf832433be..1b4e889935 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -79,12 +79,12 @@ llvmpipe_flush( struct pipe_context *pipe, for (i = 0; i < llvmpipe->framebuffer.nr_cbufs; i++) { util_snprintf(filename, sizeof(filename), "cbuf%u_%u", i, frame_no); - debug_dump_surface(filename, llvmpipe->framebuffer.cbufs[i]); + debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.cbufs[0]); } if (0) { util_snprintf(filename, sizeof(filename), "zsbuf_%u", frame_no); - debug_dump_surface(filename, llvmpipe->framebuffer.zsbuf); + debug_dump_surface_bmp(&llvmpipe->pipe, filename, llvmpipe->framebuffer.zsbuf); } ++frame_no; diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index 72492c0f0c..bfe53d4106 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -397,7 +397,7 @@ end: static boolean lp_scene_map_buffers( struct lp_scene *scene ) { - struct pipe_screen *screen = scene->pipe->screen; + struct pipe_context *pipe = scene->pipe; struct pipe_surface *cbuf, *zsbuf; int i; @@ -409,7 +409,7 @@ lp_scene_map_buffers( struct lp_scene *scene ) for (i = 0; i < scene->fb.nr_cbufs; i++) { cbuf = scene->fb.cbufs[i]; if (cbuf) { - scene->cbuf_transfer[i] = screen->get_tex_transfer(screen, + scene->cbuf_transfer[i] = pipe->get_tex_transfer(pipe, cbuf->texture, cbuf->face, cbuf->level, @@ -421,7 +421,7 @@ lp_scene_map_buffers( struct lp_scene *scene ) if (!scene->cbuf_transfer[i]) goto fail; - scene->cbuf_map[i] = screen->transfer_map(screen, + scene->cbuf_map[i] = pipe->transfer_map(pipe, scene->cbuf_transfer[i]); if (!scene->cbuf_map[i]) goto fail; @@ -432,7 +432,7 @@ lp_scene_map_buffers( struct lp_scene *scene ) */ zsbuf = scene->fb.zsbuf; if (zsbuf) { - scene->zsbuf_transfer = screen->get_tex_transfer(screen, + scene->zsbuf_transfer = pipe->get_tex_transfer(pipe, zsbuf->texture, zsbuf->face, zsbuf->level, @@ -444,7 +444,7 @@ lp_scene_map_buffers( struct lp_scene *scene ) if (!scene->zsbuf_transfer) goto fail; - scene->zsbuf_map = screen->transfer_map(screen, + scene->zsbuf_map = pipe->transfer_map(pipe, scene->zsbuf_transfer); if (!scene->zsbuf_map) goto fail; @@ -469,25 +469,25 @@ fail: static void lp_scene_unmap_buffers( struct lp_scene *scene ) { - struct pipe_screen *screen = scene->pipe->screen; + struct pipe_context *pipe = scene->pipe; unsigned i; for (i = 0; i < scene->fb.nr_cbufs; i++) { if (scene->cbuf_map[i]) - screen->transfer_unmap(screen, scene->cbuf_transfer[i]); + pipe->transfer_unmap(pipe, scene->cbuf_transfer[i]); if (scene->cbuf_transfer[i]) - screen->tex_transfer_destroy(scene->cbuf_transfer[i]); + pipe->tex_transfer_destroy(scene->cbuf_transfer[i]); scene->cbuf_transfer[i] = NULL; scene->cbuf_map[i] = NULL; } if (scene->zsbuf_map) - screen->transfer_unmap(screen, scene->zsbuf_transfer); + pipe->transfer_unmap(pipe, scene->zsbuf_transfer); if (scene->zsbuf_transfer) - screen->tex_transfer_destroy(scene->zsbuf_transfer); + pipe->tex_transfer_destroy(scene->zsbuf_transfer); scene->zsbuf_transfer = NULL; scene->zsbuf_map = NULL; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 74b7b4ec5e..65f7994e0e 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -243,7 +243,7 @@ llvmpipe_tex_surface_destroy(struct pipe_surface *surf) static struct pipe_transfer * -llvmpipe_get_tex_transfer(struct pipe_screen *screen, +llvmpipe_get_tex_transfer(struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, @@ -307,10 +307,10 @@ llvmpipe_tex_transfer_destroy(struct pipe_transfer *transfer) static void * -llvmpipe_transfer_map( struct pipe_screen *_screen, +llvmpipe_transfer_map( struct pipe_context *pipe, struct pipe_transfer *transfer ) { - struct llvmpipe_screen *screen = llvmpipe_screen(_screen); + struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen); ubyte *map, *xfer_map; struct llvmpipe_texture *lpt; enum pipe_format format; @@ -351,10 +351,10 @@ llvmpipe_transfer_map( struct pipe_screen *_screen, static void -llvmpipe_transfer_unmap(struct pipe_screen *screen, - struct pipe_transfer *transfer) +llvmpipe_transfer_unmap(struct pipe_context *pipe, + struct pipe_transfer *transfer) { - struct llvmpipe_screen *lp_screen = llvmpipe_screen(screen); + struct llvmpipe_screen *lp_screen = llvmpipe_screen(pipe->screen); struct llvmpipe_texture *lpt; assert(transfer->texture); @@ -376,9 +376,14 @@ llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen) screen->get_tex_surface = llvmpipe_get_tex_surface; screen->tex_surface_destroy = llvmpipe_tex_surface_destroy; +} + - screen->get_tex_transfer = llvmpipe_get_tex_transfer; - screen->tex_transfer_destroy = llvmpipe_tex_transfer_destroy; - screen->transfer_map = llvmpipe_transfer_map; - screen->transfer_unmap = llvmpipe_transfer_unmap; +void +llvmpipe_init_context_texture_funcs(struct pipe_context *pipe) +{ + pipe->get_tex_transfer = llvmpipe_get_tex_transfer; + pipe->tex_transfer_destroy = llvmpipe_tex_transfer_destroy; + pipe->transfer_map = llvmpipe_transfer_map; + pipe->transfer_unmap = llvmpipe_transfer_unmap; } diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h index b23f929b16..94b667abf3 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.h +++ b/src/gallium/drivers/llvmpipe/lp_texture.h @@ -98,5 +98,7 @@ llvmpipe_transfer(struct pipe_transfer *pt) extern void llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen); +extern void +llvmpipe_init_context_texture_funcs(struct pipe_context *pipe); #endif /* LP_TEXTURE_H */ diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.c b/src/gallium/drivers/nouveau/nv04_surface_2d.c index b074547c4d..93114465d5 100644 --- a/src/gallium/drivers/nouveau/nv04_surface_2d.c +++ b/src/gallium/drivers/nouveau/nv04_surface_2d.c @@ -518,7 +518,6 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ; } - struct nv40_screen* screen = (struct nv40_screen*)pscreen; ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE; struct pipe_texture templ; diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c index 279b74445c..825c167b01 100644 --- a/src/gallium/drivers/nv30/nv30_context.c +++ b/src/gallium/drivers/nv30/nv30_context.c @@ -74,6 +74,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv) nv30_init_query_functions(nv30); nv30_init_surface_functions(nv30); nv30_init_state_functions(nv30); + nv30_init_transfer_functions(nv30); /* Create, configure, and install fallback swtnl path */ nv30->draw = draw_create(); diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index 1786460aec..4a164f3b1f 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -167,6 +167,7 @@ struct nv30_state_entry { extern void nv30_init_state_functions(struct nv30_context *nv30); extern void nv30_init_surface_functions(struct nv30_context *nv30); extern void nv30_init_query_functions(struct nv30_context *nv30); +extern void nv30_init_transfer_functions(struct nv30_context *nv30); extern void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen); diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 85433d2095..db24335b7c 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -214,7 +214,6 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) pscreen->context_create = nv30_create; nv30_screen_init_miptree_functions(pscreen); - nv30_screen_init_transfer_functions(pscreen); /* 3D object */ switch (dev->chipset & 0xf0) { diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h index 8591cd31ca..b7856cdf00 100644 --- a/src/gallium/drivers/nv30/nv30_screen.h +++ b/src/gallium/drivers/nv30/nv30_screen.h @@ -35,7 +35,4 @@ nv30_screen(struct pipe_screen *screen) return (struct nv30_screen *)screen; } -void -nv30_screen_init_transfer_functions(struct pipe_screen *pscreen); - #endif diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c index 3aeda51ea1..1318c60ae4 100644 --- a/src/gallium/drivers/nv30/nv30_transfer.c +++ b/src/gallium/drivers/nv30/nv30_transfer.c @@ -33,11 +33,12 @@ nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h } static struct pipe_transfer * -nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, +nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { + struct pipe_screen *pscreen = pcontext->screen; struct nv30_miptree *mt = (struct nv30_miptree *)pt; struct nv30_transfer *tx; struct pipe_texture tx_tex_template, *tx_tex; @@ -145,8 +146,9 @@ nv30_transfer_del(struct pipe_transfer *ptx) } static void * -nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv30_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx) { + struct pipe_screen *pscreen = pcontext->screen; struct nv30_transfer *tx = (struct nv30_transfer *)ptx; struct nv04_surface *ns = (struct nv04_surface *)tx->surface; struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture; @@ -160,8 +162,9 @@ nv30_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } static void -nv30_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv30_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx) { + struct pipe_screen *pscreen = pcontext->screen; struct nv30_transfer *tx = (struct nv30_transfer *)ptx; struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture; @@ -169,10 +172,10 @@ nv30_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } void -nv30_screen_init_transfer_functions(struct pipe_screen *pscreen) +nv30_init_transfer_functions(struct nv30_context *nv30) { - pscreen->get_tex_transfer = nv30_transfer_new; - pscreen->tex_transfer_destroy = nv30_transfer_del; - pscreen->transfer_map = nv30_transfer_map; - pscreen->transfer_unmap = nv30_transfer_unmap; + nv30->pipe.get_tex_transfer = nv30_transfer_new; + nv30->pipe.tex_transfer_destroy = nv30_transfer_del; + nv30->pipe.transfer_map = nv30_transfer_map; + nv30->pipe.transfer_unmap = nv30_transfer_unmap; } diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c index 65dc73e88b..e828f17643 100644 --- a/src/gallium/drivers/nv40/nv40_context.c +++ b/src/gallium/drivers/nv40/nv40_context.c @@ -74,6 +74,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv) nv40_init_query_functions(nv40); nv40_init_surface_functions(nv40); nv40_init_state_functions(nv40); + nv40_init_transfer_functions(nv40); /* Create, configure, and install fallback swtnl path */ nv40->draw = draw_create(); diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 2550ec654b..cb5d9e2d9d 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -183,6 +183,7 @@ struct nv40_state_entry { extern void nv40_init_state_functions(struct nv40_context *nv40); extern void nv40_init_surface_functions(struct nv40_context *nv40); extern void nv40_init_query_functions(struct nv40_context *nv40); +extern void nv40_init_transfer_functions(struct nv40_context *nv40); extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen); diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c index b216c5e38c..dbcc33d8d9 100644 --- a/src/gallium/drivers/nv40/nv40_screen.c +++ b/src/gallium/drivers/nv40/nv40_screen.c @@ -201,7 +201,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) pscreen->context_create = nv40_create; nv40_screen_init_miptree_functions(pscreen); - nv40_screen_init_transfer_functions(pscreen); /* 3D object */ switch (dev->chipset & 0xf0) { diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h index 9437aa050d..2765ab764a 100644 --- a/src/gallium/drivers/nv40/nv40_screen.h +++ b/src/gallium/drivers/nv40/nv40_screen.h @@ -34,7 +34,4 @@ nv40_screen(struct pipe_screen *screen) return (struct nv40_screen *)screen; } -void -nv40_screen_init_transfer_functions(struct pipe_screen *pscreen); - #endif diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c index 0462a042c3..2ca9b94388 100644 --- a/src/gallium/drivers/nv40/nv40_transfer.c +++ b/src/gallium/drivers/nv40/nv40_transfer.c @@ -33,11 +33,12 @@ nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h } static struct pipe_transfer * -nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, +nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { + struct pipe_screen *pscreen = pcontext->screen; struct nv40_miptree *mt = (struct nv40_miptree *)pt; struct nv40_transfer *tx; struct pipe_texture tx_tex_template, *tx_tex; @@ -145,8 +146,9 @@ nv40_transfer_del(struct pipe_transfer *ptx) } static void * -nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv40_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx) { + struct pipe_screen *pscreen = pcontext->screen; struct nv40_transfer *tx = (struct nv40_transfer *)ptx; struct nv04_surface *ns = (struct nv04_surface *)tx->surface; struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture; @@ -160,8 +162,9 @@ nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } static void -nv40_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv40_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx) { + struct pipe_screen *pscreen = pcontext->screen; struct nv40_transfer *tx = (struct nv40_transfer *)ptx; struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture; @@ -169,10 +172,10 @@ nv40_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } void -nv40_screen_init_transfer_functions(struct pipe_screen *pscreen) +nv40_init_transfer_functions(struct nv40_context *nv40) { - pscreen->get_tex_transfer = nv40_transfer_new; - pscreen->tex_transfer_destroy = nv40_transfer_del; - pscreen->transfer_map = nv40_transfer_map; - pscreen->transfer_unmap = nv40_transfer_unmap; + nv40->pipe.get_tex_transfer = nv40_transfer_new; + nv40->pipe.tex_transfer_destroy = nv40_transfer_del; + nv40->pipe.transfer_map = nv40_transfer_map; + nv40->pipe.transfer_unmap = nv40_transfer_unmap; } diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 0eb42f323f..aa14e17872 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -97,6 +97,7 @@ nv50_create(struct pipe_screen *pscreen, void *priv) nv50_init_surface_functions(nv50); nv50_init_state_functions(nv50); nv50_init_query_functions(nv50); + nv50_init_transfer_functions(nv50); nv50->draw = draw_create(); assert(nv50->draw); diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 8793c2aac5..1743f6fb39 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -175,6 +175,7 @@ nv50_context(struct pipe_context *pipe) extern void nv50_init_surface_functions(struct nv50_context *nv50); extern void nv50_init_state_functions(struct nv50_context *nv50); extern void nv50_init_query_functions(struct nv50_context *nv50); +extern void nv50_init_transfer_functions(struct nv50_context *nv50); extern void nv50_screen_init_miptree_functions(struct pipe_screen *pscreen); diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 7c360e9e73..b7f2ac1b1c 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -121,11 +121,12 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, } static struct pipe_transfer * -nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt, +nv50_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { + struct pipe_screen *pscreen = pcontext->screen; struct nouveau_device *dev = nouveau_screen(pscreen)->device; struct nv50_miptree *mt = nv50_miptree(pt); struct nv50_miptree_level *lvl = &mt->level[level]; @@ -218,7 +219,7 @@ nv50_transfer_del(struct pipe_transfer *ptx) } static void * -nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv50_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx) { struct nv50_transfer *tx = (struct nv50_transfer *)ptx; unsigned flags = 0; @@ -236,7 +237,7 @@ nv50_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } static void -nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) +nv50_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx) { struct nv50_transfer *tx = (struct nv50_transfer *)ptx; @@ -244,12 +245,12 @@ nv50_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx) } void -nv50_transfer_init_screen_functions(struct pipe_screen *pscreen) +nv50_init_transfer_functions(struct nv50_context *nv50) { - pscreen->get_tex_transfer = nv50_transfer_new; - pscreen->tex_transfer_destroy = nv50_transfer_del; - pscreen->transfer_map = nv50_transfer_map; - pscreen->transfer_unmap = nv50_transfer_unmap; + nv50->pipe.get_tex_transfer = nv50_transfer_new; + nv50->pipe.tex_transfer_destroy = nv50_transfer_del; + nv50->pipe.transfer_map = nv50_transfer_map; + nv50->pipe.transfer_unmap = nv50_transfer_unmap; } void diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 923e1e541f..8606c0004e 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -34,6 +34,7 @@ #include "r300_screen.h" #include "r300_state_invariant.h" #include "r300_texture.h" +#include "r300_transfer.h" #include "radeon_winsys.h" @@ -209,6 +210,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_init_query_functions(r300); + r300_init_transfer_functions(r300); + /* r300_init_surface_functions(r300); */ r300_init_state_functions(r300); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 985e339112..03b09603c7 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -404,6 +404,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, struct draw_stage* r300_draw_stage(struct r300_context* r300); void r300_init_state_functions(struct r300_context* r300); void r300_init_surface_functions(struct r300_context* r300); +void r300_init_tex_functions( struct pipe_context *pipe ); static INLINE boolean CTX_DBG_ON(struct r300_context * ctx, unsigned flags) { diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 5880eecd5f..69c0ab496c 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -27,7 +27,6 @@ #include "r300_context.h" #include "r300_texture.h" -#include "r300_transfer.h" #include "radeon_winsys.h" #include "r300_winsys.h" @@ -252,6 +251,8 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, return retval == usage; } + + static void r300_destroy_screen(struct pipe_screen* pscreen) { struct r300_screen* r300screen = r300_screen(pscreen); @@ -290,7 +291,6 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys) r300screen->screen.context_create = r300_create_context; r300_init_screen_texture_functions(&r300screen->screen); - r300_init_screen_transfer_functions(&r300screen->screen); u_simple_screen_init(&r300screen->screen); return &r300screen->screen; diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index ec89681a3c..7dd707ff8e 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -118,15 +118,15 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx, } static struct pipe_transfer* -r300_get_tex_transfer(struct pipe_screen *screen, +r300_get_tex_transfer(struct pipe_context *ctx, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, unsigned x, unsigned y, unsigned w, unsigned h) { struct r300_texture *tex = (struct r300_texture *)texture; + struct r300_screen *r300screen = r300_screen(ctx->screen); struct r300_transfer *trans; - struct r300_screen *r300screen = r300_screen(screen); struct pipe_texture template; trans = CALLOC_STRUCT(r300_transfer); @@ -136,7 +136,7 @@ r300_get_tex_transfer(struct pipe_screen *screen, trans->transfer.usage = usage; trans->transfer.width = w; trans->transfer.height = h; - trans->ctx = r300screen->ctx; + trans->ctx = ctx; trans->x = x; trans->y = y; trans->level = level; @@ -174,8 +174,10 @@ r300_get_tex_transfer(struct pipe_screen *screen, } /* Create the temporary texture. */ - trans->detiled_texture = - (struct r300_texture*)screen->texture_create(screen, &template); + trans->detiled_texture = (struct r300_texture*) + ctx->screen->texture_create(ctx->screen, + &template); + assert(!trans->detiled_texture->microtile && !trans->detiled_texture->macrotile); @@ -187,7 +189,7 @@ r300_get_tex_transfer(struct pipe_screen *screen, if (usage & PIPE_TRANSFER_READ) { /* We cannot map a tiled texture directly because the data is * in a different order, therefore we do detiling using a blit. */ - r300_copy_from_tiled_texture(r300screen->ctx, trans); + r300_copy_from_tiled_texture(ctx, trans); } } else { trans->transfer.x = x; @@ -219,7 +221,7 @@ static void r300_tex_transfer_destroy(struct pipe_transfer *trans) FREE(trans); } -static void* r300_transfer_map(struct pipe_screen *screen, +static void* r300_transfer_map(struct pipe_context *ctx, struct pipe_transfer *transfer) { struct r300_transfer *r300transfer = r300_transfer(transfer); @@ -230,12 +232,12 @@ static void* r300_transfer_map(struct pipe_screen *screen, if (r300transfer->detiled_texture) { /* The detiled texture is of the same size as the region being mapped * (no offset needed). */ - return pipe_buffer_map(screen, + return pipe_buffer_map(ctx->screen, r300transfer->detiled_texture->buffer, pipe_transfer_buffer_flags(transfer)); } else { /* Tiling is disabled. */ - map = pipe_buffer_map(screen, tex->buffer, + map = pipe_buffer_map(ctx->screen, tex->buffer, pipe_transfer_buffer_flags(transfer)); if (!map) { @@ -248,23 +250,26 @@ static void* r300_transfer_map(struct pipe_screen *screen, } } -static void r300_transfer_unmap(struct pipe_screen *screen, +static void r300_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *transfer) { struct r300_transfer *r300transfer = r300_transfer(transfer); struct r300_texture *tex = (struct r300_texture*)transfer->texture; if (r300transfer->detiled_texture) { - pipe_buffer_unmap(screen, r300transfer->detiled_texture->buffer); + pipe_buffer_unmap(ctx->screen, r300transfer->detiled_texture->buffer); } else { - pipe_buffer_unmap(screen, tex->buffer); + pipe_buffer_unmap(ctx->screen, tex->buffer); } } -void r300_init_screen_transfer_functions(struct pipe_screen *screen) + +void r300_init_transfer_functions( struct r300_context *r300ctx ) { - screen->get_tex_transfer = r300_get_tex_transfer; - screen->tex_transfer_destroy = r300_tex_transfer_destroy; - screen->transfer_map = r300_transfer_map; - screen->transfer_unmap = r300_transfer_unmap; + struct pipe_context *ctx = &r300ctx->context; + + ctx->get_tex_transfer = r300_get_tex_transfer; + ctx->tex_transfer_destroy = r300_tex_transfer_destroy; + ctx->transfer_map = r300_transfer_map; + ctx->transfer_unmap = r300_transfer_unmap; } diff --git a/src/gallium/drivers/r300/r300_transfer.h b/src/gallium/drivers/r300/r300_transfer.h index 60d1d3dc85..79baf6d048 100644 --- a/src/gallium/drivers/r300/r300_transfer.h +++ b/src/gallium/drivers/r300/r300_transfer.h @@ -26,6 +26,8 @@ #include "pipe/p_screen.h" -void r300_init_screen_transfer_functions(struct pipe_screen *screen); +struct r300_context; + +void r300_init_transfer_functions(struct r300_context *r300ctx); #endif diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 30494719f7..de92a0cd2c 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -44,6 +44,7 @@ #include "sp_surface.h" #include "sp_tile_cache.h" #include "sp_tex_tile_cache.h" +#include "sp_texture.h" #include "sp_query.h" @@ -275,6 +276,7 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->pipe.is_buffer_referenced = softpipe_is_buffer_referenced; softpipe_init_query_funcs( softpipe ); + softpipe_init_texture_funcs( &softpipe->pipe ); softpipe->pipe.render_condition = softpipe_render_condition; @@ -283,13 +285,13 @@ softpipe_create_context( struct pipe_screen *screen, * Must be before quad stage setup! */ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) - softpipe->cbuf_cache[i] = sp_create_tile_cache( screen ); - softpipe->zsbuf_cache = sp_create_tile_cache( screen ); + softpipe->cbuf_cache[i] = sp_create_tile_cache( &softpipe->pipe ); + softpipe->zsbuf_cache = sp_create_tile_cache( &softpipe->pipe ); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) - softpipe->tex_cache[i] = sp_create_tex_tile_cache( screen ); + softpipe->tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { - softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache(screen); + softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); } /* setup quad rendering stages */ diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index e8952bf4fb..3d76af4d8c 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -93,9 +93,9 @@ softpipe_flush( struct pipe_context *pipe, 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]); + debug_dump_surface_bmp(softpipe, filename, softpipe->framebuffer.cbufs[0]); util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no); - debug_dump_surface_bmp(filename, softpipe->framebuffer.zsbuf); + debug_dump_surface_bmp(softpipe, filename, softpipe->framebuffer.zsbuf); ++frame_no; } #endif diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index a0b95c8884..a9f5b51a41 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -43,14 +43,14 @@ struct softpipe_tex_tile_cache * -sp_create_tex_tile_cache( struct pipe_screen *screen ) +sp_create_tex_tile_cache( struct pipe_context *pipe ) { struct softpipe_tex_tile_cache *tc; uint pos; tc = CALLOC_STRUCT( softpipe_tex_tile_cache ); if (tc) { - tc->screen = screen; + tc->pipe = pipe; for (pos = 0; pos < NUM_ENTRIES; pos++) { tc->entries[pos].addr.bits.invalid = 1; } @@ -63,19 +63,16 @@ sp_create_tex_tile_cache( struct pipe_screen *screen ) void sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc) { - struct pipe_screen *screen; uint pos; for (pos = 0; pos < NUM_ENTRIES; pos++) { /*assert(tc->entries[pos].x < 0);*/ } if (tc->transfer) { - screen = tc->transfer->texture->screen; - screen->tex_transfer_destroy(tc->transfer); + tc->pipe->tex_transfer_destroy(tc->transfer); } if (tc->tex_trans) { - screen = tc->tex_trans->texture->screen; - screen->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->tex_trans); } FREE( tc ); @@ -88,7 +85,7 @@ void sp_tex_tile_cache_map_transfers(struct softpipe_tex_tile_cache *tc) { if (tc->tex_trans && !tc->tex_trans_map) - tc->tex_trans_map = tc->screen->transfer_map(tc->screen, tc->tex_trans); + tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans); } @@ -96,7 +93,7 @@ void sp_tex_tile_cache_unmap_transfers(struct softpipe_tex_tile_cache *tc) { if (tc->tex_trans_map) { - tc->screen->transfer_unmap(tc->screen, tc->tex_trans); + tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans); tc->tex_trans_map = NULL; } } @@ -133,14 +130,12 @@ sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc, pipe_texture_reference(&tc->texture, texture); if (tc->tex_trans) { - struct pipe_screen *screen = tc->tex_trans->texture->screen; - if (tc->tex_trans_map) { - screen->transfer_unmap(screen, tc->tex_trans); + tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans); tc->tex_trans_map = NULL; } - screen->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->tex_trans); tc->tex_trans = NULL; } @@ -204,7 +199,6 @@ const struct softpipe_tex_cached_tile * sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, union tex_tile_address addr ) { - struct pipe_screen *screen = tc->screen; struct softpipe_tex_cached_tile *tile; tile = tc->entries + tex_cache_pos( addr ); @@ -232,16 +226,16 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, if (tc->tex_trans) { if (tc->tex_trans_map) { - tc->screen->transfer_unmap(tc->screen, tc->tex_trans); + tc->pipe->transfer_unmap(tc->pipe, tc->tex_trans); tc->tex_trans_map = NULL; } - screen->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->tex_trans); tc->tex_trans = NULL; } tc->tex_trans = - screen->get_tex_transfer(screen, tc->texture, + tc->pipe->get_tex_transfer(tc->pipe, tc->texture, addr.bits.face, addr.bits.level, addr.bits.z, @@ -249,7 +243,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, u_minify(tc->texture->width0, addr.bits.level), u_minify(tc->texture->height0, addr.bits.level)); - tc->tex_trans_map = screen->transfer_map(screen, tc->tex_trans); + tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans); tc->tex_face = addr.bits.face; tc->tex_level = addr.bits.level; diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h index ac6886a3df..b116397258 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h @@ -70,7 +70,7 @@ struct softpipe_tex_cached_tile struct softpipe_tex_tile_cache { - struct pipe_screen *screen; + struct pipe_context *pipe; struct pipe_transfer *transfer; void *transfer_map; @@ -88,7 +88,7 @@ struct softpipe_tex_tile_cache extern struct softpipe_tex_tile_cache * -sp_create_tex_tile_cache( struct pipe_screen *screen ); +sp_create_tex_tile_cache( struct pipe_context *pipe ); extern void sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc); diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 11d184effb..adae48c474 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -256,7 +256,7 @@ softpipe_tex_surface_destroy(struct pipe_surface *surf) * \param height height of region to read/write */ static struct pipe_transfer * -softpipe_get_tex_transfer(struct pipe_screen *screen, +softpipe_get_tex_transfer(struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, @@ -277,6 +277,7 @@ softpipe_get_tex_transfer(struct pipe_screen *screen, struct pipe_transfer *pt = &spt->base; int nblocksy = util_format_get_nblocksy(texture->format, u_minify(texture->height0, level)); pipe_texture_reference(&pt->texture, texture); + pt->pipe = pipe; pt->x = x; pt->y = y; pt->width = w; @@ -326,7 +327,7 @@ softpipe_tex_transfer_destroy(struct pipe_transfer *transfer) * Create memory mapping for given pipe_transfer object. */ static void * -softpipe_transfer_map( struct pipe_screen *screen, +softpipe_transfer_map( struct pipe_context *pipe, struct pipe_transfer *transfer ) { ubyte *map, *xfer_map; @@ -339,7 +340,7 @@ softpipe_transfer_map( struct pipe_screen *screen, if (spt->dt) { /* display target */ - struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys; map = winsys->displaytarget_map(winsys, spt->dt, pipe_transfer_buffer_flags(transfer)); @@ -359,7 +360,7 @@ softpipe_transfer_map( struct pipe_screen *screen, /* Do something to notify sharing contexts of a texture change. * In softpipe, that would mean flushing the texture cache. */ - softpipe_screen(screen)->timestamp++; + softpipe_screen(pipe->screen)->timestamp++; } xfer_map = map + softpipe_transfer(transfer)->offset + @@ -374,7 +375,7 @@ softpipe_transfer_map( struct pipe_screen *screen, * Unmap memory mapping for given pipe_transfer object. */ static void -softpipe_transfer_unmap(struct pipe_screen *screen, +softpipe_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { struct softpipe_texture *spt; @@ -384,7 +385,7 @@ softpipe_transfer_unmap(struct pipe_screen *screen, if (spt->dt) { /* display target */ - struct sw_winsys *winsys = softpipe_screen(screen)->winsys; + struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys; winsys->displaytarget_unmap(winsys, spt->dt); } @@ -447,6 +448,15 @@ softpipe_video_surface_destroy(struct pipe_video_surface *vsfc) } +void +softpipe_init_texture_funcs(struct pipe_context *pipe) +{ + pipe->get_tex_transfer = softpipe_get_tex_transfer; + pipe->tex_transfer_destroy = softpipe_tex_transfer_destroy; + pipe->transfer_map = softpipe_transfer_map; + pipe->transfer_unmap = softpipe_transfer_unmap; +} + void softpipe_init_screen_texture_funcs(struct pipe_screen *screen) { @@ -456,11 +466,6 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen) screen->get_tex_surface = softpipe_get_tex_surface; screen->tex_surface_destroy = softpipe_tex_surface_destroy; - screen->get_tex_transfer = softpipe_get_tex_transfer; - screen->tex_transfer_destroy = softpipe_tex_transfer_destroy; - screen->transfer_map = softpipe_transfer_map; - screen->transfer_unmap = softpipe_transfer_unmap; - screen->video_surface_create = softpipe_video_surface_create; screen->video_surface_destroy = softpipe_video_surface_destroy; } diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h index 1c8636d1d5..c0e6ba8a86 100644 --- a/src/gallium/drivers/softpipe/sp_texture.h +++ b/src/gallium/drivers/softpipe/sp_texture.h @@ -107,5 +107,8 @@ softpipe_video_surface(struct pipe_video_surface *pvs) extern void softpipe_init_screen_texture_funcs(struct pipe_screen *screen); +void +softpipe_init_texture_funcs(struct pipe_context *pipe); + #endif /* SP_TEXTURE */ diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index aedfdf1b46..d779816790 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -79,20 +79,20 @@ clear_clear_flag(uint *bitvec, union tile_address addr) struct softpipe_tile_cache * -sp_create_tile_cache( struct pipe_screen *screen ) +sp_create_tile_cache( struct pipe_context *pipe ) { struct softpipe_tile_cache *tc; uint pos; int maxLevels, maxTexSize; /* sanity checking: max sure MAX_WIDTH/HEIGHT >= largest texture image */ - maxLevels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); + maxLevels = pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS); maxTexSize = 1 << (maxLevels - 1); assert(MAX_WIDTH >= maxTexSize); tc = CALLOC_STRUCT( softpipe_tile_cache ); if (tc) { - tc->screen = screen; + tc->pipe = pipe; for (pos = 0; pos < NUM_ENTRIES; pos++) { tc->entries[pos].addr.bits.invalid = 1; } @@ -115,15 +115,13 @@ sp_create_tile_cache( struct pipe_screen *screen ) void sp_destroy_tile_cache(struct softpipe_tile_cache *tc) { - struct pipe_screen *screen; uint pos; for (pos = 0; pos < NUM_ENTRIES; pos++) { /*assert(tc->entries[pos].x < 0);*/ } if (tc->transfer) { - screen = tc->transfer->texture->screen; - screen->tex_transfer_destroy(tc->transfer); + tc->pipe->tex_transfer_destroy(tc->transfer); } FREE( tc ); @@ -137,27 +135,25 @@ void sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, struct pipe_surface *ps) { - if (tc->transfer) { - struct pipe_screen *screen = tc->transfer->texture->screen; + struct pipe_context *pipe = tc->pipe; + if (tc->transfer) { if (ps == tc->surface) return; if (tc->transfer_map) { - screen->transfer_unmap(screen, tc->transfer); + pipe->transfer_unmap(pipe, tc->transfer); tc->transfer_map = NULL; } - screen->tex_transfer_destroy(tc->transfer); + pipe->tex_transfer_destroy(tc->transfer); tc->transfer = NULL; } tc->surface = ps; if (ps) { - struct pipe_screen *screen = ps->texture->screen; - - tc->transfer = screen->get_tex_transfer(screen, ps->texture, ps->face, + tc->transfer = pipe->get_tex_transfer(pipe, ps->texture, ps->face, ps->level, ps->zslice, PIPE_TRANSFER_READ_WRITE, 0, 0, ps->width, ps->height); @@ -187,7 +183,7 @@ void sp_tile_cache_map_transfers(struct softpipe_tile_cache *tc) { if (tc->transfer && !tc->transfer_map) - tc->transfer_map = tc->screen->transfer_map(tc->screen, tc->transfer); + tc->transfer_map = tc->pipe->transfer_map(tc->pipe, tc->transfer); } @@ -195,7 +191,7 @@ void sp_tile_cache_unmap_transfers(struct softpipe_tile_cache *tc) { if (tc->transfer_map) { - tc->screen->transfer_unmap(tc->screen, tc->transfer); + tc->pipe->transfer_unmap(tc->pipe, tc->transfer); tc->transfer_map = NULL; } } diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h index a12092702a..753d8c0daa 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tile_cache.h @@ -80,7 +80,7 @@ struct softpipe_cached_tile struct softpipe_tile_cache { - struct pipe_screen *screen; + struct pipe_context *pipe; struct pipe_surface *surface; /**< the surface we're caching */ struct pipe_transfer *transfer; void *transfer_map; @@ -98,7 +98,7 @@ struct softpipe_tile_cache extern struct softpipe_tile_cache * -sp_create_tile_cache( struct pipe_screen *screen ); +sp_create_tile_cache( struct pipe_context *pipe ); extern void sp_destroy_tile_cache(struct softpipe_tile_cache *tc); diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 5b581debfc..065b8748a3 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -783,15 +783,17 @@ svga_surface_needs_propagation(struct pipe_surface *surf) return s->dirty && s->handle != tex->handle; } - +/* XXX: Still implementing this as if it was a screen function, but + * can now modify it to queue transfers on the context. + */ static struct pipe_transfer * -svga_get_tex_transfer(struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, unsigned x, unsigned y, - unsigned w, unsigned h) +svga_get_tex_transfer(struct pipe_context *pipe, + struct pipe_texture *texture, + unsigned face, unsigned level, unsigned zslice, + enum pipe_transfer_usage usage, unsigned x, unsigned y, + unsigned w, unsigned h) { - struct svga_screen *ss = svga_screen(screen); + struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st; unsigned nblocksx = util_format_get_nblocksx(texture->format, w); @@ -859,11 +861,14 @@ no_hwbuf: } +/* XXX: Still implementing this as if it was a screen function, but + * can now modify it to queue transfers on the context. + */ static void * -svga_transfer_map( struct pipe_screen *screen, +svga_transfer_map( struct pipe_context *pipe, struct pipe_transfer *transfer ) { - struct svga_screen *ss = svga_screen(screen); + struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st = svga_transfer(transfer); @@ -877,11 +882,14 @@ svga_transfer_map( struct pipe_screen *screen, } +/* XXX: Still implementing this as if it was a screen function, but + * can now modify it to queue transfers on the context. + */ static void -svga_transfer_unmap(struct pipe_screen *screen, +svga_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *transfer) { - struct svga_screen *ss = svga_screen(screen); + struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st = svga_transfer(transfer); @@ -911,6 +919,17 @@ svga_tex_transfer_destroy(struct pipe_transfer *transfer) FREE(st); } + +void +svga_init_texture_functions(struct pipe_context *pipe) +{ + pipe->get_tex_transfer = svga_get_tex_transfer; + pipe->transfer_map = svga_transfer_map; + pipe->transfer_unmap = svga_transfer_unmap; + pipe->tex_transfer_destroy = svga_tex_transfer_destroy; +} + + void svga_screen_init_texture_functions(struct pipe_screen *screen) { @@ -920,10 +939,6 @@ svga_screen_init_texture_functions(struct pipe_screen *screen) screen->texture_destroy = svga_texture_destroy; screen->get_tex_surface = svga_get_tex_surface; screen->tex_surface_destroy = svga_tex_surface_destroy; - screen->get_tex_transfer = svga_get_tex_transfer; - screen->transfer_map = svga_transfer_map; - screen->transfer_unmap = svga_transfer_unmap; - screen->tex_transfer_destroy = svga_tex_transfer_destroy; } /*********************************************************************** diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_screen_texture.h index ca6602b436..96d035b12d 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.h +++ b/src/gallium/drivers/svga/svga_screen_texture.h @@ -186,6 +186,9 @@ svga_surface_needs_propagation(struct pipe_surface *surf); extern void svga_screen_init_texture_functions(struct pipe_screen *screen); +void +svga_init_texture_functions(struct pipe_context *pipe); + enum SVGA3dSurfaceFormat svga_translate_format(enum pipe_format format); diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 133521f45e..4a0e9ac17d 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -27,7 +27,9 @@ #include "util/u_memory.h" #include "util/u_simple_list.h" +#include "util/u_format.h" +#include "pipe/p_format.h" #include "pipe/p_screen.h" #include "tr_dump.h" @@ -1283,6 +1285,135 @@ trace_is_buffer_referenced( struct pipe_context *_pipe, return referenced; } + +/******************************************************************** + * transfer + */ + + +static struct pipe_transfer * +trace_context_get_tex_transfer(struct pipe_context *_context, + struct pipe_texture *_texture, + unsigned face, unsigned level, + unsigned zslice, + enum pipe_transfer_usage usage, + unsigned x, unsigned y, unsigned w, unsigned h) +{ + struct trace_context *tr_context = trace_context(_context); + struct trace_texture *tr_tex = trace_texture(_texture); + struct pipe_context *context = tr_context->pipe; + struct pipe_texture *texture = tr_tex->texture; + struct pipe_transfer *result = NULL; + + assert(texture->screen == context->screen); + + trace_dump_call_begin("pipe_context", "get_tex_transfer"); + + trace_dump_arg(ptr, context); + 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); + + trace_dump_arg(uint, x); + trace_dump_arg(uint, y); + trace_dump_arg(uint, w); + trace_dump_arg(uint, h); + + result = context->get_tex_transfer(context, texture, face, level, zslice, usage, + x, y, w, h); + + trace_dump_ret(ptr, result); + + trace_dump_call_end(); + + if (result) + result = trace_transfer_create(tr_context, tr_tex, result); + + return result; +} + + +static void +trace_context_tex_transfer_destroy(struct pipe_transfer *_transfer) +{ + struct trace_context *tr_ctx = trace_context(_transfer->pipe); + struct trace_transfer *tr_trans = trace_transfer(_transfer); + struct pipe_context *context = tr_ctx->pipe; + struct pipe_transfer *transfer = tr_trans->transfer; + + trace_dump_call_begin("pipe_context", "tex_transfer_destroy"); + + trace_dump_arg(ptr, context); + trace_dump_arg(ptr, transfer); + + trace_dump_call_end(); + + trace_transfer_destroy(tr_trans); +} + + +static void * +trace_context_transfer_map(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct trace_context *tr_context = trace_context(_context); + struct trace_transfer *tr_trans = trace_transfer(_transfer); + struct pipe_context *context = tr_context->pipe; + struct pipe_transfer *transfer = tr_trans->transfer; + void *map; + + map = context->transfer_map(context, transfer); + if(map) { + if(transfer->usage & PIPE_TRANSFER_WRITE) { + assert(!tr_trans->map); + tr_trans->map = map; + } + } + + return map; +} + + +static void +trace_context_transfer_unmap(struct pipe_context *_context, + struct pipe_transfer *_transfer) +{ + struct trace_context *tr_ctx = trace_context(_context); + struct trace_transfer *tr_trans = trace_transfer(_transfer); + struct pipe_context *context = tr_ctx->pipe; + struct pipe_transfer *transfer = tr_trans->transfer; + + if(tr_trans->map) { + size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->height) * transfer->stride; + + trace_dump_call_begin("pipe_context", "transfer_write"); + + trace_dump_arg(ptr, context); + + trace_dump_arg(ptr, transfer); + + trace_dump_arg_begin("stride"); + trace_dump_uint(transfer->stride); + trace_dump_arg_end(); + + trace_dump_arg_begin("data"); + trace_dump_bytes(tr_trans->map, size); + trace_dump_arg_end(); + + trace_dump_arg_begin("size"); + trace_dump_uint(size); + trace_dump_arg_end(); + + trace_dump_call_end(); + + tr_trans->map = NULL; + } + + context->transfer_unmap(context, transfer); +} + static const struct debug_named_value rbug_blocker_flags[] = { {"before", 1}, {"after", 2}, @@ -1367,6 +1498,11 @@ trace_context_create(struct trace_screen *tr_scr, tr_ctx->base.is_texture_referenced = trace_is_texture_referenced; tr_ctx->base.is_buffer_referenced = trace_is_buffer_referenced; + tr_ctx->base.get_tex_transfer = trace_context_get_tex_transfer; + tr_ctx->base.tex_transfer_destroy = trace_context_tex_transfer_destroy; + tr_ctx->base.transfer_map = trace_context_transfer_map; + tr_ctx->base.transfer_unmap = trace_context_transfer_unmap; + tr_ctx->pipe = pipe; trace_screen_add_to_list(tr_scr, contexts, tr_ctx); diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c index a43adac694..b36865400d 100644 --- a/src/gallium/drivers/trace/tr_rbug.c +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -219,7 +219,7 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, struct trace_texture *tr_tex = NULL; struct tr_list *ptr; - struct pipe_screen *screen = tr_scr->screen; + struct pipe_context *context = tr_scr->private_context; struct pipe_texture *tex; struct pipe_transfer *t; @@ -239,12 +239,12 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, } tex = tr_tex->texture; - t = screen->get_tex_transfer(tr_scr->screen, tex, - gptr->face, gptr->level, gptr->zslice, - PIPE_TRANSFER_READ, - gptr->x, gptr->y, gptr->w, gptr->h); + t = context->get_tex_transfer(context, tex, + gptr->face, gptr->level, gptr->zslice, + PIPE_TRANSFER_READ, + gptr->x, gptr->y, gptr->w, gptr->h); - map = screen->transfer_map(screen, t); + map = context->transfer_map(context, t); rbug_send_texture_read_reply(tr_rbug->con, serial, t->texture->format, @@ -256,8 +256,8 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, t->stride, NULL); - screen->transfer_unmap(screen, t); - screen->tex_transfer_destroy(t); + context->transfer_unmap(context, t); + context->tex_transfer_destroy(t); pipe_mutex_unlock(tr_scr->list_mutex); diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 86ddb99540..25990bdac7 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -353,133 +353,7 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface) } -/******************************************************************** - * transfer - */ - - -static struct pipe_transfer * -trace_screen_get_tex_transfer(struct pipe_screen *_screen, - struct pipe_texture *_texture, - unsigned face, unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, unsigned w, unsigned h) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_texture *tr_tex = trace_texture(_texture); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_texture *texture = tr_tex->texture; - struct pipe_transfer *result = NULL; - - assert(texture->screen == screen); - - trace_dump_call_begin("pipe_screen", "get_tex_transfer"); - - 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); - - trace_dump_arg(uint, x); - trace_dump_arg(uint, y); - trace_dump_arg(uint, w); - trace_dump_arg(uint, h); - - result = screen->get_tex_transfer(screen, texture, face, level, zslice, usage, - x, y, w, h); - - trace_dump_ret(ptr, result); - - trace_dump_call_end(); - - if (result) - result = trace_transfer_create(tr_tex, result); - - return result; -} - - -static void -trace_screen_tex_transfer_destroy(struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_transfer->texture->screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - - trace_dump_call_begin("pipe_screen", "tex_transfer_destroy"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, transfer); - - trace_dump_call_end(); - - trace_transfer_destroy(tr_trans); -} - - -static void * -trace_screen_transfer_map(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - void *map; - - map = screen->transfer_map(screen, transfer); - if(map) { - if(transfer->usage & PIPE_TRANSFER_WRITE) { - assert(!tr_trans->map); - tr_trans->map = map; - } - } - - return map; -} - - -static void -trace_screen_transfer_unmap(struct pipe_screen *_screen, - struct pipe_transfer *_transfer) -{ - struct trace_screen *tr_scr = trace_screen(_screen); - struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_screen *screen = tr_scr->screen; - struct pipe_transfer *transfer = tr_trans->transfer; - - if(tr_trans->map) { - size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->height) * transfer->stride; - - trace_dump_call_begin("pipe_screen", "transfer_write"); - - trace_dump_arg(ptr, screen); - - trace_dump_arg(ptr, transfer); - - trace_dump_arg_begin("stride"); - trace_dump_uint(transfer->stride); - trace_dump_arg_end(); - - trace_dump_arg_begin("data"); - trace_dump_bytes(tr_trans->map, size); - trace_dump_arg_end(); - trace_dump_arg_begin("size"); - trace_dump_uint(size); - trace_dump_arg_end(); - - trace_dump_call_end(); - - tr_trans->map = NULL; - } - - screen->transfer_unmap(screen, transfer); -} /******************************************************************** @@ -901,10 +775,6 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.texture_destroy = trace_screen_texture_destroy; tr_scr->base.get_tex_surface = trace_screen_get_tex_surface; tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy; - tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer; - tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy; - tr_scr->base.transfer_map = trace_screen_transfer_map; - tr_scr->base.transfer_unmap = trace_screen_transfer_unmap; tr_scr->base.buffer_create = trace_screen_buffer_create; tr_scr->base.user_buffer_create = trace_screen_user_buffer_create; if (screen->buffer_map) @@ -920,7 +790,11 @@ trace_screen_create(struct pipe_screen *screen) tr_scr->base.fence_signalled = trace_screen_fence_signalled; tr_scr->base.fence_finish = trace_screen_fence_finish; tr_scr->base.flush_frontbuffer = trace_screen_flush_frontbuffer; + tr_scr->screen = screen; + tr_scr->private_context = screen->context_create(screen, NULL); + if (tr_scr->private_context == NULL) + goto error3; trace_dump_ret(ptr, screen); trace_dump_call_end(); @@ -930,10 +804,8 @@ trace_screen_create(struct pipe_screen *screen) return &tr_scr->base; -#if 0 error3: FREE(tr_scr); -#endif error2: trace_dump_ret(ptr, screen); trace_dump_call_end(); diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h index 597e2fc265..9bfbe72e2c 100644 --- a/src/gallium/drivers/trace/tr_screen.h +++ b/src/gallium/drivers/trace/tr_screen.h @@ -56,6 +56,7 @@ struct trace_screen struct pipe_screen base; struct pipe_screen *screen; + struct pipe_context *private_context; /* remote debugger */ struct trace_rbug *rbug; diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index 5321d68ec0..b70ccb9ce8 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -31,6 +31,7 @@ #include "util/u_simple_list.h" #include "tr_screen.h" +#include "tr_context.h" #include "tr_texture.h" @@ -124,8 +125,9 @@ trace_surface_destroy(struct trace_surface *tr_surf) struct pipe_transfer * -trace_transfer_create(struct trace_texture *tr_tex, - struct pipe_transfer *transfer) +trace_transfer_create(struct trace_context *tr_ctx, + struct trace_texture *tr_tex, + struct pipe_transfer *transfer) { struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen); struct trace_transfer *tr_trans; @@ -141,6 +143,7 @@ trace_transfer_create(struct trace_texture *tr_tex, memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer)); + tr_trans->base.pipe = &tr_ctx->base; tr_trans->base.texture = NULL; pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base); tr_trans->transfer = transfer; @@ -151,7 +154,7 @@ trace_transfer_create(struct trace_texture *tr_tex, return &tr_trans->base; error: - transfer->texture->screen->tex_transfer_destroy(transfer); + tr_ctx->pipe->tex_transfer_destroy(transfer); return NULL; } @@ -160,12 +163,12 @@ void trace_transfer_destroy(struct trace_transfer *tr_trans) { struct trace_screen *tr_scr = trace_screen(tr_trans->base.texture->screen); - struct pipe_screen *screen = tr_trans->transfer->texture->screen; + struct pipe_context *context = tr_trans->transfer->pipe; trace_screen_remove_from_list(tr_scr, transfers, tr_trans); pipe_texture_reference(&tr_trans->base.texture, NULL); - screen->tex_transfer_destroy(tr_trans->transfer); + context->tex_transfer_destroy(tr_trans->transfer); FREE(tr_trans); } diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index 395e523e73..ab284eeef3 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -34,6 +34,7 @@ #include "tr_screen.h" +struct trace_context; struct trace_texture { @@ -112,8 +113,9 @@ void trace_surface_destroy(struct trace_surface *tr_surf); struct pipe_transfer * -trace_transfer_create(struct trace_texture *tr_tex, - struct pipe_transfer *transfer); +trace_transfer_create(struct trace_context *tr_ctx, + struct trace_texture *tr_tex, + struct pipe_transfer *transfer); void trace_transfer_destroy(struct trace_transfer *tr_trans); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 376b01aa69..494b53e912 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -306,6 +306,32 @@ struct pipe_context { */ unsigned int (*is_buffer_referenced)(struct pipe_context *pipe, struct pipe_buffer *buf); + + + + /** + * Get a transfer object for transferring data to/from a texture. + * + * Transfers are (by default) context-private and allow uploads to be + * interleaved with + */ + struct pipe_transfer *(*get_tex_transfer)(struct pipe_context *, + struct pipe_texture *texture, + unsigned face, unsigned level, + unsigned zslice, + enum pipe_transfer_usage usage, + unsigned x, unsigned y, + unsigned w, unsigned h); + + void (*tex_transfer_destroy)(struct pipe_transfer *); + + void *(*transfer_map)( struct pipe_context *, + struct pipe_transfer *transfer ); + + void (*transfer_unmap)( struct pipe_context *, + struct pipe_transfer *transfer ); + + }; diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index b771bfe85e..b7cb83abbe 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -142,23 +142,6 @@ struct pipe_screen { void (*tex_surface_destroy)(struct pipe_surface *); - /** Get a transfer object for transferring data to/from a texture */ - struct pipe_transfer *(*get_tex_transfer)(struct pipe_screen *, - struct pipe_texture *texture, - unsigned face, unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h); - - void (*tex_transfer_destroy)(struct pipe_transfer *); - - void *(*transfer_map)( struct pipe_screen *, - struct pipe_transfer *transfer ); - - void (*transfer_unmap)( struct pipe_screen *, - struct pipe_transfer *transfer ); - /** * Create a new buffer. diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 3a97d888ce..2af933207d 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -304,6 +304,8 @@ struct pipe_surface */ struct pipe_transfer { + struct pipe_context *pipe; + unsigned x; /**< x offset from start of texture image */ unsigned y; /**< y offset from start of texture image */ unsigned width; /**< logical width in pixels */ diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 02248ad433..6e79dd370f 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -78,14 +78,14 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, { /* upload color_data */ struct pipe_transfer *transfer = - screen->get_tex_transfer(screen, tex, - 0, 0, 0, - PIPE_TRANSFER_READ_WRITE , - 0, 0, tex->width0, tex->height0); - void *map = screen->transfer_map(screen, transfer); + pipe->get_tex_transfer(pipe, tex, + 0, 0, 0, + PIPE_TRANSFER_READ_WRITE , + 0, 0, tex->width0, tex->height0); + void *map = pipe->transfer_map(pipe, transfer); memcpy(map, color_data, sizeof(VGint)*color_data_len); - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); } return tex; diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index 015241498e..432ba68139 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -397,7 +397,6 @@ void vgReadPixels(void * data, VGint dataStride, { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; struct st_framebuffer *stfb = ctx->draw_buffer; struct st_renderbuffer *strb = stfb->strb; @@ -442,7 +441,7 @@ void vgReadPixels(void * data, VGint dataStride, { struct pipe_transfer *transfer; - transfer = screen->get_tex_transfer(screen, strb->texture, 0, 0, 0, + transfer = pipe->get_tex_transfer(pipe, strb->texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, width, height); @@ -458,7 +457,7 @@ void vgReadPixels(void * data, VGint dataStride, dst += dataStride; } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(transfer); } } diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 41c979bfec..604a86aeb8 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -378,7 +378,7 @@ void image_sub_data(struct vg_image *image, VGfloat *df = (VGfloat*)temp; VGint i; struct vg_context *ctx = vg_current_context(); - struct pipe_screen *screen = ctx->pipe->screen; + struct pipe_context *pipe = ctx->pipe; struct pipe_texture *texture = image_texture(image); VGint xoffset = 0, yoffset = 0; @@ -412,8 +412,8 @@ void image_sub_data(struct vg_image *image, } { /* upload color_data */ - struct pipe_transfer *transfer = screen->get_tex_transfer( - screen, texture, 0, 0, 0, + struct pipe_transfer *transfer = pipe->get_tex_transfer( + pipe, texture, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0); src += (dataStride * yoffset); for (i = 0; i < height; i++) { @@ -422,7 +422,7 @@ void image_sub_data(struct vg_image *image, y += yStep; src += dataStride; } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(transfer); } } @@ -435,7 +435,6 @@ void image_get_sub_data(struct vg_image * image, { struct vg_context *ctx = vg_current_context(); struct pipe_context *pipe = ctx->pipe; - struct pipe_screen *screen = pipe->screen; VGfloat temp[VEGA_MAX_IMAGE_WIDTH][4]; VGfloat *df = (VGfloat*)temp; VGint y = 0, yStep = 1; @@ -444,7 +443,7 @@ void image_get_sub_data(struct vg_image * image, { struct pipe_transfer *transfer = - screen->get_tex_transfer(screen, + pipe->get_tex_transfer(pipe, image->texture, 0, 0, 0, PIPE_TRANSFER_READ, 0, 0, @@ -461,7 +460,7 @@ void image_get_sub_data(struct vg_image * image, dst += dataStride; } - screen->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(transfer); } } diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index cdb87d3bf6..47a7710d3e 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -164,10 +164,10 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) struct pipe_transfer *transfer = st_no_flush_get_tex_transfer(p->base.ctx, tex, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, 1024, 1); - void *map = screen->transfer_map(screen, transfer); + void *map = pipe->transfer_map(pipe, transfer); memcpy(map, p->gradient.color_data, sizeof(VGint)*1024); - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); } return tex; diff --git a/src/gallium/state_trackers/vega/st_inlines.h b/src/gallium/state_trackers/vega/st_inlines.h index 419151c3ae..4d12a4efdd 100644 --- a/src/gallium/state_trackers/vega/st_inlines.h +++ b/src/gallium/state_trackers/vega/st_inlines.h @@ -51,7 +51,6 @@ st_cond_flush_get_tex_transfer(struct vg_context *st, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - struct pipe_screen *screen = st->pipe->screen; struct pipe_context *pipe = st->pipe; unsigned referenced = pipe->is_texture_referenced(pipe, pt, face, level); @@ -60,7 +59,7 @@ st_cond_flush_get_tex_transfer(struct vg_context *st, (usage & PIPE_TRANSFER_WRITE))) vgFlush(); - return screen->get_tex_transfer(screen, pt, face, level, zslice, usage, + return pipe->get_tex_transfer(pipe, pt, face, level, zslice, usage, x, y, w, h); } @@ -74,10 +73,10 @@ st_no_flush_get_tex_transfer(struct vg_context *st, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *pipe = st->pipe; - return screen->get_tex_transfer(screen, pt, face, level, - zslice, usage, x, y, w, h); + return pipe->get_tex_transfer(pipe, pt, face, level, + zslice, usage, x, y, w, h); } static INLINE void * diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index 0b2e3f5381..b066f5c94b 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -138,7 +138,6 @@ static void load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *transfer; const GLuint rSize = ctx->PixelMaps.RtoR.Size; const GLuint gSize = ctx->PixelMaps.GtoG.Size; @@ -151,7 +150,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) transfer = st_cond_flush_get_tex_transfer(st_context(ctx), pt, 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0, texSize, texSize); - dest = (uint *) screen->transfer_map(screen, transfer); + dest = (uint *) pipe->transfer_map(pipe, transfer); /* Pack four 1D maps into a 2D texture: * R map is placed horizontally, indexed by S, in channel 0 @@ -172,8 +171,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) } } - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 33e43ddcc4..69a96e5d10 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -129,7 +129,6 @@ accum_accum(struct st_context *st, GLfloat value, struct st_renderbuffer *color_strb) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *color_trans; size_t stride = acc_strb->stride; GLubyte *data = acc_strb->data; @@ -166,7 +165,7 @@ accum_accum(struct st_context *st, GLfloat value, } free(buf); - screen->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(color_trans); } @@ -177,7 +176,6 @@ accum_load(struct st_context *st, GLfloat value, struct st_renderbuffer *color_strb) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *color_trans; size_t stride = acc_strb->stride; GLubyte *data = acc_strb->data; @@ -215,7 +213,7 @@ accum_load(struct st_context *st, GLfloat value, } free(buf); - screen->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(color_trans); } @@ -226,7 +224,6 @@ accum_return(GLcontext *ctx, GLfloat value, struct st_renderbuffer *color_strb) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; const GLubyte *colormask = ctx->Color.ColorMask[0]; enum pipe_transfer_usage usage; struct pipe_transfer *color_trans; @@ -283,7 +280,7 @@ accum_return(GLcontext *ctx, GLfloat value, pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf); free(buf); - screen->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(color_trans); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index f326601c3b..723c5f180b 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -259,7 +259,6 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, const GLubyte *bitmap) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *transfer; ubyte *dest; struct pipe_texture *pt; @@ -285,7 +284,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, PIPE_TRANSFER_WRITE, 0, 0, width, height); - dest = screen->transfer_map(screen, transfer); + dest = pipe->transfer_map(pipe, transfer); /* Put image into texture transfer */ memset(dest, 0xff, height * transfer->stride); @@ -295,8 +294,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, _mesa_unmap_pbo_source(ctx, unpack); /* Release transfer */ - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); return pt; } @@ -520,7 +519,6 @@ static void reset_cache(struct st_context *st) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct bitmap_cache *cache = st->bitmap.cache; /*memset(cache->buffer, 0xff, sizeof(cache->buffer));*/ @@ -532,7 +530,7 @@ reset_cache(struct st_context *st) cache->ymax = -1000000; if (cache->trans) { - screen->tex_transfer_destroy(cache->trans); + pipe->tex_transfer_destroy(cache->trans); cache->trans = NULL; } @@ -570,7 +568,6 @@ static void create_cache_trans(struct st_context *st) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct bitmap_cache *cache = st->bitmap.cache; if (cache->trans) @@ -583,7 +580,7 @@ create_cache_trans(struct st_context *st) PIPE_TRANSFER_WRITE, 0, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT); - cache->buffer = screen->transfer_map(screen, cache->trans); + cache->buffer = pipe->transfer_map(pipe, cache->trans); /* init image to all 0xff */ memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT); @@ -601,7 +598,6 @@ st_flush_bitmap_cache(struct st_context *st) if (st->ctx->DrawBuffer) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; assert(cache->xmin <= cache->xmax); @@ -617,10 +613,10 @@ st_flush_bitmap_cache(struct st_context *st) if (cache->trans) { if (0) print_cache(cache); - screen->transfer_unmap(screen, cache->trans); + pipe->transfer_unmap(pipe, cache->trans); cache->buffer = NULL; - screen->tex_transfer_destroy(cache->trans); + pipe->tex_transfer_destroy(cache->trans); cache->trans = NULL; } @@ -823,7 +819,6 @@ void st_destroy_bitmap(struct st_context *st) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct bitmap_cache *cache = st->bitmap.cache; @@ -840,8 +835,8 @@ st_destroy_bitmap(struct st_context *st) if (cache) { if (cache->trans) { - screen->transfer_unmap(screen, cache->trans); - screen->tex_transfer_destroy(cache->trans); + pipe->transfer_unmap(pipe, cache->trans); + pipe->tex_transfer_destroy(cache->trans); } pipe_texture_reference(&st->bitmap.cache->texture, NULL); free(st->bitmap.cache); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 8eb76f4131..3fa6d12f1c 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -349,7 +349,6 @@ make_texture(struct st_context *st, { GLcontext *ctx = st->ctx; struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; gl_format mformat; struct pipe_texture *pt; enum pipe_format pipeFormat; @@ -391,7 +390,7 @@ make_texture(struct st_context *st, width, height); /* map texture transfer */ - dest = screen->transfer_map(screen, transfer); + dest = pipe->transfer_map(pipe, transfer); /* Put image into texture transfer. @@ -411,8 +410,8 @@ make_texture(struct st_context *st, unpack); /* unmap */ - screen->transfer_unmap(screen, transfer); - screen->tex_transfer_destroy(transfer); + pipe->transfer_unmap(pipe, transfer); + pipe->tex_transfer_destroy(transfer); assert(success); @@ -658,7 +657,6 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, { struct st_context *st = st_context(ctx); struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct st_renderbuffer *strb; enum pipe_transfer_usage usage; struct pipe_transfer *pt; @@ -692,7 +690,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, usage, x, y, width, height); - stmap = screen->transfer_map(screen, pt); + stmap = pipe->transfer_map(pipe, pt); pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels); assert(pixels); @@ -792,8 +790,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, _mesa_unmap_pbo_source(ctx, &clippedUnpack); /* unmap the stencil buffer */ - screen->transfer_unmap(screen, pt); - screen->tex_transfer_destroy(pt); + pipe->transfer_unmap(pipe, pt); + pipe->tex_transfer_destroy(pt); } @@ -856,7 +854,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, GLint dstx, GLint dsty) { struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer); - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_context *pipe = ctx->st->pipe; enum pipe_transfer_usage usage; struct pipe_transfer *ptDraw; ubyte *drawMap; @@ -892,7 +890,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, assert(util_format_get_blockheight(ptDraw->texture->format) == 1); /* map the stencil buffer */ - drawMap = screen->transfer_map(screen, ptDraw); + drawMap = pipe->transfer_map(pipe, ptDraw); /* draw */ /* XXX PixelZoom not handled yet */ @@ -945,8 +943,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, free(buffer); /* unmap the stencil buffer */ - screen->transfer_unmap(screen, ptDraw); - screen->tex_transfer_destroy(ptDraw); + pipe->transfer_unmap(pipe, ptDraw); + pipe->tex_transfer_destroy(ptDraw); } @@ -1084,8 +1082,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (0) { /* debug */ - debug_dump_surface("copypixsrcsurf", psRead); - debug_dump_surface("copypixtemptex", psTex); + debug_dump_surface(pipe, "copypixsrcsurf", psRead); + debug_dump_surface(pipe, "copypixtemptex", psTex); } pipe_surface_reference(&psRead, NULL); @@ -1128,8 +1126,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, free(buf); } - screen->tex_transfer_destroy(ptRead); - screen->tex_transfer_destroy(ptTex); + pipe->tex_transfer_destroy(ptRead); + pipe->tex_transfer_destroy(ptTex); } /* draw textured quad */ diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 8cc9cfac76..98ccda821c 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -63,7 +63,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, GLvoid *pixels) { struct gl_framebuffer *fb = ctx->ReadBuffer; - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_context *pipe = ctx->st->pipe; struct st_renderbuffer *strb = st_renderbuffer(fb->_StencilBuffer); struct pipe_transfer *pt; ubyte *stmap; @@ -81,7 +81,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, width, height); /* map the stencil buffer */ - stmap = screen->transfer_map(screen, pt); + stmap = pipe->transfer_map(pipe, pt); /* width should never be > MAX_WIDTH since we did clipping earlier */ ASSERT(width <= MAX_WIDTH); @@ -161,8 +161,8 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } /* unmap the stencil buffer */ - screen->transfer_unmap(screen, pt); - screen->tex_transfer_destroy(pt); + pipe->transfer_unmap(pipe, pt); + pipe->tex_transfer_destroy(pt); } @@ -234,7 +234,6 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *trans; const GLubyte *map; GLubyte *dst; @@ -253,9 +252,9 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, return GL_FALSE; } - map = screen->transfer_map(screen, trans); + map = pipe->transfer_map(pipe, trans); if (!map) { - screen->tex_transfer_destroy(trans); + pipe->tex_transfer_destroy(trans); return GL_FALSE; } @@ -317,8 +316,8 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, ; /* nothing */ } - screen->transfer_unmap(screen, trans); - screen->tex_transfer_destroy(trans); + pipe->transfer_unmap(pipe, trans); + pipe->tex_transfer_destroy(trans); } return GL_TRUE; @@ -337,7 +336,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLvoid *dest) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; GLfloat temp[MAX_WIDTH][4]; const GLbitfield transferOps = ctx->_ImageTransferState; GLsizei i, j; @@ -541,7 +539,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } - screen->tex_transfer_destroy(trans); + pipe->tex_transfer_destroy(trans); _mesa_unmap_pbo_dest(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index c849132e74..1b20b615d0 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -371,7 +371,8 @@ compress_with_blit(GLcontext * ctx, { const GLuint dstImageOffsets[1] = {0}; struct st_texture_image *stImage = st_texture_image(texImage); - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_context *pipe = ctx->st->pipe; + struct pipe_screen *screen = pipe->screen; gl_format mesa_format; struct pipe_texture templ; struct pipe_texture *src_tex; @@ -421,7 +422,7 @@ compress_with_blit(GLcontext * ctx, 0, 0, 0, /* face, level are zero */ PIPE_TRANSFER_WRITE, 0, 0, width, height); /* x, y, w, h */ - map = screen->transfer_map(screen, tex_xfer); + map = pipe->transfer_map(pipe, tex_xfer); _mesa_texstore(ctx, 2, GL_RGBA, mesa_format, map, /* dest ptr */ @@ -433,8 +434,8 @@ compress_with_blit(GLcontext * ctx, pixels, /* source data */ unpack); /* source data packing */ - screen->transfer_unmap(screen, tex_xfer); - screen->tex_transfer_destroy(tex_xfer); + pipe->transfer_unmap(pipe, tex_xfer); + pipe->tex_transfer_destroy(tex_xfer); /* copy / compress image */ util_blit_pixels_tex(ctx->st->blit, @@ -809,7 +810,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, struct gl_texture_object *texObj, struct gl_texture_image *texImage) { - struct pipe_screen *screen = ctx->st->pipe->screen; + struct pipe_context *pipe = ctx->st->pipe; + struct pipe_screen *screen = pipe->screen; struct st_texture_image *stImage = st_texture_image(texImage); const GLuint width = texImage->Width; const GLuint height = texImage->Height; @@ -848,7 +850,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, if (st_equal_formats(stImage->pt->format, format, type)) { /* memcpy */ const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format); - ubyte *map = screen->transfer_map(screen, tex_xfer); + ubyte *map = pipe->transfer_map(pipe, tex_xfer); GLuint row; for (row = 0; row < height; row++) { GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width, @@ -856,7 +858,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, memcpy(dest, map, bytesPerRow); map += tex_xfer->stride; } - screen->transfer_unmap(screen, tex_xfer); + pipe->transfer_unmap(pipe, tex_xfer); } else { /* format translation via floats */ @@ -1256,7 +1258,6 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, GLsizei width, GLsizei height) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_transfer *src_trans; GLvoid *texDest; enum pipe_transfer_usage transfer_usage; @@ -1363,7 +1364,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } st_texture_image_unmap(ctx->st, stImage); - screen->tex_transfer_destroy(src_trans); + pipe->tex_transfer_destroy(src_trans); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index f67d7b4cb5..a73b8ed8fe 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -106,7 +106,6 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj) { struct pipe_context *pipe = ctx->st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_texture *pt = st_get_texobj_texture(texObj); const uint baseLevel = texObj->BaseLevel; const uint lastLevel = pt->last_level; @@ -142,8 +141,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, u_minify(pt->width0, dstLevel), u_minify(pt->height0, dstLevel)); - srcData = (ubyte *) screen->transfer_map(screen, srcTrans); - dstData = (ubyte *) screen->transfer_map(screen, dstTrans); + srcData = (ubyte *) pipe->transfer_map(pipe, srcTrans); + dstData = (ubyte *) pipe->transfer_map(pipe, dstTrans); srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format); dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format); @@ -161,11 +160,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, dstData, dstStride); /* stride in texels */ - screen->transfer_unmap(screen, srcTrans); - screen->transfer_unmap(screen, dstTrans); + pipe->transfer_unmap(pipe, srcTrans); + pipe->transfer_unmap(pipe, dstTrans); - screen->tex_transfer_destroy(srcTrans); - screen->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(srcTrans); + pipe->tex_transfer_destroy(dstTrans); } } diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h index e105870bc7..7fcde7b1a9 100644 --- a/src/mesa/state_tracker/st_inlines.h +++ b/src/mesa/state_tracker/st_inlines.h @@ -53,11 +53,11 @@ st_cond_flush_get_tex_transfer(struct st_context *st, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *context = st->pipe; st_teximage_flush_before_map(st, pt, face, level, usage); - return screen->get_tex_transfer(screen, pt, face, level, zslice, usage, - x, y, w, h); + return context->get_tex_transfer(context, pt, face, level, zslice, usage, + x, y, w, h); } static INLINE struct pipe_transfer * @@ -70,9 +70,9 @@ st_no_flush_get_tex_transfer(struct st_context *st, unsigned int x, unsigned int y, unsigned int w, unsigned int h) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *context = st->pipe; - return screen->get_tex_transfer(screen, pt, face, level, + return context->get_tex_transfer(context, pt, face, level, zslice, usage, x, y, w, h); } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 5a45c4358a..f1eef768eb 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -192,7 +192,6 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, GLuint x, GLuint y, GLuint w, GLuint h) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; struct pipe_texture *pt = stImage->pt; DBG("%s \n", __FUNCTION__); @@ -202,7 +201,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, usage, x, y, w, h); if (stImage->transfer) - return screen->transfer_map(screen, stImage->transfer); + return pipe->transfer_map(pipe, stImage->transfer); else return NULL; } @@ -212,13 +211,13 @@ void st_texture_image_unmap(struct st_context *st, struct st_texture_image *stImage) { - struct pipe_screen *screen = st->pipe->screen; + struct pipe_context *pipe = st->pipe; DBG("%s\n", __FUNCTION__); - screen->transfer_unmap(screen, stImage->transfer); + pipe->transfer_unmap(pipe, stImage->transfer); - screen->tex_transfer_destroy(stImage->transfer); + pipe->tex_transfer_destroy(stImage->transfer); } @@ -238,8 +237,7 @@ st_surface_data(struct pipe_context *pipe, const void *src, unsigned src_stride, unsigned srcx, unsigned srcy, unsigned width, unsigned height) { - struct pipe_screen *screen = pipe->screen; - void *map = screen->transfer_map(screen, dst); + void *map = pipe->transfer_map(pipe, dst); assert(dst->texture); util_copy_rect(map, @@ -250,7 +248,7 @@ st_surface_data(struct pipe_context *pipe, src, src_stride, srcx, srcy); - screen->transfer_unmap(screen, dst); + pipe->transfer_unmap(pipe, dst); } @@ -265,7 +263,6 @@ st_texture_image_data(struct st_context *st, GLuint src_row_stride, GLuint src_image_stride) { struct pipe_context *pipe = st->pipe; - struct pipe_screen *screen = pipe->screen; GLuint depth = u_minify(dst->depth0, level); GLuint i; const GLubyte *srcUB = src; @@ -287,7 +284,7 @@ st_texture_image_data(struct st_context *st, u_minify(dst->width0, level), u_minify(dst->height0, level)); /* width, height */ - screen->tex_transfer_destroy(dst_transfer); + pipe->tex_transfer_destroy(dst_transfer); srcUB += src_image_stride; } -- cgit v1.2.3 From 99f11f653012e8e18502cb0f5cce3cd1e0643c23 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Mar 2010 15:33:40 +0000 Subject: gallivm: Handle scalar types in lp_build_*_type. --- src/gallium/auxiliary/gallivm/lp_bld_type.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.c b/src/gallium/auxiliary/gallivm/lp_bld_type.c index c327ba045a..796af88caa 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.c @@ -58,7 +58,10 @@ LLVMTypeRef lp_build_vec_type(struct lp_type type) { LLVMTypeRef elem_type = lp_build_elem_type(type); - return LLVMVectorType(elem_type, type.length); + if (type.length == 1) + return elem_type; + else + return LLVMVectorType(elem_type, type.length); } @@ -115,6 +118,9 @@ lp_check_vec_type(struct lp_type type, LLVMTypeRef vec_type) if(!vec_type) return FALSE; + if (type.length == 1) + return lp_check_elem_type(type, vec_type); + if(LLVMGetTypeKind(vec_type) != LLVMVectorTypeKind) return FALSE; @@ -153,7 +159,10 @@ LLVMTypeRef lp_build_int_vec_type(struct lp_type type) { LLVMTypeRef elem_type = lp_build_int_elem_type(type); - return LLVMVectorType(elem_type, type.length); + if (type.length == 1) + return elem_type; + else + return LLVMVectorType(elem_type, type.length); } -- cgit v1.2.3 From e24e5324ed1adce8da8ff268f7047ad8172bb248 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 11 Mar 2010 15:36:51 +0000 Subject: gallivm: Use bitmasks for scalar masks. We could use single 1 bit conditions for scalar masks, but a lot of code expects masks. The compiler easily optimzes away masks extensions/truncations so consistency is preferable. We can revisit this when LLVM backends have more support for vector conditions. --- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index fa65895367..b7eb2c3d4e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -259,11 +259,13 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildFCmp(builder, op, a, b, ""); res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else - res = LLVMGetUndef(int_vec_type); if (type.length == 1) { - res = LLVMBuildFCmp(builder, op, a, b, ""); + cond = LLVMBuildFCmp(builder, op, a, b, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + res = LLVMGetUndef(int_vec_type); + debug_printf("%s: warning: using slow element-wise float" " vector comparison\n", __FUNCTION__); for (i = 0; i < type.length; ++i) { @@ -311,11 +313,13 @@ lp_build_compare(LLVMBuilderRef builder, cond = LLVMBuildICmp(builder, op, a, b, ""); res = LLVMBuildSExt(builder, cond, int_vec_type, ""); #else - res = LLVMGetUndef(int_vec_type); if (type.length == 1) { - res = LLVMBuildICmp(builder, op, a, b, ""); + cond = LLVMBuildICmp(builder, op, a, b, ""); + res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + res = LLVMGetUndef(int_vec_type); + debug_printf("%s: warning: using slow element-wise int" " vector comparison\n", __FUNCTION__); @@ -357,6 +361,8 @@ lp_build_cmp(struct lp_build_context *bld, /** * Return mask ? a : b; + * + * mask is a bitwise mask, composed of 0 or ~0 for each element. */ LLVMValueRef lp_build_select(struct lp_build_context *bld, @@ -371,6 +377,7 @@ lp_build_select(struct lp_build_context *bld, return a; if (type.length == 1) { + mask = LLVMBuildTrunc(bld->builder, mask, LLVMInt1Type(), ""); res = LLVMBuildSelect(bld->builder, mask, a, b, ""); } else { -- cgit v1.2.3 From 25ba04c891ce959470d55a258243b5c105de8ff5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 08:50:39 -0700 Subject: svga: use memset() to initialize u to avoid warnings --- src/gallium/drivers/svga/svgadump/svga_shader_dump.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/svga/svgadump/svga_shader_dump.c b/src/gallium/drivers/svga/svgadump/svga_shader_dump.c index 705ca29e8f..4ee1bf2c35 100644 --- a/src/gallium/drivers/svga/svgadump/svga_shader_dump.c +++ b/src/gallium/drivers/svga/svgadump/svga_shader_dump.c @@ -360,7 +360,9 @@ dump_dstreg(struct sh_dstreg dstreg, union { struct sh_reg reg; struct sh_dstreg dstreg; - } u = { { 0 } }; + } u; + + memset(&u, 0, sizeof(u)); assert( (dstreg.modifier & (SVGA3DDSTMOD_SATURATE | SVGA3DDSTMOD_PARTIALPRECISION)) == dstreg.modifier ); -- cgit v1.2.3 From 0c92dfe7f37059d9dfc523c6bf660c15c9f079f5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 08:51:18 -0700 Subject: gallium/util: use memset() to initialize vars to avoid warnings --- src/gallium/auxiliary/util/u_blitter.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 33d09085f0..36d582491f 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -106,9 +106,9 @@ struct blitter_context_priv struct blitter_context *util_blitter_create(struct pipe_context *pipe) { struct blitter_context_priv *ctx; - struct pipe_blend_state blend = { 0 }; - struct pipe_depth_stencil_alpha_state dsa = { { 0 } }; - struct pipe_rasterizer_state rs_state = { 0 }; + struct pipe_blend_state blend; + struct pipe_depth_stencil_alpha_state dsa; + struct pipe_rasterizer_state rs_state; struct pipe_sampler_state *sampler_state; struct pipe_vertex_element velem[2]; unsigned i; @@ -131,12 +131,14 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) ctx->blitter.saved_num_sampler_states = ~0; /* blend state objects */ + memset(&blend, 0, sizeof(blend)); ctx->blend_keep_color = pipe->create_blend_state(pipe, &blend); blend.rt[0].colormask = PIPE_MASK_RGBA; ctx->blend_write_color = pipe->create_blend_state(pipe, &blend); /* depth stencil alpha state objects */ + memset(&dsa, 0, sizeof(dsa)); ctx->dsa_keep_depth_stencil = pipe->create_depth_stencil_alpha_state(pipe, &dsa); -- cgit v1.2.3 From 7b42379b713ad8a48b3c97ba9a74813c834b9e74 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 08:51:44 -0700 Subject: gallivm: move declarations to silence unused var warnings --- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index b7eb2c3d4e..1308076b3e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -74,13 +74,11 @@ lp_build_compare(LLVMBuilderRef builder, LLVMValueRef a, LLVMValueRef b) { - LLVMTypeRef vec_type = lp_build_vec_type(type); LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); LLVMValueRef zeros = LLVMConstNull(int_vec_type); LLVMValueRef ones = LLVMConstAllOnes(int_vec_type); LLVMValueRef cond; LLVMValueRef res; - unsigned i; assert(func >= PIPE_FUNC_NEVER); assert(func <= PIPE_FUNC_ALWAYS); @@ -99,6 +97,7 @@ lp_build_compare(LLVMBuilderRef builder, if(type.width * type.length == 128) { if(type.floating && util_cpu_caps.has_sse) { /* float[4] comparison */ + LLVMTypeRef vec_type = lp_build_vec_type(type); LLVMValueRef args[3]; unsigned cc; boolean swap; @@ -168,6 +167,7 @@ lp_build_compare(LLVMBuilderRef builder, const char *pcmpgt; LLVMValueRef args[2]; LLVMValueRef res; + LLVMTypeRef vec_type = lp_build_vec_type(type); switch (type.width) { case 8: @@ -264,6 +264,8 @@ lp_build_compare(LLVMBuilderRef builder, res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + unsigned i; + res = LLVMGetUndef(int_vec_type); debug_printf("%s: warning: using slow element-wise float" @@ -318,6 +320,8 @@ lp_build_compare(LLVMBuilderRef builder, res = LLVMBuildSExt(builder, cond, int_vec_type, ""); } else { + unsigned i; + res = LLVMGetUndef(int_vec_type); debug_printf("%s: warning: using slow element-wise int" -- cgit v1.2.3 From 2410125d072faeb83c8373e676422f6c44c78feb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 08:52:03 -0700 Subject: gallivm: include tgsi_dump.h to silence warning --- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index b3a0fe7d9b..5ec59d636c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -41,6 +41,7 @@ #include "util/u_debug.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_info.h" #include "tgsi/tgsi_parse.h" #include "tgsi/tgsi_util.h" -- cgit v1.2.3 From d35ecca5ee231c072687578642e0c22c6c0590b1 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 11 Mar 2010 16:10:25 +0000 Subject: gallium: remove pipe_context member from pipe_transfer There was very little use for this beyond permitting the pipe_context::tex_transfer_destroy() function to omit the pipe_context argument. This change adds the pipe_context argument into tex_transfer_destroy() so that it looks like other pipe_context functions, and removes the pipe_context pointer from pipe_transfer. --- src/gallium/auxiliary/draw/draw_pipe_aaline.c | 2 +- src/gallium/auxiliary/draw/draw_pipe_pstipple.c | 2 +- src/gallium/auxiliary/util/u_debug.c | 11 +++++----- src/gallium/auxiliary/util/u_debug.h | 3 ++- src/gallium/auxiliary/util/u_gen_mipmap.c | 12 +++++------ src/gallium/auxiliary/util/u_inlines.h | 14 ++++++------- src/gallium/auxiliary/util/u_rect.c | 6 +++--- src/gallium/auxiliary/util/u_tile.c | 26 +++++++++++++----------- src/gallium/auxiliary/util/u_tile.h | 18 ++++++++++------ src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c | 2 +- src/gallium/drivers/i915/i915_texture.c | 4 ++-- src/gallium/drivers/i965/brw_screen.h | 1 + src/gallium/drivers/i965/brw_screen_texture.c | 4 ++-- src/gallium/drivers/identity/id_context.c | 6 ++++-- src/gallium/drivers/identity/id_objects.c | 12 +++++++---- src/gallium/drivers/identity/id_objects.h | 4 +++- src/gallium/drivers/llvmpipe/lp_scene.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_texture.c | 3 ++- src/gallium/drivers/nv30/nv30_transfer.c | 5 +++-- src/gallium/drivers/nv40/nv40_transfer.c | 4 ++-- src/gallium/drivers/nv50/nv50_transfer.c | 4 ++-- src/gallium/drivers/r300/r300_screen.c | 2 -- src/gallium/drivers/r300/r300_transfer.c | 3 ++- src/gallium/drivers/softpipe/sp_tex_tile_cache.c | 11 +++++----- src/gallium/drivers/softpipe/sp_texture.c | 4 ++-- src/gallium/drivers/softpipe/sp_tile_cache.c | 19 +++++++++-------- src/gallium/drivers/svga/svga_screen_texture.c | 5 +++-- src/gallium/drivers/trace/tr_context.c | 9 ++++---- src/gallium/drivers/trace/tr_rbug.c | 2 +- src/gallium/drivers/trace/tr_texture.c | 16 ++++++++------- src/gallium/drivers/trace/tr_texture.h | 4 +++- src/gallium/include/pipe/p_context.h | 3 ++- src/gallium/include/pipe/p_state.h | 2 -- src/gallium/state_trackers/vega/api_filters.c | 2 +- src/gallium/state_trackers/vega/api_images.c | 4 ++-- src/gallium/state_trackers/vega/image.c | 8 ++++---- src/gallium/state_trackers/vega/paint.c | 2 +- src/mesa/state_tracker/st_atom_pixeltransfer.c | 2 +- src/mesa/state_tracker/st_cb_accum.c | 14 ++++++------- src/mesa/state_tracker/st_cb_bitmap.c | 8 ++++---- src/mesa/state_tracker/st_cb_drawpixels.c | 18 ++++++++-------- src/mesa/state_tracker/st_cb_readpixels.c | 22 ++++++++++---------- src/mesa/state_tracker/st_cb_texture.c | 12 +++++------ src/mesa/state_tracker/st_gen_mipmap.c | 4 ++-- src/mesa/state_tracker/st_texture.c | 4 ++-- 45 files changed, 177 insertions(+), 150 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c index 2cb76b25ae..1c07ab1365 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c +++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c @@ -449,7 +449,7 @@ aaline_create_texture(struct aaline_stage *aaline) /* unmap */ pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } return TRUE; } diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c index 479777e807..38c22bf4e9 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c +++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c @@ -411,7 +411,7 @@ pstip_update_texture(struct pstip_stage *pstip) /* unmap */ pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index de775a2dbc..e997cfa8a3 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -459,7 +459,7 @@ void debug_dump_surface(struct pipe_context *pipe, pipe->transfer_unmap(pipe, transfer); error: - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } @@ -530,14 +530,15 @@ debug_dump_surface_bmp(struct pipe_context *pipe, PIPE_TRANSFER_READ, 0, 0, surface->width, surface->height); - debug_dump_transfer_bmp(filename, transfer); + debug_dump_transfer_bmp(pipe, filename, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); #endif } void -debug_dump_transfer_bmp(const char *filename, +debug_dump_transfer_bmp(struct pipe_context *pipe, + const char *filename, struct pipe_transfer *transfer) { #ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT @@ -550,7 +551,7 @@ debug_dump_transfer_bmp(const char *filename, if(!rgba) goto error1; - pipe_get_tile_rgba(transfer, 0, 0, + pipe_get_tile_rgba(pipe, transfer, 0, 0, transfer->width, transfer->height, rgba); diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index a383837743..98addeb372 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -331,7 +331,8 @@ void debug_dump_texture(struct pipe_context *pipe, void debug_dump_surface_bmp(struct pipe_context *pipe, const char *filename, struct pipe_surface *surface); -void debug_dump_transfer_bmp(const char *filename, +void debug_dump_transfer_bmp(struct pipe_context *pipe, + const char *filename, struct pipe_transfer *transfer); void debug_dump_float_rgba_bmp(const char *filename, unsigned width, unsigned height, diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index 46fbde3f4a..5c51b53d7b 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1146,8 +1146,8 @@ make_1d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(srcTrans); - pipe->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(pipe, srcTrans); + pipe->tex_transfer_destroy(pipe, dstTrans); } } @@ -1190,8 +1190,8 @@ make_2d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(srcTrans); - pipe->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(pipe, srcTrans); + pipe->tex_transfer_destroy(pipe, dstTrans); } } @@ -1235,8 +1235,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(srcTrans); - pipe->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(pipe, srcTrans); + pipe->tex_transfer_destroy(pipe, dstTrans); } #else (void) reduce_3d; diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index ada31b8182..e7255e3baa 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -264,24 +264,24 @@ pipe_buffer_read(struct pipe_screen *screen, } static INLINE void * -pipe_transfer_map( struct pipe_transfer *transf ) +pipe_transfer_map( struct pipe_context *context, + struct pipe_transfer *transf ) { - struct pipe_context *context = transf->pipe; return context->transfer_map(context, transf); } static INLINE void -pipe_transfer_unmap( struct pipe_transfer *transf ) +pipe_transfer_unmap( struct pipe_context *context, + struct pipe_transfer *transf ) { - struct pipe_context *context = transf->pipe; context->transfer_unmap(context, transf); } static INLINE void -pipe_transfer_destroy( struct pipe_transfer *transf ) +pipe_transfer_destroy( struct pipe_context *context, + struct pipe_transfer *transfer ) { - struct pipe_context *context = transf->pipe; - context->tex_transfer_destroy(transf); + context->tex_transfer_destroy(context, transfer); } static INLINE unsigned diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c index 0b8405d01f..e73797f1b7 100644 --- a/src/gallium/auxiliary/util/u_rect.c +++ b/src/gallium/auxiliary/util/u_rect.c @@ -223,8 +223,8 @@ util_surface_copy(struct pipe_context *pipe, pipe->transfer_unmap(pipe, src_trans); pipe->transfer_unmap(pipe, dst_trans); - pipe->tex_transfer_destroy(src_trans); - pipe->tex_transfer_destroy(dst_trans); + pipe->tex_transfer_destroy(pipe, src_trans); + pipe->tex_transfer_destroy(pipe, dst_trans); } @@ -301,5 +301,5 @@ util_surface_fill(struct pipe_context *pipe, } pipe->transfer_unmap(pipe, dst_trans); - pipe->tex_transfer_destroy(dst_trans); + pipe->tex_transfer_destroy(pipe, dst_trans); } diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c index 70a6d97385..e445895efc 100644 --- a/src/gallium/auxiliary/util/u_tile.c +++ b/src/gallium/auxiliary/util/u_tile.c @@ -45,11 +45,11 @@ * Move raw block of pixels from transfer object to user memory. */ void -pipe_get_tile_raw(struct pipe_transfer *pt, +pipe_get_tile_raw(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, void *dst, int dst_stride) { - struct pipe_context *pipe = pt->pipe; const void *src; if (dst_stride == 0) @@ -73,11 +73,11 @@ pipe_get_tile_raw(struct pipe_transfer *pt, * Move raw block of pixels from user memory to transfer object. */ void -pipe_put_tile_raw(struct pipe_transfer *pt, +pipe_put_tile_raw(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const void *src, int src_stride) { - struct pipe_context *pipe = pt->pipe; void *dst; enum pipe_format format = pt->texture->format; @@ -1246,7 +1246,8 @@ pipe_tile_raw_to_rgba(enum pipe_format format, void -pipe_get_tile_rgba(struct pipe_transfer *pt, +pipe_get_tile_rgba(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, float *p) { @@ -1265,7 +1266,7 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, if(format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) assert((x & 1) == 0); - pipe_get_tile_raw(pt, x, y, w, h, packed, 0); + pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0); pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride); @@ -1274,7 +1275,8 @@ pipe_get_tile_rgba(struct pipe_transfer *pt, void -pipe_put_tile_rgba(struct pipe_transfer *pt, +pipe_put_tile_rgba(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const float *p) { @@ -1363,7 +1365,7 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, 0, 0, w, h); } - pipe_put_tile_raw(pt, x, y, w, h, packed, 0); + pipe_put_tile_raw(pipe, pt, x, y, w, h, packed, 0); FREE(packed); } @@ -1373,11 +1375,11 @@ pipe_put_tile_rgba(struct pipe_transfer *pt, * Get a block of Z values, converted to 32-bit range. */ void -pipe_get_tile_z(struct pipe_transfer *pt, +pipe_get_tile_z(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, uint *z) { - struct pipe_context *pipe = pt->pipe; const uint dstStride = w; ubyte *map; uint *pDest = z; @@ -1458,11 +1460,11 @@ pipe_get_tile_z(struct pipe_transfer *pt, void -pipe_put_tile_z(struct pipe_transfer *pt, +pipe_put_tile_z(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const uint *zSrc) { - struct pipe_context *pipe = pt->pipe; const uint srcStride = w; const uint *ptrc = zSrc; ubyte *map; diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h index 1453af38b8..8329087cfa 100644 --- a/src/gallium/auxiliary/util/u_tile.h +++ b/src/gallium/auxiliary/util/u_tile.h @@ -56,34 +56,40 @@ extern "C" { #endif void -pipe_get_tile_raw(struct pipe_transfer *pt, +pipe_get_tile_raw(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, void *p, int dst_stride); void -pipe_put_tile_raw(struct pipe_transfer *pt, +pipe_put_tile_raw(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const void *p, int src_stride); void -pipe_get_tile_rgba(struct pipe_transfer *pt, +pipe_get_tile_rgba(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, float *p); void -pipe_put_tile_rgba(struct pipe_transfer *pt, +pipe_put_tile_rgba(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const float *p); void -pipe_get_tile_z(struct pipe_transfer *pt, +pipe_get_tile_z(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, uint *z); void -pipe_put_tile_z(struct pipe_transfer *pt, +pipe_put_tile_z(struct pipe_context *pipe, + struct pipe_transfer *pt, uint x, uint y, uint w, uint h, const uint *z); diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c index dcc0014479..beb4722901 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c @@ -700,7 +700,7 @@ xfer_buffers_unmap(struct vl_mpeg12_mc_renderer *r) for (i = 0; i < 3; ++i) { r->pipe->transfer_unmap(r->pipe, r->tex_transfer[i]); - r->pipe->tex_transfer_destroy(r->tex_transfer[i]); + r->pipe->tex_transfer_destroy(r->pipe, r->tex_transfer[i]); } } diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_texture.c index 3435f7797f..b252fb5330 100644 --- a/src/gallium/drivers/i915/i915_texture.c +++ b/src/gallium/drivers/i915/i915_texture.c @@ -825,7 +825,6 @@ i915_get_tex_transfer(struct pipe_context *pipe, trans = CALLOC_STRUCT(i915_transfer); if (trans) { pipe_texture_reference(&trans->base.texture, texture); - trans->base.pipe = pipe; trans->base.x = x; trans->base.y = y; trans->base.width = w; @@ -869,7 +868,8 @@ i915_transfer_unmap(struct pipe_context *pipe, } static void -i915_tex_transfer_destroy(struct pipe_transfer *trans) +i915_tex_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *trans) { pipe_texture_reference(&trans->texture, NULL); FREE(trans); diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h index 23e052d0b9..e3a7c64d48 100644 --- a/src/gallium/drivers/i965/brw_screen.h +++ b/src/gallium/drivers/i965/brw_screen.h @@ -202,4 +202,5 @@ boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen, struct brw_winsys_buffer *bo ); + #endif /* BRW_SCREEN_H */ diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_screen_texture.c index 52bf9b3c1c..cadcb7cee2 100644 --- a/src/gallium/drivers/i965/brw_screen_texture.c +++ b/src/gallium/drivers/i965/brw_screen_texture.c @@ -504,7 +504,6 @@ brw_get_tex_transfer(struct pipe_context *pipe, trans = CALLOC_STRUCT(brw_transfer); if (trans) { pipe_texture_reference(&trans->base.texture, texture); - trans->base.pipe = pipe; trans->base.x = x; trans->base.y = y; trans->base.width = w; @@ -554,7 +553,8 @@ brw_transfer_unmap(struct pipe_context *pipe, } static void -brw_tex_transfer_destroy(struct pipe_transfer *trans) +brw_tex_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *trans) { pipe_texture_reference(&trans->texture, NULL); FREE(trans); diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c index 5e371c47c8..26770d6b1e 100644 --- a/src/gallium/drivers/identity/id_context.c +++ b/src/gallium/drivers/identity/id_context.c @@ -748,9 +748,11 @@ identity_context_get_tex_transfer(struct pipe_context *_context, } static void -identity_context_tex_transfer_destroy(struct pipe_transfer *_transfer) +identity_context_tex_transfer_destroy(struct pipe_context *_pipe, + struct pipe_transfer *_transfer) { - identity_transfer_destroy(identity_transfer(_transfer)); + identity_transfer_destroy(identity_context(_pipe), + identity_transfer(_transfer)); } static void * diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c index 91831404b8..d37fb0042e 100644 --- a/src/gallium/drivers/identity/id_objects.c +++ b/src/gallium/drivers/identity/id_objects.c @@ -30,6 +30,7 @@ #include "id_screen.h" #include "id_objects.h" +#include "id_context.h" struct pipe_buffer * identity_buffer_create(struct identity_screen *id_screen, @@ -160,22 +161,25 @@ identity_transfer_create(struct identity_context *id_context, memcpy(&id_transfer->base, transfer, sizeof(struct pipe_transfer)); id_transfer->base.texture = NULL; - pipe_texture_reference(&id_transfer->base.texture, &id_texture->base); id_transfer->transfer = transfer; + + pipe_texture_reference(&id_transfer->base.texture, &id_texture->base); assert(id_transfer->base.texture == &id_texture->base); return &id_transfer->base; error: - transfer->pipe->tex_transfer_destroy(transfer); + id_context->pipe->tex_transfer_destroy(id_context->pipe, transfer); return NULL; } void -identity_transfer_destroy(struct identity_transfer *id_transfer) +identity_transfer_destroy(struct identity_context *id_context, + struct identity_transfer *id_transfer) { pipe_texture_reference(&id_transfer->base.texture, NULL); - id_transfer->transfer->pipe->tex_transfer_destroy(id_transfer->transfer); + id_context->pipe->tex_transfer_destroy(id_context->pipe, + id_transfer->transfer); FREE(id_transfer); } diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h index 3c4e6d3f8c..7333ecfb7f 100644 --- a/src/gallium/drivers/identity/id_objects.h +++ b/src/gallium/drivers/identity/id_objects.h @@ -65,6 +65,7 @@ struct identity_transfer { struct pipe_transfer base; + struct pipe_context *pipe; struct pipe_transfer *transfer; }; @@ -183,7 +184,8 @@ identity_transfer_create(struct identity_context *id_context, struct pipe_transfer *transfer); void -identity_transfer_destroy(struct identity_transfer *id_transfer); +identity_transfer_destroy(struct identity_context *id_context, + struct identity_transfer *id_transfer); struct pipe_video_surface * identity_video_surface_create(struct identity_screen *id_screen, diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c index bfe53d4106..505cb21503 100644 --- a/src/gallium/drivers/llvmpipe/lp_scene.c +++ b/src/gallium/drivers/llvmpipe/lp_scene.c @@ -477,7 +477,7 @@ lp_scene_unmap_buffers( struct lp_scene *scene ) pipe->transfer_unmap(pipe, scene->cbuf_transfer[i]); if (scene->cbuf_transfer[i]) - pipe->tex_transfer_destroy(scene->cbuf_transfer[i]); + pipe->tex_transfer_destroy(pipe, scene->cbuf_transfer[i]); scene->cbuf_transfer[i] = NULL; scene->cbuf_map[i] = NULL; @@ -487,7 +487,7 @@ lp_scene_unmap_buffers( struct lp_scene *scene ) pipe->transfer_unmap(pipe, scene->zsbuf_transfer); if (scene->zsbuf_transfer) - pipe->tex_transfer_destroy(scene->zsbuf_transfer); + pipe->tex_transfer_destroy(pipe, scene->zsbuf_transfer); scene->zsbuf_transfer = NULL; scene->zsbuf_map = NULL; diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 65f7994e0e..f2c6dbd088 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -294,7 +294,8 @@ llvmpipe_get_tex_transfer(struct pipe_context *pipe, static void -llvmpipe_tex_transfer_destroy(struct pipe_transfer *transfer) +llvmpipe_tex_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) { /* Effectively do the texture_update work here - if texture images * needed post-processing to put them into hardware layout, this is diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c index 1318c60ae4..cfc109bb74 100644 --- a/src/gallium/drivers/nv30/nv30_transfer.c +++ b/src/gallium/drivers/nv30/nv30_transfer.c @@ -118,12 +118,13 @@ nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, } static void -nv30_transfer_del(struct pipe_transfer *ptx) +nv30_transfer_del(struct pipe_context *pcontext, + struct pipe_transfer *ptx) { struct nv30_transfer *tx = (struct nv30_transfer *)ptx; if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = ptx->texture->screen; + struct pipe_screen *pscreen = pcontext->screen; struct nv30_screen *nvscreen = nv30_screen(pscreen); struct pipe_surface *dst; diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c index 2ca9b94388..c552a68113 100644 --- a/src/gallium/drivers/nv40/nv40_transfer.c +++ b/src/gallium/drivers/nv40/nv40_transfer.c @@ -118,12 +118,12 @@ nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, } static void -nv40_transfer_del(struct pipe_transfer *ptx) +nv40_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx) { struct nv40_transfer *tx = (struct nv40_transfer *)ptx; if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) { - struct pipe_screen *pscreen = ptx->texture->screen; + struct pipe_screen *pscreen = pcontext->screen; struct nv40_screen *nvscreen = nv40_screen(pscreen); struct pipe_surface *dst; diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index b7f2ac1b1c..9eb223eca6 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -187,7 +187,7 @@ nv50_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt, } static void -nv50_transfer_del(struct pipe_transfer *ptx) +nv50_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx) { struct nv50_transfer *tx = (struct nv50_transfer *)ptx; struct nv50_miptree *mt = nv50_miptree(ptx->texture); @@ -197,7 +197,7 @@ nv50_transfer_del(struct pipe_transfer *ptx) unsigned ny = util_format_get_nblocksy(pt->format, tx->base.height); if (ptx->usage & PIPE_TRANSFER_WRITE) { - struct pipe_screen *pscreen = pt->screen; + struct pipe_screen *pscreen = pcontext->screen; nv50_transfer_rect_m2mf(pscreen, tx->bo, 0, tx->base.stride, tx->bo->tile_mode, diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 69c0ab496c..64d1909a38 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -251,8 +251,6 @@ static boolean r300_is_format_supported(struct pipe_screen* screen, return retval == usage; } - - static void r300_destroy_screen(struct pipe_screen* pscreen) { struct r300_screen* r300screen = r300_screen(pscreen); diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c index 7dd707ff8e..495e3dee76 100644 --- a/src/gallium/drivers/r300/r300_transfer.c +++ b/src/gallium/drivers/r300/r300_transfer.c @@ -205,7 +205,8 @@ r300_get_tex_transfer(struct pipe_context *ctx, return &trans->transfer; } -static void r300_tex_transfer_destroy(struct pipe_transfer *trans) +static void r300_tex_transfer_destroy(struct pipe_context *ctx, + struct pipe_transfer *trans) { struct r300_transfer *r300transfer = r300_transfer(trans); diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c index a9f5b51a41..e3a5e37ce4 100644 --- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c @@ -69,10 +69,10 @@ sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc) /*assert(tc->entries[pos].x < 0);*/ } if (tc->transfer) { - tc->pipe->tex_transfer_destroy(tc->transfer); + tc->pipe->tex_transfer_destroy(tc->pipe, tc->transfer); } if (tc->tex_trans) { - tc->pipe->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans); } FREE( tc ); @@ -135,7 +135,7 @@ sp_tex_tile_cache_set_texture(struct softpipe_tex_tile_cache *tc, tc->tex_trans_map = NULL; } - tc->pipe->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans); tc->tex_trans = NULL; } @@ -230,7 +230,7 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, tc->tex_trans_map = NULL; } - tc->pipe->tex_transfer_destroy(tc->tex_trans); + tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans); tc->tex_trans = NULL; } @@ -251,7 +251,8 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc, } /* get tile from the transfer (view into texture) */ - pipe_get_tile_rgba(tc->tex_trans, + pipe_get_tile_rgba(tc->pipe, + tc->tex_trans, addr.bits.x * TILE_SIZE, addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index adae48c474..da8529c154 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -277,7 +277,6 @@ softpipe_get_tex_transfer(struct pipe_context *pipe, struct pipe_transfer *pt = &spt->base; int nblocksy = util_format_get_nblocksy(texture->format, u_minify(texture->height0, level)); pipe_texture_reference(&pt->texture, texture); - pt->pipe = pipe; pt->x = x; pt->y = y; pt->width = w; @@ -311,7 +310,8 @@ softpipe_get_tex_transfer(struct pipe_context *pipe, * softpipe_get_tex_transfer(). */ static void -softpipe_tex_transfer_destroy(struct pipe_transfer *transfer) +softpipe_tex_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) { /* Effectively do the texture_update work here - if texture images * needed post-processing to put them into hardware layout, this is diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index d779816790..1c3c2667d7 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -121,7 +121,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc) /*assert(tc->entries[pos].x < 0);*/ } if (tc->transfer) { - tc->pipe->tex_transfer_destroy(tc->transfer); + tc->pipe->tex_transfer_destroy(tc->pipe, tc->transfer); } FREE( tc ); @@ -146,7 +146,7 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc, tc->transfer_map = NULL; } - pipe->tex_transfer_destroy(tc->transfer); + pipe->tex_transfer_destroy(pipe, tc->transfer); tc->transfer = NULL; } @@ -291,7 +291,8 @@ sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc) union tile_address addr = tile_address(x, y); if (is_clear_flag_set(tc->clear_flags, addr)) { - pipe_put_tile_raw(pt, + pipe_put_tile_raw(tc->pipe, + pt, x, y, TILE_SIZE, TILE_SIZE, tc->tile.data.color32, 0/*STRIDE*/); @@ -325,14 +326,14 @@ sp_flush_tile_cache(struct softpipe_tile_cache *tc) struct softpipe_cached_tile *tile = tc->entries + pos; if (!tile->addr.bits.invalid) { if (tc->depth_stencil) { - pipe_put_tile_raw(pt, + pipe_put_tile_raw(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tile->data.depth32, 0/*STRIDE*/); } else { - pipe_put_tile_rgba(pt, + pipe_put_tile_rgba(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -375,14 +376,14 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, if (tile->addr.bits.invalid == 0) { /* put dirty tile back in framebuffer */ if (tc->depth_stencil) { - pipe_put_tile_raw(pt, + pipe_put_tile_raw(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tile->data.depth32, 0/*STRIDE*/); } else { - pipe_put_tile_rgba(pt, + pipe_put_tile_rgba(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, @@ -405,14 +406,14 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc, else { /* get new tile data from transfer */ if (tc->depth_stencil) { - pipe_get_tile_raw(pt, + pipe_get_tile_raw(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, tile->data.depth32, 0/*STRIDE*/); } else { - pipe_get_tile_rgba(pt, + pipe_get_tile_rgba(tc->pipe, pt, tile->addr.bits.x * TILE_SIZE, tile->addr.bits.y * TILE_SIZE, TILE_SIZE, TILE_SIZE, diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 065b8748a3..107e4a3962 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -899,10 +899,11 @@ svga_transfer_unmap(struct pipe_context *pipe, static void -svga_tex_transfer_destroy(struct pipe_transfer *transfer) +svga_tex_transfer_destroy(struct pipe_context *pipe, + struct pipe_transfer *transfer) { struct svga_texture *tex = svga_texture(transfer->texture); - struct svga_screen *ss = svga_screen(transfer->texture->screen); + struct svga_screen *ss = svga_screen(pipe->screen); struct svga_winsys_screen *sws = ss->sws; struct svga_transfer *st = svga_transfer(transfer); diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c index 4a0e9ac17d..b7e6bbac68 100644 --- a/src/gallium/drivers/trace/tr_context.c +++ b/src/gallium/drivers/trace/tr_context.c @@ -1336,11 +1336,12 @@ trace_context_get_tex_transfer(struct pipe_context *_context, static void -trace_context_tex_transfer_destroy(struct pipe_transfer *_transfer) +trace_context_tex_transfer_destroy(struct pipe_context *_context, + struct pipe_transfer *_transfer) { - struct trace_context *tr_ctx = trace_context(_transfer->pipe); + struct trace_context *tr_context = trace_context(_context); struct trace_transfer *tr_trans = trace_transfer(_transfer); - struct pipe_context *context = tr_ctx->pipe; + struct pipe_context *context = tr_context->pipe; struct pipe_transfer *transfer = tr_trans->transfer; trace_dump_call_begin("pipe_context", "tex_transfer_destroy"); @@ -1350,7 +1351,7 @@ trace_context_tex_transfer_destroy(struct pipe_transfer *_transfer) trace_dump_call_end(); - trace_transfer_destroy(tr_trans); + trace_transfer_destroy(tr_context, tr_trans); } diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c index b36865400d..f4f17566fd 100644 --- a/src/gallium/drivers/trace/tr_rbug.c +++ b/src/gallium/drivers/trace/tr_rbug.c @@ -257,7 +257,7 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header, NULL); context->transfer_unmap(context, t); - context->tex_transfer_destroy(t); + context->tex_transfer_destroy(context, t); pipe_mutex_unlock(tr_scr->list_mutex); diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c index b70ccb9ce8..d818e21bb8 100644 --- a/src/gallium/drivers/trace/tr_texture.c +++ b/src/gallium/drivers/trace/tr_texture.c @@ -143,10 +143,10 @@ trace_transfer_create(struct trace_context *tr_ctx, memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer)); - tr_trans->base.pipe = &tr_ctx->base; tr_trans->base.texture = NULL; - pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base); tr_trans->transfer = transfer; + + pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base); assert(tr_trans->base.texture == &tr_tex->base); trace_screen_add_to_list(tr_scr, transfers, tr_trans); @@ -154,21 +154,23 @@ trace_transfer_create(struct trace_context *tr_ctx, return &tr_trans->base; error: - tr_ctx->pipe->tex_transfer_destroy(transfer); + tr_ctx->pipe->tex_transfer_destroy(tr_ctx->pipe, transfer); return NULL; } void -trace_transfer_destroy(struct trace_transfer *tr_trans) +trace_transfer_destroy(struct trace_context *tr_context, + struct trace_transfer *tr_trans) { - struct trace_screen *tr_scr = trace_screen(tr_trans->base.texture->screen); - struct pipe_context *context = tr_trans->transfer->pipe; + struct trace_screen *tr_scr = trace_screen(tr_context->base.screen); + struct pipe_context *context = tr_context->pipe; + struct pipe_transfer *transfer = tr_trans->transfer; trace_screen_remove_from_list(tr_scr, transfers, tr_trans); pipe_texture_reference(&tr_trans->base.texture, NULL); - context->tex_transfer_destroy(tr_trans->transfer); + context->tex_transfer_destroy(context, transfer); FREE(tr_trans); } diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h index ab284eeef3..4dc95308a7 100644 --- a/src/gallium/drivers/trace/tr_texture.h +++ b/src/gallium/drivers/trace/tr_texture.h @@ -61,6 +61,7 @@ struct trace_transfer struct pipe_transfer base; struct pipe_transfer *transfer; + struct pipe_context *pipe; struct tr_list list; @@ -118,7 +119,8 @@ trace_transfer_create(struct trace_context *tr_ctx, struct pipe_transfer *transfer); void -trace_transfer_destroy(struct trace_transfer *tr_trans); +trace_transfer_destroy(struct trace_context *tr_ctx, + struct trace_transfer *tr_trans); #endif /* TR_TEXTURE_H_ */ diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 494b53e912..a7f12fb81e 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -323,7 +323,8 @@ struct pipe_context { unsigned x, unsigned y, unsigned w, unsigned h); - void (*tex_transfer_destroy)(struct pipe_transfer *); + void (*tex_transfer_destroy)(struct pipe_context *, + struct pipe_transfer *); void *(*transfer_map)( struct pipe_context *, struct pipe_transfer *transfer ); diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 2af933207d..3a97d888ce 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -304,8 +304,6 @@ struct pipe_surface */ struct pipe_transfer { - struct pipe_context *pipe; - unsigned x; /**< x offset from start of texture image */ unsigned y; /**< y offset from start of texture image */ unsigned width; /**< logical width in pixels */ diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c index 6e79dd370f..18e2cc1f25 100644 --- a/src/gallium/state_trackers/vega/api_filters.c +++ b/src/gallium/state_trackers/vega/api_filters.c @@ -85,7 +85,7 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx, void *map = pipe->transfer_map(pipe, transfer); memcpy(map, color_data, sizeof(VGint)*color_data_len); pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } return tex; diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c index 432ba68139..fec473d9d2 100644 --- a/src/gallium/state_trackers/vega/api_images.c +++ b/src/gallium/state_trackers/vega/api_images.c @@ -450,14 +450,14 @@ void vgReadPixels(void * data, VGint dataStride, #if 0 debug_printf("%d-%d == %d\n", sy, height, y); #endif - pipe_get_tile_rgba(transfer, sx, y, width, 1, df); + pipe_get_tile_rgba(pipe, transfer, sx, y, width, 1, df); y += yStep; _vega_pack_rgba_span_float(ctx, width, temp, dataFormat, dst + yoffset + xoffset); dst += dataStride; } - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } } diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c index 604a86aeb8..a71579cd26 100644 --- a/src/gallium/state_trackers/vega/image.c +++ b/src/gallium/state_trackers/vega/image.c @@ -418,11 +418,11 @@ void image_sub_data(struct vg_image *image, src += (dataStride * yoffset); for (i = 0; i < height; i++) { _vega_unpack_float_span_rgba(ctx, width, xoffset, src, dataFormat, temp); - pipe_put_tile_rgba(transfer, x+image->x, y+image->y, width, 1, df); + pipe_put_tile_rgba(pipe, transfer, x+image->x, y+image->y, width, 1, df); y += yStep; src += dataStride; } - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } } @@ -454,13 +454,13 @@ void image_get_sub_data(struct vg_image * image, #if 0 debug_printf("%d-%d == %d\n", sy, height, y); #endif - pipe_get_tile_rgba(transfer, sx+image->x, y, width, 1, df); + pipe_get_tile_rgba(pipe, transfer, sx+image->x, y, width, 1, df); y += yStep; _vega_pack_rgba_span_float(ctx, width, temp, dataFormat, dst); dst += dataStride; } - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } } diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c index 47a7710d3e..dc56b8c5f3 100644 --- a/src/gallium/state_trackers/vega/paint.c +++ b/src/gallium/state_trackers/vega/paint.c @@ -167,7 +167,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p) void *map = pipe->transfer_map(pipe, transfer); memcpy(map, p->gradient.color_data, sizeof(VGint)*1024); pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } return tex; diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c index b066f5c94b..b446b2079c 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -172,7 +172,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt) } pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 69a96e5d10..01aba3e3dd 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -144,7 +144,7 @@ accum_accum(struct st_context *st, GLfloat value, buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); + pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); switch (acc_strb->format) { case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -165,7 +165,7 @@ accum_accum(struct st_context *st, GLfloat value, } free(buf); - pipe->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(pipe, color_trans); } @@ -192,7 +192,7 @@ accum_load(struct st_context *st, GLfloat value, buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); + pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); switch (acc_strb->format) { case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -213,7 +213,7 @@ accum_load(struct st_context *st, GLfloat value, } free(buf); - pipe->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(pipe, color_trans); } @@ -248,7 +248,7 @@ accum_return(GLcontext *ctx, GLfloat value, width, height); if (usage & PIPE_TRANSFER_READ) - pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf); + pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); switch (acc_strb->format) { case PIPE_FORMAT_R16G16B16A16_SNORM: @@ -277,10 +277,10 @@ accum_return(GLcontext *ctx, GLfloat value, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf); + pipe_put_tile_rgba(pipe, color_trans, 0, 0, width, height, buf); free(buf); - pipe->tex_transfer_destroy(color_trans); + pipe->tex_transfer_destroy(pipe, color_trans); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 723c5f180b..dfd8925edf 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -295,7 +295,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, /* Release transfer */ pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); return pt; } @@ -530,7 +530,7 @@ reset_cache(struct st_context *st) cache->ymax = -1000000; if (cache->trans) { - pipe->tex_transfer_destroy(cache->trans); + pipe->tex_transfer_destroy(pipe, cache->trans); cache->trans = NULL; } @@ -616,7 +616,7 @@ st_flush_bitmap_cache(struct st_context *st) pipe->transfer_unmap(pipe, cache->trans); cache->buffer = NULL; - pipe->tex_transfer_destroy(cache->trans); + pipe->tex_transfer_destroy(pipe, cache->trans); cache->trans = NULL; } @@ -836,7 +836,7 @@ st_destroy_bitmap(struct st_context *st) if (cache) { if (cache->trans) { pipe->transfer_unmap(pipe, cache->trans); - pipe->tex_transfer_destroy(cache->trans); + pipe->tex_transfer_destroy(pipe, cache->trans); } pipe_texture_reference(&st->bitmap.cache->texture, NULL); free(st->bitmap.cache); diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 3fa6d12f1c..c44d0fc3e8 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -411,7 +411,7 @@ make_texture(struct st_context *st, /* unmap */ pipe->transfer_unmap(pipe, transfer); - pipe->tex_transfer_destroy(transfer); + pipe->tex_transfer_destroy(pipe, transfer); assert(success); @@ -791,7 +791,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* unmap the stencil buffer */ pipe->transfer_unmap(pipe, pt); - pipe->tex_transfer_destroy(pt); + pipe->tex_transfer_destroy(pipe, pt); } @@ -944,7 +944,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, /* unmap the stencil buffer */ pipe->transfer_unmap(pipe, ptDraw); - pipe->tex_transfer_destroy(ptDraw); + pipe->tex_transfer_destroy(pipe, ptDraw); } @@ -1113,21 +1113,21 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, /* alternate path using get/put_tile() */ GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf); - pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf); + pipe_get_tile_rgba(pipe, ptRead, 0, 0, width, height, buf); + pipe_put_tile_rgba(pipe, ptTex, 0, 0, width, height, buf); free(buf); } else { /* GL_DEPTH */ GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); - pipe_get_tile_z(ptRead, 0, 0, width, height, buf); - pipe_put_tile_z(ptTex, 0, 0, width, height, buf); + pipe_get_tile_z(pipe, ptRead, 0, 0, width, height, buf); + pipe_put_tile_z(pipe, ptTex, 0, 0, width, height, buf); free(buf); } - pipe->tex_transfer_destroy(ptRead); - pipe->tex_transfer_destroy(ptTex); + pipe->tex_transfer_destroy(pipe, ptRead); + pipe->tex_transfer_destroy(pipe, ptTex); } /* draw textured quad */ diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 98ccda821c..080a5f9bfb 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -162,7 +162,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, /* unmap the stencil buffer */ pipe->transfer_unmap(pipe, pt); - pipe->tex_transfer_destroy(pt); + pipe->tex_transfer_destroy(pipe, pt); } @@ -254,7 +254,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, map = pipe->transfer_map(pipe, trans); if (!map) { - pipe->tex_transfer_destroy(trans); + pipe->tex_transfer_destroy(pipe, trans); return GL_FALSE; } @@ -317,7 +317,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, } pipe->transfer_unmap(pipe, trans); - pipe->tex_transfer_destroy(trans); + pipe->tex_transfer_destroy(pipe, trans); } return GL_TRUE; @@ -441,7 +441,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / ((1 << 24) - 1); - pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * (ztemp[j] & 0xffffff)); @@ -456,7 +456,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, assert(format == GL_DEPTH_STENCIL_EXT); for (i = 0; i < height; i++) { GLuint *zshort = (GLuint *)dst; - pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, dst, 0); y += yStep; /* Reverse into 24/8 */ for (j = 0; j < width; j++) { @@ -473,7 +473,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / ((1 << 24) - 1); - pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * ((ztemp[j] >> 8) & 0xffffff)); @@ -487,7 +487,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* XXX: unreachable code -- should be before st_read_stencil_pixels */ assert(format == GL_DEPTH_STENCIL_EXT); for (i = 0; i < height; i++) { - pipe_get_tile_raw(trans, 0, y, width, 1, dst, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, dst, 0); y += yStep; dst += dstStride; } @@ -498,7 +498,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLushort ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffff; - pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * ztemp[j]); @@ -513,7 +513,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLuint ztemp[MAX_WIDTH]; GLfloat zfloat[MAX_WIDTH]; const double scale = 1.0 / 0xffffffff; - pipe_get_tile_raw(trans, 0, y, width, 1, ztemp, 0); + pipe_get_tile_raw(pipe, trans, 0, y, width, 1, ztemp, 0); y += yStep; for (j = 0; j < width; j++) { zfloat[j] = (float) (scale * ztemp[j]); @@ -527,7 +527,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, /* RGBA format */ /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { - pipe_get_tile_rgba(trans, 0, y, width, 1, df); + pipe_get_tile_rgba(pipe, trans, 0, y, width, 1, df); y += yStep; df += dfStride; if (!dfStride) { @@ -539,7 +539,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } - pipe->tex_transfer_destroy(trans); + pipe->tex_transfer_destroy(pipe, trans); _mesa_unmap_pbo_dest(ctx, &clippedPacking); } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 1b20b615d0..626e6ad660 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -435,7 +435,7 @@ compress_with_blit(GLcontext * ctx, unpack); /* source data packing */ pipe->transfer_unmap(pipe, tex_xfer); - pipe->tex_transfer_destroy(tex_xfer); + pipe->tex_transfer_destroy(pipe, tex_xfer); /* copy / compress image */ util_blit_pixels_tex(ctx->st->blit, @@ -873,7 +873,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, debug_printf("%s: fallback format translation\n", __FUNCTION__); /* get float[4] rgba row from surface */ - pipe_get_tile_rgba(tex_xfer, 0, row, width, 1, rgba); + pipe_get_tile_rgba(pipe, tex_xfer, 0, row, width, 1, rgba); _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, type, dest, &ctx->Pack, transferOps); @@ -1310,11 +1310,11 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, /* To avoid a large temp memory allocation, do copy row by row */ for (row = 0; row < height; row++, srcY += yStep) { uint data[MAX_WIDTH]; - pipe_get_tile_z(src_trans, 0, srcY, width, 1, data); + pipe_get_tile_z(pipe, src_trans, 0, srcY, width, 1, data); if (scaleOrBias) { _mesa_scale_and_bias_depth_uint(ctx, width, data); } - pipe_put_tile_z(stImage->transfer, 0, row, width, 1, data); + pipe_put_tile_z(pipe, stImage->transfer, 0, row, width, 1, data); } } else { @@ -1336,7 +1336,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, /* XXX this usually involves a lot of int/float conversion. * try to avoid that someday. */ - pipe_get_tile_rgba(src_trans, 0, 0, width, height, tempSrc); + pipe_get_tile_rgba(pipe, src_trans, 0, 0, width, height, tempSrc); /* Store into texture memory. * Note that this does some special things such as pixel transfer @@ -1364,7 +1364,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } st_texture_image_unmap(ctx->st, stImage); - pipe->tex_transfer_destroy(src_trans); + pipe->tex_transfer_destroy(pipe, src_trans); } diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index a73b8ed8fe..b2521433c8 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -163,8 +163,8 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, pipe->transfer_unmap(pipe, srcTrans); pipe->transfer_unmap(pipe, dstTrans); - pipe->tex_transfer_destroy(srcTrans); - pipe->tex_transfer_destroy(dstTrans); + pipe->tex_transfer_destroy(pipe, srcTrans); + pipe->tex_transfer_destroy(pipe, dstTrans); } } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index f1eef768eb..10a38befb4 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -217,7 +217,7 @@ st_texture_image_unmap(struct st_context *st, pipe->transfer_unmap(pipe, stImage->transfer); - pipe->tex_transfer_destroy(stImage->transfer); + pipe->tex_transfer_destroy(pipe, stImage->transfer); } @@ -284,7 +284,7 @@ st_texture_image_data(struct st_context *st, u_minify(dst->width0, level), u_minify(dst->height0, level)); /* width, height */ - pipe->tex_transfer_destroy(dst_transfer); + pipe->tex_transfer_destroy(pipe, dst_transfer); srcUB += src_image_stride; } -- cgit v1.2.3 From dfeab49a96fb520b5cb21b4cb5a8a5a0c1bf61e1 Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Mar 2010 18:40:25 +0100 Subject: cell: adapt to context texture transfers (untested) --- src/gallium/drivers/cell/ppu/cell_context.c | 1 + src/gallium/drivers/cell/ppu/cell_texture.c | 23 +++++++++++++---------- src/gallium/drivers/cell/ppu/cell_texture.h | 2 ++ 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c index afcea616d5..f6cb1fc9be 100644 --- a/src/gallium/drivers/cell/ppu/cell_context.c +++ b/src/gallium/drivers/cell/ppu/cell_context.c @@ -158,6 +158,7 @@ cell_create_context(struct pipe_screen *screen, cell_init_shader_functions(cell); cell_init_surface_functions(cell); cell_init_vertex_functions(cell); + cell_init_texture_transfer_funcs(cell); cell->draw = cell_draw_create(cell); diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c index c8a1acd86a..c65c3b4f88 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.c +++ b/src/gallium/drivers/cell/ppu/cell_texture.c @@ -355,7 +355,7 @@ cell_tex_surface_destroy(struct pipe_surface *surf) * back out for glGetTexImage). */ static struct pipe_transfer * -cell_get_tex_transfer(struct pipe_screen *screen, +cell_get_tex_transfer(struct pipe_context *ctx, struct pipe_texture *texture, unsigned face, unsigned level, unsigned zslice, enum pipe_transfer_usage usage, @@ -402,7 +402,7 @@ cell_get_tex_transfer(struct pipe_screen *screen, static void -cell_tex_transfer_destroy(struct pipe_transfer *t) +cell_tex_transfer_destroy(struct pipe_context *ctx, struct pipe_transfer *t) { struct cell_transfer *transfer = cell_transfer(t); /* Effectively do the texture_update work here - if texture images @@ -419,7 +419,7 @@ cell_tex_transfer_destroy(struct pipe_transfer *t) * Return pointer to texture image data in linear layout. */ static void * -cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer) +cell_transfer_map(struct pipe_context *ctx, struct pipe_transfer *transfer) { struct cell_transfer *ctrans = cell_transfer(transfer); struct pipe_texture *pt = transfer->texture; @@ -471,7 +471,7 @@ cell_transfer_map(struct pipe_screen *screen, struct pipe_transfer *transfer) * to tiled data. */ static void -cell_transfer_unmap(struct pipe_screen *screen, +cell_transfer_unmap(struct pipe_context *ctx, struct pipe_transfer *transfer) { struct cell_transfer *ctrans = cell_transfer(transfer); @@ -560,11 +560,14 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen) screen->get_tex_surface = cell_get_tex_surface; screen->tex_surface_destroy = cell_tex_surface_destroy; - screen->get_tex_transfer = cell_get_tex_transfer; - screen->tex_transfer_destroy = cell_tex_transfer_destroy; - - screen->transfer_map = cell_transfer_map; - screen->transfer_unmap = cell_transfer_unmap; - screen->flush_frontbuffer = cell_flush_frontbuffer; } + +void +cell_init_texture_transfer_funcs(struct cell_context *cell) +{ + cell->pipe.get_tex_transfer = cell_get_tex_transfer; + cell->pipe.tex_transfer_destroy = cell_tex_transfer_destroy; + cell->pipe.transfer_map = cell_transfer_map; + cell->pipe.transfer_unmap = cell_transfer_unmap; +} diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h index 2be0579312..ac0b916775 100644 --- a/src/gallium/drivers/cell/ppu/cell_texture.h +++ b/src/gallium/drivers/cell/ppu/cell_texture.h @@ -95,5 +95,7 @@ cell_transfer(struct pipe_transfer *pt) extern void cell_init_screen_texture_funcs(struct pipe_screen *screen); +extern void +cell_init_texture_transfer_funcs(struct cell_context *cell); #endif /* CELL_TEXTURE_H */ -- cgit v1.2.3 From ed1c69710c5046a80a86a9e8b51a1cb15b1b92eb Mon Sep 17 00:00:00 2001 From: Roland Scheidegger Date: Thu, 11 Mar 2010 18:54:14 +0100 Subject: st/mesa: don't enable extensions which aren't actually supported don't enable APPLE_client_storage, TDFX_texture_compression_FXT1, EXT_cull_vertex, NV_vertex_program, NV_vertex_program1_1 - the latter two might work somewhat with some luck. Also don't enable ARB_imaging. --- src/gallium/state_trackers/dri/dri_extensions.c | 2 +- src/mesa/state_tracker/st_extensions.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index d98fe3b47b..800677a2d1 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -40,7 +40,7 @@ dri_init_extensions(struct dri_context *ctx) { /* New extensions should be added in mesa/state_tracker/st_extensions.c * and not in this file. */ - driInitExtensions(ctx->st->ctx, NULL, GL_TRUE); + driInitExtensions(ctx->st->ctx, NULL, GL_FALSE); } /* vim: set sw=3 ts=8 sts=3 expandtab: */ diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index e837924dbd..290ee36b0f 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -179,7 +179,6 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_blend_logic_op = GL_TRUE; ctx->Extensions.EXT_blend_minmax = GL_TRUE; ctx->Extensions.EXT_blend_subtract = GL_TRUE; - ctx->Extensions.EXT_cull_vertex = GL_TRUE; ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; ctx->Extensions.EXT_framebuffer_object = GL_TRUE; ctx->Extensions.EXT_framebuffer_multisample = GL_TRUE; @@ -196,9 +195,6 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_texture_lod_bias = GL_TRUE; ctx->Extensions.EXT_vertex_array_bgra = GL_TRUE; - ctx->Extensions.TDFX_texture_compression_FXT1 = GL_TRUE; - - ctx->Extensions.APPLE_client_storage = GL_TRUE; ctx->Extensions.APPLE_vertex_array_object = GL_TRUE; ctx->Extensions.MESA_pack_invert = GL_TRUE; @@ -207,8 +203,11 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.NV_texgen_reflection = GL_TRUE; ctx->Extensions.NV_texture_env_combine4 = GL_TRUE; ctx->Extensions.NV_texture_rectangle = GL_TRUE; +#if 0 + /* possibly could support the following two */ ctx->Extensions.NV_vertex_program = GL_TRUE; ctx->Extensions.NV_vertex_program1_1 = GL_TRUE; +#endif #if FEATURE_OES_draw_texture ctx->Extensions.OES_draw_texture = GL_TRUE; -- cgit v1.2.3 From d6451190982fdae60dd0055550a54398729c64f4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 11:17:15 -0700 Subject: gallivm: fix some bugs on the 1D texture paths --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index dadae61115..9358ad3860 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1007,7 +1007,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld, } } else { - y = NULL; + y = z = NULL; } /* @@ -1075,6 +1075,7 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, } else { y0 = y1 = t_fpart = NULL; + z0 = z1 = r_fpart = NULL; } /* @@ -1092,9 +1093,11 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, if (dims == 1) { /* Interpolate two samples from 1D image to produce one color */ - colors_out[chan] = lp_build_lerp(&bld->texel_bld, s_fpart, - neighbors[0][0][chan], - neighbors[0][1][chan]); + for (chan = 0; chan < 4; chan++) { + colors_out[chan] = lp_build_lerp(&bld->texel_bld, s_fpart, + neighbors[0][0][chan], + neighbors[0][1][chan]); + } } else { /* 2D/3D texture */ @@ -1198,10 +1201,10 @@ lp_build_sample_general(struct lp_build_sample_context *bld, const int dims = texture_dims(bld->static_state->target); LLVMValueRef lod, lod_fpart; LLVMValueRef ilevel0, ilevel1, ilevel0_vec, ilevel1_vec; - LLVMValueRef width0_vec, height0_vec, depth0_vec; - LLVMValueRef width1_vec, height1_vec, depth1_vec; - LLVMValueRef row_stride0_vec, row_stride1_vec; - LLVMValueRef img_stride0_vec, img_stride1_vec; + LLVMValueRef width0_vec = NULL, height0_vec = NULL, depth0_vec = NULL; + LLVMValueRef width1_vec = NULL, height1_vec = NULL, depth1_vec = NULL; + LLVMValueRef row_stride0_vec = NULL, row_stride1_vec = NULL; + LLVMValueRef img_stride0_vec = NULL, img_stride1_vec = NULL; LLVMValueRef data_ptr0, data_ptr1; int chan; -- cgit v1.2.3 From 4833b0f199ce2728a456de9cac753ac921fef828 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 14:00:48 -0700 Subject: gallium/os: wrapper for llvm-c/Core.h and #define HAVE_LLVM if needed --- src/gallium/auxiliary/os/os_llvm.h | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/gallium/auxiliary/os/os_llvm.h (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/os/os_llvm.h b/src/gallium/auxiliary/os/os_llvm.h new file mode 100644 index 0000000000..d5edfbfe92 --- /dev/null +++ b/src/gallium/auxiliary/os/os_llvm.h @@ -0,0 +1,47 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. + * 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 VMWARE 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 + * Wrapper for LLVM header file #includes. + */ + + +#ifndef OS_LLVM_H +#define OS_LLVM_H + + +#include + + +/** Set version to 0 if missing to avoid #ifdef HAVE_LLVM everywhere */ +#ifndef HAVE_LLVM +#define HAVE_LLVM 0x0 +#endif + + +#endif /* OS_LLVM_H */ -- cgit v1.2.3 From 489af2a3ba467e4341cb8504a0e59cf5828864d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 13:57:52 -0700 Subject: gallivm/llvmpipe: include os_llvm.h instead of llvm-c/Core.h --- src/gallium/auxiliary/gallivm/lp_bld_alpha.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_arit.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_blend.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_const.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_conv.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_debug.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_depth.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_flow.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_format.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_interp.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_intr.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_logic.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_logic.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_pack.c | 2 +- src/gallium/auxiliary/gallivm/lp_bld_pack.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_struct.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_swizzle.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 2 +- src/gallium/auxiliary/gallivm/lp_bld_type.h | 2 +- src/gallium/drivers/llvmpipe/lp_screen.h | 4 +--- src/gallium/drivers/llvmpipe/lp_state.h | 2 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 3 +++ src/gallium/drivers/llvmpipe/lp_test.h | 2 +- src/gallium/drivers/llvmpipe/lp_test_format.c | 2 +- src/gallium/drivers/llvmpipe/lp_tex_sample.h | 2 +- 26 files changed, 28 insertions(+), 27 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_alpha.h b/src/gallium/auxiliary/gallivm/lp_bld_alpha.h index 634575670d..fe3cedcc48 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_alpha.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_alpha.h @@ -35,7 +35,7 @@ #define LP_BLD_ALPHA_H -#include +#include "os/os_llvm.h" struct pipe_alpha_state; struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 55385e3a66..f14b01e05f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -37,7 +37,7 @@ #define LP_BLD_ARIT_H -#include +#include "os/os_llvm.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_blend.h b/src/gallium/auxiliary/gallivm/lp_bld_blend.h index da272e549f..5a9e1c1fb2 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_blend.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_blend.h @@ -40,7 +40,7 @@ * for a standalone example. */ -#include +#include "os/os_llvm.h" #include "pipe/p_format.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_const.h b/src/gallium/auxiliary/gallivm/lp_bld_const.h index cb8e1c7b00..4078636103 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_const.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_const.h @@ -37,7 +37,7 @@ #define LP_BLD_CONST_H -#include +#include "os/os_llvm.h" #include diff --git a/src/gallium/auxiliary/gallivm/lp_bld_conv.h b/src/gallium/auxiliary/gallivm/lp_bld_conv.h index 948e68fae4..78e8155ff7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_conv.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_conv.h @@ -37,7 +37,7 @@ #define LP_BLD_CONV_H -#include +#include "os/os_llvm.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.h b/src/gallium/auxiliary/gallivm/lp_bld_debug.h index 583e6132b4..441ad94786 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.h @@ -30,7 +30,7 @@ #define LP_BLD_DEBUG_H -#include +#include "os/os_llvm.h" #include "pipe/p_compiler.h" #include "util/u_string.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_depth.h b/src/gallium/auxiliary/gallivm/lp_bld_depth.h index 79d6981bb5..8be80024ae 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_depth.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_depth.h @@ -36,7 +36,7 @@ #define LP_BLD_DEPTH_H -#include +#include "os/os_llvm.h" struct pipe_depth_state; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.h b/src/gallium/auxiliary/gallivm/lp_bld_flow.h index 8bb22543ee..e158836549 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.h @@ -35,7 +35,7 @@ #define LP_BLD_FLOW_H -#include +#include "os/os_llvm.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_format.h b/src/gallium/auxiliary/gallivm/lp_bld_format.h index 970bee379f..8972c0dc17 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_format.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_format.h @@ -34,7 +34,7 @@ * Pixel format helpers. */ -#include +#include "os/os_llvm.h" #include "pipe/p_format.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_interp.h b/src/gallium/auxiliary/gallivm/lp_bld_interp.h index ca958cdf34..177b5e943e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_interp.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_interp.h @@ -41,7 +41,7 @@ #define LP_BLD_INTERP_H -#include +#include "os/os_llvm.h" #include "tgsi/tgsi_exec.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.h b/src/gallium/auxiliary/gallivm/lp_bld_intr.h index f813f27074..7d5506c733 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.h @@ -37,7 +37,7 @@ #define LP_BLD_INTR_H -#include +#include "os/os_llvm.h" /** diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.c b/src/gallium/auxiliary/gallivm/lp_bld_logic.c index 1308076b3e..f3df3dd138 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.c @@ -92,7 +92,7 @@ lp_build_compare(LLVMBuilderRef builder, /* XXX: It is not clear if we should use the ordered or unordered operators */ -#if !defined(HAVE_LLVM) || HAVE_LLVM < 0x0207 +#if HAVE_LLVM < 0x0207 #if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) if(type.width * type.length == 128) { if(type.floating && util_cpu_caps.has_sse) { diff --git a/src/gallium/auxiliary/gallivm/lp_bld_logic.h b/src/gallium/auxiliary/gallivm/lp_bld_logic.h index a399ebf39e..b54ec13b70 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_logic.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_logic.h @@ -37,7 +37,7 @@ #define LP_BLD_LOGIC_H -#include +#include "os/os_llvm.h" #include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.c b/src/gallium/auxiliary/gallivm/lp_bld_pack.c index 4c61d10749..23398f41f9 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.c @@ -256,7 +256,7 @@ lp_build_pack2(LLVMBuilderRef builder, LLVMValueRef lo, LLVMValueRef hi) { -#if !(HAVE_LLVM >= 0x0207) +#if HAVE_LLVM < 0x0207 LLVMTypeRef src_vec_type = lp_build_vec_type(src_type); #endif LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_pack.h b/src/gallium/auxiliary/gallivm/lp_bld_pack.h index fb2a34984a..346a17d580 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_pack.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_pack.h @@ -37,7 +37,7 @@ #define LP_BLD_PACK_H -#include +#include "os/os_llvm.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 5b8da5dbf2..9e88ea54d7 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -36,7 +36,7 @@ #define LP_BLD_SAMPLE_H -#include +#include "os/os_llvm.h" struct pipe_texture; struct pipe_sampler_state; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_struct.h b/src/gallium/auxiliary/gallivm/lp_bld_struct.h index 740392f561..34478c10f5 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_struct.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_struct.h @@ -37,7 +37,7 @@ #define LP_BLD_STRUCT_H -#include +#include "os/os_llvm.h" #include #include "util/u_debug.h" diff --git a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h index b9472127a6..57b5cc079f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_swizzle.h @@ -37,7 +37,7 @@ #define LP_BLD_SWIZZLE_H -#include +#include "os/os_llvm.h" struct lp_type; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index eddb7a83fa..0f2f8a65b1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -35,7 +35,7 @@ #ifndef LP_BLD_TGSI_H #define LP_BLD_TGSI_H -#include +#include "os/os_llvm.h" struct tgsi_token; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_type.h b/src/gallium/auxiliary/gallivm/lp_bld_type.h index 4daa904e63..5b351476ac 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_type.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_type.h @@ -37,7 +37,7 @@ #define LP_BLD_TYPE_H -#include +#include "os/os_llvm.h" #include diff --git a/src/gallium/drivers/llvmpipe/lp_screen.h b/src/gallium/drivers/llvmpipe/lp_screen.h index f4e62cbf08..d977f98cfa 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.h +++ b/src/gallium/drivers/llvmpipe/lp_screen.h @@ -34,9 +34,7 @@ #ifndef LP_SCREEN_H #define LP_SCREEN_H -#include -#include -#include +#include "os/os_llvm.h" #include #include "pipe/p_screen.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h index 6dbdc195bf..a5a1a72074 100644 --- a/src/gallium/drivers/llvmpipe/lp_state.h +++ b/src/gallium/drivers/llvmpipe/lp_state.h @@ -31,7 +31,7 @@ #ifndef LP_STATE_H #define LP_STATE_H -#include +#include "os/os_llvm.h" #include "pipe/p_state.h" #include "tgsi/tgsi_scan.h" diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index c4b79dd415..ea6f056bb0 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -95,6 +95,9 @@ #include "lp_tex_sample.h" +#include + + static const unsigned char quad_offset_x[4] = {0, 1, 0, 1}; static const unsigned char quad_offset_y[4] = {0, 0, 1, 1}; diff --git a/src/gallium/drivers/llvmpipe/lp_test.h b/src/gallium/drivers/llvmpipe/lp_test.h index a9b99945f9..1df9897898 100644 --- a/src/gallium/drivers/llvmpipe/lp_test.h +++ b/src/gallium/drivers/llvmpipe/lp_test.h @@ -41,7 +41,7 @@ #include #include -#include +#include "os/os_llvm.h" #include #include #include diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index d05157991b..2c4d7fb6e1 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -29,7 +29,7 @@ #include #include -#include +#include "os/os_llvm.h" #include #include #include diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample.h b/src/gallium/drivers/llvmpipe/lp_tex_sample.h index cb59a94464..799df182b6 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample.h +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample.h @@ -29,7 +29,7 @@ #define LP_TEX_SAMPLE_H -#include +#include "os/os_llvm.h" struct lp_sampler_static_state; -- cgit v1.2.3 From 272f399434ad6b33a8444c287c5126987a222864 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 14:03:33 -0700 Subject: llvmpipe: fix comment typo --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index ea6f056bb0..9a8de0edfd 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -40,7 +40,7 @@ * - depth/stencil test (stencil TBI) * - blending * - * This file has only the glue to assembly the fragment pipeline. The actual + * This file has only the glue to assemble the fragment pipeline. The actual * plumbing of converting Gallium state into LLVM IR is done elsewhere, in the * lp_bld_*.[ch] files, and in a complete generic and reusable way. Here we * muster the LLVM JIT execution engine to create a function that follows an -- cgit v1.2.3 From 53efb634a0c134feebb5a3e47fc33660694be9c3 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 14:46:06 -0700 Subject: gallivm/llvmpipe: replace 'int stride' with 'int row_stride[MAX_LEVELS]' The stride depends on the mipmap level. Rename to row_stride to distinguish from img_stride for 3D textures. Fixes incorrect texel addressing in small mipmap levels. --- src/gallium/auxiliary/gallivm/lp_bld_sample.h | 6 +-- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 50 +++++++++++++++++++---- src/gallium/drivers/llvmpipe/lp_jit.c | 7 ++-- src/gallium/drivers/llvmpipe/lp_jit.h | 4 +- src/gallium/drivers/llvmpipe/lp_setup.c | 3 +- src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c | 4 +- 6 files changed, 54 insertions(+), 20 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h index 9e88ea54d7..7f08bfaac1 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h @@ -113,9 +113,9 @@ struct lp_sampler_dynamic_state unsigned unit); LLVMValueRef - (*stride)( struct lp_sampler_dynamic_state *state, - LLVMBuilderRef builder, - unsigned unit); + (*row_stride)( struct lp_sampler_dynamic_state *state, + LLVMBuilderRef builder, + unsigned unit); LLVMValueRef (*data_ptr)( struct lp_sampler_dynamic_state *state, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 9358ad3860..2fc22fb1fd 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -138,6 +138,34 @@ lp_build_get_const_mipmap_level(struct lp_build_sample_context *bld, } +/** + * Dereference stride_array[mipmap_level] array to get a stride. + * Return stride as a vector. + */ +static LLVMValueRef +lp_build_get_level_stride_vec(struct lp_build_sample_context *bld, + LLVMValueRef stride_array, LLVMValueRef level) +{ + LLVMValueRef indexes[2], stride; + indexes[0] = LLVMConstInt(LLVMInt32Type(), 0, 0); + indexes[1] = level; + stride = LLVMBuildGEP(bld->builder, stride_array, indexes, 2, ""); + stride = LLVMBuildLoad(bld->builder, stride, ""); + stride = lp_build_broadcast_scalar(&bld->int_coord_bld, stride); + return stride; +} + + +/** Dereference stride_array[0] array to get a stride (as vector). */ +static LLVMValueRef +lp_build_get_const_level_stride_vec(struct lp_build_sample_context *bld, + LLVMValueRef stride_array, int level) +{ + LLVMValueRef lvl = LLVMConstInt(LLVMInt32Type(), level, 0); + return lp_build_get_level_stride_vec(bld, stride_array, lvl); +} + + static int texture_dims(enum pipe_texture_target tex) { @@ -1190,7 +1218,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, LLVMValueRef width_vec, LLVMValueRef height_vec, LLVMValueRef depth_vec, - LLVMValueRef row_stride_vec, + LLVMValueRef row_stride_array, LLVMValueRef img_stride_vec, LLVMValueRef data_array, LLVMValueRef *colors_out) @@ -1248,7 +1276,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, width0_vec = lp_build_minify(bld, width_vec, ilevel0_vec); if (dims >= 2) { height0_vec = lp_build_minify(bld, height_vec, ilevel0_vec); - row_stride0_vec = lp_build_minify(bld, row_stride_vec, ilevel0_vec); + row_stride0_vec = lp_build_get_level_stride_vec(bld, row_stride_array, + ilevel0); if (dims == 3) { depth0_vec = lp_build_minify(bld, depth_vec, ilevel0_vec); } @@ -1258,7 +1287,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, width1_vec = lp_build_minify(bld, width_vec, ilevel1_vec); if (dims >= 2) { height1_vec = lp_build_minify(bld, height_vec, ilevel1_vec); - row_stride1_vec = lp_build_minify(bld, row_stride_vec, ilevel1_vec); + row_stride1_vec = lp_build_get_level_stride_vec(bld, row_stride_array, + ilevel1); if (dims == 3) { depth1_vec = lp_build_minify(bld, depth_vec, ilevel1_vec); } @@ -1380,7 +1410,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef t, LLVMValueRef width, LLVMValueRef height, - LLVMValueRef stride, + LLVMValueRef stride_array, LLVMValueRef data_array, LLVMValueRef *texel) { @@ -1397,6 +1427,7 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, LLVMValueRef neighbors_hi[2][2]; LLVMValueRef packed, packed_lo, packed_hi; LLVMValueRef unswizzled[4]; + LLVMValueRef stride; lp_build_context_init(&i32, builder, lp_type_int_vec(32)); lp_build_context_init(&h16, builder, lp_type_ufixed(16)); @@ -1504,6 +1535,8 @@ lp_build_sample_2d_linear_aos(struct lp_build_sample_context *bld, t_fpart_hi = LLVMBuildShuffleVector(builder, t_fpart, h16.undef, shuffle_hi, ""); } + stride = lp_build_get_const_level_stride_vec(bld, stride_array, 0); + /* * Fetch the pixels as 4 x 32bit (rgba order might differ): * @@ -1628,7 +1661,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, LLVMValueRef width, width_vec; LLVMValueRef height, height_vec; LLVMValueRef depth, depth_vec; - LLVMValueRef stride, stride_vec; + LLVMValueRef stride_array; LLVMValueRef data_array; LLVMValueRef s; LLVMValueRef t; @@ -1664,7 +1697,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, width = dynamic_state->width(dynamic_state, builder, unit); height = dynamic_state->height(dynamic_state, builder, unit); depth = dynamic_state->depth(dynamic_state, builder, unit); - stride = dynamic_state->stride(dynamic_state, builder, unit); + stride_array = dynamic_state->row_stride(dynamic_state, builder, unit); data_array = dynamic_state->data_ptr(dynamic_state, builder, unit); /* Note that data_array is an array[level] of pointers to texture images */ @@ -1675,7 +1708,6 @@ lp_build_sample_soa(LLVMBuilderRef builder, width_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, width); height_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, height); depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth); - stride_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, stride); if (lp_format_is_rgba8(bld.format_desc) && static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && @@ -1685,13 +1717,13 @@ lp_build_sample_soa(LLVMBuilderRef builder, is_simple_wrap_mode(static_state->wrap_t)) { /* special case */ lp_build_sample_2d_linear_aos(&bld, s, t, width_vec, height_vec, - stride_vec, data_array, texel); + stride_array, data_array, texel); } else { lp_build_sample_general(&bld, unit, s, t, r, width, height, depth, width_vec, height_vec, depth_vec, - stride_vec, NULL, data_array, + stride_array, NULL, data_array, texel); } diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 08c8f93794..5887613120 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -57,7 +57,8 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) elem_types[LP_JIT_TEXTURE_HEIGHT] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_DEPTH] = LLVMInt32Type(); elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32Type(); - elem_types[LP_JIT_TEXTURE_STRIDE] = LLVMInt32Type(); + elem_types[LP_JIT_TEXTURE_ROW_STRIDE] = + LLVMArrayType(LLVMInt32Type(), LP_MAX_TEXTURE_2D_LEVELS); elem_types[LP_JIT_TEXTURE_DATA] = LLVMArrayType(LLVMPointerType(LLVMInt8Type(), 0), LP_MAX_TEXTURE_2D_LEVELS); @@ -76,9 +77,9 @@ lp_jit_init_globals(struct llvmpipe_screen *screen) LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, last_level, screen->target, texture_type, LP_JIT_TEXTURE_LAST_LEVEL); - LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, stride, + LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, row_stride, screen->target, texture_type, - LP_JIT_TEXTURE_STRIDE); + LP_JIT_TEXTURE_ROW_STRIDE); LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, data, screen->target, texture_type, LP_JIT_TEXTURE_DATA); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.h b/src/gallium/drivers/llvmpipe/lp_jit.h index 5cc7a12c03..13167ae3bf 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.h +++ b/src/gallium/drivers/llvmpipe/lp_jit.h @@ -51,7 +51,7 @@ struct lp_jit_texture uint32_t height; uint32_t depth; uint32_t last_level; - uint32_t stride; + uint32_t row_stride[LP_MAX_TEXTURE_2D_LEVELS]; const void *data[LP_MAX_TEXTURE_2D_LEVELS]; }; @@ -61,7 +61,7 @@ enum { LP_JIT_TEXTURE_HEIGHT, LP_JIT_TEXTURE_DEPTH, LP_JIT_TEXTURE_LAST_LEVEL, - LP_JIT_TEXTURE_STRIDE, + LP_JIT_TEXTURE_ROW_STRIDE, LP_JIT_TEXTURE_DATA }; diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index d6d37c4809..c870f89d01 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -471,13 +471,13 @@ lp_setup_set_sampler_textures( struct setup_context *setup, jit_tex->height = tex->height0; jit_tex->depth = tex->depth0; jit_tex->last_level = tex->last_level; - jit_tex->stride = lp_tex->stride[0]; if (!lp_tex->dt) { /* regular texture - setup array of mipmap level pointers */ int j; for (j = 0; j <= tex->last_level; j++) { jit_tex->data[j] = (ubyte *) lp_tex->data + lp_tex->level_offset[j]; + jit_tex->row_stride[j] = lp_tex->stride[j]; } } else { @@ -490,6 +490,7 @@ lp_setup_set_sampler_textures( struct setup_context *setup, struct sw_winsys *winsys = screen->winsys; jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt, PIPE_BUFFER_USAGE_CPU_READ); + jit_tex->row_stride[0] = lp_tex->stride[0]; assert(jit_tex->data[0]); } diff --git a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c index 5a3cf37d6d..662508af61 100644 --- a/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c +++ b/src/gallium/drivers/llvmpipe/lp_tex_sample_llvm.c @@ -147,7 +147,7 @@ LP_LLVM_TEXTURE_MEMBER(width, LP_JIT_TEXTURE_WIDTH, TRUE) LP_LLVM_TEXTURE_MEMBER(height, LP_JIT_TEXTURE_HEIGHT, TRUE) LP_LLVM_TEXTURE_MEMBER(depth, LP_JIT_TEXTURE_DEPTH, TRUE) LP_LLVM_TEXTURE_MEMBER(last_level, LP_JIT_TEXTURE_LAST_LEVEL, TRUE) -LP_LLVM_TEXTURE_MEMBER(stride, LP_JIT_TEXTURE_STRIDE, TRUE) +LP_LLVM_TEXTURE_MEMBER(row_stride, LP_JIT_TEXTURE_ROW_STRIDE, FALSE) LP_LLVM_TEXTURE_MEMBER(data_ptr, LP_JIT_TEXTURE_DATA, FALSE) @@ -204,7 +204,7 @@ lp_llvm_sampler_soa_create(const struct lp_sampler_static_state *static_state, sampler->dynamic_state.base.height = lp_llvm_texture_height; sampler->dynamic_state.base.depth = lp_llvm_texture_depth; sampler->dynamic_state.base.last_level = lp_llvm_texture_last_level; - sampler->dynamic_state.base.stride = lp_llvm_texture_stride; + sampler->dynamic_state.base.row_stride = lp_llvm_texture_row_stride; sampler->dynamic_state.base.data_ptr = lp_llvm_texture_data_ptr; sampler->dynamic_state.static_state = static_state; sampler->dynamic_state.context_ptr = context_ptr; -- cgit v1.2.3 From 26ae4aab6a7d833cc9c95d70ebe4ee5ba597f591 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 14:42:26 -0700 Subject: gallivm: enable 3D texture sampling --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 2fc22fb1fd..50b61dc224 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1280,6 +1280,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, ilevel0); if (dims == 3) { depth0_vec = lp_build_minify(bld, depth_vec, ilevel0_vec); + img_stride0_vec = lp_build_mul(&bld->int_coord_bld, + row_stride0_vec, height0_vec); } } if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { @@ -1291,6 +1293,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, ilevel1); if (dims == 3) { depth1_vec = lp_build_minify(bld, depth_vec, ilevel1_vec); + img_stride1_vec = lp_build_mul(&bld->int_coord_bld, + row_stride1_vec, height1_vec); } } } @@ -1710,6 +1714,7 @@ lp_build_sample_soa(LLVMBuilderRef builder, depth_vec = lp_build_broadcast_scalar(&bld.uint_coord_bld, depth); if (lp_format_is_rgba8(bld.format_desc) && + static_state->target == PIPE_TEXTURE_2D && static_state->min_img_filter == PIPE_TEX_FILTER_LINEAR && static_state->mag_img_filter == PIPE_TEX_FILTER_LINEAR && static_state->min_mip_filter == PIPE_TEX_MIPFILTER_NONE && -- cgit v1.2.3 From 9ffdc78d1a308bb21a8627abb7bfc9da8abd2f81 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 15:29:11 -0700 Subject: softpipe: tighten up the code in sample_cube() --- src/gallium/drivers/softpipe/sp_tex_sample.c | 100 ++++++++++----------------- 1 file changed, 38 insertions(+), 62 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index ef7ccf4189..1ce21b6ca0 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -1614,7 +1614,6 @@ sample_cube(struct tgsi_sampler *tgsi_sampler, struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler); unsigned j; float ssss[4], tttt[4]; - unsigned face; /* major axis @@ -1628,7 +1627,8 @@ sample_cube(struct tgsi_sampler *tgsi_sampler, -rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz */ - /* First choose the cube face. + /* Choose the cube face and compute new s/t coords for the 2D face. + * * Use the same cube face for all four pixels in the quad. * * This isn't ideal, but if we want to use a different cube face @@ -1648,84 +1648,60 @@ sample_cube(struct tgsi_sampler *tgsi_sampler, if (arx >= ary && arx >= arz) { if (rx >= 0.0F) { - face = PIPE_TEX_FACE_POS_X; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(s[j]); + ssss[j] = (-p[j] * ima + 1.0F) * 0.5F; + tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_POS_X; + } } else { - face = PIPE_TEX_FACE_NEG_X; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(s[j]); + ssss[j] = ( p[j] * ima + 1.0F) * 0.5F; + tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_NEG_X; + } } } else if (ary >= arx && ary >= arz) { if (ry >= 0.0F) { - face = PIPE_TEX_FACE_POS_Y; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(t[j]); + ssss[j] = (s[j] * ima + 1.0F) * 0.5F; + tttt[j] = (p[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_POS_Y; + } } else { - face = PIPE_TEX_FACE_NEG_Y; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(t[j]); + ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; + tttt[j] = (-p[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_NEG_Y; + } } } else { if (rz > 0.0F) { - face = PIPE_TEX_FACE_POS_Z; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(p[j]); + ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; + tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_POS_Z; + } } else { - face = PIPE_TEX_FACE_NEG_Z; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = 1.0 / fabsf(p[j]); + ssss[j] = (-s[j] * ima + 1.0F) * 0.5F; + tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; + samp->faces[j] = PIPE_TEX_FACE_NEG_Z; + } } } } - /* Now compute the 2D _face_ texture coords from the - * 3D _cube_ texture coords. - */ - for (j = 0; j < QUAD_SIZE; j++) { - const float rx = s[j], ry = t[j], rz = p[j]; - const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); - float sc, tc, ma; - - switch (face) { - case PIPE_TEX_FACE_POS_X: - sc = -rz; - tc = -ry; - ma = arx; - break; - case PIPE_TEX_FACE_NEG_X: - sc = rz; - tc = -ry; - ma = arx; - break; - case PIPE_TEX_FACE_POS_Y: - sc = rx; - tc = rz; - ma = ary; - break; - case PIPE_TEX_FACE_NEG_Y: - sc = rx; - tc = -rz; - ma = ary; - break; - case PIPE_TEX_FACE_POS_Z: - sc = rx; - tc = -ry; - ma = arz; - break; - case PIPE_TEX_FACE_NEG_Z: - sc = -rx; - tc = -ry; - ma = arz; - break; - default: - assert(0 && "bad cube face"); - sc = 0.0F; - tc = 0.0F; - ma = 0.0F; - } - - { - const float ima = 1.0 / ma; - ssss[j] = ( sc * ima + 1.0F ) * 0.5F; - tttt[j] = ( tc * ima + 1.0F ) * 0.5F; - samp->faces[j] = face; - } - } - /* In our little pipeline, the compare stage is next. If compare * is not active, this will point somewhere deeper into the * pipeline, eg. to mip_filter or even img_filter. -- cgit v1.2.3 From c72a3b4f2ffe0673e753ad144d1b5557a42c670f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 16:23:36 -0700 Subject: softpipe: further tighen up sample_cube() The code can fairly easily be translated to llvm... --- src/gallium/drivers/softpipe/sp_tex_sample.c | 66 +++++++++------------------- 1 file changed, 21 insertions(+), 45 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index 1ce21b6ca0..fa9e19b282 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -1647,57 +1647,33 @@ sample_cube(struct tgsi_sampler *tgsi_sampler, const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); if (arx >= ary && arx >= arz) { - if (rx >= 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(s[j]); - ssss[j] = (-p[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_X; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(s[j]); - ssss[j] = ( p[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_X; - } + float sign = (rx >= 0.0F) ? 1.0F : -1.0F; + uint face = (rx >= 0.0F) ? PIPE_TEX_FACE_POS_X : PIPE_TEX_FACE_NEG_X; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5F / fabsf(s[j]); + ssss[j] = sign * p[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + samp->faces[j] = face; } } else if (ary >= arx && ary >= arz) { - if (ry >= 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(t[j]); - ssss[j] = (s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (p[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_Y; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(t[j]); - ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-p[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_Y; - } + float sign = (ry >= 0.0F) ? 1.0F : -1.0F; + uint face = (ry >= 0.0F) ? PIPE_TEX_FACE_POS_Y : PIPE_TEX_FACE_NEG_Y; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5F / fabsf(t[j]); + ssss[j] = -s[j] * ima + 0.5F; + tttt[j] = sign * -p[j] * ima + 0.5F; + samp->faces[j] = face; } } else { - if (rz > 0.0F) { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(p[j]); - ssss[j] = ( s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_POS_Z; - } - } - else { - for (j = 0; j < QUAD_SIZE; j++) { - const float ima = 1.0 / fabsf(p[j]); - ssss[j] = (-s[j] * ima + 1.0F) * 0.5F; - tttt[j] = (-t[j] * ima + 1.0F) * 0.5F; - samp->faces[j] = PIPE_TEX_FACE_NEG_Z; - } + float sign = (rz >= 0.0F) ? 1.0F : -1.0F; + uint face = (rz >= 0.0F) ? PIPE_TEX_FACE_POS_Z : PIPE_TEX_FACE_NEG_Z; + for (j = 0; j < QUAD_SIZE; j++) { + const float ima = -0.5 / fabsf(p[j]); + ssss[j] = sign * -s[j] * ima + 0.5F; + tttt[j] = t[j] * ima + 0.5F; + samp->faces[j] = face; } } } -- cgit v1.2.3 From 0b3bb6318ed1be7a6257125d5657b2bc03a75251 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 16:26:12 -0700 Subject: gallivm: added lp_build_sum_vector() --- src/gallium/auxiliary/gallivm/lp_bld_arit.c | 31 +++++++++++++++++++++++++++++ src/gallium/auxiliary/gallivm/lp_bld_arit.h | 4 ++++ 2 files changed, 35 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index f55d2b6d15..90c84c6a4e 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -232,6 +232,37 @@ lp_build_add(struct lp_build_context *bld, } +/** Return the sum of the elements of a */ +LLVMValueRef +lp_build_sum_vector(struct lp_build_context *bld, + LLVMValueRef a) +{ + const struct lp_type type = bld->type; + LLVMValueRef index, res; + int i; + + if (a == bld->zero) + return bld->zero; + if (a == bld->undef) + return bld->undef; + assert(type.length > 1); + + assert(!bld->type.norm); + + index = LLVMConstInt(LLVMInt32Type(), 0, 0); + res = LLVMBuildExtractElement(bld->builder, a, index, ""); + + for (i = 1; i < type.length; i++) { + index = LLVMConstInt(LLVMInt32Type(), i, 0); + res = LLVMBuildAdd(bld->builder, res, + LLVMBuildExtractElement(bld->builder, a, index, ""), + ""); + } + + return res; +} + + /** * Generate a - b */ diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index f14b01e05f..7a10fe1220 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -56,6 +56,10 @@ lp_build_add(struct lp_build_context *bld, LLVMValueRef a, LLVMValueRef b); +LLVMValueRef +lp_build_sum_vector(struct lp_build_context *bld, + LLVMValueRef a); + LLVMValueRef lp_build_sub(struct lp_build_context *bld, LLVMValueRef a, -- cgit v1.2.3 From e574b794853b23816aa5decd17834e135e9c4654 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 11 Mar 2010 16:26:52 -0700 Subject: gallivm: checkpoint WIP cubemap code --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 91 ++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 50b61dc224..a410688350 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -48,6 +48,7 @@ #include "lp_bld_logic.h" #include "lp_bld_swizzle.h" #include "lp_bld_pack.h" +#include "lp_bld_flow.h" #include "lp_bld_format.h" #include "lp_bld_sample.h" @@ -1200,6 +1201,93 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld, } +/** + * Generate code to do cube face selection and per-face texcoords. + */ +static void +lp_build_cube_lookup(struct lp_build_sample_context *bld, + LLVMValueRef s, + LLVMValueRef t, + LLVMValueRef r, + LLVMValueRef *face, + LLVMValueRef *face_s, + LLVMValueRef *face_t) +{ +#if 0 + struct lp_build_context *float_bld = &bld->float_bld; + LLVMValueRef rx, ry, rz; + LLVMValueRef arx, ary, arz; + LLVMValueRef sc, tc, ma; + LLVMValueRef c25 = LLVMConstReal(LLVMFloatType(), 0.25); + LLVMValueRef arx_ge_ary, arx_ge_arz; + LLVMValueRef ary_ge_arx, ary_ge_arz; + LLVMValueRef arx_ge_ary_arz, ary_ge_arx_arz; + LLVMValueRef rx_pos, ry_pos, rz_pos; + + assert(bld->coord_bld.type.length == 4); + + /* + * Use the average of the four pixel's texcoords to choose the face. + */ + rx = lp_build_mul(float_bld, c25, + lp_build_sum_vector(&bld->coord_bld, s)); + ry = lp_build_mul(float_bld, c25, + lp_build_sum_vector(&bld->coord_bld, t)); + rz = lp_build_mul(float_bld, c25, + lp_build_sum_vector(&bld->coord_bld, r)); + + arx = lp_build_abs(float_bld, rx); + ary = lp_build_abs(float_bld, ry); + arz = lp_build_abs(float_bld, rz); + + /* + * Compare sign/magnitude of rx,ry,rz to determine face + */ + arx_ge_ary = LLVMBuildFCmp(bld->builder, LLVMRealUGE, arx, ary, ""); + arx_ge_arz = LLVMBuildFCmp(bld->builder, LLVMRealUGE, arx, arz, ""); + ary_ge_arx = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ary, arx, ""); + ary_ge_arz = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ary, arz, ""); + + arx_ge_ary_arz = LLVMBuildAnd(bld->builder, arx_ge_ary, arx_ge_arz, ""); + ary_ge_arx_arz = LLVMBuildAnd(bld->builder, ary_ge_arx, ary_ge_arz, ""); + + rx_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, rx, float_bld->zero, ""); + ry_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, ry, float_bld->zero, ""); + rz_pos = LLVMBuildFCmp(bld->builder, LLVMRealUGE, rz, float_bld->zero, ""); + + { + struct lp_build_flow_context *flow_ctx; + struct lp_build_if_state if_ctx, if2_ctx; + + flow_ctx = lp_build_flow_create(bld->builder); + + lp_build_if(&if_ctx, flow_ctx, bld->builder, arx_ge_ary_arz); + { +#if 0 + lp_build_if(&if2_ctx, flow_ctx, bld->builder, rx_pos); + { + /* Positive X face */ + } + lp_build_else(&if2_ctx); + { + /* Negative X face */ + } + lp_build_endif(&if2_ctx); +#endif + } + lp_build_else(&if_ctx); + { + + + } + lp_build_endif(&if_ctx); + + lp_build_flow_destroy(flow_ctx); + } +#endif +} + + /** * General texture sampling codegen. @@ -1303,7 +1391,8 @@ lp_build_sample_general(struct lp_build_sample_context *bld, * Choose cube face, recompute texcoords. */ if (bld->static_state->target == PIPE_TEXTURE_CUBE) { - + LLVMValueRef face, face_s, face_t; + lp_build_cube_lookup(bld, s, t, r, &face, &face_s, &face_t); } /* -- cgit v1.2.3 From e4d10dada0a04245a444257112b2f0df7372e76d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Thu, 11 Mar 2010 20:52:38 -0800 Subject: llvmpipe: Remove unnecessary header. --- src/gallium/drivers/llvmpipe/lp_buffer.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/llvmpipe/lp_buffer.c b/src/gallium/drivers/llvmpipe/lp_buffer.c index dab20cb639..6e0f37393e 100644 --- a/src/gallium/drivers/llvmpipe/lp_buffer.c +++ b/src/gallium/drivers/llvmpipe/lp_buffer.c @@ -33,7 +33,6 @@ #include "lp_screen.h" #include "lp_buffer.h" -#include "state_tracker/sw_winsys.h" static void * llvmpipe_buffer_map(struct pipe_screen *screen, -- cgit v1.2.3 From e42b2f768509b6984c7186805c6a8afdaebf3a06 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 12 Mar 2010 02:47:44 -0800 Subject: r300g: Properly clamp index limits. Make the kernel even less likely to barf on us. --- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 9c001ae186..ef1b7510e1 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -280,7 +280,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); - maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); + maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, (1 << 24) - 1); if (alt_num_verts) { BEGIN_CS(15); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index bd4c2766cb..ced6c810ec 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1031,7 +1031,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, const struct pipe_vertex_buffer* buffers) { struct r300_context* r300 = r300_context(pipe); - unsigned i, max_index = ~0; + unsigned i, max_index = (1 << 24) - 1; memcpy(r300->vertex_buffer, buffers, sizeof(struct pipe_vertex_buffer) * count); -- cgit v1.2.3 From c16d04bd2939154c0360f1ac51fe61a86e5dd9e5 Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Tue, 9 Mar 2010 01:55:42 +0000 Subject: gallium: fix BGRA vertex color swizzles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The mapping for vertex_array_bgra: (gl -> st -> translate) GL_RGBA -> PIPE_FORMAT_R8G8B8A8 (RGBA) -> no swizzle (XYZW) GL_BGRA -> PIPE_FORMAT_A8R8G8B8 (ARGB) -> ZYXW (BGRA again??) Iẗ́'s pretty clear that PIPE_FORMAT_A8R8G8B8 here is wrong. This commit fixes the pipe format and removes obvious workarounds in util/translate. Tested with: softpipe, llvmpipe, r300g. Signed-off-by: José Fonseca --- src/gallium/auxiliary/translate/translate_generic.c | 8 ++++---- src/gallium/auxiliary/translate/translate_sse.c | 4 ++-- src/mesa/state_tracker/st_draw.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/auxiliary/translate/translate_generic.c b/src/gallium/auxiliary/translate/translate_generic.c index c9ec2b32bf..c3ec9ae3f4 100644 --- a/src/gallium/auxiliary/translate/translate_generic.c +++ b/src/gallium/auxiliary/translate/translate_generic.c @@ -393,10 +393,10 @@ static fetch_func get_fetch_func( enum pipe_format format ) return &fetch_R8G8B8A8_SSCALED; case PIPE_FORMAT_B8G8R8A8_UNORM: - return &fetch_A8R8G8B8_UNORM; + return &fetch_B8G8R8A8_UNORM; case PIPE_FORMAT_A8R8G8B8_UNORM: - return &fetch_B8G8R8A8_UNORM; + return &fetch_A8R8G8B8_UNORM; case PIPE_FORMAT_R32_FIXED: return &fetch_R32_FIXED; @@ -552,10 +552,10 @@ static emit_func get_emit_func( enum pipe_format format ) return &emit_R8G8B8A8_SSCALED; case PIPE_FORMAT_B8G8R8A8_UNORM: - return &emit_A8R8G8B8_UNORM; + return &emit_B8G8R8A8_UNORM; case PIPE_FORMAT_A8R8G8B8_UNORM: - return &emit_B8G8R8A8_UNORM; + return &emit_A8R8G8B8_UNORM; default: assert(0); diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index 03e093c11e..c13e742738 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -336,7 +336,7 @@ static boolean translate_attr( struct translate_sse *p, case PIPE_FORMAT_R32G32B32A32_FLOAT: emit_load_R32G32B32A32(p, dataXMM, srcECX); break; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: emit_load_R8G8B8A8_UNORM(p, dataXMM, srcECX); emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W)); break; @@ -360,7 +360,7 @@ static boolean translate_attr( struct translate_sse *p, case PIPE_FORMAT_R32G32B32A32_FLOAT: emit_store_R32G32B32A32(p, dstEAX, dataXMM); break; - case PIPE_FORMAT_A8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8A8_UNORM: emit_swizzle(p, dataXMM, dataXMM, SHUF(Z,Y,X,W)); emit_store_R8G8B8A8_UNORM(p, dstEAX, dataXMM); break; diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index d81b3611b7..c473815c41 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -184,7 +184,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, /* this is an odd-ball case */ assert(type == GL_UNSIGNED_BYTE); assert(normalized); - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; } if (normalized) { -- cgit v1.2.3 From 475ab3b5aff71edd95776783dd65417006db951f Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Mar 2010 12:13:32 +0000 Subject: st/xorg: context transfers --- src/gallium/state_trackers/xorg/xorg_crtc.c | 14 ++++----- src/gallium/state_trackers/xorg/xorg_exa.c | 24 +++++++-------- src/gallium/state_trackers/xorg/xorg_xv.c | 46 ++++++++++++++--------------- 3 files changed, 42 insertions(+), 42 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index f60e9abb76..eef428232b 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -220,16 +220,16 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) crtcp->cursor_handle = whandle.handle; } - transfer = ms->screen->get_tex_transfer(ms->screen, crtcp->cursor_tex, - 0, 0, 0, - PIPE_TRANSFER_WRITE, - 0, 0, 64, 64); - ptr = ms->screen->transfer_map(ms->screen, transfer); + transfer = ms->ctx->get_tex_transfer(ms->ctx, crtcp->cursor_tex, + 0, 0, 0, + PIPE_TRANSFER_WRITE, + 0, 0, 64, 64); + ptr = ms->ctx->transfer_map(ms->ctx, transfer); util_copy_rect(ptr, crtcp->cursor_tex->format, transfer->stride, 0, 0, 64, 64, (void*)image, 64 * 4, 0, 0); - ms->screen->transfer_unmap(ms->screen, transfer); - ms->screen->tex_transfer_destroy(transfer); + ms->ctx->transfer_unmap(ms->ctx, transfer); + ms->ctx->tex_transfer_destroy(ms->ctx, transfer); } #if HAVE_LIBKMS diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index a7ffe3f499..b5e7adc26e 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -192,7 +192,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst, PIPE_REFERENCED_FOR_WRITE) exa->pipe->flush(exa->pipe, 0, NULL); - transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, + transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0, PIPE_TRANSFER_READ, x, y, w, h); if (!transfer) return FALSE; @@ -203,11 +203,11 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst, #endif util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0, - w, h, exa->scrn->transfer_map(exa->scrn, transfer), + w, h, exa->pipe->transfer_map(exa->pipe, transfer), transfer->stride, 0, 0); - exa->scrn->transfer_unmap(exa->scrn, transfer); - exa->scrn->tex_transfer_destroy(transfer); + exa->pipe->transfer_unmap(exa->pipe, transfer); + exa->pipe->tex_transfer_destroy(exa->pipe, transfer); return TRUE; } @@ -231,7 +231,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src, (PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE)) xorg_exa_flush(exa, 0, NULL); - transfer = exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, + transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0, PIPE_TRANSFER_WRITE, x, y, w, h); if (!transfer) return FALSE; @@ -241,12 +241,12 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src, x, y, w, h, src_pitch); #endif - util_copy_rect(exa->scrn->transfer_map(exa->scrn, transfer), + util_copy_rect(exa->pipe->transfer_map(exa->pipe, transfer), priv->tex->format, transfer->stride, 0, 0, w, h, (unsigned char*)src, src_pitch, 0, 0); - exa->scrn->transfer_unmap(exa->scrn, transfer); - exa->scrn->tex_transfer_destroy(transfer); + exa->pipe->transfer_unmap(exa->pipe, transfer); + exa->pipe->tex_transfer_destroy(exa->pipe, transfer); return TRUE; } @@ -278,7 +278,7 @@ ExaPrepareAccess(PixmapPtr pPix, int index) assert(pPix->drawable.height <= priv->tex->height0); priv->map_transfer = - exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0, + exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0, #ifdef EXA_MIXED_PIXMAPS PIPE_TRANSFER_MAP_DIRECTLY | #endif @@ -294,7 +294,7 @@ ExaPrepareAccess(PixmapPtr pPix, int index) #endif pPix->devPrivate.ptr = - exa->scrn->transfer_map(exa->scrn, priv->map_transfer); + exa->pipe->transfer_map(exa->pipe, priv->map_transfer); pPix->devKind = priv->map_transfer->stride; } @@ -321,8 +321,8 @@ ExaFinishAccess(PixmapPtr pPix, int index) if (--priv->map_count == 0) { assert(priv->map_transfer); - exa->scrn->transfer_unmap(exa->scrn, priv->map_transfer); - exa->scrn->tex_transfer_destroy(priv->map_transfer); + exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer); + exa->pipe->tex_transfer_destroy(exa->pipe, priv->map_transfer); priv->map_transfer = NULL; pPix->devPrivate.ptr = NULL; } diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c index e37a1c3959..5a195cb482 100644 --- a/src/gallium/state_trackers/xorg/xorg_xv.c +++ b/src/gallium/state_trackers/xorg/xorg_xv.c @@ -275,28 +275,28 @@ copy_packed_data(ScrnInfoPtr pScrn, int i, j; struct pipe_texture **dst = port->yuv[port->current_set]; struct pipe_transfer *ytrans, *utrans, *vtrans; - struct pipe_screen *screen = port->r->pipe->screen; + struct pipe_context *pipe = port->r->pipe; char *ymap, *vmap, *umap; unsigned char y1, y2, u, v; int yidx, uidx, vidx; int y_array_size = w * h; - ytrans = screen->get_tex_transfer(screen, dst[0], - 0, 0, 0, - PIPE_TRANSFER_WRITE, - left, top, w, h); - utrans = screen->get_tex_transfer(screen, dst[1], - 0, 0, 0, - PIPE_TRANSFER_WRITE, - left, top, w, h); - vtrans = screen->get_tex_transfer(screen, dst[2], - 0, 0, 0, - PIPE_TRANSFER_WRITE, - left, top, w, h); - - ymap = (char*)screen->transfer_map(screen, ytrans); - umap = (char*)screen->transfer_map(screen, utrans); - vmap = (char*)screen->transfer_map(screen, vtrans); + ytrans = pipe->get_tex_transfer(pipe, dst[0], + 0, 0, 0, + PIPE_TRANSFER_WRITE, + left, top, w, h); + utrans = pipe->get_tex_transfer(pipe, dst[1], + 0, 0, 0, + PIPE_TRANSFER_WRITE, + left, top, w, h); + vtrans = pipe->get_tex_transfer(pipe, dst[2], + 0, 0, 0, + PIPE_TRANSFER_WRITE, + left, top, w, h); + + ymap = (char*)pipe->transfer_map(pipe, ytrans); + umap = (char*)pipe->transfer_map(pipe, utrans); + vmap = (char*)pipe->transfer_map(pipe, vtrans); yidx = uidx = vidx = 0; @@ -362,12 +362,12 @@ copy_packed_data(ScrnInfoPtr pScrn, break; } - screen->transfer_unmap(screen, ytrans); - screen->transfer_unmap(screen, utrans); - screen->transfer_unmap(screen, vtrans); - screen->tex_transfer_destroy(ytrans); - screen->tex_transfer_destroy(utrans); - screen->tex_transfer_destroy(vtrans); + pipe->transfer_unmap(pipe, ytrans); + pipe->transfer_unmap(pipe, utrans); + pipe->transfer_unmap(pipe, vtrans); + pipe->tex_transfer_destroy(pipe, ytrans); + pipe->tex_transfer_destroy(pipe, utrans); + pipe->tex_transfer_destroy(pipe, vtrans); } -- cgit v1.2.3 From fab1f07d6ad01463897ae792f4b33738afb07369 Mon Sep 17 00:00:00 2001 From: Jeff Smith Date: Fri, 13 Jun 2008 09:50:43 -0500 Subject: Grammar and spelling fixes Signed-off-by: Jeff Smith Signed-off-by: Brian Paul --- docs/README.3DFX | 2 +- docs/egl.html | 2 +- progs/objviewer/glm.c | 2 +- progs/objviewer/glm.h | 2 +- progs/tests/vao-01.c | 2 +- progs/tests/vao-02.c | 2 +- src/gallium/auxiliary/os/os_time.h | 2 +- src/gallium/drivers/cell/ppu/cell_gen_fragment.c | 2 +- src/gallium/drivers/cell/ppu/cell_spu.c | 2 +- src/gallium/drivers/nv40/nv40_vertprog.c | 2 +- src/gallium/drivers/r300/r300_reg.h | 4 ++-- src/gallium/state_trackers/wgl/stw_framebuffer.h | 2 +- src/glu/sgi/libnurbs/nurbtess/partitionY.h | 2 +- src/glu/sgi/libtess/normal.c | 2 +- src/mesa/drivers/dri/common/dri_util.c | 2 +- src/mesa/drivers/dri/r128/r128_tex.c | 2 +- src/mesa/drivers/dri/r200/r200_reg.h | 2 +- src/mesa/drivers/dri/r300/r300_reg.h | 4 ++-- src/mesa/drivers/dri/radeon/radeon_state.c | 2 +- src/mesa/drivers/x11/xmesa.h | 2 +- src/mesa/drivers/x11/xmesaP.h | 2 +- src/mesa/main/dd.h | 2 +- src/mesa/main/texcompress_fxt1.c | 2 +- src/mesa/math/m_debug_util.h | 2 +- src/mesa/math/m_matrix.c | 2 +- src/mesa/shader/prog_instruction.h | 4 ++-- src/mesa/shader/program_parser.h | 2 +- src/mesa/shader/slang/library/slang_common_builtin.gc | 2 +- src/mesa/swrast/s_depth.c | 2 +- src/mesa/vbo/vbo_save_loopback.c | 2 +- 30 files changed, 33 insertions(+), 33 deletions(-) (limited to 'src/gallium') diff --git a/docs/README.3DFX b/docs/README.3DFX index 037e8fa7cc..7feda6f33f 100644 --- a/docs/README.3DFX +++ b/docs/README.3DFX @@ -644,7 +644,7 @@ Hints and Special Features: - The Voodoo driver supports the GL_EXT_paletted_texture. it works only with GL_COLOR_INDEX8_EXT, GL_RGBA palettes and the alpha value - is ignored because this is a limitation of the the current Glide + is ignored because this is a limitation of the current Glide version and of the Voodoo hardware. See Mesa-3.1/3Dfx/demos/paltex.c for a demo of this extension. diff --git a/docs/egl.html b/docs/egl.html index 82cc06600b..55907f6cfa 100644 --- a/docs/egl.html +++ b/docs/egl.html @@ -28,7 +28,7 @@ cards.

  1. -

    Run configure with the desired state trackers and and enable +

    Run configure with the desired state trackers and enable the Gallium driver for your hardware. For example

    diff --git a/progs/objviewer/glm.c b/progs/objviewer/glm.c
    index 7c964e489d..77e62bfab1 100644
    --- a/progs/objviewer/glm.c
    +++ b/progs/objviewer/glm.c
    @@ -1041,7 +1041,7 @@ glmFacetNormals(GLMmodel* model)
     
     /* glmVertexNormals: Generates smooth vertex normals for a model.
      * First builds a list of all the triangles each vertex is in.  Then
    - * loops through each vertex in the the list averaging all the facet
    + * loops through each vertex in the list averaging all the facet
      * normals of the triangles each vertex is in.  Finally, sets the
      * normal index in the triangle for the vertex to the generated smooth
      * normal.  If the dot product of a facet normal and the facet normal
    diff --git a/progs/objviewer/glm.h b/progs/objviewer/glm.h
    index 8740b3684d..1a5646fa4c 100644
    --- a/progs/objviewer/glm.h
    +++ b/progs/objviewer/glm.h
    @@ -153,7 +153,7 @@ glmFacetNormals(GLMmodel* model);
     
     /* glmVertexNormals: Generates smooth vertex normals for a model.
      * First builds a list of all the triangles each vertex is in.  Then
    - * loops through each vertex in the the list averaging all the facet
    + * loops through each vertex in the list averaging all the facet
      * normals of the triangles each vertex is in.  Finally, sets the
      * normal index in the triangle for the vertex to the generated smooth
      * normal.  If the dot product of a facet normal and the facet normal
    diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c
    index e4a89cb19d..ee528d2243 100644
    --- a/progs/tests/vao-01.c
    +++ b/progs/tests/vao-01.c
    @@ -30,7 +30,7 @@
      * it (via \c glPopClientAttrib).  After popping, the state of the VAO is
      * examined.
      * 
    - * According the the APPLE_vertex_array_object spec, the contents of the VAO
    + * According to the APPLE_vertex_array_object spec, the contents of the VAO
      * should be restored to the values that they had when pushed.
      * 
      * \author Ian Romanick 
    diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c
    index 9f7f5c2779..c23b4ab05a 100644
    --- a/progs/tests/vao-02.c
    +++ b/progs/tests/vao-02.c
    @@ -30,7 +30,7 @@
      * it (via \c glPopClientAttrib).  After popping, the state of the VAO is
      * examined.
      * 
    - * According the the APPLE_vertex_array_object spec, the contents of the VAO
    + * According to the APPLE_vertex_array_object spec, the contents of the VAO
      * should be restored to the values that they had when pushed.
      * 
      * \author Ian Romanick 
    diff --git a/src/gallium/auxiliary/os/os_time.h b/src/gallium/auxiliary/os/os_time.h
    index 5b55c1b374..7e0f67a76b 100644
    --- a/src/gallium/auxiliary/os/os_time.h
    +++ b/src/gallium/auxiliary/os/os_time.h
    @@ -71,7 +71,7 @@ os_time_sleep(int64_t usecs);
     /*
      * Helper function for detecting time outs, taking in account overflow.
      *
    - * Returns true the the current time has elapsed beyond the specified interval.
    + * Returns true if the current time has elapsed beyond the specified interval.
      */
     static INLINE boolean
     os_time_timeout(int64_t start,
    diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
    index 576d514741..c54576b3c3 100644
    --- a/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
    +++ b/src/gallium/drivers/cell/ppu/cell_gen_fragment.c
    @@ -1352,7 +1352,7 @@ gen_stencil_values(struct spe_function *f,
         */
        ASSERT(fbS_reg != newS_reg);
     
    -   /* The code also assumes the the stencil_max_value is of the form 
    +   /* The code also assumes that the stencil_max_value is of the form
         * 2^n-1 and can therefore be used as a mask for the valid bits in 
         * addition to a maximum.  Make sure this is the case as well.
         * The clever math below exploits the fact that incrementing a 
    diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c
    index 28e5e6d706..39284f3a5d 100644
    --- a/src/gallium/drivers/cell/ppu/cell_spu.c
    +++ b/src/gallium/drivers/cell/ppu/cell_spu.c
    @@ -135,7 +135,7 @@ cell_thread_function(void *arg)
     
     /**
      * Create the SPU threads.  This is done once during driver initialization.
    - * This involves setting the the "init" message which is sent to each SPU.
    + * This involves setting 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.
      */
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    index b289eef0fc..c93c5d127c 100644
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ b/src/gallium/drivers/nv40/nv40_vertprog.c
    @@ -742,7 +742,7 @@ nv40_vertprog_translate(struct nv40_context *nv40,
     	}
     
     	/* Redirect post-transform vertex position to a temp if user clip
    -	 * planes are enabled.  We need to append code the the vtxprog
    +	 * planes are enabled.  We need to append code to the vtxprog
     	 * to handle clip planes later.
     	 */
     	if (vp->ucp.nr)  {
    diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
    index a249e8b36b..c67cc86871 100644
    --- a/src/gallium/drivers/r300/r300_reg.h
    +++ b/src/gallium/drivers/r300/r300_reg.h
    @@ -540,7 +540,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
     #       define R300_PVS_FIRST_INST(x)            ((x) << 0)
     #       define R300_PVS_XYZW_VALID_INST(x)       ((x) << 10)
     #       define R300_PVS_LAST_INST(x)             ((x) << 20)
    -/* Addresses are relative the the vertex program parameters area. */
    +/* Addresses are relative to the vertex program parameters area. */
     #define R300_VAP_PVS_CONST_CNTL             0x22D4
     #       define R300_PVS_CONST_BASE_OFFSET_SHIFT  0
     #       define R300_PVS_MAX_CONST_ADDR_SHIFT     16
    @@ -1857,7 +1857,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
      * The destination register index is in FPI1 (color) and FPI3 (alpha)
      * together with enable bits.
      * There are separate enable bits for writing into temporary registers
    - * (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_*
    + * (DSTC_REG_* /DSTA_REG) and program output registers (DSTC_OUTPUT_*
      * /DSTA_OUTPUT). You can write to both at once, or not write at all (the
      * same index must be used for both).
      *
    diff --git a/src/gallium/state_trackers/wgl/stw_framebuffer.h b/src/gallium/state_trackers/wgl/stw_framebuffer.h
    index 08cc4973bc..e61e9bf9c2 100644
    --- a/src/gallium/state_trackers/wgl/stw_framebuffer.h
    +++ b/src/gallium/state_trackers/wgl/stw_framebuffer.h
    @@ -45,7 +45,7 @@ struct stw_framebuffer
        /**
         * This mutex has two purposes:
         * - protect the access to the mutable data members below
    -    * - prevent the the framebuffer from being deleted while being accessed.
    +    * - prevent the framebuffer from being deleted while being accessed.
         * 
         * It is OK to lock this mutex while holding the stw_device::fb_mutex lock, 
         * but the opposite must never happen.
    diff --git a/src/glu/sgi/libnurbs/nurbtess/partitionY.h b/src/glu/sgi/libnurbs/nurbtess/partitionY.h
    index 8dda409de1..5570c183d7 100644
    --- a/src/glu/sgi/libnurbs/nurbtess/partitionY.h
    +++ b/src/glu/sgi/libnurbs/nurbtess/partitionY.h
    @@ -39,7 +39,7 @@
      *or both at or below v. In addition, at least one of the ajacent verteces is
      *strictly below or above v. 
      * A vertex is a relex vertex if the internals angle is strictly greater than 
    - *180. In other words, if the the signed area is negative:
    + *180. In other words, if the signed area is negative:
      *(x1, y1), (x2, y2), (x3, y3) are the three vertices along a polygon, the 
      *order is such that left hand side is inside the polygon. Then (x2,y2) is
      *reflex if: 
    diff --git a/src/glu/sgi/libtess/normal.c b/src/glu/sgi/libtess/normal.c
    index 0a2494be34..7ab83167bb 100644
    --- a/src/glu/sgi/libtess/normal.c
    +++ b/src/glu/sgi/libtess/normal.c
    @@ -142,7 +142,7 @@ static void CheckOrientation( GLUtesselator *tess )
       GLUhalfEdge *e;
     
       /* When we compute the normal automatically, we choose the orientation
    -   * so that the the sum of the signed areas of all contours is non-negative.
    +   * so that the sum of the signed areas of all contours is non-negative.
        */
       area = 0;
       for( f = fHead->next; f != fHead; f = f->next ) {
    diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c
    index 890ae51339..75c98825b7 100644
    --- a/src/mesa/drivers/dri/common/dri_util.c
    +++ b/src/mesa/drivers/dri/common/dri_util.c
    @@ -698,7 +698,7 @@ setupLoaderExtensions(__DRIscreen *psp,
      * \param drm_version Version of the kernel DRM.
      * \param frame_buffer Data describing the location and layout of the
      *                     framebuffer.
    - * \param pSAREA       Pointer the the SAREA.
    + * \param pSAREA       Pointer to the SAREA.
      * \param fd           Device handle for the DRM.
      * \param extensions   ??
      * \param driver_modes  Returns modes suppoted by the driver
    diff --git a/src/mesa/drivers/dri/r128/r128_tex.c b/src/mesa/drivers/dri/r128/r128_tex.c
    index 24fbf8f519..4ec4be9a47 100644
    --- a/src/mesa/drivers/dri/r128/r128_tex.c
    +++ b/src/mesa/drivers/dri/r128/r128_tex.c
    @@ -468,7 +468,7 @@ static void r128TexEnv( GLcontext *ctx, GLenum target,
     	  * certain point.  It is better than completely ignoring the LOD
     	  * bias.  Unfortunately there isn't much range in the bias, the
     	  * spec mentions strides that vary between 0.5 and 2.0 but these
    -	  * numbers don't seem to relate the the GL LOD bias value at all.
    +	  * numbers don't seem to relate to the GL LOD bias value at all.
     	  */
     	 if ( param[0] >= 1.0 ) {
     	    bias = -128;
    diff --git a/src/mesa/drivers/dri/r200/r200_reg.h b/src/mesa/drivers/dri/r200/r200_reg.h
    index 59115212ce..b3a4940a7a 100644
    --- a/src/mesa/drivers/dri/r200/r200_reg.h
    +++ b/src/mesa/drivers/dri/r200/r200_reg.h
    @@ -690,7 +690,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
     #       define R200_PVS_CNTL_1_PROGRAM_START_SHIFT   0
     #       define R200_PVS_CNTL_1_POS_END_SHIFT         10
     #       define R200_PVS_CNTL_1_PROGRAM_END_SHIFT     20
    -/* Addresses are relative the the vertex program parameters area. */
    +/* Addresses are relative to the vertex program parameters area. */
     #define R200_VAP_PVS_CNTL_2                 0x22d4
     #       define R200_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0
     #       define R200_PVS_CNTL_2_PARAM_COUNT_SHIFT  16
    diff --git a/src/mesa/drivers/dri/r300/r300_reg.h b/src/mesa/drivers/dri/r300/r300_reg.h
    index d18ebab8ff..ac93563ed9 100644
    --- a/src/mesa/drivers/dri/r300/r300_reg.h
    +++ b/src/mesa/drivers/dri/r300/r300_reg.h
    @@ -482,7 +482,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
     #       define R300_PVS_FIRST_INST_SHIFT         0
     #       define R300_PVS_XYZW_VALID_INST_SHIFT    10
     #       define R300_PVS_LAST_INST_SHIFT          20
    -/* Addresses are relative the the vertex program parameters area. */
    +/* Addresses are relative to the vertex program parameters area. */
     #define R300_VAP_PVS_CONST_CNTL             0x22D4
     #       define R300_PVS_CONST_BASE_OFFSET_SHIFT  0
     #       define R300_PVS_MAX_CONST_ADDR_SHIFT     16
    @@ -1760,7 +1760,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
      * The destination register index is in FPI1 (color) and FPI3 (alpha)
      * together with enable bits.
      * There are separate enable bits for writing into temporary registers
    - * (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_*
    + * (DSTC_REG_* /DSTA_REG) and program output registers (DSTC_OUTPUT_*
      * /DSTA_OUTPUT). You can write to both at once, or not write at all (the
      * same index must be used for both).
      *
    diff --git a/src/mesa/drivers/dri/radeon/radeon_state.c b/src/mesa/drivers/dri/radeon/radeon_state.c
    index 0ce97e8697..583751d64d 100644
    --- a/src/mesa/drivers/dri/radeon/radeon_state.c
    +++ b/src/mesa/drivers/dri/radeon/radeon_state.c
    @@ -1900,7 +1900,7 @@ void radeonUploadTexMatrix( r100ContextPtr rmesa,
        So: if we need the q coord in the end (solely determined by the texture
        target, i.e. 2d / 1d / texrect targets) we swap the third and 4th row.
        Additionally, if we don't have texgen but 4 tex coords submitted, we swap
    -   column 3 and 4 (for the 2d / 1d / texrect targets) since the the q coord
    +   column 3 and 4 (for the 2d / 1d / texrect targets) since the q coord
        will get submitted in the "wrong", i.e. 3rd, slot.
        If an app submits 3 coords for 2d targets, we assume it is saving on vertex
        size and using the texture matrix to swap the r and q coords around (ut2k3
    diff --git a/src/mesa/drivers/x11/xmesa.h b/src/mesa/drivers/x11/xmesa.h
    index 98139af833..f63626a970 100644
    --- a/src/mesa/drivers/x11/xmesa.h
    +++ b/src/mesa/drivers/x11/xmesa.h
    @@ -287,7 +287,7 @@ extern void XMesaCopySubBuffer( XMesaBuffer b,
     
     
     /*
    - * Return a pointer to the the Pixmap or XImage being used as the back
    + * Return a pointer to the Pixmap or XImage being used as the back
      * color buffer of an XMesaBuffer.  This function is a way to get "under
      * the hood" of X/Mesa so one can manipulate the back buffer directly.
      * Input:  b - the XMesaBuffer
    diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h
    index 3ffd7661e3..e0a6908228 100644
    --- a/src/mesa/drivers/x11/xmesaP.h
    +++ b/src/mesa/drivers/x11/xmesaP.h
    @@ -431,7 +431,7 @@ extern const int xmesa_kernel8[DITH_DY * DITH_DX];
      * If pixelformat==PF_HPCR:
      *
      *      HP Color Recovery dithering               (ad@lms.be 30/08/95)
    - *      HP has on it's 8-bit 700-series computers, a feature called
    + *      HP has on its 8-bit 700-series computers, a feature called
      *      'Color Recovery'.  This allows near 24-bit output (so they say).
      *      It is enabled by selecting the 8-bit  TrueColor  visual AND
      *      corresponding  colormap (see tkInitWindow) AND doing some special
    diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
    index 197de09b22..7c02faaa53 100644
    --- a/src/mesa/main/dd.h
    +++ b/src/mesa/main/dd.h
    @@ -1072,7 +1072,7 @@ struct dd_function_table {
      * These are the initial values to be installed into dispatch by
      * mesa.  If the T&L driver wants to modify the dispatch table
      * while installed, it must do so itself.  It would be possible for
    - * the vertexformat to install it's own initial values for these
    + * the vertexformat to install its own initial values for these
      * functions, but this way there is an obvious list of what is
      * expected of the driver.
      *
    diff --git a/src/mesa/main/texcompress_fxt1.c b/src/mesa/main/texcompress_fxt1.c
    index 149853f7ac..04acf05e52 100644
    --- a/src/mesa/main/texcompress_fxt1.c
    +++ b/src/mesa/main/texcompress_fxt1.c
    @@ -476,7 +476,7 @@ fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
         *     for each sample color
         *         sort to nearest vector.
         *
    -    *     replace each vector with the centroid of it's matching colors.
    +    *     replace each vector with the centroid of its matching colors.
         *
         *     repeat until RMS doesn't improve.
         *
    diff --git a/src/mesa/math/m_debug_util.h b/src/mesa/math/m_debug_util.h
    index 2e67db8e55..ed11c849ec 100644
    --- a/src/mesa/math/m_debug_util.h
    +++ b/src/mesa/math/m_debug_util.h
    @@ -61,7 +61,7 @@ extern long counter_overhead;
      */
     extern char *mesa_profile;
     
    -/* Modify the the number of tests if you like.
    +/* Modify the number of tests if you like.
      * We take the minimum of all results, because every error should be
      * positive (time used by other processes, task switches etc).
      * It is assumed that all calculations are done in the cache.
    diff --git a/src/mesa/math/m_matrix.c b/src/mesa/math/m_matrix.c
    index ef8a40fbec..4b33d0bbb3 100644
    --- a/src/mesa/math/m_matrix.c
    +++ b/src/mesa/math/m_matrix.c
    @@ -889,7 +889,7 @@ _math_matrix_rotate( GLmatrix *mat,
            *  Y-axis to bring the axis vector parallel with the X-axis.  The
            *  rotation about the X-axis is then performed.  Ry and Rz are
            *  simply the respective inverse transforms to bring the arbitrary
    -       *  axis back to it's original orientation.  The first transforms
    +       *  axis back to its original orientation.  The first transforms
            *  Rz' and Ry' are considered inverses, since the data from the
            *  arbitrary axis gives you info on how to get to it, not how
            *  to get away from it, and an inverse must be applied.
    diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h
    index 224350caac..28c797a4ba 100644
    --- a/src/mesa/shader/prog_instruction.h
    +++ b/src/mesa/shader/prog_instruction.h
    @@ -97,8 +97,8 @@
     #define COND_EQ  2  /**< equal to zero */
     #define COND_LT  3  /**< less than zero */
     #define COND_UN  4  /**< unordered (NaN) */
    -#define COND_GE  5  /**< greater then or equal to zero */
    -#define COND_LE  6  /**< less then or equal to zero */
    +#define COND_GE  5  /**< greater than or equal to zero */
    +#define COND_LE  6  /**< less than or equal to zero */
     #define COND_NE  7  /**< not equal to zero */
     #define COND_TR  8  /**< always true */
     #define COND_FL  9  /**< always false */
    diff --git a/src/mesa/shader/program_parser.h b/src/mesa/shader/program_parser.h
    index 730466c30f..be952d4b9c 100644
    --- a/src/mesa/shader/program_parser.h
    +++ b/src/mesa/shader/program_parser.h
    @@ -62,7 +62,7 @@ struct asm_symbol {
         */
        unsigned param_binding_swizzle;
     
    -   /* This is how many entries in the the program_parameter_list we take up
    +   /* This is how many entries in the program_parameter_list we take up
         * with our state tokens or constants. Note that this is _not_ the same as
         * the number of param registers we eventually use.
         */
    diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc
    index 8b7771c284..a25ca55bc4 100644
    --- a/src/mesa/shader/slang/library/slang_common_builtin.gc
    +++ b/src/mesa/shader/slang/library/slang_common_builtin.gc
    @@ -695,7 +695,7 @@ vec3 normalize(const vec3 v)
     {
     //   const float s = inversesqrt(dot(v, v));
     //   __retVal = v * s;
    -// XXX note, we _could_ use __retVal.w instead of tmp and and save a
    +// XXX note, we _could_ use __retVal.w instead of tmp and save a
     // register, but that's actually a compilation error because v is a vec3
     // and the .w suffix is illegal.  Oh well.
        float tmp;
    diff --git a/src/mesa/swrast/s_depth.c b/src/mesa/swrast/s_depth.c
    index 3e36cf9a7e..ed637cac12 100644
    --- a/src/mesa/swrast/s_depth.c
    +++ b/src/mesa/swrast/s_depth.c
    @@ -526,7 +526,7 @@ _swrast_depth_clamp_span( GLcontext *ctx, SWspan *span )
     
        /* Convert floating point values in [0,1] to device Z coordinates in
         * [0, DepthMax].
    -    * ex: If the the Z buffer has 24 bits, DepthMax = 0xffffff.
    +    * ex: If the Z buffer has 24 bits, DepthMax = 0xffffff.
         * 
         * XXX this all falls apart if we have 31 or more bits of Z because
         * the triangle rasterization code produces unsigned Z values.  Negative
    diff --git a/src/mesa/vbo/vbo_save_loopback.c b/src/mesa/vbo/vbo_save_loopback.c
    index f253c854d2..3f581ea02d 100644
    --- a/src/mesa/vbo/vbo_save_loopback.c
    +++ b/src/mesa/vbo/vbo_save_loopback.c
    @@ -78,7 +78,7 @@ struct loopback_attr {
     };
     
     /* Don't emit ends and begins on wrapped primitives.  Don't replay
    - * wrapped vertices.  If we get here, it's probably because the the
    + * wrapped vertices.  If we get here, it's probably because the
      * precalculated wrapping is wrong.
      */
     static void loopback_prim( GLcontext *ctx,
    -- 
    cgit v1.2.3
    
    
    From 51a51899d0e7eab93468f51296c196b2f3978332 Mon Sep 17 00:00:00 2001
    From: Michel Dänzer 
    Date: Fri, 12 Mar 2010 18:24:34 +0100
    Subject: st/dri: Always try to set up R5G6B5 configs.
    
    Allows compiz to work in depth 16.
    
    The DRI2 getBuffersWithFormat hook is only required for 16/32 bit depth
    buffers, for colour buffers the only requirement is that the format matches
    the drawable depth, which we can't check here.
    
    (cherry picked from commit c50477c255a34444720fb944c54373462ef39fb9)
    ---
     src/gallium/state_trackers/dri/dri_screen.c | 101 ++++++++++++++--------------
     1 file changed, 52 insertions(+), 49 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
    index 60bc560049..7ccad8f5dd 100644
    --- a/src/gallium/state_trackers/dri/dri_screen.c
    +++ b/src/gallium/state_trackers/dri/dri_screen.c
    @@ -90,6 +90,9 @@ dri_fill_in_modes(struct dri_screen *screen,
     		  unsigned pixel_bits)
     {
        __DRIconfig **configs = NULL;
    +   __DRIconfig **configs_r5g6b5 = NULL;
    +   __DRIconfig **configs_a8r8g8b8 = NULL;
    +   __DRIconfig **configs_x8r8g8b8 = NULL;
        unsigned num_modes;
        uint8_t depth_bits_array[5];
        uint8_t stencil_bits_array[5];
    @@ -127,25 +130,23 @@ dri_fill_in_modes(struct dri_screen *screen,
        pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
     					       PIPE_TEXTURE_2D,
     					       PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
    -
    -   /* we support buffers with different depths only if we can tell the driver
    -    * the actual depth of each of them. */
    -   if (screen->sPriv->dri2.loader
    -       && (screen->sPriv->dri2.loader->base.version > 2)
    -       && (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
    +   pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
    +					     PIPE_TEXTURE_2D,
    +					     PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
    +
    +   /* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
    +   if (screen->sPriv->dri2.loader &&
    +       (screen->sPriv->dri2.loader->base.version > 2) &&
    +       (screen->sPriv->dri2.loader->getBuffersWithFormat != NULL)) {
           pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
                                                  PIPE_TEXTURE_2D,
                                                  PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
           pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
                                                  PIPE_TEXTURE_2D,
                                                  PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
    -      pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
    -                                                PIPE_TEXTURE_2D,
    -                                                PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
        } else {
           pf_z16 = FALSE;
           pf_z32 = FALSE;
    -      pf_r5g6b5 = FALSE;
        }
     
        if (pf_z16) {
    @@ -175,46 +176,48 @@ dri_fill_in_modes(struct dri_screen *screen,
        num_modes =
           depth_buffer_factor * back_buffer_factor * msaa_samples_factor * 4;
     
    -   if (pixel_bits == 16 && pf_r5g6b5) {
    -      configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
    -				 depth_bits_array, stencil_bits_array,
    -				 depth_buffer_factor, back_buffer_modes,
    -				 back_buffer_factor,
    -				 msaa_samples_array, msaa_samples_factor,
    -				 GL_TRUE);
    +   if (pf_r5g6b5)
    +      configs_r5g6b5 = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
    +                                        depth_bits_array, stencil_bits_array,
    +                                        depth_buffer_factor, back_buffer_modes,
    +                                        back_buffer_factor,
    +                                        msaa_samples_array, msaa_samples_factor,
    +                                        GL_TRUE);
    +
    +   if (pf_a8r8g8b8)
    +      configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
    +                                          depth_bits_array,
    +                                          stencil_bits_array,
    +                                          depth_buffer_factor,
    +                                          back_buffer_modes,
    +                                          back_buffer_factor,
    +                                          msaa_samples_array,
    +                                          msaa_samples_factor,
    +                                          GL_TRUE);
    +
    +   if (pf_x8r8g8b8)
    +      configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
    +                                          depth_bits_array,
    +                                          stencil_bits_array,
    +                                          depth_buffer_factor,
    +                                          back_buffer_modes,
    +                                          back_buffer_factor,
    +                                          msaa_samples_array,
    +                                          msaa_samples_factor,
    +                                          GL_TRUE);
    +
    +   if (pixel_bits == 16) {
    +      configs = configs_r5g6b5;
    +      if (configs_a8r8g8b8)
    +         configs = configs ? driConcatConfigs(configs, configs_a8r8g8b8) : configs_a8r8g8b8;
    +      if (configs_x8r8g8b8)
    +	 configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
        } else {
    -      __DRIconfig **configs_a8r8g8b8 = NULL;
    -      __DRIconfig **configs_x8r8g8b8 = NULL;
    -
    -      if (pf_a8r8g8b8)
    -	 configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
    -					     depth_bits_array,
    -					     stencil_bits_array,
    -					     depth_buffer_factor,
    -					     back_buffer_modes,
    -					     back_buffer_factor,
    -					     msaa_samples_array,
    -                                             msaa_samples_factor,
    -					     GL_TRUE);
    -      if (pf_x8r8g8b8)
    -	 configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
    -					     depth_bits_array,
    -					     stencil_bits_array,
    -					     depth_buffer_factor,
    -					     back_buffer_modes,
    -					     back_buffer_factor,
    -					     msaa_samples_array,
    -                                             msaa_samples_factor,
    -					     GL_TRUE);
    -
    -      if (configs_a8r8g8b8 && configs_x8r8g8b8)
    -	 configs = driConcatConfigs(configs_x8r8g8b8, configs_a8r8g8b8);
    -      else if (configs_a8r8g8b8)
    -	 configs = configs_a8r8g8b8;
    -      else if (configs_x8r8g8b8)
    -	 configs = configs_x8r8g8b8;
    -      else
    -	 configs = NULL;
    +      configs = configs_a8r8g8b8;
    +      if (configs_x8r8g8b8)
    +	 configs = configs ? driConcatConfigs(configs, configs_x8r8g8b8) : configs_x8r8g8b8;
    +      if (configs_r5g6b5)
    +         configs = configs ? driConcatConfigs(configs, configs_r5g6b5) : configs_r5g6b5;
        }
     
        if (configs == NULL) {
    -- 
    cgit v1.2.3
    
    
    From 8561bec0ac1ae5a8871c86f1f2cc29d44cb0f878 Mon Sep 17 00:00:00 2001
    From: Michel Dänzer 
    Date: Fri, 12 Mar 2010 18:54:23 +0100
    Subject: vmwgfx/dri: Fix SCons build.
    
    ---
     src/gallium/winsys/drm/vmware/dri/SConscript | 1 +
     1 file changed, 1 insertion(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/winsys/drm/vmware/dri/SConscript b/src/gallium/winsys/drm/vmware/dri/SConscript
    index 84319f91ff..d26d0cd748 100644
    --- a/src/gallium/winsys/drm/vmware/dri/SConscript
    +++ b/src/gallium/winsys/drm/vmware/dri/SConscript
    @@ -48,6 +48,7 @@ if env['platform'] == 'linux':
                 svgadrm,
                 svga,
                 mesa,
    +            glsl,
                 gallium,
                 ])
           
    -- 
    cgit v1.2.3
    
    
    From 59d6f3eb4a4052ef764a9ba0589e64a5252feceb Mon Sep 17 00:00:00 2001
    From: Michel Dänzer 
    Date: Fri, 12 Mar 2010 19:52:24 +0100
    Subject: st/xorg: Remove flushes no longer necessary thanks to context
     transfers.
    
    ---
     src/gallium/state_trackers/xorg/xorg_composite.c |  8 --------
     src/gallium/state_trackers/xorg/xorg_exa.c       | 13 -------------
     2 files changed, 21 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c
    index c50873c150..715a5e7b94 100644
    --- a/src/gallium/state_trackers/xorg/xorg_composite.c
    +++ b/src/gallium/state_trackers/xorg/xorg_composite.c
    @@ -359,14 +359,6 @@ bind_samplers(struct exa_context *exa, int op,
     
        exa->num_bound_samplers = 0;
     
    -#if 0
    -   if ((pSrc && (exa->pipe->is_texture_referenced(exa->pipe, pSrc->tex, 0, 0) &
    -                 PIPE_REFERENCED_FOR_WRITE)) ||
    -       (pMask && (exa->pipe->is_texture_referenced(exa->pipe, pMask->tex, 0, 0) &
    -        PIPE_REFERENCED_FOR_WRITE)))
    -      xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL);
    -#endif
    -
        memset(&src_sampler, 0, sizeof(struct pipe_sampler_state));
        memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state));
     
    diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
    index b5e7adc26e..bdec0e254f 100644
    --- a/src/gallium/state_trackers/xorg/xorg_exa.c
    +++ b/src/gallium/state_trackers/xorg/xorg_exa.c
    @@ -188,10 +188,6 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x,  int y, int w,  int h, char *dst,
         if (!priv || !priv->tex)
     	return FALSE;
     
    -    if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) &
    -	PIPE_REFERENCED_FOR_WRITE)
    -	exa->pipe->flush(exa->pipe, 0, NULL);
    -
         transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0,
     					   PIPE_TRANSFER_READ, x, y, w, h);
         if (!transfer)
    @@ -226,11 +222,6 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
         if (!priv || !priv->tex)
     	return FALSE;
     
    -    /* make sure that any pending operations are flushed to hardware */
    -    if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) &
    -	(PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE))
    -	xorg_exa_flush(exa, 0, NULL);
    -
         transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0,
     					   PIPE_TRANSFER_WRITE, x, y, w, h);
         if (!transfer)
    @@ -270,10 +261,6 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
     
         if (priv->map_count == 0)
         {
    -	if (exa->pipe->is_texture_referenced(exa->pipe, priv->tex, 0, 0) &
    -	    PIPE_REFERENCED_FOR_WRITE)
    -	    exa->pipe->flush(exa->pipe, 0, NULL);
    -
             assert(pPix->drawable.width <= priv->tex->width0);
             assert(pPix->drawable.height <= priv->tex->height0);
     
    -- 
    cgit v1.2.3
    
    
    From 13a13fcb8054ed2d1138f6754fc67b014cc5cd5d Mon Sep 17 00:00:00 2001
    From: Michel Dänzer 
    Date: Fri, 12 Mar 2010 19:52:24 +0100
    Subject: svga: Fix up for context transfers.
    
    ---
     src/gallium/drivers/svga/svga_context.c | 2 ++
     1 file changed, 2 insertions(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
    index d499ae6acc..adb7840182 100644
    --- a/src/gallium/drivers/svga/svga_context.c
    +++ b/src/gallium/drivers/svga/svga_context.c
    @@ -164,6 +164,8 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen,
        svga_init_constbuffer_functions(svga);
        svga_init_query_functions(svga);
     
    +   svga_init_texture_functions(&svga->pipe);
    +
        /* debug */
        svga->debug.no_swtnl = debug_get_bool_option("SVGA_NO_SWTNL", FALSE);
        svga->debug.force_swtnl = debug_get_bool_option("SVGA_FORCE_SWTNL", FALSE);
    -- 
    cgit v1.2.3
    
    
    From a6196ce8beb8d7c17da8a09ce0526f1a2af082f0 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Fri, 12 Mar 2010 14:24:03 -0700
    Subject: gallivm: support non-vector float in lp_build_sgn()
    
    ---
     src/gallium/auxiliary/gallivm/lp_bld_arit.c | 27 +++++++++++++++++++++------
     1 file changed, 21 insertions(+), 6 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    index 90c84c6a4e..aa47338b32 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    @@ -720,12 +720,12 @@ lp_build_negate(struct lp_build_context *bld,
     }
     
     
    +/** Return -1, 0 or +1 depending on the sign of a */
     LLVMValueRef
     lp_build_sgn(struct lp_build_context *bld,
                  LLVMValueRef a)
     {
        const struct lp_type type = bld->type;
    -   LLVMTypeRef vec_type = lp_build_vec_type(type);
        LLVMValueRef cond;
        LLVMValueRef res;
     
    @@ -735,14 +735,29 @@ lp_build_sgn(struct lp_build_context *bld,
           res = bld->one;
        }
        else if(type.floating) {
    -      /* Take the sign bit and add it to 1 constant */
    -      LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
    -      LLVMValueRef mask = lp_build_int_const_scalar(type, (unsigned long long)1 << (type.width - 1));
    +      LLVMTypeRef vec_type;
    +      LLVMTypeRef int_type;
    +      LLVMValueRef mask;
           LLVMValueRef sign;
           LLVMValueRef one;
    -      sign = LLVMBuildBitCast(bld->builder, a, int_vec_type, "");
    +      unsigned long long maskBit = (unsigned long long)1 << (type.width - 1);
    +
    +      if (type.length == 1) {
    +         int_type = lp_build_int_elem_type(type);
    +         vec_type = lp_build_elem_type(type);
    +         mask = LLVMConstInt(int_type, maskBit, 0);
    +      }
    +      else {
    +         /* vector */
    +         int_type = lp_build_int_vec_type(type);
    +         vec_type = lp_build_vec_type(type);
    +         mask = lp_build_int_const_scalar(type, maskBit);
    +      }
    +
    +      /* Take the sign bit and add it to 1 constant */
    +      sign = LLVMBuildBitCast(bld->builder, a, int_type, "");
           sign = LLVMBuildAnd(bld->builder, sign, mask, "");
    -      one = LLVMConstBitCast(bld->one, int_vec_type);
    +      one = LLVMConstBitCast(bld->one, int_type);
           res = LLVMBuildOr(bld->builder, sign, one, "");
           res = LLVMBuildBitCast(bld->builder, res, vec_type, "");
        }
    -- 
    cgit v1.2.3
    
    
    From e910c0ba9e3ef08d5ca7aa396ec009232088530b Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Fri, 12 Mar 2010 16:53:51 -0700
    Subject: gallivm: fix bugs in nested if/then/else codegen
    
    Quite a bit a hair pulling was involved...
    ---
     src/gallium/auxiliary/gallivm/lp_bld_flow.c | 26 +++++++++++++++++---------
     1 file changed, 17 insertions(+), 9 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
    index c2f35419ec..106fc03e46 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
    @@ -648,7 +648,9 @@ lp_build_if(struct lp_build_if_state *ctx,
           ifthen->phi[i] = LLVMBuildPhi(builder, LLVMTypeOf(*flow->variables[i]), "");
     
           /* add add the initial value of the var from the entry block */
    -      LLVMAddIncoming(ifthen->phi[i], flow->variables[i], &ifthen->entry_block, 1);
    +      if (!LLVMIsUndef(*flow->variables[i]))
    +         LLVMAddIncoming(ifthen->phi[i], flow->variables[i],
    +                         &ifthen->entry_block, 1);
        }
     
        /* create/insert true_block before merge_block */
    @@ -695,18 +697,21 @@ lp_build_endif(struct lp_build_if_state *ctx)
     {
        struct lp_build_flow_context *flow = ctx->flow;
        struct lp_build_flow_if *ifthen;
    +   LLVMBasicBlockRef curBlock = LLVMGetInsertBlock(ctx->builder);
        unsigned i;
     
        ifthen = &lp_build_flow_pop(flow, LP_BUILD_FLOW_IF)->ifthen;
        assert(ifthen);
     
    +   /* Insert branch to the merge block from current block */
    +   LLVMBuildBr(ctx->builder, ifthen->merge_block);
    +
        if (ifthen->false_block) {
           LLVMPositionBuilderAtEnd(ctx->builder, ifthen->merge_block);
           /* for each variable, update the Phi node with a (variable, block) pair */
           for (i = 0; i < flow->num_variables; i++) {
              assert(*flow->variables[i]);
    -         LLVMAddIncoming(ifthen->phi[i], flow->variables[i], &ifthen->false_block, 1);
    -
    +         LLVMAddIncoming(ifthen->phi[i], flow->variables[i], &curBlock, 1);
              /* replace the variable ref with the phi function */
              *flow->variables[i] = ifthen->phi[i];
           }
    @@ -742,15 +747,18 @@ lp_build_endif(struct lp_build_if_state *ctx)
                           ifthen->true_block, ifthen->merge_block);
        }
     
    -   /* Append an unconditional Br(anch) instruction on the true_block */
    -   LLVMPositionBuilderAtEnd(ctx->builder, ifthen->true_block);
    -   LLVMBuildBr(ctx->builder, ifthen->merge_block);
    +   /* Insert branch from end of true_block to merge_block */
        if (ifthen->false_block) {
    -      /* Append an unconditional Br(anch) instruction on the false_block */
    -      LLVMPositionBuilderAtEnd(ctx->builder, ifthen->false_block);
    +      /* Append an unconditional Br(anch) instruction on the true_block */
    +      LLVMPositionBuilderAtEnd(ctx->builder, ifthen->true_block);
           LLVMBuildBr(ctx->builder, ifthen->merge_block);
        }
    -
    +   else {
    +      /* No else clause.
    +       * Note that we've already inserted the branch at the end of
    +       * true_block.  See the very first LLVMBuildBr() call in this function.
    +       */
    +   }
     
        /* Resume building code at end of the ifthen->merge_block */
        LLVMPositionBuilderAtEnd(ctx->builder, ifthen->merge_block);
    -- 
    cgit v1.2.3
    
    
    From 3c80e525415982fec4b1a32ca16d69662d83b3a4 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Fri, 12 Mar 2010 16:54:55 -0700
    Subject: gallivm: cube map sampling works now
    
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 176 +++++++++++++++++++---
     1 file changed, 154 insertions(+), 22 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    index a410688350..72018737a8 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    @@ -994,6 +994,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
     
     /**
      * Generate code to sample a mipmap level with nearest filtering.
    + * If sampling a cube texture, r = cube face in [0,5].
      */
     static void
     lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
    @@ -1031,6 +1032,9 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
                                               bld->static_state->wrap_r);
              lp_build_name(z, "tex.z.wrapped");
           }
    +      else if (bld->static_state->target == PIPE_TEXTURE_CUBE) {
    +         z = r;
    +      }
           else {
              z = NULL;
           }
    @@ -1051,7 +1055,7 @@ lp_build_sample_image_nearest(struct lp_build_sample_context *bld,
     
     /**
      * Generate code to sample a mipmap level with linear filtering.
    - * 1D, 2D and 3D images are suppored.
    + * If sampling a cube texture, r = cube face in [0,5].
      */
     static void
     lp_build_sample_image_linear(struct lp_build_sample_context *bld,
    @@ -1098,8 +1102,13 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
              lp_build_name(z0, "tex.z0.wrapped");
              lp_build_name(z1, "tex.z1.wrapped");
           }
    +      else if (bld->static_state->target == PIPE_TEXTURE_CUBE) {
    +         z0 = z1 = r;  /* cube face */
    +         r_fpart = NULL;
    +      }
           else {
    -         z0 = z1 = r_fpart = NULL;
    +         z0 = z1 = NULL;
    +         r_fpart = NULL;
           }
        }
        else {
    @@ -1201,6 +1210,70 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
     }
     
     
    +/** Helper used by lp_build_cube_lookup() */
    +static LLVMValueRef
    +lp_build_cube_ima(struct lp_build_context *coord_bld, LLVMValueRef coord)
    +{
    +   /* ima = -0.5 / abs(coord); */
    +   LLVMValueRef negHalf = lp_build_const_scalar(coord_bld->type, -0.5);
    +   LLVMValueRef absCoord = lp_build_abs(coord_bld, coord);
    +   LLVMValueRef ima = lp_build_mul(coord_bld, negHalf,
    +                                   lp_build_rcp(coord_bld, absCoord));
    +   return ima;
    +}
    +
    +
    +/**
    + * Helper used by lp_build_cube_lookup()
    + * \param sign  scalar +1 or -1
    + * \param coord  float vector
    + * \param ima  float vector
    + */
    +static LLVMValueRef
    +lp_build_cube_coord(struct lp_build_context *coord_bld,
    +                    LLVMValueRef sign, int negate_coord,
    +                    LLVMValueRef coord, LLVMValueRef ima)
    +{
    +   /* return negate(coord) * ima * sign + 0.5; */
    +   LLVMValueRef half = lp_build_const_scalar(coord_bld->type, 0.5);
    +   LLVMValueRef res;
    +
    +   assert(negate_coord == +1 || negate_coord == -1);
    +
    +   if (negate_coord == -1) {
    +      coord = lp_build_negate(coord_bld, coord);
    +   }
    +
    +   res = lp_build_mul(coord_bld, coord, ima);
    +   if (sign) {
    +      sign = lp_build_broadcast_scalar(coord_bld, sign);
    +      res = lp_build_mul(coord_bld, res, sign);
    +   }
    +   res = lp_build_add(coord_bld, res, half);
    +
    +   return res;
    +}
    +
    +
    +/** Helper used by lp_build_cube_lookup()
    + * Return (major_coord >= 0) ? pos_face : neg_face;
    + */
    +static LLVMValueRef
    +lp_build_cube_face(struct lp_build_sample_context *bld,
    +                   LLVMValueRef major_coord,
    +                   unsigned pos_face, unsigned neg_face)
    +{
    +   LLVMValueRef cmp = LLVMBuildFCmp(bld->builder, LLVMRealUGE,
    +                                    major_coord,
    +                                    bld->float_bld.zero, "");
    +   LLVMValueRef pos = LLVMConstInt(LLVMInt32Type(), pos_face, 0);
    +   LLVMValueRef neg = LLVMConstInt(LLVMInt32Type(), neg_face, 0);
    +   LLVMValueRef res = LLVMBuildSelect(bld->builder, cmp, pos, neg, "");
    +   return res;
    +}
    +
    +
    +
     /**
      * Generate code to do cube face selection and per-face texcoords.
      */
    @@ -1213,11 +1286,10 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
                          LLVMValueRef *face_s,
                          LLVMValueRef *face_t)
     {
    -#if 0
        struct lp_build_context *float_bld = &bld->float_bld;
    +   struct lp_build_context *coord_bld = &bld->coord_bld;
        LLVMValueRef rx, ry, rz;
        LLVMValueRef arx, ary, arz;
    -   LLVMValueRef sc, tc, ma;
        LLVMValueRef c25 = LLVMConstReal(LLVMFloatType(), 0.25);
        LLVMValueRef arx_ge_ary, arx_ge_arz;
        LLVMValueRef ary_ge_arx, ary_ge_arz;
    @@ -1257,34 +1329,86 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
     
        {
           struct lp_build_flow_context *flow_ctx;
    -      struct lp_build_if_state if_ctx, if2_ctx;
    +      struct lp_build_if_state if_ctx;
     
           flow_ctx = lp_build_flow_create(bld->builder);
    +      lp_build_flow_scope_begin(flow_ctx);
    +
    +      *face_s = bld->coord_bld.undef;
    +      *face_t = bld->coord_bld.undef;
    +      *face = bld->int_bld.undef;
    +
    +      lp_build_name(*face_s, "face_s");
    +      lp_build_name(*face_t, "face_t");
    +      lp_build_name(*face, "face");
    +
    +      lp_build_flow_scope_declare(flow_ctx, face_s);
    +      lp_build_flow_scope_declare(flow_ctx, face_t);
    +      lp_build_flow_scope_declare(flow_ctx, face);
     
           lp_build_if(&if_ctx, flow_ctx, bld->builder, arx_ge_ary_arz);
           {
    -#if 0
    -         lp_build_if(&if2_ctx, flow_ctx, bld->builder, rx_pos);
    -         {
    -            /* Positive X face */
    -         }
    -         lp_build_else(&if2_ctx);
    -         {
    -            /* Negative X face */
    -         }
    -         lp_build_endif(&if2_ctx);
    -#endif
    +         /* +/- X face */
    +         LLVMValueRef sign = lp_build_sgn(float_bld, rx);
    +         LLVMValueRef ima = lp_build_cube_ima(coord_bld, s);
    +         *face_s = lp_build_cube_coord(coord_bld, sign, +1, r, ima);
    +         *face_t = lp_build_cube_coord(coord_bld, NULL, +1, t, ima);
    +         *face = lp_build_cube_face(bld, rx,
    +                                    PIPE_TEX_FACE_POS_X,
    +                                    PIPE_TEX_FACE_NEG_X);
           }
           lp_build_else(&if_ctx);
           {
    +         struct lp_build_flow_context *flow_ctx2;
    +         struct lp_build_if_state if_ctx2;
    +
    +         LLVMValueRef face_s2 = bld->coord_bld.undef;
    +         LLVMValueRef face_t2 = bld->coord_bld.undef;
    +         LLVMValueRef face2 = bld->int_bld.undef;
     
    +         flow_ctx2 = lp_build_flow_create(bld->builder);
    +         lp_build_flow_scope_begin(flow_ctx2);
    +         lp_build_flow_scope_declare(flow_ctx2, &face_s2);
    +         lp_build_flow_scope_declare(flow_ctx2, &face_t2);
    +         lp_build_flow_scope_declare(flow_ctx2, &face2);
     
    +         ary_ge_arx_arz = LLVMBuildAnd(bld->builder, ary_ge_arx, ary_ge_arz, "");
    +
    +         lp_build_if(&if_ctx2, flow_ctx2, bld->builder, ary_ge_arx_arz);
    +         {
    +            /* +/- Y face */
    +            LLVMValueRef sign = lp_build_sgn(float_bld, ry);
    +            LLVMValueRef ima = lp_build_cube_ima(coord_bld, t);
    +            face_s2 = lp_build_cube_coord(coord_bld, NULL, -1, s, ima);
    +            face_t2 = lp_build_cube_coord(coord_bld, sign, -1, r, ima);
    +            face2 = lp_build_cube_face(bld, ry,
    +                                       PIPE_TEX_FACE_POS_Y,
    +                                       PIPE_TEX_FACE_NEG_Y);
    +         }
    +         lp_build_else(&if_ctx2);
    +         {
    +            /* +/- Z face */
    +            LLVMValueRef sign = lp_build_sgn(float_bld, rz);
    +            LLVMValueRef ima = lp_build_cube_ima(coord_bld, r);
    +            face_s2 = lp_build_cube_coord(coord_bld, sign, -1, s, ima);
    +            face_t2 = lp_build_cube_coord(coord_bld, NULL, +1, t, ima);
    +            face2 = lp_build_cube_face(bld, rz,
    +                                       PIPE_TEX_FACE_POS_Z,
    +                                       PIPE_TEX_FACE_NEG_Z);
    +         }
    +         lp_build_endif(&if_ctx2);
    +         lp_build_flow_scope_end(flow_ctx2);
    +         lp_build_flow_destroy(flow_ctx2);
    +
    +         *face_s = face_s2;
    +         *face_t = face_t2;
    +         *face = face2;
           }
    -      lp_build_endif(&if_ctx);
     
    +      lp_build_endif(&if_ctx);
    +      lp_build_flow_scope_end(flow_ctx);
           lp_build_flow_destroy(flow_ctx);
        }
    -#endif
     }
     
     
    @@ -1366,10 +1490,12 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
           height0_vec = lp_build_minify(bld, height_vec, ilevel0_vec);
           row_stride0_vec = lp_build_get_level_stride_vec(bld, row_stride_array,
                                                           ilevel0);
    -      if (dims == 3) {
    -         depth0_vec = lp_build_minify(bld, depth_vec, ilevel0_vec);
    +      if (dims == 3 || bld->static_state->target == PIPE_TEXTURE_CUBE) {
              img_stride0_vec = lp_build_mul(&bld->int_coord_bld,
                                             row_stride0_vec, height0_vec);
    +         if (dims == 3) {
    +            depth0_vec = lp_build_minify(bld, depth_vec, ilevel0_vec);
    +         }
           }
        }
        if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    @@ -1379,10 +1505,12 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
              height1_vec = lp_build_minify(bld, height_vec, ilevel1_vec);
              row_stride1_vec = lp_build_get_level_stride_vec(bld, row_stride_array,
                                                              ilevel1);
    -         if (dims == 3) {
    -            depth1_vec = lp_build_minify(bld, depth_vec, ilevel1_vec);
    +         if (dims == 3 || bld->static_state->target == PIPE_TEXTURE_CUBE) {
                 img_stride1_vec = lp_build_mul(&bld->int_coord_bld,
                                                row_stride1_vec, height1_vec);
    +            if (dims ==3) {
    +               depth1_vec = lp_build_minify(bld, depth_vec, ilevel1_vec);
    +            }
              }
           }
        }
    @@ -1393,6 +1521,10 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        if (bld->static_state->target == PIPE_TEXTURE_CUBE) {
           LLVMValueRef face, face_s, face_t;
           lp_build_cube_lookup(bld, s, t, r, &face, &face_s, &face_t);
    +      s = face_s; /* vec */
    +      t = face_t; /* vec */
    +      /* use 'r' to indicate cube face */
    +      r = lp_build_broadcast_scalar(&bld->int_coord_bld, face); /* vec */
        }
     
        /*
    -- 
    cgit v1.2.3
    
    
    From 2764a5191ffcaf93a77beff464ac8eca15163fcc Mon Sep 17 00:00:00 2001
    From: Corbin Simpson 
    Date: Fri, 12 Mar 2010 18:13:18 -0800
    Subject: r300g: Forcibly sanitize max index.
    
    Not perfect, but the kernel should shut up now.
    ---
     src/gallium/drivers/r300/r300_render.c | 6 +++---
     1 file changed, 3 insertions(+), 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
    index ef1b7510e1..ccf39876a5 100644
    --- a/src/gallium/drivers/r300/r300_render.c
    +++ b/src/gallium/drivers/r300/r300_render.c
    @@ -274,14 +274,14 @@ static void r300_emit_draw_elements(struct r300_context *r300,
     #endif
         CS_LOCALS(r300);
     
    -    assert((start * indexSize)  % 4 == 0);
    +    assert((start * indexSize) % 4 == 0);
         assert(count < (1 << 24));
     
    +    maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, count - minIndex);
    +
         DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n",
             count, minIndex, maxIndex);
     
    -    maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, (1 << 24) - 1);
    -
         if (alt_num_verts) {
             BEGIN_CS(15);
             OUT_CS_REG(R500_VAP_ALT_NUM_VERTICES, count);
    -- 
    cgit v1.2.3
    
    
    From 9222c0934910172daf2405b0e581becdfbc80405 Mon Sep 17 00:00:00 2001
    From: Chia-I Wu 
    Date: Sat, 13 Mar 2010 00:48:23 +0800
    Subject: st/egl: Cache the pipe surface used in flush_frontbuffer.
    
    It is very likely that the same surface will be flushed again and again.
    Caching the surface should reduce the overhead of surface creation.
    ---
     src/gallium/state_trackers/egl/x11/native_ximage.c | 22 +++++++++++++++-------
     1 file changed, 15 insertions(+), 7 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
    index e0d12acabe..c6b16354f9 100644
    --- a/src/gallium/state_trackers/egl/x11/native_ximage.c
    +++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
    @@ -82,6 +82,8 @@ struct ximage_surface {
        int width, height;
        struct ximage_buffer buffers[NUM_NATIVE_ATTACHMENTS];
        uint valid_mask;
    +
    +   struct pipe_surface *draw_surface;
     };
     
     struct ximage_config {
    @@ -266,15 +268,19 @@ ximage_surface_draw_buffer(struct native_surface *nsurf,
     
        assert(xsurf->drawable && xbuf->texture);
     
    -   /* what's the cost of surface creation? */
    -   psurf = screen->get_tex_surface(screen,
    -         xbuf->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
    -   if (!psurf)
    -      return FALSE;
    +   psurf = xsurf->draw_surface;
    +   if (!psurf || psurf->texture != xbuf->texture) {
    +      pipe_surface_reference(&xsurf->draw_surface, NULL);
     
    -   screen->flush_frontbuffer(screen, psurf, &xbuf->xdraw);
    +      psurf = screen->get_tex_surface(screen,
    +            xbuf->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
    +      if (!psurf)
    +         return FALSE;
     
    -   pipe_surface_reference(&psurf, NULL);
    +      xsurf->draw_surface = psurf;
    +   }
    +
    +   screen->flush_frontbuffer(screen, psurf, &xbuf->xdraw);
     
        return TRUE;
     }
    @@ -371,6 +377,8 @@ ximage_surface_destroy(struct native_surface *nsurf)
        struct ximage_surface *xsurf = ximage_surface(nsurf);
        int i;
     
    +   pipe_surface_reference(&xsurf->draw_surface, NULL);
    +
        for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
           ximage_surface_free_buffer(&xsurf->base, i);
     
    -- 
    cgit v1.2.3
    
    
    From 50a778661930ec7aa875a9c5235e9910143ec700 Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Fri, 12 Mar 2010 13:12:15 +0000
    Subject: python: Temporarily disable python state tracker until transfers are
     done by contexts
    
    It requires changes not ony to the state tracker but to the python
    scripts too.
    ---
     src/gallium/state_trackers/python/SConscript | 3 ++-
     1 file changed, 2 insertions(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/state_trackers/python/SConscript b/src/gallium/state_trackers/python/SConscript
    index 781f54bf2b..d0d141fd24 100644
    --- a/src/gallium/state_trackers/python/SConscript
    +++ b/src/gallium/state_trackers/python/SConscript
    @@ -3,7 +3,8 @@ import os.path
     
     Import('*')
     
    -if 'python' in env['statetrackers']:
    +if 'python' in env['statetrackers'] and 0:
    +    # FIXME: Disable python state tracker until transfers are done by contexts  
     
         env = env.Clone()
         
    -- 
    cgit v1.2.3
    
    
    From 83fe7149eaea7ca607a5aa74e092b9cf86f12b73 Mon Sep 17 00:00:00 2001
    From: Xavier Chantry 
    Date: Sat, 13 Mar 2010 11:33:27 +0100
    Subject: nv50: fixup after gallium-context-transfers merge
    
    ---
     src/gallium/drivers/nv50/nv50_screen.c | 1 -
     src/gallium/drivers/nv50/nv50_screen.h | 2 --
     2 files changed, 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
    index 7e2e8aa336..adf0d3b374 100644
    --- a/src/gallium/drivers/nv50/nv50_screen.c
    +++ b/src/gallium/drivers/nv50/nv50_screen.c
    @@ -234,7 +234,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	pscreen->context_create = nv50_create;
     
     	nv50_screen_init_miptree_functions(pscreen);
    -	nv50_transfer_init_screen_functions(pscreen);
     
     	/* DMA engine object */
     	ret = nouveau_grobj_alloc(chan, 0xbeef5039,
    diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
    index d1bc80cb9e..ec19ea655b 100644
    --- a/src/gallium/drivers/nv50/nv50_screen.h
    +++ b/src/gallium/drivers/nv50/nv50_screen.h
    @@ -38,6 +38,4 @@ nv50_screen(struct pipe_screen *screen)
     	return (struct nv50_screen *)screen;
     }
     
    -void nv50_transfer_init_screen_functions(struct pipe_screen *);
    -
     #endif
    -- 
    cgit v1.2.3
    
    
    From 3160cbabccf1f7d8bdf344242507b9c3082f15c6 Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Sat, 13 Mar 2010 10:45:52 +0000
    Subject: llvmpipe: setup_context -> lp_setup_context
    
    Otherwise IDEs and debuggers have trouble distinguishing from softpipe's
    setup_context.
    ---
     src/gallium/drivers/llvmpipe/lp_context.h       |  4 +-
     src/gallium/drivers/llvmpipe/lp_rast.h          |  2 +-
     src/gallium/drivers/llvmpipe/lp_setup.c         | 58 ++++++++++++-------------
     src/gallium/drivers/llvmpipe/lp_setup.h         | 32 +++++++-------
     src/gallium/drivers/llvmpipe/lp_setup_context.h | 22 +++++-----
     src/gallium/drivers/llvmpipe/lp_setup_line.c    |  4 +-
     src/gallium/drivers/llvmpipe/lp_setup_point.c   |  4 +-
     src/gallium/drivers/llvmpipe/lp_setup_tri.c     | 14 +++---
     src/gallium/drivers/llvmpipe/lp_setup_vbuf.c    | 24 +++++-----
     9 files changed, 82 insertions(+), 82 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
    index 217ec59b68..f391871b0e 100644
    --- a/src/gallium/drivers/llvmpipe/lp_context.h
    +++ b/src/gallium/drivers/llvmpipe/lp_context.h
    @@ -45,7 +45,7 @@ struct draw_stage;
     struct lp_fragment_shader;
     struct lp_vertex_shader;
     struct lp_blend_state;
    -struct setup_context;
    +struct lp_setup_context;
     struct lp_velems_state;
     
     struct llvmpipe_context {
    @@ -98,7 +98,7 @@ struct llvmpipe_context {
        int psize_slot;
     
        /** The tiling engine */
    -   struct setup_context *setup;
    +   struct lp_setup_context *setup;
     
        /** The primitive drawing context */
        struct draw_context *draw;
    diff --git a/src/gallium/drivers/llvmpipe/lp_rast.h b/src/gallium/drivers/llvmpipe/lp_rast.h
    index dc5fc5fc7d..303f6e3f7e 100644
    --- a/src/gallium/drivers/llvmpipe/lp_rast.h
    +++ b/src/gallium/drivers/llvmpipe/lp_rast.h
    @@ -95,7 +95,7 @@ struct lp_rast_shader_inputs {
      * Rasterization information for a triangle known to be in this bin,
      * plus inputs to run the shader:
      * These fields are tile- and bin-independent.
    - * Objects of this type are put into the setup_context::data buffer.
    + * Objects of this type are put into the lp_setup_context::data buffer.
      */
     struct lp_rast_triangle {
     #ifdef DEBUG
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
    index c870f89d01..ba55daf78f 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup.c
    @@ -52,11 +52,11 @@
     #include "draw/draw_vbuf.h"
     
     
    -static void set_scene_state( struct setup_context *, unsigned );
    +static void set_scene_state( struct lp_setup_context *, unsigned );
     
     
     struct lp_scene *
    -lp_setup_get_current_scene(struct setup_context *setup)
    +lp_setup_get_current_scene(struct lp_setup_context *setup)
     {
        if (!setup->scene) {
     
    @@ -74,7 +74,7 @@ lp_setup_get_current_scene(struct setup_context *setup)
     
     
     static void
    -first_triangle( struct setup_context *setup,
    +first_triangle( struct lp_setup_context *setup,
                     const float (*v0)[4],
                     const float (*v1)[4],
                     const float (*v2)[4])
    @@ -85,7 +85,7 @@ first_triangle( struct setup_context *setup,
     }
     
     static void
    -first_line( struct setup_context *setup,
    +first_line( struct lp_setup_context *setup,
     	    const float (*v0)[4],
     	    const float (*v1)[4])
     {
    @@ -95,7 +95,7 @@ first_line( struct setup_context *setup,
     }
     
     static void
    -first_point( struct setup_context *setup,
    +first_point( struct lp_setup_context *setup,
     	     const float (*v0)[4])
     {
        set_scene_state( setup, SETUP_ACTIVE );
    @@ -103,7 +103,7 @@ first_point( struct setup_context *setup,
        setup->point( setup, v0 );
     }
     
    -static void reset_context( struct setup_context *setup )
    +static void reset_context( struct lp_setup_context *setup )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
     
    @@ -131,7 +131,7 @@ static void reset_context( struct setup_context *setup )
     
     /** Rasterize all scene's bins */
     static void
    -lp_setup_rasterize_scene( struct setup_context *setup,
    +lp_setup_rasterize_scene( struct lp_setup_context *setup,
                               boolean write_depth )
     {
        struct lp_scene *scene = lp_setup_get_current_scene(setup);
    @@ -148,7 +148,7 @@ lp_setup_rasterize_scene( struct setup_context *setup,
     
     
     static void
    -begin_binning( struct setup_context *setup )
    +begin_binning( struct lp_setup_context *setup )
     {
        struct lp_scene *scene = lp_setup_get_current_scene(setup);
     
    @@ -184,7 +184,7 @@ begin_binning( struct setup_context *setup )
      * TODO: fast path for fullscreen clears and no triangles.
      */
     static void
    -execute_clears( struct setup_context *setup )
    +execute_clears( struct lp_setup_context *setup )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
     
    @@ -194,7 +194,7 @@ execute_clears( struct setup_context *setup )
     
     
     static void
    -set_scene_state( struct setup_context *setup,
    +set_scene_state( struct lp_setup_context *setup,
                unsigned new_state )
     {
        unsigned old_state = setup->state;
    @@ -229,7 +229,7 @@ set_scene_state( struct setup_context *setup,
     
     
     void
    -lp_setup_flush( struct setup_context *setup,
    +lp_setup_flush( struct lp_setup_context *setup,
                     unsigned flags )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
    @@ -239,7 +239,7 @@ lp_setup_flush( struct setup_context *setup,
     
     
     void
    -lp_setup_bind_framebuffer( struct setup_context *setup,
    +lp_setup_bind_framebuffer( struct lp_setup_context *setup,
                                const struct pipe_framebuffer_state *fb )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
    @@ -256,7 +256,7 @@ lp_setup_bind_framebuffer( struct setup_context *setup,
     
     
     void
    -lp_setup_clear( struct setup_context *setup,
    +lp_setup_clear( struct lp_setup_context *setup,
                     const float *color,
                     double depth,
                     unsigned stencil,
    @@ -314,7 +314,7 @@ lp_setup_clear( struct setup_context *setup,
      * Emit a fence.
      */
     struct pipe_fence_handle *
    -lp_setup_fence( struct setup_context *setup )
    +lp_setup_fence( struct lp_setup_context *setup )
     {
        struct lp_scene *scene = lp_setup_get_current_scene(setup);
        const unsigned rank = lp_scene_get_num_bins( scene ); /* xxx */
    @@ -334,7 +334,7 @@ lp_setup_fence( struct setup_context *setup )
     
     
     void 
    -lp_setup_set_triangle_state( struct setup_context *setup,
    +lp_setup_set_triangle_state( struct lp_setup_context *setup,
                                  unsigned cull_mode,
                                  boolean ccw_is_frontface,
                                  boolean scissor )
    @@ -350,7 +350,7 @@ lp_setup_set_triangle_state( struct setup_context *setup,
     
     
     void
    -lp_setup_set_fs_inputs( struct setup_context *setup,
    +lp_setup_set_fs_inputs( struct lp_setup_context *setup,
                             const struct lp_shader_input *input,
                             unsigned nr )
     {
    @@ -361,7 +361,7 @@ lp_setup_set_fs_inputs( struct setup_context *setup,
     }
     
     void
    -lp_setup_set_fs_functions( struct setup_context *setup,
    +lp_setup_set_fs_functions( struct lp_setup_context *setup,
                                lp_jit_frag_func jit_function0,
                                lp_jit_frag_func jit_function1,
                                boolean opaque )
    @@ -376,7 +376,7 @@ lp_setup_set_fs_functions( struct setup_context *setup,
     }
     
     void
    -lp_setup_set_fs_constants(struct setup_context *setup,
    +lp_setup_set_fs_constants(struct lp_setup_context *setup,
                               struct pipe_buffer *buffer)
     {
        LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) buffer);
    @@ -388,7 +388,7 @@ lp_setup_set_fs_constants(struct setup_context *setup,
     
     
     void
    -lp_setup_set_alpha_ref_value( struct setup_context *setup,
    +lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
                                   float alpha_ref_value )
     {
        LP_DBG(DEBUG_SETUP, "%s %f\n", __FUNCTION__, alpha_ref_value);
    @@ -400,7 +400,7 @@ lp_setup_set_alpha_ref_value( struct setup_context *setup,
     }
     
     void
    -lp_setup_set_blend_color( struct setup_context *setup,
    +lp_setup_set_blend_color( struct lp_setup_context *setup,
                               const struct pipe_blend_color *blend_color )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
    @@ -415,7 +415,7 @@ lp_setup_set_blend_color( struct setup_context *setup,
     
     
     void
    -lp_setup_set_scissor( struct setup_context *setup,
    +lp_setup_set_scissor( struct lp_setup_context *setup,
                           const struct pipe_scissor_state *scissor )
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
    @@ -430,7 +430,7 @@ lp_setup_set_scissor( struct setup_context *setup,
     
     
     void 
    -lp_setup_set_flatshade_first( struct setup_context *setup,
    +lp_setup_set_flatshade_first( struct lp_setup_context *setup,
                                   boolean flatshade_first )
     {
        setup->flatshade_first = flatshade_first;
    @@ -438,7 +438,7 @@ lp_setup_set_flatshade_first( struct setup_context *setup,
     
     
     void 
    -lp_setup_set_vertex_info( struct setup_context *setup,
    +lp_setup_set_vertex_info( struct lp_setup_context *setup,
                               struct vertex_info *vertex_info )
     {
        /* XXX: just silently holding onto the pointer:
    @@ -451,7 +451,7 @@ lp_setup_set_vertex_info( struct setup_context *setup,
      * Called during state validation when LP_NEW_TEXTURE is set.
      */
     void
    -lp_setup_set_sampler_textures( struct setup_context *setup,
    +lp_setup_set_sampler_textures( struct lp_setup_context *setup,
                                    unsigned num, struct pipe_texture **texture)
     {
        unsigned i;
    @@ -512,7 +512,7 @@ lp_setup_set_sampler_textures( struct setup_context *setup,
      * being rendered and the current scene being built.
      */
     unsigned
    -lp_setup_is_texture_referenced( const struct setup_context *setup,
    +lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
                                     const struct pipe_texture *texture )
     {
        unsigned i;
    @@ -541,7 +541,7 @@ lp_setup_is_texture_referenced( const struct setup_context *setup,
      * Called by vbuf code when we're about to draw something.
      */
     void
    -lp_setup_update_state( struct setup_context *setup )
    +lp_setup_update_state( struct lp_setup_context *setup )
     {
        struct lp_scene *scene = lp_setup_get_current_scene(setup);
     
    @@ -659,7 +659,7 @@ lp_setup_update_state( struct setup_context *setup )
     /* Only caller is lp_setup_vbuf_destroy()
      */
     void 
    -lp_setup_destroy( struct setup_context *setup )
    +lp_setup_destroy( struct lp_setup_context *setup )
     {
        reset_context( setup );
     
    @@ -684,12 +684,12 @@ lp_setup_destroy( struct setup_context *setup )
      * the draw module.  Currently also creates a rasterizer to use with
      * it.
      */
    -struct setup_context *
    +struct lp_setup_context *
     lp_setup_create( struct pipe_context *pipe,
                      struct draw_context *draw )
     {
        unsigned i;
    -   struct setup_context *setup = CALLOC_STRUCT(setup_context);
    +   struct lp_setup_context *setup = CALLOC_STRUCT(lp_setup_context);
     
        if (!setup)
           return NULL;
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
    index 17c112b528..71244869a9 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup.h
    +++ b/src/gallium/drivers/llvmpipe/lp_setup.h
    @@ -61,78 +61,78 @@ struct pipe_framebuffer_state;
     struct lp_fragment_shader;
     struct lp_jit_context;
     
    -struct setup_context *
    +struct lp_setup_context *
     lp_setup_create( struct pipe_context *pipe,
                      struct draw_context *draw );
     
     void
    -lp_setup_clear(struct setup_context *setup,
    +lp_setup_clear(struct lp_setup_context *setup,
                    const float *clear_color,
                    double clear_depth,
                    unsigned clear_stencil,
                    unsigned flags);
     
     struct pipe_fence_handle *
    -lp_setup_fence( struct setup_context *setup );
    +lp_setup_fence( struct lp_setup_context *setup );
     
     
     void
    -lp_setup_flush( struct setup_context *setup,
    +lp_setup_flush( struct lp_setup_context *setup,
                     unsigned flags );
     
     
     void
    -lp_setup_bind_framebuffer( struct setup_context *setup,
    +lp_setup_bind_framebuffer( struct lp_setup_context *setup,
                                const struct pipe_framebuffer_state *fb );
     
     void 
    -lp_setup_set_triangle_state( struct setup_context *setup,
    +lp_setup_set_triangle_state( struct lp_setup_context *setup,
                                  unsigned cullmode,
                                  boolean front_is_ccw,
                                  boolean scissor );
     
     void
    -lp_setup_set_fs_inputs( struct setup_context *setup,
    +lp_setup_set_fs_inputs( struct lp_setup_context *setup,
                             const struct lp_shader_input *interp,
                             unsigned nr );
     
     void
    -lp_setup_set_fs_functions( struct setup_context *setup,
    +lp_setup_set_fs_functions( struct lp_setup_context *setup,
                                lp_jit_frag_func jit_function0,
                                lp_jit_frag_func jit_function1,
                                boolean opaque );
     
     void
    -lp_setup_set_fs_constants(struct setup_context *setup,
    +lp_setup_set_fs_constants(struct lp_setup_context *setup,
                               struct pipe_buffer *buffer);
     
     
     void
    -lp_setup_set_alpha_ref_value( struct setup_context *setup,
    +lp_setup_set_alpha_ref_value( struct lp_setup_context *setup,
                                   float alpha_ref_value );
     
     void
    -lp_setup_set_blend_color( struct setup_context *setup,
    +lp_setup_set_blend_color( struct lp_setup_context *setup,
                               const struct pipe_blend_color *blend_color );
     
     void
    -lp_setup_set_scissor( struct setup_context *setup,
    +lp_setup_set_scissor( struct lp_setup_context *setup,
                           const struct pipe_scissor_state *scissor );
     
     void
    -lp_setup_set_sampler_textures( struct setup_context *setup,
    +lp_setup_set_sampler_textures( struct lp_setup_context *setup,
                                    unsigned num, struct pipe_texture **texture);
     
     unsigned
    -lp_setup_is_texture_referenced( const struct setup_context *setup,
    +lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
                                     const struct pipe_texture *texture );
     
     void
    -lp_setup_set_flatshade_first( struct setup_context *setup, 
    +lp_setup_set_flatshade_first( struct lp_setup_context *setup, 
                                   boolean flatshade_first );
     
     void
    -lp_setup_set_vertex_info( struct setup_context *setup, 
    +lp_setup_set_vertex_info( struct lp_setup_context *setup, 
                               struct vertex_info *info );
     
     
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
    index a5fc34e54a..d3c9949dc8 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
    @@ -65,7 +65,7 @@ struct lp_scene_queue;
      * Subclass of vbuf_render, plugged directly into the draw module as
      * the rendering backend.
      */
    -struct setup_context
    +struct lp_setup_context
     {
        struct vbuf_render base;
     
    @@ -131,29 +131,29 @@ struct setup_context
     
        unsigned dirty;   /**< bitmask of LP_SETUP_NEW_x bits */
     
    -   void (*point)( struct setup_context *,
    +   void (*point)( struct lp_setup_context *,
                       const float (*v0)[4]);
     
    -   void (*line)( struct setup_context *,
    +   void (*line)( struct lp_setup_context *,
                      const float (*v0)[4],
                      const float (*v1)[4]);
     
    -   void (*triangle)( struct setup_context *,
    +   void (*triangle)( struct lp_setup_context *,
                          const float (*v0)[4],
                          const float (*v1)[4],
                          const float (*v2)[4]);
     };
     
    -void lp_setup_choose_triangle( struct setup_context *setup );
    -void lp_setup_choose_line( struct setup_context *setup );
    -void lp_setup_choose_point( struct setup_context *setup );
    +void lp_setup_choose_triangle( struct lp_setup_context *setup );
    +void lp_setup_choose_line( struct lp_setup_context *setup );
    +void lp_setup_choose_point( struct lp_setup_context *setup );
     
    -struct lp_scene *lp_setup_get_current_scene(struct setup_context *setup);
    +struct lp_scene *lp_setup_get_current_scene(struct lp_setup_context *setup);
     
    -void lp_setup_init_vbuf(struct setup_context *setup);
    +void lp_setup_init_vbuf(struct lp_setup_context *setup);
     
    -void lp_setup_update_state( struct setup_context *setup );
    +void lp_setup_update_state( struct lp_setup_context *setup );
     
    -void lp_setup_destroy( struct setup_context *setup );
    +void lp_setup_destroy( struct lp_setup_context *setup );
     
     #endif
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_line.c b/src/gallium/drivers/llvmpipe/lp_setup_line.c
    index feea79d394..be41c44e6f 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_line.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_line.c
    @@ -31,7 +31,7 @@
     
     #include "lp_setup_context.h"
     
    -static void line_nop( struct setup_context *setup,
    +static void line_nop( struct lp_setup_context *setup,
                           const float (*v0)[4],
                           const float (*v1)[4] )
     {
    @@ -39,7 +39,7 @@ static void line_nop( struct setup_context *setup,
     
     
     void 
    -lp_setup_choose_line( struct setup_context *setup )
    +lp_setup_choose_line( struct lp_setup_context *setup )
     {
        setup->line = line_nop;
     }
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_point.c b/src/gallium/drivers/llvmpipe/lp_setup_point.c
    index f03ca729b2..9f69e6c5ce 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_point.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_point.c
    @@ -31,14 +31,14 @@
     
     #include "lp_setup_context.h"
     
    -static void point_nop( struct setup_context *setup,
    +static void point_nop( struct lp_setup_context *setup,
                            const float (*v0)[4] )
     {
     }
     
     
     void 
    -lp_setup_choose_point( struct setup_context *setup )
    +lp_setup_choose_point( struct lp_setup_context *setup )
     {
        setup->point = point_nop;
     }
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    index e75412ac9a..8d781e358f 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    @@ -173,7 +173,7 @@ static void setup_facing_coef( struct lp_rast_triangle *tri,
     /**
      * Compute the tri->coef[] array dadx, dady, a0 values.
      */
    -static void setup_tri_coefficients( struct setup_context *setup,
    +static void setup_tri_coefficients( struct lp_setup_context *setup,
     				    struct lp_rast_triangle *tri,
                                         float oneoverarea,
     				    const float (*v1)[4],
    @@ -274,7 +274,7 @@ alloc_triangle(struct lp_scene *scene, unsigned nr_inputs, unsigned *tri_size)
      * bins for the tiles which we overlap.
      */
     static void 
    -do_triangle_ccw(struct setup_context *setup,
    +do_triangle_ccw(struct lp_setup_context *setup,
     		const float (*v1)[4],
     		const float (*v2)[4],
     		const float (*v3)[4],
    @@ -565,7 +565,7 @@ do_triangle_ccw(struct setup_context *setup,
     }
     
     
    -static void triangle_cw( struct setup_context *setup,
    +static void triangle_cw( struct lp_setup_context *setup,
     			 const float (*v0)[4],
     			 const float (*v1)[4],
     			 const float (*v2)[4] )
    @@ -574,7 +574,7 @@ static void triangle_cw( struct setup_context *setup,
     }
     
     
    -static void triangle_ccw( struct setup_context *setup,
    +static void triangle_ccw( struct lp_setup_context *setup,
     			 const float (*v0)[4],
     			 const float (*v1)[4],
     			 const float (*v2)[4] )
    @@ -583,7 +583,7 @@ static void triangle_ccw( struct setup_context *setup,
     }
     
     
    -static void triangle_both( struct setup_context *setup,
    +static void triangle_both( struct lp_setup_context *setup,
     			   const float (*v0)[4],
     			   const float (*v1)[4],
     			   const float (*v2)[4] )
    @@ -602,7 +602,7 @@ static void triangle_both( struct setup_context *setup,
     }
     
     
    -static void triangle_nop( struct setup_context *setup,
    +static void triangle_nop( struct lp_setup_context *setup,
     			  const float (*v0)[4],
     			  const float (*v1)[4],
     			  const float (*v2)[4] )
    @@ -611,7 +611,7 @@ static void triangle_nop( struct setup_context *setup,
     
     
     void 
    -lp_setup_choose_triangle( struct setup_context *setup )
    +lp_setup_choose_triangle( struct lp_setup_context *setup )
     {
        switch (setup->cullmode) {
        case PIPE_WINDING_NONE:
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
    index 671e74465c..d7336d82b2 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_vbuf.c
    @@ -48,10 +48,10 @@
       
     
     /** cast wrapper */
    -static struct setup_context *
    -setup_context(struct vbuf_render *vbr)
    +static struct lp_setup_context *
    +lp_setup_context(struct vbuf_render *vbr)
     {
    -   return (struct setup_context *) vbr;
    +   return (struct lp_setup_context *) vbr;
     }
     
     
    @@ -59,7 +59,7 @@ setup_context(struct vbuf_render *vbr)
     static const struct vertex_info *
     lp_setup_get_vertex_info(struct vbuf_render *vbr)
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        return setup->vertex_info;
     }
     
    @@ -68,7 +68,7 @@ static boolean
     lp_setup_allocate_vertices(struct vbuf_render *vbr,
                               ushort vertex_size, ushort nr_vertices)
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        unsigned size = vertex_size * nr_vertices;
     
        if (setup->vertex_buffer_size < size) {
    @@ -92,7 +92,7 @@ lp_setup_release_vertices(struct vbuf_render *vbr)
     static void *
     lp_setup_map_vertices(struct vbuf_render *vbr)
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        return setup->vertex_buffer;
     }
     
    @@ -101,7 +101,7 @@ lp_setup_unmap_vertices(struct vbuf_render *vbr,
                            ushort min_index,
                            ushort max_index )
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        assert( setup->vertex_buffer_size >= (max_index+1) * setup->vertex_size );
        /* do nothing */
     }
    @@ -110,7 +110,7 @@ lp_setup_unmap_vertices(struct vbuf_render *vbr,
     static boolean
     lp_setup_set_primitive(struct vbuf_render *vbr, unsigned prim)
     {
    -   setup_context(vbr)->prim = prim;
    +   lp_setup_context(vbr)->prim = prim;
        return TRUE;
     }
     
    @@ -129,7 +129,7 @@ static INLINE const_float4_ptr get_vert( const void *vertex_buffer,
     static void
     lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        const unsigned stride = setup->vertex_info->size * sizeof(float);
        const void *vertex_buffer = setup->vertex_buffer;
        unsigned i;
    @@ -284,7 +284,7 @@ lp_setup_draw(struct vbuf_render *vbr, const ushort *indices, uint nr)
     static void
     lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
     {
    -   struct setup_context *setup = setup_context(vbr);
    +   struct lp_setup_context *setup = lp_setup_context(vbr);
        const unsigned stride = setup->vertex_info->size * sizeof(float);
        const void *vertex_buffer =
           (void *) get_vert(setup->vertex_buffer, start, stride);
    @@ -436,7 +436,7 @@ lp_setup_draw_arrays(struct vbuf_render *vbr, uint start, uint nr)
     static void
     lp_setup_vbuf_destroy(struct vbuf_render *vbr)
     {
    -   lp_setup_destroy(setup_context(vbr));
    +   lp_setup_destroy(lp_setup_context(vbr));
     }
     
     
    @@ -444,7 +444,7 @@ lp_setup_vbuf_destroy(struct vbuf_render *vbr)
      * Create the post-transform vertex handler for the given context.
      */
     void
    -lp_setup_init_vbuf(struct setup_context *setup)
    +lp_setup_init_vbuf(struct lp_setup_context *setup)
     {
        setup->base.max_indices = LP_MAX_VBUF_INDEXES;
        setup->base.max_vertex_buffer_bytes = LP_MAX_VBUF_SIZE;
    -- 
    cgit v1.2.3
    
    
    From a80e33f40731f07e8a39896bfdcd1b1504aedc1f Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Sat, 13 Mar 2010 11:22:39 +0000
    Subject: llvmpipe: Obey rasterization rules.
    
    Replicates softpipe.
    ---
     src/gallium/drivers/llvmpipe/lp_setup.c            |  4 +-
     src/gallium/drivers/llvmpipe/lp_setup.h            |  3 +-
     src/gallium/drivers/llvmpipe/lp_setup_context.h    |  1 +
     src/gallium/drivers/llvmpipe/lp_setup_tri.c        | 59 ++++++++++++----------
     src/gallium/drivers/llvmpipe/lp_state_rasterizer.c |  3 +-
     5 files changed, 40 insertions(+), 30 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
    index ba55daf78f..16128c34c8 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup.c
    @@ -337,7 +337,8 @@ void
     lp_setup_set_triangle_state( struct lp_setup_context *setup,
                                  unsigned cull_mode,
                                  boolean ccw_is_frontface,
    -                             boolean scissor )
    +                             boolean scissor,
    +                             boolean gl_rasterization_rules)
     {
        LP_DBG(DEBUG_SETUP, "%s\n", __FUNCTION__);
     
    @@ -345,6 +346,7 @@ lp_setup_set_triangle_state( struct lp_setup_context *setup,
        setup->cullmode = cull_mode;
        setup->triangle = first_triangle;
        setup->scissor_test = scissor;
    +   setup->pixel_offset = gl_rasterization_rules ? 0.5f : 0.0f;
     }
     
     
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
    index 71244869a9..be1bf96f12 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup.h
    +++ b/src/gallium/drivers/llvmpipe/lp_setup.h
    @@ -89,7 +89,8 @@ void
     lp_setup_set_triangle_state( struct lp_setup_context *setup,
                                  unsigned cullmode,
                                  boolean front_is_ccw,
    -                             boolean scissor );
    +                             boolean scissor,
    +                             boolean gl_rasterization_rules );
     
     void
     lp_setup_set_fs_inputs( struct lp_setup_context *setup,
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
    index d3c9949dc8..464fb36984 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
    @@ -89,6 +89,7 @@ struct lp_setup_context
        boolean ccw_is_frontface;
        boolean scissor_test;
        unsigned cullmode;
    +   float pixel_offset;
     
        struct pipe_framebuffer_state fb;
     
    diff --git a/src/gallium/drivers/llvmpipe/lp_setup_tri.c b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    index 8d781e358f..ac6264dc73 100644
    --- a/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    +++ b/src/gallium/drivers/llvmpipe/lp_setup_tri.c
    @@ -41,7 +41,8 @@
     /**
      * Compute a0 for a constant-valued coefficient (GL_FLAT shading).
      */
    -static void constant_coef( struct lp_rast_triangle *tri,
    +static void constant_coef( struct lp_setup_context *setup,
    +                           struct lp_rast_triangle *tri,
                                unsigned slot,
     			   const float value,
                                unsigned i )
    @@ -56,7 +57,8 @@ static void constant_coef( struct lp_rast_triangle *tri,
      * Compute a0, dadx and dady for a linearly interpolated coefficient,
      * for a triangle.
      */
    -static void linear_coef( struct lp_rast_triangle *tri,
    +static void linear_coef( struct lp_setup_context *setup,
    +                         struct lp_rast_triangle *tri,
                              float oneoverarea,
                              unsigned slot,
                              const float (*v1)[4],
    @@ -90,8 +92,8 @@ static void linear_coef( struct lp_rast_triangle *tri,
         * instead - i'll switch to this later.
         */
        tri->inputs.a0[slot][i] = (a1 -
    -                              (dadx * (v1[0][0] - 0.5f) +
    -                               dady * (v1[0][1] - 0.5f)));
    +                              (dadx * (v1[0][0] - setup->pixel_offset) +
    +                               dady * (v1[0][1] - setup->pixel_offset)));
     }
     
     
    @@ -103,7 +105,8 @@ static void linear_coef( struct lp_rast_triangle *tri,
      * Later, when we compute the value at a particular fragment position we'll
      * divide the interpolated value by the interpolated W at that fragment.
      */
    -static void perspective_coef( struct lp_rast_triangle *tri,
    +static void perspective_coef( struct lp_setup_context *setup,
    +                              struct lp_rast_triangle *tri,
                                   float oneoverarea,
                                   unsigned slot,
     			      const float (*v1)[4],
    @@ -125,8 +128,8 @@ static void perspective_coef( struct lp_rast_triangle *tri,
        tri->inputs.dadx[slot][i] = dadx;
        tri->inputs.dady[slot][i] = dady;
        tri->inputs.a0[slot][i] = (a1 -
    -                              (dadx * (v1[0][0] - 0.5f) +
    -                               dady * (v1[0][1] - 0.5f)));
    +                              (dadx * (v1[0][0] - setup->pixel_offset) +
    +                               dady * (v1[0][1] - setup->pixel_offset)));
     }
     
     
    @@ -137,7 +140,8 @@ static void perspective_coef( struct lp_rast_triangle *tri,
      * We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
      */
     static void
    -setup_fragcoord_coef(struct lp_rast_triangle *tri,
    +setup_fragcoord_coef(struct lp_setup_context *setup,
    +                     struct lp_rast_triangle *tri,
                          float oneoverarea,
                          unsigned slot,
                          const float (*v1)[4],
    @@ -153,20 +157,21 @@ setup_fragcoord_coef(struct lp_rast_triangle *tri,
        tri->inputs.dadx[slot][1] = 0.0;
        tri->inputs.dady[slot][1] = 1.0;
        /*Z*/
    -   linear_coef(tri, oneoverarea, slot, v1, v2, v3, 0, 2);
    +   linear_coef(setup, tri, oneoverarea, slot, v1, v2, v3, 0, 2);
        /*W*/
    -   linear_coef(tri, oneoverarea, slot, v1, v2, v3, 0, 3);
    +   linear_coef(setup, tri, oneoverarea, slot, v1, v2, v3, 0, 3);
     }
     
     
    -static void setup_facing_coef( struct lp_rast_triangle *tri,
    +static void setup_facing_coef( struct lp_setup_context *setup,
    +                               struct lp_rast_triangle *tri,
                                    unsigned slot,
                                    boolean frontface )
     {
    -   constant_coef( tri, slot, 1.0f - frontface, 0 );
    -   constant_coef( tri, slot, 0.0f, 1 ); /* wasted */
    -   constant_coef( tri, slot, 0.0f, 2 ); /* wasted */
    -   constant_coef( tri, slot, 0.0f, 3 ); /* wasted */
    +   constant_coef( setup, tri, slot, 1.0f - frontface, 0 );
    +   constant_coef( setup, tri, slot, 0.0f, 1 ); /* wasted */
    +   constant_coef( setup, tri, slot, 0.0f, 2 ); /* wasted */
    +   constant_coef( setup, tri, slot, 0.0f, 3 ); /* wasted */
     }
     
     
    @@ -185,7 +190,7 @@ static void setup_tri_coefficients( struct lp_setup_context *setup,
     
        /* The internal position input is in slot zero:
         */
    -   setup_fragcoord_coef(tri, oneoverarea, 0, v1, v2, v3);
    +   setup_fragcoord_coef(setup, tri, oneoverarea, 0, v1, v2, v3);
     
        /* setup interpolation for all the remaining attributes:
         */
    @@ -196,27 +201,27 @@ static void setup_tri_coefficients( struct lp_setup_context *setup,
           switch (setup->fs.input[slot].interp) {
           case LP_INTERP_CONSTANT:
              for (i = 0; i < NUM_CHANNELS; i++)
    -            constant_coef(tri, slot+1, v3[vert_attr][i], i);
    +            constant_coef(setup, tri, slot+1, v3[vert_attr][i], i);
              break;
     
           case LP_INTERP_LINEAR:
              for (i = 0; i < NUM_CHANNELS; i++)
    -            linear_coef(tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
    +            linear_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
              break;
     
           case LP_INTERP_PERSPECTIVE:
              for (i = 0; i < NUM_CHANNELS; i++)
    -            perspective_coef(tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
    +            perspective_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3, vert_attr, i);
              break;
     
           case LP_INTERP_POSITION:
              /* XXX: fix me - duplicates the values in slot zero.
               */
    -         setup_fragcoord_coef(tri, oneoverarea, slot+1, v1, v2, v3);
    +         setup_fragcoord_coef(setup, tri, oneoverarea, slot+1, v1, v2, v3);
              break;
     
           case LP_INTERP_FACING:
    -         setup_facing_coef(tri, slot+1, frontface);
    +         setup_facing_coef(setup, tri, slot+1, frontface);
              break;
     
           default:
    @@ -281,12 +286,12 @@ do_triangle_ccw(struct lp_setup_context *setup,
     		boolean frontfacing )
     {
        /* x/y positions in fixed point */
    -   const int x1 = subpixel_snap(v1[0][0]);
    -   const int x2 = subpixel_snap(v2[0][0]);
    -   const int x3 = subpixel_snap(v3[0][0]);
    -   const int y1 = subpixel_snap(v1[0][1]);
    -   const int y2 = subpixel_snap(v2[0][1]);
    -   const int y3 = subpixel_snap(v3[0][1]);
    +   const int x1 = subpixel_snap(v1[0][0] + 0.5 - setup->pixel_offset);
    +   const int x2 = subpixel_snap(v2[0][0] + 0.5 - setup->pixel_offset);
    +   const int x3 = subpixel_snap(v3[0][0] + 0.5 - setup->pixel_offset);
    +   const int y1 = subpixel_snap(v1[0][1] + 0.5 - setup->pixel_offset);
    +   const int y2 = subpixel_snap(v2[0][1] + 0.5 - setup->pixel_offset);
    +   const int y3 = subpixel_snap(v3[0][1] + 0.5 - setup->pixel_offset);
     
        struct lp_scene *scene = lp_setup_get_current_scene(setup);
        struct lp_rast_triangle *tri;
    diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
    index feb012816c..6df3ef25b0 100644
    --- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
    +++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c
    @@ -62,7 +62,8 @@ void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe,
           lp_setup_set_triangle_state( llvmpipe->setup,
                        llvmpipe->rasterizer->cull_mode,
                        llvmpipe->rasterizer->front_winding == PIPE_WINDING_CCW,
    -                   llvmpipe->rasterizer->scissor);
    +                   llvmpipe->rasterizer->scissor,
    +                   llvmpipe->rasterizer->gl_rasterization_rules);
        }
     
        llvmpipe->dirty |= LP_NEW_RASTERIZER;
    -- 
    cgit v1.2.3
    
    
    From 3abc7b985ce0787c5103d1a86bd0ba07b127a82f Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Sat, 13 Mar 2010 16:04:06 +0000
    Subject: llvmpipe: Don't use texture transfer internally.
    
    Now that transfers are context objects their sideeffects must happen in
    order when used by the state tracker, but that synchronization must be
    bypassed when used inside the driver, or it would cause infinite
    recursion.
    ---
     src/gallium/drivers/llvmpipe/lp_rast.c    |  14 +--
     src/gallium/drivers/llvmpipe/lp_scene.c   |  70 +++++--------
     src/gallium/drivers/llvmpipe/lp_scene.h   |   2 -
     src/gallium/drivers/llvmpipe/lp_texture.c | 158 ++++++++++++++++++------------
     src/gallium/drivers/llvmpipe/lp_texture.h |  22 +++++
     5 files changed, 150 insertions(+), 116 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
    index dd9a8e8856..81ea11a16b 100644
    --- a/src/gallium/drivers/llvmpipe/lp_rast.c
    +++ b/src/gallium/drivers/llvmpipe/lp_rast.c
    @@ -62,18 +62,20 @@ lp_rast_begin( struct lp_rasterizer *rast,
        rast->state.write_color = write_color;
        
        for (i = 0; i < rast->state.nr_cbufs; i++) {
    +      struct pipe_surface *cbuf = scene->fb.cbufs[i];
           rast->cbuf[i].map = scene->cbuf_map[i];
    -      rast->cbuf[i].format = scene->cbuf_transfer[i]->texture->format;
    -      rast->cbuf[i].width = scene->cbuf_transfer[i]->width;
    -      rast->cbuf[i].height = scene->cbuf_transfer[i]->height;
    -      rast->cbuf[i].stride = scene->cbuf_transfer[i]->stride;
    +      rast->cbuf[i].format = cbuf->texture->format;
    +      rast->cbuf[i].width = cbuf->width;
    +      rast->cbuf[i].height = cbuf->height;
    +      rast->cbuf[i].stride = llvmpipe_texture_stride(cbuf->texture, cbuf->level);
        }
     
        if (write_zstencil) {
    +      struct pipe_surface *zsbuf = scene->fb.zsbuf;
           rast->zsbuf.map = scene->zsbuf_map;
    -      rast->zsbuf.stride = scene->zsbuf_transfer->stride;
    +      rast->zsbuf.stride = llvmpipe_texture_stride(zsbuf->texture, zsbuf->level);
           rast->zsbuf.blocksize = 
    -         util_format_get_blocksize(scene->zsbuf_transfer->texture->format);
    +         util_format_get_blocksize(zsbuf->texture->format);
        }
     
        lp_scene_bin_iter_begin( scene );
    diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
    index 505cb21503..681ce674d4 100644
    --- a/src/gallium/drivers/llvmpipe/lp_scene.c
    +++ b/src/gallium/drivers/llvmpipe/lp_scene.c
    @@ -397,7 +397,6 @@ end:
     static boolean
     lp_scene_map_buffers( struct lp_scene *scene )
     {
    -   struct pipe_context *pipe = scene->pipe;
        struct pipe_surface *cbuf, *zsbuf;
        int i;
     
    @@ -409,20 +408,10 @@ lp_scene_map_buffers( struct lp_scene *scene )
        for (i = 0; i < scene->fb.nr_cbufs; i++) {
           cbuf = scene->fb.cbufs[i];
           if (cbuf) {
    -	 scene->cbuf_transfer[i] = pipe->get_tex_transfer(pipe,
    -                                                          cbuf->texture,
    -                                                          cbuf->face,
    -                                                          cbuf->level,
    -                                                          cbuf->zslice,
    -                                                          PIPE_TRANSFER_READ_WRITE,
    -                                                          0, 0,
    -                                                          cbuf->width, 
    -                                                          cbuf->height);
    -	 if (!scene->cbuf_transfer[i])
    -	    goto fail;
    -
    -	 scene->cbuf_map[i] = pipe->transfer_map(pipe, 
    -                                                 scene->cbuf_transfer[i]);
    +	 scene->cbuf_map[i] = llvmpipe_texture_map(cbuf->texture,
    +	                                           cbuf->face,
    +                                                   cbuf->level,
    +                                                   cbuf->zslice);
     	 if (!scene->cbuf_map[i])
     	    goto fail;
           }
    @@ -432,20 +421,10 @@ lp_scene_map_buffers( struct lp_scene *scene )
         */
        zsbuf = scene->fb.zsbuf;
        if (zsbuf) {
    -      scene->zsbuf_transfer = pipe->get_tex_transfer(pipe,
    -                                                       zsbuf->texture,
    -                                                       zsbuf->face,
    -                                                       zsbuf->level,
    -                                                       zsbuf->zslice,
    -                                                       PIPE_TRANSFER_READ_WRITE,
    -                                                       0, 0,
    -                                                       zsbuf->width,
    -                                                       zsbuf->height);
    -      if (!scene->zsbuf_transfer)
    -         goto fail;
    -
    -      scene->zsbuf_map = pipe->transfer_map(pipe, 
    -                                              scene->zsbuf_transfer);
    +      scene->zsbuf_map = llvmpipe_texture_map(zsbuf->texture,
    +                                              zsbuf->face,
    +                                              zsbuf->level,
    +                                              zsbuf->zslice);
           if (!scene->zsbuf_map)
     	 goto fail;
        }
    @@ -469,28 +448,27 @@ fail:
     static void
     lp_scene_unmap_buffers( struct lp_scene *scene )
     {
    -   struct pipe_context *pipe = scene->pipe;
        unsigned i;
     
        for (i = 0; i < scene->fb.nr_cbufs; i++) {
    -      if (scene->cbuf_map[i]) 
    -	 pipe->transfer_unmap(pipe, scene->cbuf_transfer[i]);
    -
    -      if (scene->cbuf_transfer[i])
    -	 pipe->tex_transfer_destroy(pipe, scene->cbuf_transfer[i]);
    -
    -      scene->cbuf_transfer[i] = NULL;
    -      scene->cbuf_map[i] = NULL;
    +      if (scene->cbuf_map[i]) {
    +         struct pipe_surface *cbuf = scene->fb.cbufs[i];
    +         llvmpipe_texture_unmap(cbuf->texture,
    +                                cbuf->face,
    +                                cbuf->level,
    +                                cbuf->zslice);
    +         scene->cbuf_map[i] = NULL;
    +      }
        }
     
    -   if (scene->zsbuf_map) 
    -      pipe->transfer_unmap(pipe, scene->zsbuf_transfer);
    -
    -   if (scene->zsbuf_transfer)
    -      pipe->tex_transfer_destroy(pipe, scene->zsbuf_transfer);
    -
    -   scene->zsbuf_transfer = NULL;
    -   scene->zsbuf_map = NULL;
    +   if (scene->zsbuf_map) {
    +      struct pipe_surface *zsbuf = scene->fb.zsbuf;
    +      llvmpipe_texture_unmap(zsbuf->texture,
    +                             zsbuf->face,
    +                             zsbuf->level,
    +                             zsbuf->zslice);
    +      scene->zsbuf_map = NULL;
    +   }
     
        util_unreference_framebuffer_state( &scene->fb );
     }
    diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h
    index 739ac22908..b602b1e8a0 100644
    --- a/src/gallium/drivers/llvmpipe/lp_scene.h
    +++ b/src/gallium/drivers/llvmpipe/lp_scene.h
    @@ -114,8 +114,6 @@ struct texture_ref {
      */
     struct lp_scene {
        struct pipe_context *pipe;
    -   struct pipe_transfer *cbuf_transfer[PIPE_MAX_COLOR_BUFS];
    -   struct pipe_transfer *zsbuf_transfer;
     
        /* Scene's buffers are mapped at the time the scene is enqueued:
         */
    diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
    index f2c6dbd088..f3f0cd7b47 100644
    --- a/src/gallium/drivers/llvmpipe/lp_texture.c
    +++ b/src/gallium/drivers/llvmpipe/lp_texture.c
    @@ -40,6 +40,7 @@
     
     #include "lp_context.h"
     #include "lp_screen.h"
    +#include "lp_flush.h"
     #include "lp_texture.h"
     #include "lp_tile_size.h"
     #include "state_tracker/sw_winsys.h"
    @@ -163,6 +164,92 @@ llvmpipe_texture_destroy(struct pipe_texture *pt)
     }
     
     
    +/**
    + * Map a texture. Without any synchronization.
    + */
    +void *
    +llvmpipe_texture_map(struct pipe_texture *texture,
    +                     unsigned face,
    +                     unsigned level,
    +                     unsigned zslice)
    +{
    +   struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
    +   uint8_t *map;
    +
    +   if (lpt->dt) {
    +      /* display target */
    +      struct llvmpipe_screen *screen = llvmpipe_screen(texture->screen);
    +      struct sw_winsys *winsys = screen->winsys;
    +      const unsigned usage = PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    +
    +      assert(face == 0);
    +      assert(level == 0);
    +      assert(zslice == 0);
    +
    +      /* FIXME: keep map count? */
    +      map = winsys->displaytarget_map(winsys, lpt->dt, usage);
    +   }
    +   else {
    +      /* regular texture */
    +      unsigned offset;
    +      unsigned stride;
    +
    +      map = lpt->data;
    +
    +      assert(level < LP_MAX_TEXTURE_2D_LEVELS);
    +
    +      offset = lpt->level_offset[level];
    +      stride = lpt->stride[level];
    +
    +      /* XXX shouldn't that rather be
    +         tex_height = align(u_minify(texture->height0, level), 2)
    +         to account for alignment done in llvmpipe_texture_layout ?
    +      */
    +      if (texture->target == PIPE_TEXTURE_CUBE) {
    +         unsigned tex_height = u_minify(texture->height0, level);
    +         offset += face *  util_format_get_nblocksy(texture->format, tex_height) * stride;
    +      }
    +      else if (texture->target == PIPE_TEXTURE_3D) {
    +         unsigned tex_height = u_minify(texture->height0, level);
    +         offset += zslice * util_format_get_nblocksy(texture->format, tex_height) * stride;
    +      }
    +      else {
    +         assert(face == 0);
    +         assert(zslice == 0);
    +      }
    +
    +      map += offset;
    +   }
    +
    +   return map;
    +}
    +
    +
    +/**
    + * Unmap a texture. Without any synchronization.
    + */
    +void
    +llvmpipe_texture_unmap(struct pipe_texture *texture,
    +                       unsigned face,
    +                       unsigned level,
    +                       unsigned zslice)
    +{
    +   struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
    +
    +   if (lpt->dt) {
    +      /* display target */
    +      struct llvmpipe_screen *lp_screen = llvmpipe_screen(texture->screen);
    +      struct sw_winsys *winsys = lp_screen->winsys;
    +
    +      assert(face == 0);
    +      assert(level == 0);
    +      assert(zslice == 0);
    +
    +      winsys->displaytarget_unmap(winsys, lpt->dt);
    +   }
    +}
    +
    +
     static struct pipe_surface *
     llvmpipe_get_tex_surface(struct pipe_screen *screen,
                              struct pipe_texture *pt,
    @@ -181,7 +268,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
           ps->format = pt->format;
           ps->width = u_minify(pt->width0, level);
           ps->height = u_minify(pt->height0, level);
    -      ps->offset = lpt->level_offset[level];
           ps->usage = usage;
     
           /* Because we are llvmpipe, anything that the state tracker
    @@ -207,23 +293,6 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
           ps->face = face;
           ps->level = level;
           ps->zslice = zslice;
    -
    -      /* XXX shouldn't that rather be
    -         tex_height = align(ps->height, 2);
    -         to account for alignment done in llvmpipe_texture_layout ?
    -      */
    -      if (pt->target == PIPE_TEXTURE_CUBE) {
    -         unsigned tex_height = ps->height;
    -         ps->offset += face * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
    -      }
    -      else if (pt->target == PIPE_TEXTURE_3D) {
    -         unsigned tex_height = ps->height;
    -         ps->offset += zslice * util_format_get_nblocksy(pt->format, tex_height) * lpt->stride[level];
    -      }
    -      else {
    -         assert(face == 0);
    -         assert(zslice == 0);
    -      }
        }
        return ps;
     }
    @@ -269,24 +338,6 @@ llvmpipe_get_tex_transfer(struct pipe_context *pipe,
           pt->level = level;
           pt->zslice = zslice;
     
    -      lpt->offset = lptex->level_offset[level];
    -
    -      /* XXX shouldn't that rather be
    -         tex_height = align(u_minify(texture->height0, level), 2)
    -         to account for alignment done in llvmpipe_texture_layout ?
    -      */
    -      if (texture->target == PIPE_TEXTURE_CUBE) {
    -         unsigned tex_height = u_minify(texture->height0, level);
    -         lpt->offset += face *  util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
    -      }
    -      else if (texture->target == PIPE_TEXTURE_3D) {
    -         unsigned tex_height = u_minify(texture->height0, level);
    -         lpt->offset += zslice * util_format_get_nblocksy(texture->format, tex_height) * pt->stride;
    -      }
    -      else {
    -         assert(face == 0);
    -         assert(zslice == 0);
    -      }
           return pt;
        }
        return NULL;
    @@ -312,7 +363,7 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
                            struct pipe_transfer *transfer )
     {
        struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
    -   ubyte *map, *xfer_map;
    +   ubyte *map;
        struct llvmpipe_texture *lpt;
        enum pipe_format format;
     
    @@ -320,34 +371,24 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
        lpt = llvmpipe_texture(transfer->texture);
        format = lpt->base.format;
     
    -   if (lpt->dt) {
    -      /* display target */
    -      struct sw_winsys *winsys = screen->winsys;
     
    -      map = winsys->displaytarget_map(winsys, lpt->dt,
    -                                      pipe_transfer_buffer_flags(transfer));
    -      if (map == NULL)
    -         return NULL;
    -   }
    -   else {
    -      /* regular texture */
    -      map = lpt->data;
    -   }
    +   map = llvmpipe_texture_map(transfer->texture,
    +                              transfer->face, transfer->level, transfer->zslice);
     
        /* May want to different things here depending on read/write nature
         * of the map:
         */
    -   if (transfer->texture && (transfer->usage & PIPE_TRANSFER_WRITE)) {
    +   if (transfer->usage & PIPE_TRANSFER_WRITE) {
           /* Do something to notify sharing contexts of a texture change.
            */
           screen->timestamp++;
        }
        
    -   xfer_map = map + llvmpipe_transfer(transfer)->offset +
    +   map +=
           transfer->y / util_format_get_blockheight(format) * transfer->stride +
           transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
    -   /*printf("map = %p  xfer map = %p\n", map, xfer_map);*/
    -   return xfer_map;
    +
    +   return map;
     }
     
     
    @@ -355,17 +396,10 @@ static void
     llvmpipe_transfer_unmap(struct pipe_context *pipe,
                             struct pipe_transfer *transfer)
     {
    -   struct llvmpipe_screen *lp_screen = llvmpipe_screen(pipe->screen);
    -   struct llvmpipe_texture *lpt;
    -
        assert(transfer->texture);
    -   lpt = llvmpipe_texture(transfer->texture);
     
    -   if (lpt->dt) {
    -      /* display target */
    -      struct sw_winsys *winsys = lp_screen->winsys;
    -      winsys->displaytarget_unmap(winsys, lpt->dt);
    -   }
    +   llvmpipe_texture_unmap(transfer->texture,
    +                          transfer->face, transfer->level, transfer->zslice);
     }
     
     
    diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h
    index 94b667abf3..2350c26e4f 100644
    --- a/src/gallium/drivers/llvmpipe/lp_texture.h
    +++ b/src/gallium/drivers/llvmpipe/lp_texture.h
    @@ -95,6 +95,28 @@ llvmpipe_transfer(struct pipe_transfer *pt)
     }
     
     
    +static INLINE unsigned
    +llvmpipe_texture_stride(struct pipe_texture *texture,
    +                        unsigned level)
    +{
    +   struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
    +   assert(level < LP_MAX_TEXTURE_2D_LEVELS);
    +   return lpt->stride[level];
    +}
    +
    +
    +void *
    +llvmpipe_texture_map(struct pipe_texture *texture,
    +                     unsigned face,
    +                     unsigned level,
    +                     unsigned zslice);
    +
    +void
    +llvmpipe_texture_unmap(struct pipe_texture *texture,
    +                       unsigned face,
    +                       unsigned level,
    +                       unsigned zslice);
    +
     extern void
     llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen);
     
    -- 
    cgit v1.2.3
    
    
    From bf40c346637325862d6d9cdbc9838c5726abc0c0 Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Sat, 13 Mar 2010 16:13:26 +0000
    Subject: llvmpipe: Ensure the context is flushed before modifying textures.
    
    ---
     src/gallium/drivers/llvmpipe/lp_flush.c   | 65 +++++++++++++++++++++++++++++++
     src/gallium/drivers/llvmpipe/lp_flush.h   | 12 ++++++
     src/gallium/drivers/llvmpipe/lp_surface.c | 15 +++++++
     src/gallium/drivers/llvmpipe/lp_texture.c | 10 +++++
     4 files changed, 102 insertions(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c
    index 1b4e889935..636d72a9bb 100644
    --- a/src/gallium/drivers/llvmpipe/lp_flush.c
    +++ b/src/gallium/drivers/llvmpipe/lp_flush.c
    @@ -92,3 +92,68 @@ llvmpipe_flush( struct pipe_context *pipe,
     #endif
     }
     
    +
    +/**
    + * Flush context if necessary.
    + *
    + * TODO: move this logic to an auxiliary library?
    + *
    + * FIXME: We must implement DISCARD/DONTBLOCK/UNSYNCHRONIZED/etc for
    + * textures to avoid blocking.
    + */
    +boolean
    +llvmpipe_flush_texture(struct pipe_context *pipe,
    +                       struct pipe_texture *texture,
    +                       unsigned face,
    +                       unsigned level,
    +                       unsigned flush_flags,
    +                       boolean read_only,
    +                       boolean cpu_access,
    +                       boolean do_not_flush)
    +{
    +   struct pipe_fence_handle *last_fence = NULL;
    +   unsigned referenced;
    +
    +   referenced = pipe->is_texture_referenced(pipe, texture, face, level);
    +
    +   if ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
    +       ((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) {
    +
    +      if (do_not_flush)
    +         return FALSE;
    +
    +      /*
    +       * TODO: The semantics of these flush flags are too obtuse. They should
    +       * disappear and the pipe driver should just ensure that all visible
    +       * side-effects happen when they need to happen.
    +       */
    +      if (referenced & PIPE_REFERENCED_FOR_WRITE)
    +         flush_flags |= PIPE_FLUSH_RENDER_CACHE;
    +
    +      if (referenced & PIPE_REFERENCED_FOR_READ)
    +         flush_flags |= PIPE_FLUSH_TEXTURE_CACHE;
    +
    +      if (cpu_access) {
    +         /*
    +          * Flush and wait.
    +          */
    +
    +         struct pipe_fence_handle *fence = NULL;
    +
    +         pipe->flush(pipe, flush_flags, &fence);
    +
    +         if (last_fence) {
    +            pipe->screen->fence_finish(pipe->screen, fence, 0);
    +            pipe->screen->fence_reference(pipe->screen, &fence, NULL);
    +         }
    +      } else {
    +         /*
    +          * Just flush.
    +          */
    +
    +         pipe->flush(pipe, flush_flags, NULL);
    +      }
    +   }
    +
    +   return TRUE;
    +}
    diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h
    index 10b2b52583..e13f57ccec 100644
    --- a/src/gallium/drivers/llvmpipe/lp_flush.h
    +++ b/src/gallium/drivers/llvmpipe/lp_flush.h
    @@ -28,10 +28,22 @@
     #ifndef LP_FLUSH_H
     #define LP_FLUSH_H
     
    +#include "pipe/p_compiler.h"
    +
     struct pipe_context;
     struct pipe_fence_handle;
     
     void llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
                         struct pipe_fence_handle **fence);
     
    +boolean
    +llvmpipe_flush_texture(struct pipe_context *pipe,
    +                       struct pipe_texture *texture,
    +                       unsigned face,
    +                       unsigned level,
    +                       unsigned flush_flags,
    +                       boolean read_only,
    +                       boolean cpu_access,
    +                       boolean do_not_flush);
    +
     #endif
    diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c
    index 6110b0a193..ca3d62c361 100644
    --- a/src/gallium/drivers/llvmpipe/lp_surface.c
    +++ b/src/gallium/drivers/llvmpipe/lp_surface.c
    @@ -27,6 +27,7 @@
     
     #include "util/u_rect.h"
     #include "lp_context.h"
    +#include "lp_flush.h"
     #include "lp_surface.h"
     
     
    @@ -36,6 +37,20 @@ lp_surface_copy(struct pipe_context *pipe,
                     struct pipe_surface *src, unsigned srcx, unsigned srcy,
                     unsigned width, unsigned height)
     {
    +   llvmpipe_flush_texture(pipe,
    +                          dest->texture, dest->face, dest->level,
    +                          0, /* flush_flags */
    +                          FALSE, /* read_only */
    +                          FALSE, /* cpu_access */
    +                          FALSE); /* do_not_flush */
    +
    +   llvmpipe_flush_texture(pipe,
    +                          src->texture, src->face, src->level,
    +                          0, /* flush_flags */
    +                          TRUE, /* read_only */
    +                          FALSE, /* cpu_access */
    +                          FALSE); /* do_not_flush */
    +
        util_surface_copy(pipe, FALSE,
                          dest, destx, desty,
                          src, srcx, srcy,
    diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
    index f3f0cd7b47..9a85a42897 100644
    --- a/src/gallium/drivers/llvmpipe/lp_texture.c
    +++ b/src/gallium/drivers/llvmpipe/lp_texture.c
    @@ -371,6 +371,16 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
        lpt = llvmpipe_texture(transfer->texture);
        format = lpt->base.format;
     
    +   /*
    +    * Transfers, like other pipe operations, must happen in order, so flush the
    +    * context if necessary.
    +    */
    +   llvmpipe_flush_texture(pipe,
    +                          transfer->texture, transfer->face, transfer->level,
    +                          0, /* flush_flags */
    +                          !(transfer->usage & PIPE_TRANSFER_WRITE), /* read_only */
    +                          TRUE, /* cpu_access */
    +                          FALSE); /* do_not_flush */
     
        map = llvmpipe_texture_map(transfer->texture,
                                   transfer->face, transfer->level, transfer->zslice);
    -- 
    cgit v1.2.3
    
    
    From e31bca139f720396d1a1639b46d37aee4fd9736e Mon Sep 17 00:00:00 2001
    From: Marek Olšák 
    Date: Sat, 13 Mar 2010 04:43:46 +0100
    Subject: r300g: fix up function names
    
    ---
     src/gallium/drivers/r300/r300_emit.c | 2 +-
     src/gallium/drivers/r300/r300_emit.h | 3 +--
     2 files changed, 2 insertions(+), 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
    index 55e9217fd3..f8242625fe 100644
    --- a/src/gallium/drivers/r300/r300_emit.c
    +++ b/src/gallium/drivers/r300/r300_emit.c
    @@ -448,7 +448,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
         END_CS;
     }
     
    -static void r300_emit_query_start(struct r300_context *r300)
    +void r300_emit_query_start(struct r300_context *r300)
     {
         struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps;
         struct r300_query *query = r300->query_current;
    diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
    index 449e640a88..7db2fc6a1a 100644
    --- a/src/gallium/drivers/r300/r300_emit.h
    +++ b/src/gallium/drivers/r300/r300_emit.h
    @@ -57,8 +57,7 @@ void r500_emit_fs_constant_buffer(struct r300_context* r300,
     
     void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state);
     
    -void r300_emit_query_begin(struct r300_context* r300,
    -                           struct r300_query* query);
    +void r300_emit_query_start(struct r300_context* r300);
     
     void r300_emit_query_end(struct r300_context* r300);
     
    -- 
    cgit v1.2.3
    
    
    From bcec6d851ce6ec2d948f03e5a1adfb5871e4e627 Mon Sep 17 00:00:00 2001
    From: Marek Olšák 
    Date: Sat, 13 Mar 2010 06:07:33 +0100
    Subject: r300g: refrain from using immediate mode if it causes slowdown
    
    E.g. when mapping buffers could flush CS or cause waiting
    for a busy buffer.
    
    The side effect of this is it also fixes progs/demos/arbocclude however
    a separate fix should be proposed to address this issue in other cases
    it might occur.
    ---
     src/gallium/drivers/r300/r300_render.c             | 33 ++++++++++++++++++++--
     src/gallium/winsys/drm/radeon/core/radeon_buffer.c | 14 +++++++++
     src/gallium/winsys/drm/radeon/core/radeon_winsys.h |  3 ++
     3 files changed, 48 insertions(+), 2 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
    index ccf39876a5..971e7f3521 100644
    --- a/src/gallium/drivers/r300/r300_render.c
    +++ b/src/gallium/drivers/r300/r300_render.c
    @@ -131,9 +131,38 @@ static boolean r300_reserve_cs_space(struct r300_context *r300,
     }
     
     static boolean immd_is_good_idea(struct r300_context *r300,
    -                                      unsigned count)
    +                                 unsigned count)
     {
    -    return count <= 4;
    +    struct pipe_vertex_element* velem;
    +    struct pipe_vertex_buffer* vbuf;
    +    boolean checked[PIPE_MAX_ATTRIBS] = {0};
    +    unsigned vertex_element_count = r300->velems->count;
    +    unsigned i, vbi;
    +
    +    if (count > 4) {
    +        return FALSE;
    +    }
    +
    +    /* We shouldn't map buffers referenced by CS, busy buffers,
    +     * and ones placed in VRAM. */
    +    /* XXX Check for VRAM buffers. */
    +    for (i = 0; i < vertex_element_count; i++) {
    +        velem = &r300->velems->velem[i];
    +        vbi = velem->vertex_buffer_index;
    +
    +        if (!checked[vbi]) {
    +            vbuf = &r300->vertex_buffer[vbi];
    +
    +            if (r300->winsys->is_buffer_referenced(r300->winsys,
    +                                                   vbuf->buffer)) {
    +                /* It's a very bad idea to map it... */
    +                return FALSE;
    +            }
    +            checked[vbi] = TRUE;
    +        }
    +    }
    +
    +    return TRUE;
     }
     
     static void r300_emit_draw_arrays_immediate(struct r300_context *r300,
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
    index daa032af6f..25b58b2926 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.c
    @@ -213,6 +213,18 @@ static void radeon_buffer_unmap(struct pipe_winsys *ws,
         }
     }
     
    +static boolean radeon_is_buffer_referenced(struct radeon_winsys *ws,
    +                                           struct pipe_buffer *buffer)
    +{
    +    struct radeon_pipe_buffer *radeon_buffer =
    +        (struct radeon_pipe_buffer*)buffer;
    +    uint32_t domain;
    +
    +    /* Referenced by CS or HW. */
    +    return radeon_bo_is_referenced_by_cs(radeon_buffer->bo, ws->priv->cs) ||
    +           radeon_bo_is_busy(radeon_buffer->bo, &domain);
    +}
    +
     static void radeon_buffer_set_tiling(struct radeon_winsys *ws,
                                          struct pipe_buffer *buffer,
                                          uint32_t pitch,
    @@ -370,5 +382,7 @@ struct radeon_winsys* radeon_pipe_winsys(int fd)
         radeon_ws->buffer_from_handle = radeon_buffer_from_handle;
         radeon_ws->buffer_get_handle = radeon_buffer_get_handle;
     
    +    radeon_ws->is_buffer_referenced = radeon_is_buffer_referenced;
    +
         return radeon_ws;
     }
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    index 37eeb45979..887a381cc4 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    @@ -118,6 +118,9 @@ struct radeon_winsys {
                                   uint32_t pitch,
                                   boolean microtiled,
                                   boolean macrotiled);
    +
    +    boolean (*is_buffer_referenced)(struct radeon_winsys *winsys,
    +                                    struct pipe_buffer *buffer);
     };
     
     #endif
    -- 
    cgit v1.2.3
    
    
    From d5749fb6fc9b7bb3c8a8b1632eee6db28678b3ba Mon Sep 17 00:00:00 2001
    From: Marek Olšák 
    Date: Sat, 13 Mar 2010 16:24:50 +0100
    Subject: r300g: fix anisotropic filtering, fix macrotiling
    
    Two bug fixes at the same time. :)
    ---
     src/gallium/drivers/r300/r300_state.c | 4 ++--
     1 file changed, 2 insertions(+), 2 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
    index ced6c810ec..bcd75a4225 100644
    --- a/src/gallium/drivers/r300/r300_state.c
    +++ b/src/gallium/drivers/r300/r300_state.c
    @@ -864,6 +864,8 @@ static void*
                                                        state->min_mip_filter,
                                                        state->max_anisotropy > 0);
     
    +    sampler->filter0 |= r300_anisotropy(state->max_anisotropy);
    +
         /* Unfortunately, r300-r500 don't support floating-point mipmap lods. */
         /* We must pass these to the merge function to clamp them properly. */
         sampler->min_lod = MAX2((unsigned)state->min_lod, 0);
    @@ -873,8 +875,6 @@ static void*
     
         sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT;
     
    -    sampler->filter1 |= r300_anisotropy(state->max_anisotropy);
    -
         util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
         sampler->border_color = uc.ui;
     
    -- 
    cgit v1.2.3
    
    
    From 3996e493693d5aa048fed1c2fd6db4027cb47df4 Mon Sep 17 00:00:00 2001
    From: Marek Olšák 
    Date: Sat, 13 Mar 2010 17:38:43 +0100
    Subject: r300g: add high quality anisotropic filtering for R5xx (disabled by
     default)
    
    Oh look, an undocumented feature. It's a nice tool for benchmarking
    texturing.
    ---
     src/gallium/drivers/r300/r300_debug.c         |  1 +
     src/gallium/drivers/r300/r300_reg.h           |  4 ++++
     src/gallium/drivers/r300/r300_screen.h        |  1 +
     src/gallium/drivers/r300/r300_state.c         |  9 +++++++++
     src/gallium/drivers/r300/r300_state_inlines.h | 12 ++++++++++++
     5 files changed, 27 insertions(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c
    index b881730848..d6177577c8 100644
    --- a/src/gallium/drivers/r300/r300_debug.c
    +++ b/src/gallium/drivers/r300/r300_debug.c
    @@ -37,6 +37,7 @@ static struct debug_option debug_options[] = {
         { "draw", DBG_DRAW, "Draw and emit" },
         { "tex", DBG_TEX, "Textures" },
         { "fall", DBG_FALL, "Fallbacks" },
    +    { "anisohq", DBG_ANISOHQ, "High quality anisotropic filtering (for benchmarking purposes only!)" },
     
         { "all", ~0, "Convenience option that enables all debug flags" },
     
    diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
    index c67cc86871..1c2b252887 100644
    --- a/src/gallium/drivers/r300/r300_reg.h
    +++ b/src/gallium/drivers/r300/r300_reg.h
    @@ -1500,6 +1500,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
     #	define R300_ANISO_THRESHOLD_MASK       (7<<17)
     
     #	define R500_MACRO_SWITCH               (1<<22)
    +#       define R500_TX_MAX_ANISO(x)            ((x) << 23)
    +#       define R500_TX_MAX_ANISO_MASK          (63 << 23)
    +#       define R500_TX_ANISO_HIGH_QUALITY      (1 << 30)
    +
     #	define R500_BORDER_FIX                 (1<<31)
     
     #define R300_TX_FORMAT0_0                   0x4480
    diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
    index 484bde6a6b..71310b2692 100644
    --- a/src/gallium/drivers/r300/r300_screen.h
    +++ b/src/gallium/drivers/r300/r300_screen.h
    @@ -77,6 +77,7 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys);
     #define DBG_DRAW    0x0000010
     #define DBG_TEX     0x0000020
     #define DBG_FALL    0x0000040
    +#define DBG_ANISOHQ 0x0000080
     /*@}*/
     
     static INLINE boolean SCREEN_DBG_ON(struct r300_screen * screen, unsigned flags)
    diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
    index bcd75a4225..3098145dfb 100644
    --- a/src/gallium/drivers/r300/r300_state.c
    +++ b/src/gallium/drivers/r300/r300_state.c
    @@ -849,6 +849,7 @@ static void*
     {
         struct r300_context* r300 = r300_context(pipe);
         struct r300_sampler_state* sampler = CALLOC_STRUCT(r300_sampler_state);
    +    boolean is_r500 = r300_screen(pipe->screen)->caps->is_r500;
         int lod_bias;
         union util_color uc;
     
    @@ -875,6 +876,14 @@ static void*
     
         sampler->filter1 |= lod_bias << R300_LOD_BIAS_SHIFT;
     
    +    /* This is very high quality anisotropic filtering for R5xx.
    +     * It's good for benchmarking the performance of texturing but
    +     * in practice we don't want to slow down the driver because it's
    +     * a pretty good performance killer. Feel free to play with it. */
    +    if (DBG_ON(r300, DBG_ANISOHQ) && is_r500) {
    +        sampler->filter1 |= r500_anisotropy(state->max_anisotropy);
    +    }
    +
         util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
         sampler->border_color = uc.ui;
     
    diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h
    index a32924ed0a..8485d4f8f9 100644
    --- a/src/gallium/drivers/r300/r300_state_inlines.h
    +++ b/src/gallium/drivers/r300/r300_state_inlines.h
    @@ -327,6 +327,18 @@ static INLINE uint32_t r300_anisotropy(unsigned max_aniso)
         }
     }
     
    +static INLINE uint32_t r500_anisotropy(unsigned max_aniso)
    +{
    +    if (!max_aniso) {
    +        return 0;
    +    }
    +    max_aniso -= 1;
    +
    +    // Map the range [0, 15] to [0, 63].
    +    return R500_TX_MAX_ANISO(MIN2((unsigned)(max_aniso*4.2001), 63)) |
    +           R500_TX_ANISO_HIGH_QUALITY;;
    +}
    +
     /* Non-CSO state. (For now.) */
     
     static INLINE uint32_t r300_translate_gb_pipes(int pipe_count)
    -- 
    cgit v1.2.3
    
    
    From 392d37609d85f42bf5fbcecbc285857e8ed265e5 Mon Sep 17 00:00:00 2001
    From: José Fonseca 
    Date: Sat, 13 Mar 2010 19:11:08 +0000
    Subject: llvmpipe: Switch to PIPE_TEX_MIPFILTER_NONE when texture has no
     mipmaps.
    
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample.c | 6 +++++-
     1 file changed, 5 insertions(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
    index 543fd5fea3..2f74aa5e00 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
    @@ -84,8 +84,12 @@ lp_sampler_static_state(struct lp_sampler_static_state *state,
        state->wrap_t            = sampler->wrap_t;
        state->wrap_r            = sampler->wrap_r;
        state->min_img_filter    = sampler->min_img_filter;
    -   state->min_mip_filter    = sampler->min_mip_filter;
        state->mag_img_filter    = sampler->mag_img_filter;
    +   if (texture->last_level) {
    +      state->min_mip_filter = sampler->min_mip_filter;
    +   } else {
    +      state->min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
    +   }
     
        state->compare_mode      = sampler->compare_mode;
        if (sampler->compare_mode != PIPE_TEX_COMPARE_NONE) {
    -- 
    cgit v1.2.3
    
    
    From de4ee20578a79e024b0de83c40648112f42c994e Mon Sep 17 00:00:00 2001
    From: Dan Nicholson 
    Date: Sat, 13 Mar 2010 11:56:59 -0800
    Subject: gallium: Respect user's CFLAGS for including X headers
    
    This can break on systems that don't have a system X installation.
    
    Signed-off-by: Dan Nicholson 
    ---
     src/gallium/state_trackers/glx/xlib/Makefile | 3 ++-
     src/gallium/winsys/xlib/Makefile             | 3 ++-
     2 files changed, 4 insertions(+), 2 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/state_trackers/glx/xlib/Makefile b/src/gallium/state_trackers/glx/xlib/Makefile
    index 7b2adc62c3..8c7cc524df 100644
    --- a/src/gallium/state_trackers/glx/xlib/Makefile
    +++ b/src/gallium/state_trackers/glx/xlib/Makefile
    @@ -5,7 +5,8 @@ LIBNAME = xlib
     
     LIBRARY_INCLUDES = \
     	-I$(TOP)/include \
    -	-I$(TOP)/src/mesa
    +	-I$(TOP)/src/mesa \
    +	$(X_CFLAGS)
     
     C_SOURCES = \
     	glx_api.c \
    diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile
    index 68542b488d..18357a4112 100644
    --- a/src/gallium/winsys/xlib/Makefile
    +++ b/src/gallium/winsys/xlib/Makefile
    @@ -6,7 +6,8 @@ LIBNAME = ws_xlib
     LIBRARY_INCLUDES = \
     	-I$(TOP)/src/gallium/include \
     	-I$(TOP)/src/gallium/drivers \
    -	-I$(TOP)/src/gallium/auxiliary
    +	-I$(TOP)/src/gallium/auxiliary \
    +	$(X_CFLAGS)
     
     C_SOURCES = \
     	xlib_sw_winsys.c 
    -- 
    cgit v1.2.3
    
    
    From 2615bba182bf6ec4b406d31e714be78b9161ce8b Mon Sep 17 00:00:00 2001
    From: Vinson Lee 
    Date: Sat, 13 Mar 2010 18:05:39 -0800
    Subject: softpipe: Remove unnecessary header.
    
    ---
     src/gallium/drivers/softpipe/sp_texture.c | 1 -
     1 file changed, 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
    index da8529c154..2aff6118f4 100644
    --- a/src/gallium/drivers/softpipe/sp_texture.c
    +++ b/src/gallium/drivers/softpipe/sp_texture.c
    @@ -36,7 +36,6 @@
     #include "util/u_format.h"
     #include "util/u_math.h"
     #include "util/u_memory.h"
    -#include "util/u_simple_screen.h"
     
     #include "sp_context.h"
     #include "sp_texture.h"
    -- 
    cgit v1.2.3
    
    
    From 6e4b05637fa08020a9142b2391166d2c62b54896 Mon Sep 17 00:00:00 2001
    From: Marek Olšák 
    Date: Sun, 14 Mar 2010 14:32:50 +0100
    Subject: r300g: remove pipe_context from r300_screen
    
    ---
     src/gallium/drivers/r300/r300_context.c | 4 ----
     src/gallium/drivers/r300/r300_screen.h  | 4 ----
     2 files changed, 8 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
    index 8606c0004e..ed24fb54ab 100644
    --- a/src/gallium/drivers/r300/r300_context.c
    +++ b/src/gallium/drivers/r300/r300_context.c
    @@ -162,8 +162,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
         if (!r300)
             return NULL;
     
    -    r300screen->ctx = (struct pipe_context*)r300;
    -
         r300->winsys = radeon_winsys;
     
         r300->context.winsys = (struct pipe_winsys*)radeon_winsys;
    @@ -212,8 +210,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     
         r300_init_transfer_functions(r300);
     
    -    /* r300_init_surface_functions(r300); */
    -
         r300_init_state_functions(r300);
     
         r300->invariant_state.dirty = TRUE;
    diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
    index 71310b2692..abc1303e12 100644
    --- a/src/gallium/drivers/r300/r300_screen.h
    +++ b/src/gallium/drivers/r300/r300_screen.h
    @@ -38,10 +38,6 @@ struct r300_screen {
     
         struct radeon_winsys* radeon_winsys;
     
    -    /* XXX This hack will be removed once texture transfers become part of
    -     * pipe_context. */
    -    struct pipe_context* ctx;
    -
         /* Chipset capabilities */
         struct r300_capabilities* caps;
     
    -- 
    cgit v1.2.3
    
    
    From 08cddfe2912ec6f8cb2a54dfa5ae12f755e549f8 Mon Sep 17 00:00:00 2001
    From: Vinson Lee 
    Date: Sun, 14 Mar 2010 15:38:04 -0700
    Subject: svga: Remove unnecessary header.
    
    ---
     src/gallium/drivers/svga/svga_screen_texture.c | 2 --
     1 file changed, 2 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
    index 107e4a3962..4a058eda88 100644
    --- a/src/gallium/drivers/svga/svga_screen_texture.c
    +++ b/src/gallium/drivers/svga/svga_screen_texture.c
    @@ -41,8 +41,6 @@
     #include "svga_debug.h"
     #include "svga_screen_buffer.h"
     
    -#include 
    -
     
     /* XXX: This isn't a real hardware flag, but just a hack for kernel to
      * know about primary surfaces. Find a better way to accomplish this.
    -- 
    cgit v1.2.3
    
    
    From 725d77a6b535672a6fde89935913ca18a882f892 Mon Sep 17 00:00:00 2001
    From: Vinson Lee 
    Date: Sun, 14 Mar 2010 15:47:05 -0700
    Subject: trace: Remove unnecessary headers.
    
    ---
     src/gallium/drivers/trace/tr_drm.c | 3 ---
     1 file changed, 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c
    index 906b3262e4..eaa47df406 100644
    --- a/src/gallium/drivers/trace/tr_drm.c
    +++ b/src/gallium/drivers/trace/tr_drm.c
    @@ -30,9 +30,6 @@
     #include "util/u_memory.h"
     #include "tr_drm.h"
     #include "tr_screen.h"
    -#include "tr_context.h"
    -#include "tr_buffer.h"
    -#include "tr_texture.h"
     #include "tr_public.h"
     
     struct trace_drm_api
    -- 
    cgit v1.2.3
    
    
    From 883aa5974bcf31f19294cb40b0c4df43bb550820 Mon Sep 17 00:00:00 2001
    From: Vinson Lee 
    Date: Sun, 14 Mar 2010 16:43:01 -0700
    Subject: r300g: Remove unnecessary headers.
    
    ---
     src/gallium/drivers/r300/r300_screen.c | 1 -
     src/gallium/drivers/r300/r300_vs.c     | 2 --
     2 files changed, 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
    index 64d1909a38..b6282fccd7 100644
    --- a/src/gallium/drivers/r300/r300_screen.c
    +++ b/src/gallium/drivers/r300/r300_screen.c
    @@ -29,7 +29,6 @@
     #include "r300_texture.h"
     
     #include "radeon_winsys.h"
    -#include "r300_winsys.h"
     
     /* Return the identifier behind whom the brave coders responsible for this
      * amalgamation of code, sweat, and duct tape, routinely obscure their names.
    diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c
    index 379939ac75..bd6b95dccb 100644
    --- a/src/gallium/drivers/r300/r300_vs.c
    +++ b/src/gallium/drivers/r300/r300_vs.c
    @@ -34,8 +34,6 @@
     
     #include "radeon_compiler.h"
     
    -#include "util/u_math.h"
    -
     /* Convert info about VS output semantics into r300_shader_semantics. */
     static void r300_shader_read_vs_outputs(
         struct tgsi_shader_info* info,
    -- 
    cgit v1.2.3
    
    
    From 5f71414fc941f0d390c03633f1a53534807cfca6 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 17:43:31 +0100
    Subject: nv40: use NV34TCL_ constants where available
    
    It was decided to just use the NV34TCL_ constants for constants
    common between nv30 and nv40, and deprecate the NV40TCL_ versions.
    
    This patch changes the nv40 driver to use NV34TCL_ constants for
    common functionality.
    
    This reduces differences between nv30 and nv40 to ease further
    unification.
    ---
     src/gallium/drivers/nv40/nv40_draw.c           |  40 ++++----
     src/gallium/drivers/nv40/nv40_fragprog.c       |   8 +-
     src/gallium/drivers/nv40/nv40_fragtex.c        |  30 +++---
     src/gallium/drivers/nv40/nv40_query.c          |  10 +-
     src/gallium/drivers/nv40/nv40_screen.c         |  14 +--
     src/gallium/drivers/nv40/nv40_state.c          | 122 ++++++++++++-------------
     src/gallium/drivers/nv40/nv40_state_blend.c    |   2 +-
     src/gallium/drivers/nv40/nv40_state_fb.c       |  36 ++++----
     src/gallium/drivers/nv40/nv40_state_scissor.c  |   2 +-
     src/gallium/drivers/nv40/nv40_state_stipple.c  |   6 +-
     src/gallium/drivers/nv40/nv40_state_viewport.c |   2 +-
     src/gallium/drivers/nv40/nv40_state_zsa.c      |   4 +-
     src/gallium/drivers/nv40/nv40_vbo.c            |  74 +++++++--------
     src/gallium/drivers/nv40/nv40_vertprog.c       |  22 ++---
     14 files changed, 186 insertions(+), 186 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    index 48bd84d16c..849f24fe40 100644
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ b/src/gallium/drivers/nv40/nv40_draw.c
    @@ -44,29 +44,29 @@ nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
     		case EMIT_OMIT:
     			break;
     		case EMIT_1F:
    -			BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_1F(hw), 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_1F(hw), 1);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			break;
     		case EMIT_2F:
    -			BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_2F_X(hw), 2);
    +			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_2F_X(hw), 2);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			break;
     		case EMIT_3F:
    -			BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_3F_X(hw), 3);
    +			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_3F_X(hw), 3);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			OUT_RING  (chan, fui(v->data[idx][2]));
     			break;
     		case EMIT_4F:
    -			BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_4F_X(hw), 4);
    +			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_4F_X(hw), 4);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			OUT_RING  (chan, fui(v->data[idx][2]));
     			OUT_RING  (chan, fui(v->data[idx][3]));
     			break;
     		case EMIT_4UB:
    -			BEGIN_RING(chan, curie, NV40TCL_VTX_ATTR_4UB(hw), 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_4UB(hw), 1);
     			OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
     					    float_to_ubyte(v->data[idx][1]),
     					    float_to_ubyte(v->data[idx][2]),
    @@ -93,7 +93,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     
     	/* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
     	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    -		if (rs->prim != NV40TCL_BEGIN_END_STOP) {
    +		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
     			NOUVEAU_ERR("AIII, missed flush\n");
     			assert(0);
     		}
    @@ -103,12 +103,12 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     
     	/* Switch primitive modes if necessary */
     	if (rs->prim != mode) {
    -		if (rs->prim != NV40TCL_BEGIN_END_STOP) {
    -			BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    -			OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
    +		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    +			BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +			OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, mode);
     		rs->prim = mode;
     	}
    @@ -121,28 +121,28 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     	 * off the primitive now.
     	 */
     	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    -		OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
    -		rs->prim = NV40TCL_BEGIN_END_STOP;
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    +		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
     	}
     }
     
     static void
     nv40_render_point(struct draw_stage *draw, struct prim_header *prim)
     {
    -	nv40_render_prim(draw, prim, NV40TCL_BEGIN_END_POINTS, 1);
    +	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_POINTS, 1);
     }
     
     static void
     nv40_render_line(struct draw_stage *draw, struct prim_header *prim)
     {
    -	nv40_render_prim(draw, prim, NV40TCL_BEGIN_END_LINES, 2);
    +	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_LINES, 2);
     }
     
     static void
     nv40_render_tri(struct draw_stage *draw, struct prim_header *prim)
     {
    -	nv40_render_prim(draw, prim, NV40TCL_BEGIN_END_TRIANGLES, 3);
    +	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_TRIANGLES, 3);
     }
     
     static void
    @@ -154,10 +154,10 @@ nv40_render_flush(struct draw_stage *draw, unsigned flags)
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *curie = screen->curie;
     
    -	if (rs->prim != NV40TCL_BEGIN_END_STOP) {
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    -		OUT_RING  (chan, NV40TCL_BEGIN_END_STOP);
    -		rs->prim = NV40TCL_BEGIN_END_STOP;
    +	if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    +		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
     	}
     }
     
    diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
    index dc24f9b08a..d881fea6f5 100644
    --- a/src/gallium/drivers/nv40/nv40_fragprog.c
    +++ b/src/gallium/drivers/nv40/nv40_fragprog.c
    @@ -920,12 +920,12 @@ nv40_fragprog_validate(struct nv40_context *nv40)
     	nv40_fragprog_upload(nv40, fp);
     
     	so = so_new(2, 2, 1);
    -	so_method(so, nv40->screen->curie, NV40TCL_FP_ADDRESS, 1);
    +	so_method(so, nv40->screen->curie, NV34TCL_FP_ACTIVE_PROGRAM, 1);
     	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
     		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
    -		      NOUVEAU_BO_OR, NV40TCL_FP_ADDRESS_DMA0,
    -		      NV40TCL_FP_ADDRESS_DMA1);
    -	so_method(so, nv40->screen->curie, NV40TCL_FP_CONTROL, 1);
    +		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
    +		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    +	so_method(so, nv40->screen->curie, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
     	so_ref(so, &fp->so);
     	so_ref(NULL, &so);
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index b60118922a..44bf4333bd 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -7,12 +7,12 @@
       TRUE,                                                                        \
       PIPE_FORMAT_##m,                                                             \
       NV40TCL_TEX_FORMAT_FORMAT_##tf,                                              \
    -  (NV40TCL_TEX_SWIZZLE_S0_X_##ts0x | NV40TCL_TEX_SWIZZLE_S0_Y_##ts0y |         \
    -   NV40TCL_TEX_SWIZZLE_S0_Z_##ts0z | NV40TCL_TEX_SWIZZLE_S0_W_##ts0w |         \
    -   NV40TCL_TEX_SWIZZLE_S1_X_##ts1x | NV40TCL_TEX_SWIZZLE_S1_Y_##ts1y |         \
    -   NV40TCL_TEX_SWIZZLE_S1_Z_##ts1z | NV40TCL_TEX_SWIZZLE_S1_W_##ts1w),         \
    -  ((NV40TCL_TEX_FILTER_SIGNED_RED*sx) | (NV40TCL_TEX_FILTER_SIGNED_GREEN*sy) |       \
    -   (NV40TCL_TEX_FILTER_SIGNED_BLUE*sz) | (NV40TCL_TEX_FILTER_SIGNED_ALPHA*sw))       \
    +  (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |         \
    +   NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |         \
    +   NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |         \
    +   NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w),         \
    +  ((NV34TCL_TX_FILTER_SIGNED_RED*sx) | (NV34TCL_TX_FILTER_SIGNED_GREEN*sy) |       \
    +   (NV34TCL_TX_FILTER_SIGNED_BLUE*sz) | (NV34TCL_TX_FILTER_SIGNED_ALPHA*sw))       \
     }
     
     struct nv40_texture_format {
    @@ -81,20 +81,20 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	txf |= ((pt->last_level + 1) << NV40TCL_TEX_FORMAT_MIPMAP_COUNT_SHIFT);
     
     	if (1) /* XXX */
    -		txf |= NV40TCL_TEX_FORMAT_NO_BORDER;
    +		txf |= NV34TCL_TX_FORMAT_NO_BORDER;
     
     	switch (pt->target) {
     	case PIPE_TEXTURE_CUBE:
    -		txf |= NV40TCL_TEX_FORMAT_CUBIC;
    +		txf |= NV34TCL_TX_FORMAT_CUBIC;
     		/* fall-through */
     	case PIPE_TEXTURE_2D:
    -		txf |= NV40TCL_TEX_FORMAT_DIMS_2D;
    +		txf |= NV34TCL_TX_FORMAT_DIMS_2D;
     		break;
     	case PIPE_TEXTURE_3D:
    -		txf |= NV40TCL_TEX_FORMAT_DIMS_3D;
    +		txf |= NV34TCL_TX_FORMAT_DIMS_3D;
     		break;
     	case PIPE_TEXTURE_1D:
    -		txf |= NV40TCL_TEX_FORMAT_DIMS_1D;
    +		txf |= NV34TCL_TX_FORMAT_DIMS_1D;
     		break;
     	default:
     		NOUVEAU_ERR("Unknown target %d\n", pt->target);
    @@ -111,15 +111,15 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	txs = tf->swizzle;
     
     	so = so_new(2, 9, 2);
    -	so_method(so, nv40->screen->curie, NV40TCL_TEX_OFFSET(unit), 8);
    +	so_method(so, nv40->screen->curie, NV34TCL_TX_OFFSET(unit), 8);
     	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
     	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
    -		      NV40TCL_TEX_FORMAT_DMA0, NV40TCL_TEX_FORMAT_DMA1);
    +		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
     	so_data  (so, ps->wrap);
     	so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
     	so_data  (so, txs);
     	so_data  (so, ps->filt | tf->sign | 0x2000 /*voodoo*/);
    -	so_data  (so, (pt->width0 << NV40TCL_TEX_SIZE0_W_SHIFT) |
    +	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
     		       pt->height0);
     	so_data  (so, ps->bcol);
     	so_method(so, nv40->screen->curie, NV40TCL_TEX_SIZE1(unit), 1);
    @@ -142,7 +142,7 @@ nv40_fragtex_validate(struct nv40_context *nv40)
     		samplers &= ~(1 << unit);
     
     		so = so_new(1, 1, 0);
    -		so_method(so, nv40->screen->curie, NV40TCL_TEX_ENABLE(unit), 1);
    +		so_method(so, nv40->screen->curie, NV34TCL_TX_ENABLE(unit), 1);
     		so_data  (so, 0);
     		so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
     		state->dirty |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
    diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c
    index 8ed4a67dd0..45c5468537 100644
    --- a/src/gallium/drivers/nv40/nv40_query.c
    +++ b/src/gallium/drivers/nv40/nv40_query.c
    @@ -60,9 +60,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     		assert(0);
     	nouveau_notifier_reset(nv40->screen->query, q->object->start);
     
    -	BEGIN_RING(chan, curie, NV40TCL_QUERY_RESET, 1);
    +	BEGIN_RING(chan, curie, NV34TCL_QUERY_RESET, 1);
     	OUT_RING  (chan, 1);
    -	BEGIN_RING(chan, curie, NV40TCL_QUERY_UNK17CC, 1);
    +	BEGIN_RING(chan, curie, NV34TCL_QUERY_UNK17CC, 1);
     	OUT_RING  (chan, 1);
     
     	q->ready = FALSE;
    @@ -77,9 +77,9 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *curie = screen->curie;
     
    -	BEGIN_RING(chan, curie, NV40TCL_QUERY_GET, 1);
    -	OUT_RING  (chan, (0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
    -		   ((q->object->start * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
    +	BEGIN_RING(chan, curie, NV34TCL_QUERY_GET, 1);
    +	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
    +		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
     	FIRE_RING(chan);
     }
     
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    index dbcc33d8d9..9c49e2b6ec 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ b/src/gallium/drivers/nv40/nv40_screen.c
    @@ -264,23 +264,23 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     
     	/* Static curie initialisation */
     	so = so_new(16, 25, 0);
    -	so_method(so, screen->curie, NV40TCL_DMA_NOTIFY, 1);
    +	so_method(so, screen->curie, NV34TCL_DMA_NOTIFY, 1);
     	so_data  (so, screen->sync->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_TEXTURE0, 2);
    +	so_method(so, screen->curie, NV34TCL_DMA_TEXTURE0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_COLOR1, 1);
    +	so_method(so, screen->curie, NV34TCL_DMA_COLOR1, 1);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_COLOR0, 2);
    +	so_method(so, screen->curie, NV34TCL_DMA_COLOR0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_VTXBUF0, 2);
    +	so_method(so, screen->curie, NV34TCL_DMA_VTXBUF0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_FENCE, 2);
    +	so_method(so, screen->curie, NV34TCL_DMA_FENCE, 2);
     	so_data  (so, 0);
     	so_data  (so, screen->query->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_UNK01AC, 2);
    +	so_method(so, screen->curie, NV34TCL_DMA_IN_MEMORY7, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
     	so_method(so, screen->curie, NV40TCL_DMA_COLOR2, 2);
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    index ee471e6ce4..3db000a219 100644
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ b/src/gallium/drivers/nv40/nv40_state.c
    @@ -19,7 +19,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
     	struct nouveau_stateobj *so = so_new(5, 8, 0);
     
     	if (cso->rt[0].blend_enable) {
    -		so_method(so, curie, NV40TCL_BLEND_ENABLE, 3);
    +		so_method(so, curie, NV34TCL_BLEND_FUNC_ENABLE, 3);
     		so_data  (so, 1);
     		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
     			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
    @@ -29,26 +29,26 @@ nv40_blend_state_create(struct pipe_context *pipe,
     		so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
     			      nvgl_blend_eqn(cso->rt[0].rgb_func));
     	} else {
    -		so_method(so, curie, NV40TCL_BLEND_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_BLEND_FUNC_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, curie, NV40TCL_COLOR_MASK, 1);
    +	so_method(so, curie, NV34TCL_COLOR_MASK, 1);
     	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
     
     	if (cso->logicop_enable) {
    -		so_method(so, curie, NV40TCL_COLOR_LOGIC_OP_ENABLE, 2);
    +		so_method(so, curie, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
     		so_data  (so, 1);
     		so_data  (so, nvgl_logicop_func(cso->logicop_func));
     	} else {
    -		so_method(so, curie, NV40TCL_COLOR_LOGIC_OP_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, curie, NV40TCL_DITHER_ENABLE, 1);
    +	so_method(so, curie, NV34TCL_DITHER_ENABLE, 1);
     	so_data  (so, cso->dither ? 1 : 0);
     
     	so_ref(so, &bso->so);
    @@ -82,19 +82,19 @@ wrap_mode(unsigned wrap) {
     
     	switch (wrap) {
     	case PIPE_TEX_WRAP_REPEAT:
    -		ret = NV40TCL_TEX_WRAP_S_REPEAT;
    +		ret = NV34TCL_TX_WRAP_S_REPEAT;
     		break;
     	case PIPE_TEX_WRAP_MIRROR_REPEAT:
    -		ret = NV40TCL_TEX_WRAP_S_MIRRORED_REPEAT;
    +		ret = NV34TCL_TX_WRAP_S_MIRRORED_REPEAT;
     		break;
     	case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
    -		ret = NV40TCL_TEX_WRAP_S_CLAMP_TO_EDGE;
    +		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE;
     		break;
     	case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
    -		ret = NV40TCL_TEX_WRAP_S_CLAMP_TO_BORDER;
    +		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER;
     		break;
     	case PIPE_TEX_WRAP_CLAMP:
    -		ret = NV40TCL_TEX_WRAP_S_CLAMP;
    +		ret = NV34TCL_TX_WRAP_S_CLAMP;
     		break;
     	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
     		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
    @@ -107,11 +107,11 @@ wrap_mode(unsigned wrap) {
     		break;
     	default:
     		NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
    -		ret = NV40TCL_TEX_WRAP_S_REPEAT;
    +		ret = NV34TCL_TX_WRAP_S_REPEAT;
     		break;
     	}
     
    -	return ret >> NV40TCL_TEX_WRAP_S_SHIFT;
    +	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
     }
     
     static void *
    @@ -127,9 +127,9 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     	if (!cso->normalized_coords)
     		ps->fmt |= NV40TCL_TEX_FORMAT_RECT;
     
    -	ps->wrap = ((wrap_mode(cso->wrap_s) << NV40TCL_TEX_WRAP_S_SHIFT) |
    -		    (wrap_mode(cso->wrap_t) << NV40TCL_TEX_WRAP_T_SHIFT) |
    -		    (wrap_mode(cso->wrap_r) << NV40TCL_TEX_WRAP_R_SHIFT));
    +	ps->wrap = ((wrap_mode(cso->wrap_s) << NV34TCL_TX_WRAP_S_SHIFT) |
    +		    (wrap_mode(cso->wrap_t) << NV34TCL_TX_WRAP_T_SHIFT) |
    +		    (wrap_mode(cso->wrap_r) << NV34TCL_TX_WRAP_R_SHIFT));
     
     	ps->en = 0;
     	if (cso->max_anisotropy >= 2) {
    @@ -160,11 +160,11 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     
     	switch (cso->mag_img_filter) {
     	case PIPE_TEX_FILTER_LINEAR:
    -		filter |= NV40TCL_TEX_FILTER_MAG_LINEAR;
    +		filter |= NV34TCL_TX_FILTER_MAGNIFY_LINEAR;
     		break;
     	case PIPE_TEX_FILTER_NEAREST:
     	default:
    -		filter |= NV40TCL_TEX_FILTER_MAG_NEAREST;
    +		filter |= NV34TCL_TX_FILTER_MAGNIFY_NEAREST;
     		break;
     	}
     
    @@ -172,14 +172,14 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     	case PIPE_TEX_FILTER_LINEAR:
     		switch (cso->min_mip_filter) {
     		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV40TCL_TEX_FILTER_MIN_LINEAR_MIPMAP_NEAREST;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
     			break;
     		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV40TCL_TEX_FILTER_MIN_LINEAR_MIPMAP_LINEAR;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
     			break;
     		case PIPE_TEX_MIPFILTER_NONE:
     		default:
    -			filter |= NV40TCL_TEX_FILTER_MIN_LINEAR;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR;
     			break;
     		}
     		break;
    @@ -187,14 +187,14 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     	default:
     		switch (cso->min_mip_filter) {
     		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV40TCL_TEX_FILTER_MIN_NEAREST_MIPMAP_NEAREST;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
     		break;
     		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV40TCL_TEX_FILTER_MIN_NEAREST_MIPMAP_LINEAR;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
     			break;
     		case PIPE_TEX_MIPFILTER_NONE:
     		default:
    -			filter |= NV40TCL_TEX_FILTER_MIN_NEAREST;
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST;
     			break;
     		}
     		break;
    @@ -219,28 +219,28 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     	if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
     		switch (cso->compare_func) {
     		case PIPE_FUNC_NEVER:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_NEVER;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NEVER;
     			break;
     		case PIPE_FUNC_GREATER:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_GREATER;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GREATER;
     			break;
     		case PIPE_FUNC_EQUAL:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_EQUAL;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_EQUAL;
     			break;
     		case PIPE_FUNC_GEQUAL:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_GEQUAL;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GEQUAL;
     			break;
     		case PIPE_FUNC_LESS:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_LESS;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LESS;
     			break;
     		case PIPE_FUNC_NOTEQUAL:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_NOTEQUAL;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NOTEQUAL;
     			break;
     		case PIPE_FUNC_LEQUAL:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_LEQUAL;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LEQUAL;
     			break;
     		case PIPE_FUNC_ALWAYS:
    -			ps->wrap |= NV40TCL_TEX_WRAP_RCOMP_ALWAYS;
    +			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_ALWAYS;
     			break;
     		default:
     			break;
    @@ -319,66 +319,66 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	 * 	multisample
     	 */
     
    -	so_method(so, curie, NV40TCL_SHADE_MODEL, 1);
    -	so_data  (so, cso->flatshade ? NV40TCL_SHADE_MODEL_FLAT :
    -				       NV40TCL_SHADE_MODEL_SMOOTH);
    +	so_method(so, curie, NV34TCL_SHADE_MODEL, 1);
    +	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
    +				       NV34TCL_SHADE_MODEL_SMOOTH);
     
    -	so_method(so, curie, NV40TCL_LINE_WIDTH, 2);
    +	so_method(so, curie, NV34TCL_LINE_WIDTH, 2);
     	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
     	so_data  (so, cso->line_smooth ? 1 : 0);
    -	so_method(so, curie, NV40TCL_LINE_STIPPLE_ENABLE, 2);
    +	so_method(so, curie, NV34TCL_LINE_STIPPLE_ENABLE, 2);
     	so_data  (so, cso->line_stipple_enable ? 1 : 0);
     	so_data  (so, (cso->line_stipple_pattern << 16) |
     		       cso->line_stipple_factor);
     
    -	so_method(so, curie, NV40TCL_POINT_SIZE, 1);
    +	so_method(so, curie, NV34TCL_POINT_SIZE, 1);
     	so_data  (so, fui(cso->point_size));
     
    -	so_method(so, curie, NV40TCL_POLYGON_MODE_FRONT, 6);
    +	so_method(so, curie, NV34TCL_POLYGON_MODE_FRONT, 6);
     	if (cso->front_winding == PIPE_WINDING_CCW) {
     		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
     		so_data(so, nvgl_polygon_mode(cso->fill_cw));
     		switch (cso->cull_mode) {
     		case PIPE_WINDING_CCW:
    -			so_data(so, NV40TCL_CULL_FACE_FRONT);
    +			so_data(so, NV34TCL_CULL_FACE_FRONT);
     			break;
     		case PIPE_WINDING_CW:
    -			so_data(so, NV40TCL_CULL_FACE_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
     			break;
     		case PIPE_WINDING_BOTH:
    -			so_data(so, NV40TCL_CULL_FACE_FRONT_AND_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
     			break;
     		default:
    -			so_data(so, NV40TCL_CULL_FACE_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
     			break;
     		}
    -		so_data(so, NV40TCL_FRONT_FACE_CCW);
    +		so_data(so, NV34TCL_FRONT_FACE_CCW);
     	} else {
     		so_data(so, nvgl_polygon_mode(cso->fill_cw));
     		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
     		switch (cso->cull_mode) {
     		case PIPE_WINDING_CCW:
    -			so_data(so, NV40TCL_CULL_FACE_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
     			break;
     		case PIPE_WINDING_CW:
    -			so_data(so, NV40TCL_CULL_FACE_FRONT);
    +			so_data(so, NV34TCL_CULL_FACE_FRONT);
     			break;
     		case PIPE_WINDING_BOTH:
    -			so_data(so, NV40TCL_CULL_FACE_FRONT_AND_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
     			break;
     		default:
    -			so_data(so, NV40TCL_CULL_FACE_BACK);
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
     			break;
     		}
    -		so_data(so, NV40TCL_FRONT_FACE_CW);
    +		so_data(so, NV34TCL_FRONT_FACE_CW);
     	}
     	so_data(so, cso->poly_smooth ? 1 : 0);
     	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
     
    -	so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
    +	so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
     
    -	so_method(so, curie, NV40TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    +	so_method(so, curie, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
     	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
     	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
     		so_data(so, 1);
    @@ -395,12 +395,12 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	else
     		so_data(so, 0);
     	if (cso->offset_cw || cso->offset_ccw) {
    -		so_method(so, curie, NV40TCL_POLYGON_OFFSET_FACTOR, 2);
    +		so_method(so, curie, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
     		so_data  (so, fui(cso->offset_scale));
     		so_data  (so, fui(cso->offset_units * 2));
     	}
     
    -	so_method(so, curie, NV40TCL_POINT_SPRITE, 1);
    +	so_method(so, curie, NV34TCL_POINT_SPRITE, 1);
     	if (cso->point_quad_rasterization) {
     		unsigned psctl = (1 << 0), i;
     
    @@ -448,43 +448,43 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     	struct nouveau_stateobj *so = so_new(6, 20, 0);
     	struct nouveau_grobj *curie = nv40->screen->curie;
     
    -	so_method(so, curie, NV40TCL_DEPTH_FUNC, 3);
    +	so_method(so, curie, NV34TCL_DEPTH_FUNC, 3);
     	so_data  (so, nvgl_comparison_op(cso->depth.func));
     	so_data  (so, cso->depth.writemask ? 1 : 0);
     	so_data  (so, cso->depth.enabled ? 1 : 0);
     
    -	so_method(so, curie, NV40TCL_ALPHA_TEST_ENABLE, 3);
    +	so_method(so, curie, NV34TCL_ALPHA_FUNC_ENABLE, 3);
     	so_data  (so, cso->alpha.enabled ? 1 : 0);
     	so_data  (so, nvgl_comparison_op(cso->alpha.func));
     	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
     
     	if (cso->stencil[0].enabled) {
    -		so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 3);
    +		so_method(so, curie, NV34TCL_STENCIL_FRONT_ENABLE, 3);
     		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[0].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    -		so_method(so, curie, NV40TCL_STENCIL_FRONT_FUNC_MASK, 4);
    +		so_method(so, curie, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[0].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
     	} else {
    -		so_method(so, curie, NV40TCL_STENCIL_FRONT_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_STENCIL_FRONT_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
     	if (cso->stencil[1].enabled) {
    -		so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 3);
    +		so_method(so, curie, NV34TCL_STENCIL_BACK_ENABLE, 3);
     		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[1].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    -		so_method(so, curie, NV40TCL_STENCIL_BACK_FUNC_MASK, 4);
    +		so_method(so, curie, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[1].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
     	} else {
    -		so_method(so, curie, NV40TCL_STENCIL_BACK_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_STENCIL_BACK_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_blend.c b/src/gallium/drivers/nv40/nv40_state_blend.c
    index 3ff00a37f6..9da13123ab 100644
    --- a/src/gallium/drivers/nv40/nv40_state_blend.c
    +++ b/src/gallium/drivers/nv40/nv40_state_blend.c
    @@ -21,7 +21,7 @@ nv40_state_blend_colour_validate(struct nv40_context *nv40)
     	struct nouveau_stateobj *so = so_new(1, 1, 0);
     	struct pipe_blend_color *bcol = &nv40->blend_colour;
     
    -	so_method(so, nv40->screen->curie, NV40TCL_BLEND_COLOR, 1);
    +	so_method(so, nv40->screen->curie, NV34TCL_BLEND_COLOR, 1);
     	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
     		       (float_to_ubyte(bcol->color[0]) << 16) |
     		       (float_to_ubyte(bcol->color[1]) <<  8) |
    diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c
    index fd3fdfddc0..93e91b9e3b 100644
    --- a/src/gallium/drivers/nv40/nv40_state_fb.c
    +++ b/src/gallium/drivers/nv40/nv40_state_fb.c
    @@ -49,23 +49,23 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     		for (i = 1; i < fb->nr_cbufs; i++)
     			assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
     
    -		rt_format = NV40TCL_RT_FORMAT_TYPE_SWIZZLED |
    -		            log2i(fb->width) << NV40TCL_RT_FORMAT_LOG2_WIDTH_SHIFT |
    -		            log2i(fb->height) << NV40TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT;
    +		rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    +		            log2i(fb->width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT |
    +		            log2i(fb->height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT;
     	}
     	else
    -		rt_format = NV40TCL_RT_FORMAT_TYPE_LINEAR;
    +		rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
     
     	switch (colour_format) {
     	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		rt_format |= NV40TCL_RT_FORMAT_COLOR_X8R8G8B8;
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8;
     		break;
     	case PIPE_FORMAT_B8G8R8A8_UNORM:
     	case 0:
    -		rt_format |= NV40TCL_RT_FORMAT_COLOR_A8R8G8B8;
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8;
     		break;
     	case PIPE_FORMAT_B5G6R5_UNORM:
    -		rt_format |= NV40TCL_RT_FORMAT_COLOR_R5G6B5;
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
     		break;
     	default:
     		assert(0);
    @@ -73,23 +73,23 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     
     	switch (zeta_format) {
     	case PIPE_FORMAT_Z16_UNORM:
    -		rt_format |= NV40TCL_RT_FORMAT_ZETA_Z16;
    +		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
     		break;
     	case PIPE_FORMAT_S8Z24_UNORM:
     	case PIPE_FORMAT_X8Z24_UNORM:
     	case 0:
    -		rt_format |= NV40TCL_RT_FORMAT_ZETA_Z24S8;
    +		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
     		break;
     	default:
     		assert(0);
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
    -		so_method(so, curie, NV40TCL_DMA_COLOR0, 1);
    +		so_method(so, curie, NV34TCL_DMA_COLOR0, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV40TCL_COLOR0_PITCH, 2);
    +		so_method(so, curie, NV34TCL_COLOR0_PITCH, 2);
     		so_data  (so, rt[0]->pitch);
     		so_reloc (so, nv40_surface_buffer(&rt[0]->base),
     			      rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    @@ -97,11 +97,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
    -		so_method(so, curie, NV40TCL_DMA_COLOR1, 1);
    +		so_method(so, curie, NV34TCL_DMA_COLOR1, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV40TCL_COLOR1_OFFSET, 2);
    +		so_method(so, curie, NV34TCL_COLOR1_OFFSET, 2);
     		so_reloc (so, nv40_surface_buffer(&rt[1]->base),
     			      rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW,
     			      0, 0);
    @@ -135,11 +135,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	}
     
     	if (zeta_format) {
    -		so_method(so, curie, NV40TCL_DMA_ZETA, 1);
    +		so_method(so, curie, NV34TCL_DMA_ZETA, 1);
     		so_reloc (so, nv40_surface_buffer(&zeta->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV40TCL_ZETA_OFFSET, 1);
    +		so_method(so, curie, NV34TCL_ZETA_OFFSET, 1);
     		so_reloc (so, nv40_surface_buffer(&zeta->base),
     			      zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0);
     		so_method(so, curie, NV40TCL_ZETA_PITCH, 1);
    @@ -148,14 +148,14 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     
     	so_method(so, curie, NV40TCL_RT_ENABLE, 1);
     	so_data  (so, rt_enable);
    -	so_method(so, curie, NV40TCL_RT_HORIZ, 3);
    +	so_method(so, curie, NV34TCL_RT_HORIZ, 3);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
     	so_data  (so, rt_format);
    -	so_method(so, curie, NV40TCL_VIEWPORT_HORIZ, 2);
    +	so_method(so, curie, NV34TCL_VIEWPORT_HORIZ, 2);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
    -	so_method(so, curie, NV40TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    +	so_method(so, curie, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
     	so_data  (so, ((w - 1) << 16) | 0);
     	so_data  (so, ((h - 1) << 16) | 0);
     	so_method(so, curie, 0x1d88, 1);
    diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
    index 753a505e93..91bff4849c 100644
    --- a/src/gallium/drivers/nv40/nv40_state_scissor.c
    +++ b/src/gallium/drivers/nv40/nv40_state_scissor.c
    @@ -13,7 +13,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
     	nv40->state.scissor_enabled = rast->scissor;
     
     	so = so_new(1, 2, 0);
    -	so_method(so, nv40->screen->curie, NV40TCL_SCISSOR_HORIZ, 2);
    +	so_method(so, nv40->screen->curie, NV34TCL_SCISSOR_HORIZ, 2);
     	if (nv40->state.scissor_enabled) {
     		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
     		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    diff --git a/src/gallium/drivers/nv40/nv40_state_stipple.c b/src/gallium/drivers/nv40/nv40_state_stipple.c
    index 2b371ebfec..ed8643b9c1 100644
    --- a/src/gallium/drivers/nv40/nv40_state_stipple.c
    +++ b/src/gallium/drivers/nv40/nv40_state_stipple.c
    @@ -15,14 +15,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40)
     		unsigned i;
     
     		so = so_new(2, 33, 0);
    -		so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 1);
    -		so_method(so, curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    +		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
     		for (i = 0; i < 32; i++)
     			so_data(so, nv40->stipple[i]);
     	} else {
     		so = so_new(1, 1, 0);
    -		so_method(so, curie, NV40TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c
    index 3aacb00f99..3a5ea0e480 100644
    --- a/src/gallium/drivers/nv40/nv40_state_viewport.c
    +++ b/src/gallium/drivers/nv40/nv40_state_viewport.c
    @@ -12,7 +12,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
     
     	so = so_new(2, 9, 0);
     	so_method(so, nv40->screen->curie,
    -		  NV40TCL_VIEWPORT_TRANSLATE_X, 8);
    +		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
     	so_data  (so, fui(vpt->translate[0]));
     	so_data  (so, fui(vpt->translate[1]));
     	so_data  (so, fui(vpt->translate[2]));
    diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c
    index 9cbe7da6db..bf68c60ace 100644
    --- a/src/gallium/drivers/nv40/nv40_state_zsa.c
    +++ b/src/gallium/drivers/nv40/nv40_state_zsa.c
    @@ -22,9 +22,9 @@ nv40_state_sr_validate(struct nv40_context *nv40)
     	struct nouveau_stateobj *so = so_new(2, 2, 0);
     	struct pipe_stencil_ref *sr = &nv40->stencil_ref;
     
    -	so_method(so, nv40->screen->curie, NV40TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_method(so, nv40->screen->curie, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nv40->screen->curie, NV40TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_method(so, nv40->screen->curie, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[1]);
     
     	so_ref(so, &nv40->state.hw[NV40_STATE_SR]);
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    index fabdf4bf23..a2f06ead86 100644
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ b/src/gallium/drivers/nv40/nv40_vbo.c
    @@ -20,19 +20,19 @@ nv40_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
     	case PIPE_FORMAT_R32G32_FLOAT:
     	case PIPE_FORMAT_R32G32B32_FLOAT:
     	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    -		*fmt = NV40TCL_VTXFMT_TYPE_FLOAT;
    +		*fmt = NV34TCL_VTXFMT_TYPE_FLOAT;
     		break;
     	case PIPE_FORMAT_R8_UNORM:
     	case PIPE_FORMAT_R8G8_UNORM:
     	case PIPE_FORMAT_R8G8B8_UNORM:
     	case PIPE_FORMAT_R8G8B8A8_UNORM:
    -		*fmt = NV40TCL_VTXFMT_TYPE_UBYTE;
    +		*fmt = NV34TCL_VTXFMT_TYPE_UBYTE;
     		break;
     	case PIPE_FORMAT_R16_SSCALED:
     	case PIPE_FORMAT_R16G16_SSCALED:
     	case PIPE_FORMAT_R16G16B16_SSCALED:
     	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    -		*fmt = NV40TCL_VTXFMT_TYPE_USHORT;
    +		*fmt = NV34TCL_VTXFMT_TYPE_USHORT;
     		break;
     	default:
     		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    @@ -86,10 +86,10 @@ nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
     
     	switch (ib_size) {
     	case 2:
    -		type = NV40TCL_IDXBUF_FORMAT_TYPE_U16;
    +		type = NV34TCL_IDXBUF_FORMAT_TYPE_U16;
     		break;
     	case 4:
    -		type = NV40TCL_IDXBUF_FORMAT_TYPE_U32;
    +		type = NV34TCL_IDXBUF_FORMAT_TYPE_U32;
     		break;
     	default:
     		return FALSE;
    @@ -122,31 +122,31 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
     	map += vb->buffer_offset + ve->src_offset;
     
     	switch (type) {
    -	case NV40TCL_VTXFMT_TYPE_FLOAT:
    +	case NV34TCL_VTXFMT_TYPE_FLOAT:
     	{
     		float *v = map;
     
     		switch (ncomp) {
     		case 4:
    -			so_method(so, curie, NV40TCL_VTX_ATTR_4F_X(attrib), 4);
    +			so_method(so, curie, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			so_data  (so, fui(v[3]));
     			break;
     		case 3:
    -			so_method(so, curie, NV40TCL_VTX_ATTR_3F_X(attrib), 3);
    +			so_method(so, curie, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			break;
     		case 2:
    -			so_method(so, curie, NV40TCL_VTX_ATTR_2F_X(attrib), 2);
    +			so_method(so, curie, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			break;
     		case 1:
    -			so_method(so, curie, NV40TCL_VTX_ATTR_1F(attrib), 1);
    +			so_method(so, curie, NV34TCL_VTX_ATTR_1F(attrib), 1);
     			so_data  (so, fui(v[0]));
     			break;
     		default:
    @@ -194,12 +194,12 @@ nv40_draw_arrays(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, curie, NV40TCL_VB_VERTEX_BATCH, 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VB_VERTEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -210,14 +210,14 @@ nv40_draw_arrays(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, curie, NV40TCL_VB_VERTEX_BATCH, push);
    +			BEGIN_RING_NI(chan, curie, NV34TCL_VB_VERTEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -249,11 +249,11 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, curie, NV40TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -263,7 +263,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -271,7 +271,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -300,11 +300,11 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, curie, NV40TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -314,7 +314,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -322,7 +322,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -351,20 +351,20 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		while (vc) {
     			push = MIN2(vc, 2047);
     
    -			BEGIN_RING_NI(chan, curie, NV40TCL_VB_ELEMENT_U32, push);
    +			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U32, push);
     			OUT_RINGp    (chan, elts, push);
     
     			vc -= push;
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -426,12 +426,12 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, curie, NV40TCL_VB_INDEX_BATCH, 1);
    +			BEGIN_RING(chan, curie, NV34TCL_VB_INDEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -442,14 +442,14 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, curie, NV40TCL_VB_INDEX_BATCH, push);
    +			BEGIN_RING_NI(chan, curie, NV34TCL_VB_INDEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, curie, NV40TCL_BEGIN_END, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -493,9 +493,9 @@ nv40_vbo_validate(struct nv40_context *nv40)
     	int hw;
     
     	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
    +	so_method(vtxbuf, curie, NV34TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
     	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt->num_elements);
    +	so_method(vtxfmt, curie, NV34TCL_VTXFMT(0), nv40->vtxelt->num_elements);
     
     	for (hw = 0; hw < nv40->vtxelt->num_elements; hw++) {
     		struct pipe_vertex_element *ve;
    @@ -511,7 +511,7 @@ nv40_vbo_validate(struct nv40_context *nv40)
     
     			if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) {
     				so_data(vtxbuf, 0);
    -				so_data(vtxfmt, NV40TCL_VTXFMT_TYPE_FLOAT);
    +				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
     				continue;
     			}
     		}
    @@ -526,18 +526,18 @@ nv40_vbo_validate(struct nv40_context *nv40)
     		so_reloc(vtxbuf, nouveau_bo(vb->buffer),
     				 vb->buffer_offset + ve->src_offset,
     				 vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
    -				 0, NV40TCL_VTXBUF_ADDRESS_DMA1);
    -		so_data (vtxfmt, ((vb->stride << NV40TCL_VTXFMT_STRIDE_SHIFT) |
    -				  (ncomp << NV40TCL_VTXFMT_SIZE_SHIFT) | type));
    +				 0, NV34TCL_VTXBUF_ADDRESS_DMA1);
    +		so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) |
    +				  (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type));
     	}
     
     	if (ib) {
     		struct nouveau_bo *bo = nouveau_bo(ib);
     
    -		so_method(vtxbuf, curie, NV40TCL_IDXBUF_ADDRESS, 2);
    +		so_method(vtxbuf, curie, NV34TCL_IDXBUF_ADDRESS, 2);
     		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
     		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
    -			  0, NV40TCL_IDXBUF_FORMAT_DMA1);
    +			  0, NV34TCL_IDXBUF_FORMAT_DMA1);
     	}
     
     	so_method(vtxbuf, curie, 0x1710, 1);
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    index c93c5d127c..2abda14f31 100644
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ b/src/gallium/drivers/nv40/nv40_vertprog.c
    @@ -207,32 +207,32 @@ emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nv40_sreg dst)
     		case NV40_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
     		case NV40_VP_INST_DEST_CLIP(0):
     			vp->or |= (1 << 6);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE0;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE0;
     			dst.index = NV40_VP_INST_DEST_FOGC;
     			break;
     		case NV40_VP_INST_DEST_CLIP(1):
     			vp->or |= (1 << 7);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE1;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE1;
     			dst.index = NV40_VP_INST_DEST_FOGC;
     			break;
     		case NV40_VP_INST_DEST_CLIP(2):
     			vp->or |= (1 << 8);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE2;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE2;
     			dst.index = NV40_VP_INST_DEST_FOGC;
     			break;
     		case NV40_VP_INST_DEST_CLIP(3):
     			vp->or |= (1 << 9);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE3;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE3;
     			dst.index = NV40_VP_INST_DEST_PSZ;
     			break;
     		case NV40_VP_INST_DEST_CLIP(4):
     			vp->or |= (1 << 10);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE4;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE4;
     			dst.index = NV40_VP_INST_DEST_PSZ;
     			break;
     		case NV40_VP_INST_DEST_CLIP(5):
     			vp->or |= (1 << 11);
    -			vp->clip_ctrl |= NV40TCL_CLIP_PLANE_ENABLE_PLANE5;
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE5;
     			dst.index = NV40_VP_INST_DEST_PSZ;
     			break;
     		default:
    @@ -887,12 +887,12 @@ check_gpu_resources:
     		}
     
     		so = so_new(3, 4, 0);
    -		so_method(so, curie, NV40TCL_VP_START_FROM_ID, 1);
    +		so_method(so, curie, NV34TCL_VP_START_FROM_ID, 1);
     		so_data  (so, vp->exec->start);
     		so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);
     		so_data  (so, vp->ir);
     		so_data  (so, vp->or);
    -		so_method(so, curie,  NV40TCL_CLIP_PLANE_ENABLE, 1);
    +		so_method(so, curie,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
     		so_data  (so, vp->clip_ctrl);
     		so_ref(so, &vp->so);
     		so_ref(NULL, &so);
    @@ -976,7 +976,7 @@ check_gpu_resources:
     				       4 * sizeof(float));
     			}
     
    -			BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_CONST_ID, 5);
    +			BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_CONST_ID, 5);
     			OUT_RING  (chan, i + vp->data->start);
     			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
     		}
    @@ -995,10 +995,10 @@ check_gpu_resources:
     			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[3]);
     		}
     #endif
    -		BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_FROM_ID, 1);
    +		BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_FROM_ID, 1);
     		OUT_RING  (chan, vp->exec->start);
     		for (i = 0; i < vp->nr_insns; i++) {
    -			BEGIN_RING(chan, curie, NV40TCL_VP_UPLOAD_INST(0), 4);
    +			BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_INST(0), 4);
     			OUT_RINGp (chan, vp->insns[i].data, 4);
     		}
     	}
    -- 
    cgit v1.2.3
    
    
    From 1771d8f8f4256773de1883a033081f9cc4cddf00 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 18:18:48 +0100
    Subject: nv30: remove unused on_hw field and constant fp_reg_control field
    
    This makes nv30_state.h equivalent to nv40_state.h
    ---
     src/gallium/drivers/nv30/nv30_fragprog.c | 4 +---
     src/gallium/drivers/nv30/nv30_state.h    | 2 --
     2 files changed, 1 insertion(+), 5 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
    index 2c432c6dfa..74bf68012a 100644
    --- a/src/gallium/drivers/nv30/nv30_fragprog.c
    +++ b/src/gallium/drivers/nv30/nv30_fragprog.c
    @@ -759,7 +759,6 @@ nv30_fragprog_translate(struct nv30_context *nv30,
     	}
     
     	fp->fp_control |= (fpc->num_regs-1)/2;
    -	fp->fp_reg_control = (1<<16)|0x4;
     
     	/* Terminate final instruction */
     	fp->insn[fpc->inst_offset] |= 0x00000001;
    @@ -773,7 +772,6 @@ nv30_fragprog_translate(struct nv30_context *nv30,
     	fp->insn[fpc->inst_offset + 3] = 0x00000000;
     
     	fp->translated = TRUE;
    -	fp->on_hw = FALSE;
     out_err:
     	tgsi_parse_free(&parse);
     	FREE(fpc);
    @@ -846,7 +844,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
     	so_method(so, nv30->screen->rankine, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
     	so_method(so, nv30->screen->rankine, NV34TCL_FP_REG_CONTROL, 1);
    -	so_data  (so, fp->fp_reg_control);
    +	so_data  (so, (1<<16)|0x4);
     	so_method(so, nv30->screen->rankine, NV34TCL_TX_UNITS_ENABLE, 1);
     	so_data  (so, fp->samplers);
     	so_ref(so, &fp->so);
    diff --git a/src/gallium/drivers/nv30/nv30_state.h b/src/gallium/drivers/nv30/nv30_state.h
    index 66c26360cb..b1c7f84a0a 100644
    --- a/src/gallium/drivers/nv30/nv30_state.h
    +++ b/src/gallium/drivers/nv30/nv30_state.h
    @@ -54,7 +54,6 @@ struct nv30_fragment_program {
     	struct tgsi_shader_info info;
     
     	boolean translated;
    -	boolean on_hw;
     	unsigned samplers;
     
     	uint32_t *insn;
    @@ -66,7 +65,6 @@ struct nv30_fragment_program {
     	struct pipe_buffer *buffer;
     
     	uint32_t fp_control;
    -	uint32_t fp_reg_control;
     	struct nouveau_stateobj *so;
     };
     
    -- 
    cgit v1.2.3
    
    
    From d673c92810636dcc6de33d3618d494ce9f5717c1 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 18:34:00 +0100
    Subject: nouveau: s/rankine/eng3d/g; s/curie/eng3d/g
    
    Result of running:
    perl -i -p -e 's/rankine/eng3d/g; s/curie/eng3d/g;' nv[34]0/*.[ch]
    
    This will allow to more easily unify nv30 and nv40.
    ---
     src/gallium/drivers/nv30/nv30_context.c        |  6 +--
     src/gallium/drivers/nv30/nv30_fragprog.c       |  8 +--
     src/gallium/drivers/nv30/nv30_fragtex.c        |  4 +-
     src/gallium/drivers/nv30/nv30_query.c          | 10 ++--
     src/gallium/drivers/nv30/nv30_screen.c         | 66 ++++++++++++-------------
     src/gallium/drivers/nv30/nv30_screen.h         |  2 +-
     src/gallium/drivers/nv30/nv30_state.c          | 54 ++++++++++----------
     src/gallium/drivers/nv30/nv30_state_blend.c    |  2 +-
     src/gallium/drivers/nv30/nv30_state_fb.c       | 26 +++++-----
     src/gallium/drivers/nv30/nv30_state_scissor.c  |  2 +-
     src/gallium/drivers/nv30/nv30_state_stipple.c  |  8 +--
     src/gallium/drivers/nv30/nv30_state_viewport.c |  6 +--
     src/gallium/drivers/nv30/nv30_state_zsa.c      |  4 +-
     src/gallium/drivers/nv30/nv30_vbo.c            | 68 +++++++++++++-------------
     src/gallium/drivers/nv30/nv30_vertprog.c       | 10 ++--
     src/gallium/drivers/nv40/nv40_context.c        |  6 +--
     src/gallium/drivers/nv40/nv40_draw.c           | 24 ++++-----
     src/gallium/drivers/nv40/nv40_fragprog.c       |  4 +-
     src/gallium/drivers/nv40/nv40_fragtex.c        |  6 +--
     src/gallium/drivers/nv40/nv40_query.c          | 10 ++--
     src/gallium/drivers/nv40/nv40_screen.c         | 50 +++++++++----------
     src/gallium/drivers/nv40/nv40_screen.h         |  2 +-
     src/gallium/drivers/nv40/nv40_state.c          | 54 ++++++++++----------
     src/gallium/drivers/nv40/nv40_state_blend.c    |  2 +-
     src/gallium/drivers/nv40/nv40_state_emit.c     |  6 +--
     src/gallium/drivers/nv40/nv40_state_fb.c       | 38 +++++++-------
     src/gallium/drivers/nv40/nv40_state_scissor.c  |  2 +-
     src/gallium/drivers/nv40/nv40_state_stipple.c  |  8 +--
     src/gallium/drivers/nv40/nv40_state_viewport.c |  4 +-
     src/gallium/drivers/nv40/nv40_state_zsa.c      |  4 +-
     src/gallium/drivers/nv40/nv40_vbo.c            | 68 +++++++++++++-------------
     src/gallium/drivers/nv40/nv40_vertprog.c       | 14 +++---
     32 files changed, 289 insertions(+), 289 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 825c167b01..be6407805b 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -11,12 +11,12 @@ nv30_flush(struct pipe_context *pipe, unsigned flags,
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
    -		BEGIN_RING(chan, rankine, 0x1fd8, 1);
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
     		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, rankine, 0x1fd8, 1);
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
     		OUT_RING  (chan, 1);
     	}
     
    diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
    index 74bf68012a..4c96e6d733 100644
    --- a/src/gallium/drivers/nv30/nv30_fragprog.c
    +++ b/src/gallium/drivers/nv30/nv30_fragprog.c
    @@ -836,16 +836,16 @@ nv30_fragprog_validate(struct nv30_context *nv30)
     	nv30_fragprog_upload(nv30, fp);
     
     	so = so_new(4, 4, 1);
    -	so_method(so, nv30->screen->rankine, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
     	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
     		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
     		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
     		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nv30->screen->rankine, NV34TCL_FP_CONTROL, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
    -	so_method(so, nv30->screen->rankine, NV34TCL_FP_REG_CONTROL, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_FP_REG_CONTROL, 1);
     	so_data  (so, (1<<16)|0x4);
    -	so_method(so, nv30->screen->rankine, NV34TCL_TX_UNITS_ENABLE, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_TX_UNITS_ENABLE, 1);
     	so_data  (so, fp->samplers);
     	so_ref(so, &fp->so);
     	so_ref(NULL, &so);
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    index f7d98f3f20..63b5015ed4 100644
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ b/src/gallium/drivers/nv30/nv30_fragtex.c
    @@ -101,7 +101,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
     	txs = tf->swizzle;
     
     	so = so_new(1, 8, 2);
    -	so_method(so, nv30->screen->rankine, NV34TCL_TX_OFFSET(unit), 8);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
     	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
     	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
     		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    @@ -130,7 +130,7 @@ nv30_fragtex_validate(struct nv30_context *nv30)
     		samplers &= ~(1 << unit);
     
     		so = so_new(1, 1, 0);
    -		so_method(so, nv30->screen->rankine, NV34TCL_TX_ENABLE(unit), 1);
    +		so_method(so, nv30->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
     		so_data  (so, 0);
     		so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
     		so_ref(NULL, &so);
    diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
    index e27e9ccbf6..21a5e8ad7c 100644
    --- a/src/gallium/drivers/nv30/nv30_query.c
    +++ b/src/gallium/drivers/nv30/nv30_query.c
    @@ -43,7 +43,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     	struct nv30_query *q = nv30_query(pq);
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
     
    @@ -60,9 +60,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     		assert(0);
     	nouveau_notifier_reset(nv30->screen->query, q->object->start);
     
    -	BEGIN_RING(chan, rankine, NV34TCL_QUERY_RESET, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
     	OUT_RING  (chan, 1);
    -	BEGIN_RING(chan, rankine, NV34TCL_QUERY_UNK17CC, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
     	OUT_RING  (chan, 1);
     
     	q->ready = FALSE;
    @@ -74,10 +74,10 @@ nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	struct nv30_query *q = nv30_query(pq);
     
    -	BEGIN_RING(chan, rankine, NV34TCL_QUERY_GET, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
     	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
     		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
     	FIRE_RING(chan);
    diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
    index db24335b7c..40193f2795 100644
    --- a/src/gallium/drivers/nv30/nv30_screen.c
    +++ b/src/gallium/drivers/nv30/nv30_screen.c
    @@ -177,7 +177,7 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
     	nouveau_resource_destroy(&screen->query_heap);
     	nouveau_notifier_free(&screen->query);
     	nouveau_notifier_free(&screen->sync);
    -	nouveau_grobj_free(&screen->rankine);
    +	nouveau_grobj_free(&screen->eng3d);
     	nv04_surface_2d_takedown(&screen->eng2d);
     
     	nouveau_screen_fini(&screen->base);
    @@ -192,7 +192,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	struct nouveau_channel *chan;
     	struct pipe_screen *pscreen;
     	struct nouveau_stateobj *so;
    -	unsigned rankine_class = 0;
    +	unsigned eng3d_class = 0;
     	int ret, i;
     
     	if (!screen)
    @@ -219,25 +219,25 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	switch (dev->chipset & 0xf0) {
     	case 0x30:
     		if (NV30TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			rankine_class = 0x0397;
    +			eng3d_class = 0x0397;
     		else
     		if (NV34TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			rankine_class = 0x0697;
    +			eng3d_class = 0x0697;
     		else
     		if (NV35TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			rankine_class = 0x0497;
    +			eng3d_class = 0x0497;
     		break;
     	default:
     		break;
     	}
     
    -	if (!rankine_class) {
    +	if (!eng3d_class) {
     		NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", dev->chipset);
     		return NULL;
     	}
     
    -	ret = nouveau_grobj_alloc(chan, 0xbeef3097, rankine_class,
    -				  &screen->rankine);
    +	ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class,
    +				  &screen->eng3d);
     	if (ret) {
     		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
     		return FALSE;
    @@ -277,80 +277,80 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     		return NULL;
     	}
     
    -	/* Static rankine initialisation */
    +	/* Static eng3d initialisation */
     	so = so_new(36, 60, 0);
    -	so_method(so, screen->rankine, NV34TCL_DMA_NOTIFY, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_NOTIFY, 1);
     	so_data  (so, screen->sync->handle);
    -	so_method(so, screen->rankine, NV34TCL_DMA_TEXTURE0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_TEXTURE0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->rankine, NV34TCL_DMA_COLOR1, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR1, 1);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->rankine, NV34TCL_DMA_COLOR0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->rankine, NV34TCL_DMA_VTXBUF0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_VTXBUF0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -/*	so_method(so, screen->rankine, NV34TCL_DMA_FENCE, 2);
    +/*	so_method(so, screen->eng3d, NV34TCL_DMA_FENCE, 2);
     	so_data  (so, 0);
     	so_data  (so, screen->query->handle);*/
    -	so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY7, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY7, 1);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->rankine, NV34TCL_DMA_IN_MEMORY8, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY8, 1);
     	so_data  (so, chan->vram->handle);
     
     	for (i=1; i<8; i++) {
    -		so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
    +		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
     		so_data  (so, 0);
    -		so_method(so, screen->rankine, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
    +		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, screen->rankine, 0x220, 1);
    +	so_method(so, screen->eng3d, 0x220, 1);
     	so_data  (so, 1);
     
    -	so_method(so, screen->rankine, 0x03b0, 1);
    +	so_method(so, screen->eng3d, 0x03b0, 1);
     	so_data  (so, 0x00100000);
    -	so_method(so, screen->rankine, 0x1454, 1);
    +	so_method(so, screen->eng3d, 0x1454, 1);
     	so_data  (so, 0);
    -	so_method(so, screen->rankine, 0x1d80, 1);
    +	so_method(so, screen->eng3d, 0x1d80, 1);
     	so_data  (so, 3);
    -	so_method(so, screen->rankine, 0x1450, 1);
    +	so_method(so, screen->eng3d, 0x1450, 1);
     	so_data  (so, 0x00030004);
     
     	/* NEW */
    -	so_method(so, screen->rankine, 0x1e98, 1);
    +	so_method(so, screen->eng3d, 0x1e98, 1);
     	so_data  (so, 0);
    -	so_method(so, screen->rankine, 0x17e0, 3);
    +	so_method(so, screen->eng3d, 0x17e0, 3);
     	so_data  (so, fui(0.0));
     	so_data  (so, fui(0.0));
     	so_data  (so, fui(1.0));
    -	so_method(so, screen->rankine, 0x1f80, 16);
    +	so_method(so, screen->eng3d, 0x1f80, 16);
     	for (i=0; i<16; i++) {
     		so_data  (so, (i==8) ? 0x0000ffff : 0);
     	}
     
    -	so_method(so, screen->rankine, 0x120, 3);
    +	so_method(so, screen->eng3d, 0x120, 3);
     	so_data  (so, 0);
     	so_data  (so, 1);
     	so_data  (so, 2);
     
    -	so_method(so, screen->rankine, 0x1d88, 1);
    +	so_method(so, screen->eng3d, 0x1d88, 1);
     	so_data  (so, 0x00001200);
     
    -	so_method(so, screen->rankine, NV34TCL_RC_ENABLE, 1);
    +	so_method(so, screen->eng3d, NV34TCL_RC_ENABLE, 1);
     	so_data  (so, 0);
     
    -	so_method(so, screen->rankine, NV34TCL_DEPTH_RANGE_NEAR, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DEPTH_RANGE_NEAR, 2);
     	so_data  (so, fui(0.0));
     	so_data  (so, fui(1.0));
     
    -	so_method(so, screen->rankine, NV34TCL_MULTISAMPLE_CONTROL, 1);
    +	so_method(so, screen->eng3d, NV34TCL_MULTISAMPLE_CONTROL, 1);
     	so_data  (so, 0xffff0000);
     
     	/* enables use of vp rather than fixed-function somehow */
    -	so_method(so, screen->rankine, 0x1e94, 1);
    +	so_method(so, screen->eng3d, 0x1e94, 1);
     	so_data  (so, 0x13);
     
     	so_emit(chan, so);
    diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
    index b7856cdf00..69a94593f9 100644
    --- a/src/gallium/drivers/nv30/nv30_screen.h
    +++ b/src/gallium/drivers/nv30/nv30_screen.h
    @@ -14,7 +14,7 @@ struct nv30_screen {
     
     	/* HW graphics objects */
     	struct nv04_surface_2d *eng2d;
    -	struct nouveau_grobj *rankine;
    +	struct nouveau_grobj *eng3d;
     	struct nouveau_notifier *sync;
     
     	/* Query object resources */
    diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
    index 24b15a63ac..330448000b 100644
    --- a/src/gallium/drivers/nv30/nv30_state.c
    +++ b/src/gallium/drivers/nv30/nv30_state.c
    @@ -12,12 +12,12 @@ nv30_blend_state_create(struct pipe_context *pipe,
     			const struct pipe_blend_state *cso)
     {
     	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     	struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso));
     	struct nouveau_stateobj *so = so_new(5, 8, 0);
     
     	if (cso->rt[0].blend_enable) {
    -		so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
     		so_data  (so, 1);
     		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
     			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
    @@ -25,29 +25,29 @@ nv30_blend_state_create(struct pipe_context *pipe,
     			      nvgl_blend_func(cso->rt[0].rgb_dst_factor));
     		/* FIXME: Gallium assumes GL_EXT_blend_func_separate.
     		   It is not the case for NV30 */
    -		so_method(so, rankine, NV34TCL_BLEND_EQUATION, 1);
    +		so_method(so, eng3d, NV34TCL_BLEND_EQUATION, 1);
     		so_data  (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
     	} else {
    -		so_method(so, rankine, NV34TCL_BLEND_FUNC_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, rankine, NV34TCL_COLOR_MASK, 1);
    +	so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
     	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
     
     	if (cso->logicop_enable) {
    -		so_method(so, rankine, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
     		so_data  (so, 1);
     		so_data  (so, nvgl_logicop_func(cso->logicop_func));
     	} else {
    -		so_method(so, rankine, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, rankine, NV34TCL_DITHER_ENABLE, 1);
    +	so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
     	so_data  (so, cso->dither ? 1 : 0);
     
     	so_ref(so, &bso->so);
    @@ -301,7 +301,7 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
     	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     
     	/*XXX: ignored:
     	 * 	light_twoside
    @@ -309,22 +309,22 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
     	 * 	multisample
     	 */
     
    -	so_method(so, rankine, NV34TCL_SHADE_MODEL, 1);
    +	so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
     	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
     				       NV34TCL_SHADE_MODEL_SMOOTH);
     
    -	so_method(so, rankine, NV34TCL_LINE_WIDTH, 2);
    +	so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
     	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
     	so_data  (so, cso->line_smooth ? 1 : 0);
    -	so_method(so, rankine, NV34TCL_LINE_STIPPLE_ENABLE, 2);
    +	so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
     	so_data  (so, cso->line_stipple_enable ? 1 : 0);
     	so_data  (so, (cso->line_stipple_pattern << 16) |
     		       cso->line_stipple_factor);
     
    -	so_method(so, rankine, NV34TCL_POINT_SIZE, 1);
    +	so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
     	so_data  (so, fui(cso->point_size));
     
    -	so_method(so, rankine, NV34TCL_POLYGON_MODE_FRONT, 6);
    +	so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
     	if (cso->front_winding == PIPE_WINDING_CCW) {
     		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
     		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    @@ -365,10 +365,10 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
     	so_data(so, cso->poly_smooth ? 1 : 0);
     	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
     
    -	so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +	so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
     
    -	so_method(so, rankine, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    +	so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
     	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
     	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
     		so_data(so, 1);
    @@ -385,12 +385,12 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
     	else
     		so_data(so, 0);
     	if (cso->offset_cw || cso->offset_ccw) {
    -		so_method(so, rankine, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
    +		so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
     		so_data  (so, fui(cso->offset_scale));
     		so_data  (so, fui(cso->offset_units * 2));
     	}
     
    -	so_method(so, rankine, NV34TCL_POINT_SPRITE, 1);
    +	so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
     	if (cso->point_quad_rasterization) {
     		unsigned psctl = (1 << 0), i;
     
    @@ -436,45 +436,45 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
     	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     
    -	so_method(so, rankine, NV34TCL_DEPTH_FUNC, 3);
    +	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
     	so_data  (so, nvgl_comparison_op(cso->depth.func));
     	so_data  (so, cso->depth.writemask ? 1 : 0);
     	so_data  (so, cso->depth.enabled ? 1 : 0);
     
    -	so_method(so, rankine, NV34TCL_ALPHA_FUNC_ENABLE, 3);
    +	so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
     	so_data  (so, cso->alpha.enabled ? 1 : 0);
     	so_data  (so, nvgl_comparison_op(cso->alpha.func));
     	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
     
     	if (cso->stencil[0].enabled) {
    -		so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
     		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[0].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    -		so_method(so, rankine, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[0].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
     	} else {
    -		so_method(so, rankine, NV34TCL_STENCIL_FRONT_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
     	if (cso->stencil[1].enabled) {
    -		so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
     		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[1].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    -		so_method(so, rankine, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[1].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
     	} else {
    -		so_method(so, rankine, NV34TCL_STENCIL_BACK_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv30/nv30_state_blend.c b/src/gallium/drivers/nv30/nv30_state_blend.c
    index c36d58c040..eb0199cf65 100644
    --- a/src/gallium/drivers/nv30/nv30_state_blend.c
    +++ b/src/gallium/drivers/nv30/nv30_state_blend.c
    @@ -21,7 +21,7 @@ nv30_state_blend_colour_validate(struct nv30_context *nv30)
     	struct nouveau_stateobj *so = so_new(1, 1, 0);
     	struct pipe_blend_color *bcol = &nv30->blend_colour;
     
    -	so_method(so, nv30->screen->rankine, NV34TCL_BLEND_COLOR, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
     	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
     		       (float_to_ubyte(bcol->color[0]) << 16) |
     		       (float_to_ubyte(bcol->color[1]) <<  8) |
    diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c
    index f7fe9833c7..23d17c0c60 100644
    --- a/src/gallium/drivers/nv30/nv30_state_fb.c
    +++ b/src/gallium/drivers/nv30/nv30_state_fb.c
    @@ -6,7 +6,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     {
     	struct pipe_framebuffer_state *fb = &nv30->framebuffer;
     	struct nouveau_channel *chan = nv30->screen->base.channel;
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     	struct nv04_surface *rt[2], *zeta = NULL;
     	uint32_t rt_enable = 0, rt_format = 0;
     	int i, colour_format = 0, zeta_format = 0, depth_only = 0;
    @@ -110,10 +110,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     		}
     
     		nv30mt = (struct nv30_miptree *) rt0->base.texture;
    -		so_method(so, rankine, NV34TCL_DMA_COLOR0, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, rankine, NV34TCL_COLOR0_PITCH, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR0_PITCH, 2);
     		so_data  (so, pitch);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), rt0->base.offset,
     			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
    @@ -121,10 +121,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     
     	if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
     		nv30mt = (struct nv30_miptree *)rt[1]->base.texture;
    -		so_method(so, rankine, NV34TCL_DMA_COLOR1, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, rankine, NV34TCL_COLOR1_OFFSET, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR1_OFFSET, 2);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset,
     			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
     		so_data  (so, rt[1]->pitch);
    @@ -132,31 +132,31 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     
     	if (zeta_format) {
     		nv30mt = (struct nv30_miptree *)zeta->base.texture;
    -		so_method(so, rankine, NV34TCL_DMA_ZETA, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, rankine, NV34TCL_ZETA_OFFSET, 1);
    +		so_method(so, eng3d, NV34TCL_ZETA_OFFSET, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset,
     			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
     		/* TODO: allocate LMA depth buffer */
     	}
     
    -	so_method(so, rankine, NV34TCL_RT_ENABLE, 1);
    +	so_method(so, eng3d, NV34TCL_RT_ENABLE, 1);
     	so_data  (so, rt_enable);
    -	so_method(so, rankine, NV34TCL_RT_HORIZ, 3);
    +	so_method(so, eng3d, NV34TCL_RT_HORIZ, 3);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
     	so_data  (so, rt_format);
    -	so_method(so, rankine, NV34TCL_VIEWPORT_HORIZ, 2);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_HORIZ, 2);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
    -	so_method(so, rankine, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
     	so_data  (so, ((w - 1) << 16) | 0);
     	so_data  (so, ((h - 1) << 16) | 0);
    -	so_method(so, rankine, 0x1d88, 1);
    +	so_method(so, eng3d, 0x1d88, 1);
     	so_data  (so, (1 << 12) | h);
     	/* Wonder why this is needed, context should all be set to zero on init */
    -	so_method(so, rankine, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
     	so_data  (so, 0);
     
     	so_ref(so, &nv30->state.hw[NV30_STATE_FB]);
    diff --git a/src/gallium/drivers/nv30/nv30_state_scissor.c b/src/gallium/drivers/nv30/nv30_state_scissor.c
    index ba61a9e24a..f58bb0161e 100644
    --- a/src/gallium/drivers/nv30/nv30_state_scissor.c
    +++ b/src/gallium/drivers/nv30/nv30_state_scissor.c
    @@ -13,7 +13,7 @@ nv30_state_scissor_validate(struct nv30_context *nv30)
     	nv30->state.scissor_enabled = rast->scissor;
     
     	so = so_new(1, 2, 0);
    -	so_method(so, nv30->screen->rankine, NV34TCL_SCISSOR_HORIZ, 2);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
     	if (nv30->state.scissor_enabled) {
     		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
     		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    diff --git a/src/gallium/drivers/nv30/nv30_state_stipple.c b/src/gallium/drivers/nv30/nv30_state_stipple.c
    index ed520a4f43..46a6975438 100644
    --- a/src/gallium/drivers/nv30/nv30_state_stipple.c
    +++ b/src/gallium/drivers/nv30/nv30_state_stipple.c
    @@ -4,7 +4,7 @@ static boolean
     nv30_state_stipple_validate(struct nv30_context *nv30)
     {
     	struct pipe_rasterizer_state *rast = &nv30->rasterizer->pipe;
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     	struct nouveau_stateobj *so;
     
     	if (nv30->state.hw[NV30_STATE_STIPPLE] &&
    @@ -15,14 +15,14 @@ nv30_state_stipple_validate(struct nv30_context *nv30)
     		unsigned i;
     
     		so = so_new(2, 33, 0);
    -		so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 1);
    -		so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
     		for (i = 0; i < 32; i++)
     			so_data(so, nv30->stipple[i]);
     	} else {
     		so = so_new(1, 1, 0);
    -		so_method(so, rankine, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv30/nv30_state_viewport.c b/src/gallium/drivers/nv30/nv30_state_viewport.c
    index 6fccd6b60e..66fc112f3c 100644
    --- a/src/gallium/drivers/nv30/nv30_state_viewport.c
    +++ b/src/gallium/drivers/nv30/nv30_state_viewport.c
    @@ -11,7 +11,7 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
     		return FALSE;
     
     	so = so_new(3, 10, 0);
    -	so_method(so, nv30->screen->rankine,
    +	so_method(so, nv30->screen->eng3d,
     		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
     	so_data  (so, fui(vpt->translate[0]));
     	so_data  (so, fui(vpt->translate[1]));
    @@ -21,11 +21,11 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
     	so_data  (so, fui(vpt->scale[1]));
     	so_data  (so, fui(vpt->scale[2]));
     	so_data  (so, fui(vpt->scale[3]));
    -/*	so_method(so, nv30->screen->rankine, 0x1d78, 1);
    +/*	so_method(so, nv30->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     */
     	/* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */
    -	so_method(so, nv30->screen->rankine, 0x1d78, 1);
    +	so_method(so, nv30->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     
     	so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
    diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c
    index 88cd74f180..b0aac8ee46 100644
    --- a/src/gallium/drivers/nv30/nv30_state_zsa.c
    +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c
    @@ -22,9 +22,9 @@ nv30_state_sr_validate(struct nv30_context *nv30)
     	struct nouveau_stateobj *so = so_new(2, 2, 0);
     	struct pipe_stencil_ref *sr = &nv30->stencil_ref;
     
    -	so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nv30->screen->rankine, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_method(so, nv30->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[1]);
     
     	so_ref(so, &nv30->state.hw[NV30_STATE_SR]);
    diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
    index f3856bb5a5..c7f119e90a 100644
    --- a/src/gallium/drivers/nv30/nv30_vbo.c
    +++ b/src/gallium/drivers/nv30/nv30_vbo.c
    @@ -111,7 +111,7 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
     		       struct pipe_vertex_buffer *vb)
     {
     	struct pipe_screen *pscreen = nv30->pipe.screen;
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     	unsigned type, ncomp;
     	void *map;
     
    @@ -128,25 +128,25 @@ nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
     
     		switch (ncomp) {
     		case 4:
    -			so_method(so, rankine, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			so_data  (so, fui(v[3]));
     			break;
     		case 3:
    -			so_method(so, rankine, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			break;
     		case 2:
    -			so_method(so, rankine, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			break;
     		case 1:
    -			so_method(so, rankine, NV34TCL_VTX_ATTR_1F(attrib), 1);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_1F(attrib), 1);
     			so_data  (so, fui(v[0]));
     			break;
     		default:
    @@ -171,7 +171,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart = 0;
     
     	nv30_vbo_set_idxbuf(nv30, NULL, 0);
    @@ -193,12 +193,12 @@ nv30_draw_arrays(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, rankine, NV34TCL_VB_VERTEX_BATCH, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -209,14 +209,14 @@ nv30_draw_arrays(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, rankine, NV34TCL_VB_VERTEX_BATCH, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -232,7 +232,7 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     {
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint8_t *elts = (uint8_t *)ib + start;
    @@ -248,11 +248,11 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, rankine, NV34TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -262,7 +262,7 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -270,7 +270,7 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -283,7 +283,7 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     {
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint16_t *elts = (uint16_t *)ib + start;
    @@ -299,11 +299,11 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, rankine, NV34TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -313,7 +313,7 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -321,7 +321,7 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -334,7 +334,7 @@ nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
     {
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint32_t *elts = (uint32_t *)ib + start;
    @@ -350,20 +350,20 @@ nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		while (vc) {
     			push = MIN2(vc, 2047);
     
    -			BEGIN_RING_NI(chan, rankine, NV34TCL_VB_ELEMENT_U32, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U32, push);
     			OUT_RINGp    (chan, elts, push);
     
     			vc -= push;
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -410,7 +410,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
     	struct nv30_context *nv30 = nv30_context(pipe);
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart = 0;
     
     	while (count) {
    @@ -425,12 +425,12 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, rankine, NV34TCL_VB_INDEX_BATCH, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_INDEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -441,14 +441,14 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, rankine, NV34TCL_VB_INDEX_BATCH, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_INDEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, rankine, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -485,16 +485,16 @@ static boolean
     nv30_vbo_validate(struct nv30_context *nv30)
     {
     	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *rankine = nv30->screen->rankine;
    +	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
     	struct pipe_buffer *ib = nv30->idxbuf;
     	unsigned ib_format = nv30->idxbuf_format;
     	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
     	int hw;
     
     	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, rankine, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt->num_elements);
    +	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt->num_elements);
     	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, rankine, NV34TCL_VTXFMT(0), nv30->vtxelt->num_elements);
    +	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nv30->vtxelt->num_elements);
     
     	for (hw = 0; hw < nv30->vtxelt->num_elements; hw++) {
     		struct pipe_vertex_element *ve;
    @@ -532,13 +532,13 @@ nv30_vbo_validate(struct nv30_context *nv30)
     	if (ib) {
     		struct nouveau_bo *bo = nouveau_bo(ib);
     
    -		so_method(vtxbuf, rankine, NV34TCL_IDXBUF_ADDRESS, 2);
    +		so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
     		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
     		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
     				  0, NV34TCL_IDXBUF_FORMAT_DMA1);
     	}
     
    -	so_method(vtxbuf, rankine, 0x1710, 1);
    +	so_method(vtxbuf, eng3d, 0x1710, 1);
     	so_data  (vtxbuf, 0);
     
     	so_ref(vtxbuf, &nv30->state.hw[NV30_STATE_VTXBUF]);
    diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
    index 809be3712d..f0cecba4c4 100644
    --- a/src/gallium/drivers/nv30/nv30_vertprog.c
    +++ b/src/gallium/drivers/nv30/nv30_vertprog.c
    @@ -652,7 +652,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     	struct pipe_screen *pscreen = nv30->pipe.screen;
     	struct nv30_screen *screen = nv30->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *rankine = screen->rankine;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	struct nv30_vertex_program *vp;
     	struct pipe_buffer *constbuf;
     	boolean upload_code = FALSE, upload_data = FALSE;
    @@ -687,7 +687,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     		}
     
     		so = so_new(1, 1, 0);
    -		so_method(so, rankine, NV34TCL_VP_START_FROM_ID, 1);
    +		so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
     		so_data  (so, vp->exec->start);
     		so_ref(so, &vp->so);
     		so_ref(NULL, &so);
    @@ -772,7 +772,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     				       4 * sizeof(float));
     			}
     
    -			BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_CONST_ID, 5);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_CONST_ID, 5);
     			OUT_RING  (chan, i + vp->data->start);
     			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
     		}
    @@ -790,10 +790,10 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     				vp->insns[i].data[2], vp->insns[i].data[3]);
     		}
     #endif
    -		BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_FROM_ID, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_FROM_ID, 1);
     		OUT_RING  (chan, vp->exec->start);
     		for (i = 0; i < vp->nr_insns; i++) {
    -			BEGIN_RING(chan, rankine, NV34TCL_VP_UPLOAD_INST(0), 4);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_INST(0), 4);
     			OUT_RINGp (chan, vp->insns[i].data, 4);
     		}
     	}
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index e828f17643..da35676fd5 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -11,12 +11,12 @@ nv40_flush(struct pipe_context *pipe, unsigned flags,
     	struct nv40_context *nv40 = nv40_context(pipe);
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
    -		BEGIN_RING(chan, curie, 0x1fd8, 1);
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
     		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, curie, 0x1fd8, 1);
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
     		OUT_RING  (chan, 1);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    index 849f24fe40..05d237d1bb 100644
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ b/src/gallium/drivers/nv40/nv40_draw.c
    @@ -33,7 +33,7 @@ nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
     {
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
     
     	for (i = 0; i < nv40->swtnl.nr_attribs; i++) {
    @@ -44,29 +44,29 @@ nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
     		case EMIT_OMIT:
     			break;
     		case EMIT_1F:
    -			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_1F(hw), 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_1F(hw), 1);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			break;
     		case EMIT_2F:
    -			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_2F_X(hw), 2);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_2F_X(hw), 2);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			break;
     		case EMIT_3F:
    -			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_3F_X(hw), 3);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_3F_X(hw), 3);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			OUT_RING  (chan, fui(v->data[idx][2]));
     			break;
     		case EMIT_4F:
    -			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_4F_X(hw), 4);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4F_X(hw), 4);
     			OUT_RING  (chan, fui(v->data[idx][0]));
     			OUT_RING  (chan, fui(v->data[idx][1]));
     			OUT_RING  (chan, fui(v->data[idx][2]));
     			OUT_RING  (chan, fui(v->data[idx][3]));
     			break;
     		case EMIT_4UB:
    -			BEGIN_RING(chan, curie, NV34TCL_VTX_ATTR_4UB(hw), 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
     			OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
     					    float_to_ubyte(v->data[idx][1]),
     					    float_to_ubyte(v->data[idx][2]),
    @@ -88,7 +88,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
     
     	/* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
    @@ -104,11 +104,11 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     	/* Switch primitive modes if necessary */
     	if (rs->prim != mode) {
     		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    -			BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     			OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, mode);
     		rs->prim = mode;
     	}
    @@ -121,7 +121,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     	 * off the primitive now.
     	 */
     	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
     		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
     	}
    @@ -152,10 +152,10 @@ nv40_render_flush(struct draw_stage *draw, unsigned flags)
     	struct nv40_context *nv40 = rs->nv40;
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
     		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
     	}
    diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
    index d881fea6f5..3d08828bea 100644
    --- a/src/gallium/drivers/nv40/nv40_fragprog.c
    +++ b/src/gallium/drivers/nv40/nv40_fragprog.c
    @@ -920,12 +920,12 @@ nv40_fragprog_validate(struct nv40_context *nv40)
     	nv40_fragprog_upload(nv40, fp);
     
     	so = so_new(2, 2, 1);
    -	so_method(so, nv40->screen->curie, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
     	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
     		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
     		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
     		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nv40->screen->curie, NV34TCL_FP_CONTROL, 1);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
     	so_ref(so, &fp->so);
     	so_ref(NULL, &so);
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index 44bf4333bd..4c26f3cb12 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -111,7 +111,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	txs = tf->swizzle;
     
     	so = so_new(2, 9, 2);
    -	so_method(so, nv40->screen->curie, NV34TCL_TX_OFFSET(unit), 8);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
     	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
     	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
     		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    @@ -122,7 +122,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
     		       pt->height0);
     	so_data  (so, ps->bcol);
    -	so_method(so, nv40->screen->curie, NV40TCL_TEX_SIZE1(unit), 1);
    +	so_method(so, nv40->screen->eng3d, NV40TCL_TEX_SIZE1(unit), 1);
     	so_data  (so, (pt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
     
     	return so;
    @@ -142,7 +142,7 @@ nv40_fragtex_validate(struct nv40_context *nv40)
     		samplers &= ~(1 << unit);
     
     		so = so_new(1, 1, 0);
    -		so_method(so, nv40->screen->curie, NV34TCL_TX_ENABLE(unit), 1);
    +		so_method(so, nv40->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
     		so_data  (so, 0);
     		so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
     		state->dirty |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
    diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c
    index 45c5468537..899a8dc0b2 100644
    --- a/src/gallium/drivers/nv40/nv40_query.c
    +++ b/src/gallium/drivers/nv40/nv40_query.c
    @@ -43,7 +43,7 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     	struct nv40_query *q = nv40_query(pq);
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
     
    @@ -60,9 +60,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     		assert(0);
     	nouveau_notifier_reset(nv40->screen->query, q->object->start);
     
    -	BEGIN_RING(chan, curie, NV34TCL_QUERY_RESET, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
     	OUT_RING  (chan, 1);
    -	BEGIN_RING(chan, curie, NV34TCL_QUERY_UNK17CC, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
     	OUT_RING  (chan, 1);
     
     	q->ready = FALSE;
    @@ -75,9 +75,9 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
     	struct nv40_query *q = nv40_query(pq);
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
    -	BEGIN_RING(chan, curie, NV34TCL_QUERY_GET, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
     	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
     		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
     	FIRE_RING(chan);
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    index 9c49e2b6ec..3c901c1c53 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ b/src/gallium/drivers/nv40/nv40_screen.c
    @@ -49,7 +49,7 @@ nv40_screen_get_param(struct pipe_screen *pscreen, int param)
     	case NOUVEAU_CAP_HW_VTXBUF:
     		return 1;
     	case NOUVEAU_CAP_HW_IDXBUF:
    -		if (screen->curie->grclass == NV40TCL)
    +		if (screen->eng3d->grclass == NV40TCL)
     			return 1;
     		return 0;
     	case PIPE_CAP_INDEP_BLEND_ENABLE:
    @@ -164,7 +164,7 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
     	nouveau_resource_destroy(&screen->query_heap);
     	nouveau_notifier_free(&screen->query);
     	nouveau_notifier_free(&screen->sync);
    -	nouveau_grobj_free(&screen->curie);
    +	nouveau_grobj_free(&screen->eng3d);
     	nv04_surface_2d_takedown(&screen->eng2d);
     
     	nouveau_screen_fini(&screen->base);
    @@ -179,7 +179,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	struct nouveau_channel *chan;
     	struct pipe_screen *pscreen;
     	struct nouveau_stateobj *so;
    -	unsigned curie_class = 0;
    +	unsigned eng3d_class = 0;
     	int ret;
     
     	if (!screen)
    @@ -206,23 +206,23 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	switch (dev->chipset & 0xf0) {
     	case 0x40:
     		if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			curie_class = NV40TCL;
    +			eng3d_class = NV40TCL;
     		else
     		if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			curie_class = NV44TCL;
    +			eng3d_class = NV44TCL;
     		break;
     	case 0x60:
     		if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			curie_class = NV44TCL;
    +			eng3d_class = NV44TCL;
     		break;
     	}
     
    -	if (!curie_class) {
    +	if (!eng3d_class) {
     		NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", dev->chipset);
     		return NULL;
     	}
     
    -	ret = nouveau_grobj_alloc(chan, 0xbeef3097, curie_class, &screen->curie);
    +	ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d);
     	if (ret) {
     		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
     		return FALSE;
    @@ -262,52 +262,52 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     		return NULL;
     	}
     
    -	/* Static curie initialisation */
    +	/* Static eng3d initialisation */
     	so = so_new(16, 25, 0);
    -	so_method(so, screen->curie, NV34TCL_DMA_NOTIFY, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_NOTIFY, 1);
     	so_data  (so, screen->sync->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_TEXTURE0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_TEXTURE0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_COLOR1, 1);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR1, 1);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_COLOR0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_VTXBUF0, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_VTXBUF0, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_FENCE, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_FENCE, 2);
     	so_data  (so, 0);
     	so_data  (so, screen->query->handle);
    -	so_method(so, screen->curie, NV34TCL_DMA_IN_MEMORY7, 2);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY7, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->curie, NV40TCL_DMA_COLOR2, 2);
    +	so_method(so, screen->eng3d, NV40TCL_DMA_COLOR2, 2);
     	so_data  (so, chan->vram->handle);
     	so_data  (so, chan->vram->handle);
     
    -	so_method(so, screen->curie, 0x1ea4, 3);
    +	so_method(so, screen->eng3d, 0x1ea4, 3);
     	so_data  (so, 0x00000010);
     	so_data  (so, 0x01000100);
     	so_data  (so, 0xff800006);
     
     	/* vtxprog output routing */
    -	so_method(so, screen->curie, 0x1fc4, 1);
    +	so_method(so, screen->eng3d, 0x1fc4, 1);
     	so_data  (so, 0x06144321);
    -	so_method(so, screen->curie, 0x1fc8, 2);
    +	so_method(so, screen->eng3d, 0x1fc8, 2);
     	so_data  (so, 0xedcba987);
     	so_data  (so, 0x00000021);
    -	so_method(so, screen->curie, 0x1fd0, 1);
    +	so_method(so, screen->eng3d, 0x1fd0, 1);
     	so_data  (so, 0x00171615);
    -	so_method(so, screen->curie, 0x1fd4, 1);
    +	so_method(so, screen->eng3d, 0x1fd4, 1);
     	so_data  (so, 0x001b1a19);
     
    -	so_method(so, screen->curie, 0x1ef8, 1);
    +	so_method(so, screen->eng3d, 0x1ef8, 1);
     	so_data  (so, 0x0020ffff);
    -	so_method(so, screen->curie, 0x1d64, 1);
    +	so_method(so, screen->eng3d, 0x1d64, 1);
     	so_data  (so, 0x00d30000);
    -	so_method(so, screen->curie, 0x1e94, 1);
    +	so_method(so, screen->eng3d, 0x1e94, 1);
     	so_data  (so, 0x00000001);
     
     	so_emit(chan, so);
    diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
    index 2765ab764a..ad0ee63da6 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.h
    +++ b/src/gallium/drivers/nv40/nv40_screen.h
    @@ -13,7 +13,7 @@ struct nv40_screen {
     
     	/* HW graphics objects */
     	struct nv04_surface_2d *eng2d;
    -	struct nouveau_grobj *curie;
    +	struct nouveau_grobj *eng3d;
     	struct nouveau_notifier *sync;
     
     	/* Query object resources */
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    index 3db000a219..e8076e059b 100644
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ b/src/gallium/drivers/nv40/nv40_state.c
    @@ -14,41 +14,41 @@ nv40_blend_state_create(struct pipe_context *pipe,
     			const struct pipe_blend_state *cso)
     {
     	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     	struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso));
     	struct nouveau_stateobj *so = so_new(5, 8, 0);
     
     	if (cso->rt[0].blend_enable) {
    -		so_method(so, curie, NV34TCL_BLEND_FUNC_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
     		so_data  (so, 1);
     		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
     			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
     		so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
     			      nvgl_blend_func(cso->rt[0].rgb_dst_factor));
    -		so_method(so, curie, NV40TCL_BLEND_EQUATION, 1);
    +		so_method(so, eng3d, NV40TCL_BLEND_EQUATION, 1);
     		so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
     			      nvgl_blend_eqn(cso->rt[0].rgb_func));
     	} else {
    -		so_method(so, curie, NV34TCL_BLEND_FUNC_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, curie, NV34TCL_COLOR_MASK, 1);
    +	so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
     	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
     		       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
     
     	if (cso->logicop_enable) {
    -		so_method(so, curie, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
     		so_data  (so, 1);
     		so_data  (so, nvgl_logicop_func(cso->logicop_func));
     	} else {
    -		so_method(so, curie, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_method(so, curie, NV34TCL_DITHER_ENABLE, 1);
    +	so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
     	so_data  (so, cso->dither ? 1 : 0);
     
     	so_ref(so, &bso->so);
    @@ -311,7 +311,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	struct nv40_context *nv40 = nv40_context(pipe);
     	struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
     	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     
     	/*XXX: ignored:
     	 * 	light_twoside
    @@ -319,22 +319,22 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	 * 	multisample
     	 */
     
    -	so_method(so, curie, NV34TCL_SHADE_MODEL, 1);
    +	so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
     	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
     				       NV34TCL_SHADE_MODEL_SMOOTH);
     
    -	so_method(so, curie, NV34TCL_LINE_WIDTH, 2);
    +	so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
     	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
     	so_data  (so, cso->line_smooth ? 1 : 0);
    -	so_method(so, curie, NV34TCL_LINE_STIPPLE_ENABLE, 2);
    +	so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
     	so_data  (so, cso->line_stipple_enable ? 1 : 0);
     	so_data  (so, (cso->line_stipple_pattern << 16) |
     		       cso->line_stipple_factor);
     
    -	so_method(so, curie, NV34TCL_POINT_SIZE, 1);
    +	so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
     	so_data  (so, fui(cso->point_size));
     
    -	so_method(so, curie, NV34TCL_POLYGON_MODE_FRONT, 6);
    +	so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
     	if (cso->front_winding == PIPE_WINDING_CCW) {
     		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
     		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    @@ -375,10 +375,10 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	so_data(so, cso->poly_smooth ? 1 : 0);
     	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
     
    -	so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +	so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
     
    -	so_method(so, curie, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    +	so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
     	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
     	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
     		so_data(so, 1);
    @@ -395,12 +395,12 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     	else
     		so_data(so, 0);
     	if (cso->offset_cw || cso->offset_ccw) {
    -		so_method(so, curie, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
    +		so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
     		so_data  (so, fui(cso->offset_scale));
     		so_data  (so, fui(cso->offset_units * 2));
     	}
     
    -	so_method(so, curie, NV34TCL_POINT_SPRITE, 1);
    +	so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
     	if (cso->point_quad_rasterization) {
     		unsigned psctl = (1 << 0), i;
     
    @@ -446,45 +446,45 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     	struct nv40_context *nv40 = nv40_context(pipe);
     	struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
     	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     
    -	so_method(so, curie, NV34TCL_DEPTH_FUNC, 3);
    +	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
     	so_data  (so, nvgl_comparison_op(cso->depth.func));
     	so_data  (so, cso->depth.writemask ? 1 : 0);
     	so_data  (so, cso->depth.enabled ? 1 : 0);
     
    -	so_method(so, curie, NV34TCL_ALPHA_FUNC_ENABLE, 3);
    +	so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
     	so_data  (so, cso->alpha.enabled ? 1 : 0);
     	so_data  (so, nvgl_comparison_op(cso->alpha.func));
     	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
     
     	if (cso->stencil[0].enabled) {
    -		so_method(so, curie, NV34TCL_STENCIL_FRONT_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
     		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[0].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    -		so_method(so, curie, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[0].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
     	} else {
    -		so_method(so, curie, NV34TCL_STENCIL_FRONT_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
     	if (cso->stencil[1].enabled) {
    -		so_method(so, curie, NV34TCL_STENCIL_BACK_ENABLE, 3);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
     		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
     		so_data  (so, cso->stencil[1].writemask);
     		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    -		so_method(so, curie, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
     		so_data  (so, cso->stencil[1].valuemask);
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
     		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
     	} else {
    -		so_method(so, curie, NV34TCL_STENCIL_BACK_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_blend.c b/src/gallium/drivers/nv40/nv40_state_blend.c
    index 9da13123ab..83202ec23c 100644
    --- a/src/gallium/drivers/nv40/nv40_state_blend.c
    +++ b/src/gallium/drivers/nv40/nv40_state_blend.c
    @@ -21,7 +21,7 @@ nv40_state_blend_colour_validate(struct nv40_context *nv40)
     	struct nouveau_stateobj *so = so_new(1, 1, 0);
     	struct pipe_blend_color *bcol = &nv40->blend_colour;
     
    -	so_method(so, nv40->screen->curie, NV34TCL_BLEND_COLOR, 1);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
     	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
     		       (float_to_ubyte(bcol->color[0]) << 16) |
     		       (float_to_ubyte(bcol->color[1]) <<  8) |
    diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c
    index 297d71f4fa..6ad7a8d4fd 100644
    --- a/src/gallium/drivers/nv40/nv40_state_emit.c
    +++ b/src/gallium/drivers/nv40/nv40_state_emit.c
    @@ -59,7 +59,7 @@ nv40_state_emit(struct nv40_context *nv40)
     	struct nv40_state *state = &nv40->state;
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
     	uint64_t states;
     
    @@ -85,9 +85,9 @@ nv40_state_emit(struct nv40_context *nv40)
     
     	if (state->dirty & ((1ULL << NV40_STATE_FRAGPROG) |
     			    (1ULL << NV40_STATE_FRAGTEX0))) {
    -		BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
    +		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
     		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, curie, NV40TCL_TEX_CACHE_CTL, 1);
    +		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
     		OUT_RING  (chan, 1);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c
    index 93e91b9e3b..207b70923e 100644
    --- a/src/gallium/drivers/nv40/nv40_state_fb.c
    +++ b/src/gallium/drivers/nv40/nv40_state_fb.c
    @@ -14,7 +14,7 @@ static boolean
     nv40_state_framebuffer_validate(struct nv40_context *nv40)
     {
     	struct nouveau_channel *chan = nv40->screen->base.channel;
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     	struct pipe_framebuffer_state *fb = &nv40->framebuffer;
     	struct nv04_surface *rt[4], *zeta;
     	uint32_t rt_enable, rt_format;
    @@ -85,11 +85,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
    -		so_method(so, curie, NV34TCL_DMA_COLOR0, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV34TCL_COLOR0_PITCH, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR0_PITCH, 2);
     		so_data  (so, rt[0]->pitch);
     		so_reloc (so, nv40_surface_buffer(&rt[0]->base),
     			      rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    @@ -97,11 +97,11 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
    -		so_method(so, curie, NV34TCL_DMA_COLOR1, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV34TCL_COLOR1_OFFSET, 2);
    +		so_method(so, eng3d, NV34TCL_COLOR1_OFFSET, 2);
     		so_reloc (so, nv40_surface_buffer(&rt[1]->base),
     			      rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW,
     			      0, 0);
    @@ -109,56 +109,56 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
    -		so_method(so, curie, NV40TCL_DMA_COLOR2, 1);
    +		so_method(so, eng3d, NV40TCL_DMA_COLOR2, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV40TCL_COLOR2_OFFSET, 1);
    +		so_method(so, eng3d, NV40TCL_COLOR2_OFFSET, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[2]->base),
     			      rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW,
     			      0, 0);
    -		so_method(so, curie, NV40TCL_COLOR2_PITCH, 1);
    +		so_method(so, eng3d, NV40TCL_COLOR2_PITCH, 1);
     		so_data  (so, rt[2]->pitch);
     	}
     
     	if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
    -		so_method(so, curie, NV40TCL_DMA_COLOR3, 1);
    +		so_method(so, eng3d, NV40TCL_DMA_COLOR3, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV40TCL_COLOR3_OFFSET, 1);
    +		so_method(so, eng3d, NV40TCL_COLOR3_OFFSET, 1);
     		so_reloc (so, nv40_surface_buffer(&rt[3]->base),
     			      rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW,
     			      0, 0);
    -		so_method(so, curie, NV40TCL_COLOR3_PITCH, 1);
    +		so_method(so, eng3d, NV40TCL_COLOR3_PITCH, 1);
     		so_data  (so, rt[3]->pitch);
     	}
     
     	if (zeta_format) {
    -		so_method(so, curie, NV34TCL_DMA_ZETA, 1);
    +		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
     		so_reloc (so, nv40_surface_buffer(&zeta->base), 0,
     			      rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, curie, NV34TCL_ZETA_OFFSET, 1);
    +		so_method(so, eng3d, NV34TCL_ZETA_OFFSET, 1);
     		so_reloc (so, nv40_surface_buffer(&zeta->base),
     			      zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0);
    -		so_method(so, curie, NV40TCL_ZETA_PITCH, 1);
    +		so_method(so, eng3d, NV40TCL_ZETA_PITCH, 1);
     		so_data  (so, zeta->pitch);
     	}
     
    -	so_method(so, curie, NV40TCL_RT_ENABLE, 1);
    +	so_method(so, eng3d, NV40TCL_RT_ENABLE, 1);
     	so_data  (so, rt_enable);
    -	so_method(so, curie, NV34TCL_RT_HORIZ, 3);
    +	so_method(so, eng3d, NV34TCL_RT_HORIZ, 3);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
     	so_data  (so, rt_format);
    -	so_method(so, curie, NV34TCL_VIEWPORT_HORIZ, 2);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_HORIZ, 2);
     	so_data  (so, (w << 16) | 0);
     	so_data  (so, (h << 16) | 0);
    -	so_method(so, curie, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
     	so_data  (so, ((w - 1) << 16) | 0);
     	so_data  (so, ((h - 1) << 16) | 0);
    -	so_method(so, curie, 0x1d88, 1);
    +	so_method(so, eng3d, 0x1d88, 1);
     	so_data  (so, (1 << 12) | h);
     
     	so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
    diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
    index 91bff4849c..dcb068d059 100644
    --- a/src/gallium/drivers/nv40/nv40_state_scissor.c
    +++ b/src/gallium/drivers/nv40/nv40_state_scissor.c
    @@ -13,7 +13,7 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
     	nv40->state.scissor_enabled = rast->scissor;
     
     	so = so_new(1, 2, 0);
    -	so_method(so, nv40->screen->curie, NV34TCL_SCISSOR_HORIZ, 2);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
     	if (nv40->state.scissor_enabled) {
     		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
     		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    diff --git a/src/gallium/drivers/nv40/nv40_state_stipple.c b/src/gallium/drivers/nv40/nv40_state_stipple.c
    index ed8643b9c1..4514618772 100644
    --- a/src/gallium/drivers/nv40/nv40_state_stipple.c
    +++ b/src/gallium/drivers/nv40/nv40_state_stipple.c
    @@ -4,7 +4,7 @@ static boolean
     nv40_state_stipple_validate(struct nv40_context *nv40)
     {
     	struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     	struct nouveau_stateobj *so;
     
     	if (nv40->state.hw[NV40_STATE_STIPPLE] &&
    @@ -15,14 +15,14 @@ nv40_state_stipple_validate(struct nv40_context *nv40)
     		unsigned i;
     
     		so = so_new(2, 33, 0);
    -		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 1);
    -		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
     		for (i = 0; i < 32; i++)
     			so_data(so, nv40->stipple[i]);
     	} else {
     		so = so_new(1, 1, 0);
    -		so_method(so, curie, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c
    index 3a5ea0e480..43cf6e5a0a 100644
    --- a/src/gallium/drivers/nv40/nv40_state_viewport.c
    +++ b/src/gallium/drivers/nv40/nv40_state_viewport.c
    @@ -11,7 +11,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
     		return FALSE;
     
     	so = so_new(2, 9, 0);
    -	so_method(so, nv40->screen->curie,
    +	so_method(so, nv40->screen->eng3d,
     		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
     	so_data  (so, fui(vpt->translate[0]));
     	so_data  (so, fui(vpt->translate[1]));
    @@ -21,7 +21,7 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
     	so_data  (so, fui(vpt->scale[1]));
     	so_data  (so, fui(vpt->scale[2]));
     	so_data  (so, fui(vpt->scale[3]));
    -	so_method(so, nv40->screen->curie, 0x1d78, 1);
    +	so_method(so, nv40->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     
     	so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
    diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c
    index bf68c60ace..cb56948a1b 100644
    --- a/src/gallium/drivers/nv40/nv40_state_zsa.c
    +++ b/src/gallium/drivers/nv40/nv40_state_zsa.c
    @@ -22,9 +22,9 @@ nv40_state_sr_validate(struct nv40_context *nv40)
     	struct nouveau_stateobj *so = so_new(2, 2, 0);
     	struct pipe_stencil_ref *sr = &nv40->stencil_ref;
     
    -	so_method(so, nv40->screen->curie, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nv40->screen->curie, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_method(so, nv40->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[1]);
     
     	so_ref(so, &nv40->state.hw[NV40_STATE_SR]);
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    index a2f06ead86..b77c9e924b 100644
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ b/src/gallium/drivers/nv40/nv40_vbo.c
    @@ -111,7 +111,7 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
     		       struct pipe_vertex_buffer *vb)
     {
     	struct pipe_screen *pscreen = nv40->pipe.screen;
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     	unsigned type, ncomp;
     	void *map;
     
    @@ -128,25 +128,25 @@ nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
     
     		switch (ncomp) {
     		case 4:
    -			so_method(so, curie, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			so_data  (so, fui(v[3]));
     			break;
     		case 3:
    -			so_method(so, curie, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			so_data  (so, fui(v[2]));
     			break;
     		case 2:
    -			so_method(so, curie, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
     			so_data  (so, fui(v[0]));
     			so_data  (so, fui(v[1]));
     			break;
     		case 1:
    -			so_method(so, curie, NV34TCL_VTX_ATTR_1F(attrib), 1);
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_1F(attrib), 1);
     			so_data  (so, fui(v[0]));
     			break;
     		default:
    @@ -172,7 +172,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
     	struct nv40_context *nv40 = nv40_context(pipe);
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart;
     
     	nv40_vbo_set_idxbuf(nv40, NULL, 0);
    @@ -194,12 +194,12 @@ nv40_draw_arrays(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, curie, NV34TCL_VB_VERTEX_BATCH, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -210,14 +210,14 @@ nv40_draw_arrays(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, curie, NV34TCL_VB_VERTEX_BATCH, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -233,7 +233,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     {
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint8_t *elts = (uint8_t *)ib + start;
    @@ -249,11 +249,11 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, curie, NV34TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -263,7 +263,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -271,7 +271,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -284,7 +284,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     {
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint16_t *elts = (uint16_t *)ib + start;
    @@ -300,11 +300,11 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		if (vc & 1) {
    -			BEGIN_RING(chan, curie, NV34TCL_VB_ELEMENT_U32, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
     			OUT_RING  (chan, elts[0]);
     			elts++; vc--;
     		}
    @@ -314,7 +314,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     
     			push = MIN2(vc, 2047 * 2);
     
    -			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
     			for (i = 0; i < push; i+=2)
     				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
     
    @@ -322,7 +322,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -335,7 +335,7 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
     {
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     
     	while (count) {
     		uint32_t *elts = (uint32_t *)ib + start;
    @@ -351,20 +351,20 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
     		}
     		count -= vc;
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		while (vc) {
     			push = MIN2(vc, 2047);
     
    -			BEGIN_RING_NI(chan, curie, NV34TCL_VB_ELEMENT_U32, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U32, push);
     			OUT_RINGp    (chan, elts, push);
     
     			vc -= push;
     			elts += push;
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		start = restart;
    @@ -411,7 +411,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     	struct nv40_context *nv40 = nv40_context(pipe);
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart;
     
     	while (count) {
    @@ -426,12 +426,12 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     			continue;
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, nvgl_primitive(mode));
     
     		nr = (vc & 0xff);
     		if (nr) {
    -			BEGIN_RING(chan, curie, NV34TCL_VB_INDEX_BATCH, 1);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_INDEX_BATCH, 1);
     			OUT_RING  (chan, ((nr - 1) << 24) | start);
     			start += nr;
     		}
    @@ -442,14 +442,14 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     
     			nr -= push;
     
    -			BEGIN_RING_NI(chan, curie, NV34TCL_VB_INDEX_BATCH, push);
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_INDEX_BATCH, push);
     			while (push--) {
     				OUT_RING(chan, ((0x100 - 1) << 24) | start);
     				start += 0x100;
     			}
     		}
     
    -		BEGIN_RING(chan, curie, NV34TCL_VERTEX_BEGIN_END, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
     		OUT_RING  (chan, 0);
     
     		count -= vc;
    @@ -486,16 +486,16 @@ static boolean
     nv40_vbo_validate(struct nv40_context *nv40)
     {
     	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *curie = nv40->screen->curie;
    +	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
     	struct pipe_buffer *ib = nv40->idxbuf;
     	unsigned ib_format = nv40->idxbuf_format;
     	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
     	int hw;
     
     	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, curie, NV34TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
    +	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
     	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, curie, NV34TCL_VTXFMT(0), nv40->vtxelt->num_elements);
    +	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nv40->vtxelt->num_elements);
     
     	for (hw = 0; hw < nv40->vtxelt->num_elements; hw++) {
     		struct pipe_vertex_element *ve;
    @@ -534,13 +534,13 @@ nv40_vbo_validate(struct nv40_context *nv40)
     	if (ib) {
     		struct nouveau_bo *bo = nouveau_bo(ib);
     
    -		so_method(vtxbuf, curie, NV34TCL_IDXBUF_ADDRESS, 2);
    +		so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
     		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
     		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
     			  0, NV34TCL_IDXBUF_FORMAT_DMA1);
     	}
     
    -	so_method(vtxbuf, curie, 0x1710, 1);
    +	so_method(vtxbuf, eng3d, 0x1710, 1);
     	so_data  (vtxbuf, 0);
     
     	so_ref(vtxbuf, &nv40->state.hw[NV40_STATE_VTXBUF]);
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    index 2abda14f31..96f2743429 100644
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ b/src/gallium/drivers/nv40/nv40_vertprog.c
    @@ -836,7 +836,7 @@ nv40_vertprog_validate(struct nv40_context *nv40)
     	struct pipe_screen *pscreen = nv40->pipe.screen;
     	struct nv40_screen *screen = nv40->screen;
     	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *curie = screen->curie;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
     	struct nv40_vertex_program *vp;
     	struct pipe_buffer *constbuf;
     	boolean upload_code = FALSE, upload_data = FALSE;
    @@ -887,12 +887,12 @@ check_gpu_resources:
     		}
     
     		so = so_new(3, 4, 0);
    -		so_method(so, curie, NV34TCL_VP_START_FROM_ID, 1);
    +		so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
     		so_data  (so, vp->exec->start);
    -		so_method(so, curie, NV40TCL_VP_ATTRIB_EN, 2);
    +		so_method(so, eng3d, NV40TCL_VP_ATTRIB_EN, 2);
     		so_data  (so, vp->ir);
     		so_data  (so, vp->or);
    -		so_method(so, curie,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
    +		so_method(so, eng3d,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
     		so_data  (so, vp->clip_ctrl);
     		so_ref(so, &vp->so);
     		so_ref(NULL, &so);
    @@ -976,7 +976,7 @@ check_gpu_resources:
     				       4 * sizeof(float));
     			}
     
    -			BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_CONST_ID, 5);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_CONST_ID, 5);
     			OUT_RING  (chan, i + vp->data->start);
     			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
     		}
    @@ -995,10 +995,10 @@ check_gpu_resources:
     			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[3]);
     		}
     #endif
    -		BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_FROM_ID, 1);
    +		BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_FROM_ID, 1);
     		OUT_RING  (chan, vp->exec->start);
     		for (i = 0; i < vp->nr_insns; i++) {
    -			BEGIN_RING(chan, curie, NV34TCL_VP_UPLOAD_INST(0), 4);
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_INST(0), 4);
     			OUT_RINGp (chan, vp->insns[i].data, 4);
     		}
     	}
    -- 
    cgit v1.2.3
    
    
    From b8e56d4cddbd9c491b940e3ce5974c526802c752 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 18:37:43 +0100
    Subject: nv30, nv40: unify all structures and headers, except shaders
    
    This patch unifies nv[34]0_screen.h, nv[34]0_context.h and
    nv[34]0_state.h
    
    The unified files are put in a new "nvfx" directory.
    
    nv30_context.h and nv40_context.h still exist to hold the function
    prototypes and include nvfx_context.h
    
    nv[34]0_screen.h and nv[34]0_state.h are deleted, replaced by the
    unified versions.
    
    nv40 includes some extra fields for swtnl and user clip planes
    support.
    
    These fields will be unused on nv30 until that functionality gets
    added to it too (by unification with nv40).
    ---
     src/gallium/drivers/nv30/Makefile                |   2 +
     src/gallium/drivers/nv30/nv30_clear.c            |   2 +-
     src/gallium/drivers/nv30/nv30_context.c          |  78 +++----
     src/gallium/drivers/nv30/nv30_context.h          | 215 +++----------------
     src/gallium/drivers/nv30/nv30_draw.c             |   8 +-
     src/gallium/drivers/nv30/nv30_fragprog.c         |  66 +++---
     src/gallium/drivers/nv30/nv30_fragtex.c          |  34 +--
     src/gallium/drivers/nv30/nv30_miptree.c          |  18 +-
     src/gallium/drivers/nv30/nv30_query.c            |  32 +--
     src/gallium/drivers/nv30/nv30_screen.c           |  10 +-
     src/gallium/drivers/nv30/nv30_screen.h           |  38 ----
     src/gallium/drivers/nv30/nv30_state.c            | 254 +++++++++++-----------
     src/gallium/drivers/nv30/nv30_state.h            |  86 --------
     src/gallium/drivers/nv30/nv30_state_blend.c      |  24 +--
     src/gallium/drivers/nv30/nv30_state_emit.c       |  75 ++++---
     src/gallium/drivers/nv30/nv30_state_fb.c         |  24 +--
     src/gallium/drivers/nv30/nv30_state_rasterizer.c |  12 +-
     src/gallium/drivers/nv30/nv30_state_scissor.c    |  24 +--
     src/gallium/drivers/nv30/nv30_state_stipple.c    |  20 +-
     src/gallium/drivers/nv30/nv30_state_viewport.c   |  22 +-
     src/gallium/drivers/nv30/nv30_state_zsa.c        |  28 +--
     src/gallium/drivers/nv30/nv30_surface.c          |  14 +-
     src/gallium/drivers/nv30/nv30_transfer.c         |  26 +--
     src/gallium/drivers/nv30/nv30_vbo.c              | 112 +++++-----
     src/gallium/drivers/nv30/nv30_vertprog.c         |  60 +++---
     src/gallium/drivers/nv40/Makefile                |   2 +
     src/gallium/drivers/nv40/nv40_clear.c            |   2 +-
     src/gallium/drivers/nv40/nv40_context.c          |  78 +++----
     src/gallium/drivers/nv40/nv40_context.h          | 235 +++-----------------
     src/gallium/drivers/nv40/nv40_draw.c             | 116 +++++-----
     src/gallium/drivers/nv40/nv40_fragprog.c         |  62 +++---
     src/gallium/drivers/nv40/nv40_fragtex.c          |  36 ++--
     src/gallium/drivers/nv40/nv40_miptree.c          |  18 +-
     src/gallium/drivers/nv40/nv40_query.c            |  32 +--
     src/gallium/drivers/nv40/nv40_screen.c           |  12 +-
     src/gallium/drivers/nv40/nv40_screen.h           |  37 ----
     src/gallium/drivers/nv40/nv40_state.c            | 262 +++++++++++------------
     src/gallium/drivers/nv40/nv40_state.h            |  91 --------
     src/gallium/drivers/nv40/nv40_state_blend.c      |  24 +--
     src/gallium/drivers/nv40/nv40_state_emit.c       | 126 +++++------
     src/gallium/drivers/nv40/nv40_state_fb.c         |  18 +-
     src/gallium/drivers/nv40/nv40_state_rasterizer.c |  12 +-
     src/gallium/drivers/nv40/nv40_state_scissor.c    |  24 +--
     src/gallium/drivers/nv40/nv40_state_stipple.c    |  20 +-
     src/gallium/drivers/nv40/nv40_state_viewport.c   |  20 +-
     src/gallium/drivers/nv40/nv40_state_zsa.c        |  28 +--
     src/gallium/drivers/nv40/nv40_surface.c          |  14 +-
     src/gallium/drivers/nv40/nv40_transfer.c         |  26 +--
     src/gallium/drivers/nv40/nv40_vbo.c              | 112 +++++-----
     src/gallium/drivers/nv40/nv40_vertprog.c         |  84 ++++----
     src/gallium/drivers/nvfx/nvfx_context.h          | 182 ++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_screen.h           |  37 ++++
     src/gallium/drivers/nvfx/nvfx_state.h            |  91 ++++++++
     53 files changed, 1404 insertions(+), 1681 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_screen.h
     delete mode 100644 src/gallium/drivers/nv30/nv30_state.h
     delete mode 100644 src/gallium/drivers/nv40/nv40_screen.h
     delete mode 100644 src/gallium/drivers/nv40/nv40_state.h
     create mode 100644 src/gallium/drivers/nvfx/nvfx_context.h
     create mode 100644 src/gallium/drivers/nvfx/nvfx_screen.h
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state.h
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 364c80d8f3..ed02075d13 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -26,4 +26,6 @@ C_SOURCES = \
     	nv30_vbo.c \
     	nv30_vertprog.c
     
    +LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    +
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nv30/nv30_clear.c b/src/gallium/drivers/nv30/nv30_clear.c
    index c4ba926664..e7ba73de7c 100644
    --- a/src/gallium/drivers/nv30/nv30_clear.c
    +++ b/src/gallium/drivers/nv30/nv30_clear.c
    @@ -9,6 +9,6 @@ void
     nv30_clear(struct pipe_context *pipe, unsigned buffers,
                const float *rgba, double depth, unsigned stencil)
     {
    -	util_clear(pipe, &nv30_context(pipe)->framebuffer, buffers, rgba, depth,
    +	util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
     		   stencil);
     }
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index be6407805b..628b50d8dc 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -2,14 +2,14 @@
     #include "pipe/p_defines.h"
     
     #include "nv30_context.h"
    -#include "nv30_screen.h"
    +#include "nvfx_screen.h"
     
     static void
     nv30_flush(struct pipe_context *pipe, unsigned flags,
     	   struct pipe_fence_handle **fence)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -28,61 +28,61 @@ nv30_flush(struct pipe_context *pipe, unsigned flags,
     static void
     nv30_destroy(struct pipe_context *pipe)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned i;
     
    -	for (i = 0; i < NV30_STATE_MAX; i++) {
    -		if (nv30->state.hw[i])
    -			so_ref(NULL, &nv30->state.hw[i]);
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
    +		if (nvfx->state.hw[i])
    +			so_ref(NULL, &nvfx->state.hw[i]);
     	}
     
    -	if (nv30->draw)
    -		draw_destroy(nv30->draw);
    -	FREE(nv30);
    +	if (nvfx->draw)
    +		draw_destroy(nvfx->draw);
    +	FREE(nvfx);
     }
     
     struct pipe_context *
     nv30_create(struct pipe_screen *pscreen, void *priv)
     {
    -	struct nv30_screen *screen = nv30_screen(pscreen);
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
     	struct pipe_winsys *ws = pscreen->winsys;
    -	struct nv30_context *nv30;
    +	struct nvfx_context *nvfx;
     	struct nouveau_winsys *nvws = screen->nvws;
     
    -	nv30 = CALLOC(1, sizeof(struct nv30_context));
    -	if (!nv30)
    +	nvfx = CALLOC(1, sizeof(struct nvfx_context));
    +	if (!nvfx)
     		return NULL;
    -	nv30->screen = screen;
    +	nvfx->screen = screen;
     
    -	nv30->nvws = nvws;
    +	nvfx->nvws = nvws;
     
    -	nv30->pipe.winsys = ws;
    -	nv30->pipe.screen = pscreen;
    -	nv30->pipe.priv = priv;
    -	nv30->pipe.destroy = nv30_destroy;
    -	nv30->pipe.draw_arrays = nv30_draw_arrays;
    -	nv30->pipe.draw_elements = nv30_draw_elements;
    -	nv30->pipe.clear = nv30_clear;
    -	nv30->pipe.flush = nv30_flush;
    +	nvfx->pipe.winsys = ws;
    +	nvfx->pipe.screen = pscreen;
    +	nvfx->pipe.priv = priv;
    +	nvfx->pipe.destroy = nv30_destroy;
    +	nvfx->pipe.draw_arrays = nv30_draw_arrays;
    +	nvfx->pipe.draw_elements = nv30_draw_elements;
    +	nvfx->pipe.clear = nv30_clear;
    +	nvfx->pipe.flush = nv30_flush;
     
    -	nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    -	nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
    +	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    +	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
     
    -	screen->base.channel->user_private = nv30;
    +	screen->base.channel->user_private = nvfx;
     	screen->base.channel->flush_notify = nv30_state_flush_notify;
     
    -	nv30_init_query_functions(nv30);
    -	nv30_init_surface_functions(nv30);
    -	nv30_init_state_functions(nv30);
    -	nv30_init_transfer_functions(nv30);
    +	nv30_init_query_functions(nvfx);
    +	nv30_init_surface_functions(nvfx);
    +	nv30_init_state_functions(nvfx);
    +	nv30_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
    -	nv30->draw = draw_create();
    -	draw_wide_point_threshold(nv30->draw, 9999999.0);
    -	draw_wide_line_threshold(nv30->draw, 9999999.0);
    -	draw_enable_line_stipple(nv30->draw, FALSE);
    -	draw_enable_point_sprites(nv30->draw, FALSE);
    -	draw_set_rasterize_stage(nv30->draw, nv30_draw_render_stage(nv30));
    -
    -	return &nv30->pipe;
    +	nvfx->draw = draw_create();
    +	draw_wide_point_threshold(nvfx->draw, 9999999.0);
    +	draw_wide_line_threshold(nvfx->draw, 9999999.0);
    +	draw_enable_line_stipple(nvfx->draw, FALSE);
    +	draw_enable_point_sprites(nvfx->draw, FALSE);
    +	draw_set_rasterize_stage(nvfx->draw, nv30_draw_render_stage(nvfx));
    +
    +	return &nvfx->pipe;
     }
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 4a164f3b1f..2fc148cded 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -1,207 +1,46 @@
     #ifndef __NV30_CONTEXT_H__
     #define __NV30_CONTEXT_H__
     
    -#include 
    +#include "nvfx_context.h"
     
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "pipe/p_compiler.h"
    -
    -#include "util/u_memory.h"
    -#include "util/u_math.h"
    -#include "util/u_inlines.h"
    -
    -#include "draw/draw_vertex.h"
    -
    -#include "nouveau/nouveau_winsys.h"
    -#include "nouveau/nouveau_gldefs.h"
    -#include "nouveau/nouveau_context.h"
    -#include "nouveau/nouveau_stateobj.h"
    -
    -#include "nv30_state.h"
    -
    -#define NOUVEAU_ERR(fmt, args...) \
    -	fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
    -#define NOUVEAU_MSG(fmt, args...) \
    -	fprintf(stderr, "nouveau: "fmt, ##args);
    -
    -enum nv30_state_index {
    -	NV30_STATE_FB = 0,
    -	NV30_STATE_VIEWPORT = 1,
    -	NV30_STATE_BLEND = 2,
    -	NV30_STATE_RAST = 3,
    -	NV30_STATE_ZSA = 4,
    -	NV30_STATE_BCOL = 5,
    -	NV30_STATE_CLIP = 6,
    -	NV30_STATE_SCISSOR = 7,
    -	NV30_STATE_STIPPLE = 8,
    -	NV30_STATE_FRAGPROG = 9,
    -	NV30_STATE_VERTPROG = 10,
    -	NV30_STATE_FRAGTEX0 = 11,
    -	NV30_STATE_FRAGTEX1 = 12,
    -	NV30_STATE_FRAGTEX2 = 13,
    -	NV30_STATE_FRAGTEX3 = 14,
    -	NV30_STATE_FRAGTEX4 = 15,
    -	NV30_STATE_FRAGTEX5 = 16,
    -	NV30_STATE_FRAGTEX6 = 17,
    -	NV30_STATE_FRAGTEX7 = 18,
    -	NV30_STATE_FRAGTEX8 = 19,
    -	NV30_STATE_FRAGTEX9 = 20,
    -	NV30_STATE_FRAGTEX10 = 21,
    -	NV30_STATE_FRAGTEX11 = 22,
    -	NV30_STATE_FRAGTEX12 = 23,
    -	NV30_STATE_FRAGTEX13 = 24,
    -	NV30_STATE_FRAGTEX14 = 25,
    -	NV30_STATE_FRAGTEX15 = 26,
    -	NV30_STATE_VERTTEX0 = 27,
    -	NV30_STATE_VERTTEX1 = 28,
    -	NV30_STATE_VERTTEX2 = 29,
    -	NV30_STATE_VERTTEX3 = 30,
    -	NV30_STATE_VTXBUF = 31,
    -	NV30_STATE_VTXFMT = 32,
    -	NV30_STATE_VTXATTR = 33,
    -	NV30_STATE_SR = 34,
    -	NV30_STATE_MAX = 35
    -};
    -
    -#include "nv30_screen.h"
    -
    -#define NV30_NEW_BLEND		(1 <<  0)
    -#define NV30_NEW_RAST		(1 <<  1)
    -#define NV30_NEW_ZSA		(1 <<  2)
    -#define NV30_NEW_SAMPLER	(1 <<  3)
    -#define NV30_NEW_FB		(1 <<  4)
    -#define NV30_NEW_STIPPLE	(1 <<  5)
    -#define NV30_NEW_SCISSOR	(1 <<  6)
    -#define NV30_NEW_VIEWPORT	(1 <<  7)
    -#define NV30_NEW_BCOL		(1 <<  8)
    -#define NV30_NEW_VERTPROG	(1 <<  9)
    -#define NV30_NEW_FRAGPROG	(1 << 10)
    -#define NV30_NEW_ARRAYS		(1 << 11)
    -#define NV30_NEW_UCP		(1 << 12)
    -#define NV30_NEW_SR		(1 << 13)
    -
    -struct nv30_rasterizer_state {
    -	struct pipe_rasterizer_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv30_zsa_state {
    -	struct pipe_depth_stencil_alpha_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv30_blend_state {
    -	struct pipe_blend_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -
    -struct nv30_state {
    -	unsigned scissor_enabled;
    -	unsigned stipple_enabled;
    -	unsigned fp_samplers;
    -
    -	uint64_t dirty;
    -	struct nouveau_stateobj *hw[NV30_STATE_MAX];
    -};
    -
    -struct nv30_vtxelt_state {
    -	struct pipe_vertex_element pipe[16];
    -	unsigned num_elements;
    -};
    -
    -struct nv30_context {
    -	struct pipe_context pipe;
    -
    -	struct nouveau_winsys *nvws;
    -	struct nv30_screen *screen;
    -
    -	struct draw_context *draw;
    -
    -	/* HW state derived from pipe states */
    -	struct nv30_state state;
    -
    -	/* Context state */
    -	unsigned dirty;
    -	struct pipe_scissor_state scissor;
    -	unsigned stipple[32];
    -	struct nv30_vertex_program *vertprog;
    -	struct nv30_fragment_program *fragprog;
    -	struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
    -	unsigned constbuf_nr[PIPE_SHADER_TYPES];
    -	struct nv30_rasterizer_state *rasterizer;
    -	struct nv30_zsa_state *zsa;
    -	struct nv30_blend_state *blend;
    -	struct pipe_blend_color blend_colour;
    -	struct pipe_stencil_ref stencil_ref;
    -	struct pipe_viewport_state viewport;
    -	struct pipe_framebuffer_state framebuffer;
    -	struct pipe_buffer *idxbuf;
    -	unsigned idxbuf_format;
    -	struct nv30_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
    -	struct nv30_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
    -	unsigned nr_samplers;
    -	unsigned nr_textures;
    -	unsigned dirty_samplers;
    -	struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
    -	unsigned vtxbuf_nr;
    -	struct nv30_vtxelt_state *vtxelt;
    -};
    -
    -static INLINE struct nv30_context *
    -nv30_context(struct pipe_context *pipe)
    -{
    -	return (struct nv30_context *)pipe;
    -}
    -
    -struct nv30_state_entry {
    -	boolean (*validate)(struct nv30_context *nv30);
    -	struct {
    -		unsigned pipe;
    -		unsigned hw;
    -	} dirty;
    -};
    -
    -extern void nv30_init_state_functions(struct nv30_context *nv30);
    -extern void nv30_init_surface_functions(struct nv30_context *nv30);
    -extern void nv30_init_query_functions(struct nv30_context *nv30);
    -extern void nv30_init_transfer_functions(struct nv30_context *nv30);
    +extern void nv30_init_state_functions(struct nvfx_context *nvfx);
    +extern void nv30_init_surface_functions(struct nvfx_context *nvfx);
    +extern void nv30_init_query_functions(struct nvfx_context *nvfx);
    +extern void nv30_init_transfer_functions(struct nvfx_context *nvfx);
     
     extern void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen);
     
     /* nv30_draw.c */
    -extern struct draw_stage *nv30_draw_render_stage(struct nv30_context *nv30);
    +extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
     
     /* nv30_vertprog.c */
    -extern void nv30_vertprog_destroy(struct nv30_context *,
    -				  struct nv30_vertex_program *);
    +extern void nv30_vertprog_destroy(struct nvfx_context *,
    +				  struct nvfx_vertex_program *);
     
     /* nv30_fragprog.c */
    -extern void nv30_fragprog_destroy(struct nv30_context *,
    -				  struct nv30_fragment_program *);
    +extern void nv30_fragprog_destroy(struct nvfx_context *,
    +				  struct nvfx_fragment_program *);
     
     /* nv30_fragtex.c */
    -extern void nv30_fragtex_bind(struct nv30_context *);
    +extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern boolean nv30_state_validate(struct nv30_context *nv30);
    -extern void nv30_state_emit(struct nv30_context *nv30);
    +extern boolean nv30_state_validate(struct nvfx_context *nvfx);
    +extern void nv30_state_emit(struct nvfx_context *nvfx);
     extern void nv30_state_flush_notify(struct nouveau_channel *chan);
    -extern struct nv30_state_entry nv30_state_rasterizer;
    -extern struct nv30_state_entry nv30_state_scissor;
    -extern struct nv30_state_entry nv30_state_stipple;
    -extern struct nv30_state_entry nv30_state_fragprog;
    -extern struct nv30_state_entry nv30_state_vertprog;
    -extern struct nv30_state_entry nv30_state_blend;
    -extern struct nv30_state_entry nv30_state_blend_colour;
    -extern struct nv30_state_entry nv30_state_zsa;
    -extern struct nv30_state_entry nv30_state_viewport;
    -extern struct nv30_state_entry nv30_state_framebuffer;
    -extern struct nv30_state_entry nv30_state_fragtex;
    -extern struct nv30_state_entry nv30_state_vbo;
    -extern struct nv30_state_entry nv30_state_sr;
    +extern struct nvfx_state_entry nv30_state_rasterizer;
    +extern struct nvfx_state_entry nv30_state_scissor;
    +extern struct nvfx_state_entry nv30_state_stipple;
    +extern struct nvfx_state_entry nv30_state_fragprog;
    +extern struct nvfx_state_entry nv30_state_vertprog;
    +extern struct nvfx_state_entry nv30_state_blend;
    +extern struct nvfx_state_entry nv30_state_blend_colour;
    +extern struct nvfx_state_entry nv30_state_zsa;
    +extern struct nvfx_state_entry nv30_state_viewport;
    +extern struct nvfx_state_entry nv30_state_framebuffer;
    +extern struct nvfx_state_entry nv30_state_fragtex;
    +extern struct nvfx_state_entry nv30_state_vbo;
    +extern struct nvfx_state_entry nv30_state_sr;
     
     /* nv30_vbo.c */
     extern void nv30_draw_arrays(struct pipe_context *, unsigned mode,
    @@ -216,7 +55,7 @@ extern void nv30_draw_elements(struct pipe_context *pipe,
     extern void nv30_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    -/* nv30_context.c */
    +/* nvfx_context.c */
     struct pipe_context *
     nv30_create(struct pipe_screen *pscreen, void *priv);
     
    diff --git a/src/gallium/drivers/nv30/nv30_draw.c b/src/gallium/drivers/nv30/nv30_draw.c
    index 74fc138c05..5d22e78abf 100644
    --- a/src/gallium/drivers/nv30/nv30_draw.c
    +++ b/src/gallium/drivers/nv30/nv30_draw.c
    @@ -4,7 +4,7 @@
     
     struct nv30_draw_stage {
     	struct draw_stage draw;
    -	struct nv30_context *nv30;
    +	struct nvfx_context *nvfx;
     };
     
     static void
    @@ -43,12 +43,12 @@ nv30_draw_destroy(struct draw_stage *draw)
     }
     
     struct draw_stage *
    -nv30_draw_render_stage(struct nv30_context *nv30)
    +nv30_draw_render_stage(struct nvfx_context *nvfx)
     {
     	struct nv30_draw_stage *nv30draw = CALLOC_STRUCT(nv30_draw_stage);
     
    -	nv30draw->nv30 = nv30;
    -	nv30draw->draw.draw = nv30->draw;
    +	nv30draw->nvfx = nvfx;
    +	nv30draw->draw.draw = nvfx->draw;
     	nv30draw->draw.point = nv30_draw_point;
     	nv30draw->draw.line = nv30_draw_line;
     	nv30draw->draw.tri = nv30_draw_tri;
    diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
    index 4c96e6d733..ae246ffd64 100644
    --- a/src/gallium/drivers/nv30/nv30_fragprog.c
    +++ b/src/gallium/drivers/nv30/nv30_fragprog.c
    @@ -31,7 +31,7 @@
     #define MAX_CONSTS 128
     #define MAX_IMM 32
     struct nv30_fpc {
    -	struct nv30_fragment_program *fp;
    +	struct nvfx_fragment_program *fp;
     
     	uint attrib_map[PIPE_MAX_SHADER_INPUTS];
     
    @@ -89,7 +89,7 @@ constant(struct nv30_fpc *fpc, int pipe, float vals[4])
     static void
     grow_insns(struct nv30_fpc *fpc, int size)
     {
    -	struct nv30_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     
     	fp->insn_len += size;
     	fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);
    @@ -98,7 +98,7 @@ grow_insns(struct nv30_fpc *fpc, int size)
     static void
     emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
     {
    -	struct nv30_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     	uint32_t sr = 0;
     
    @@ -118,7 +118,7 @@ emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
     		grow_insns(fpc, 4);
     		hw = &fp->insn[fpc->inst_offset];
     		if (fpc->consts[src.index].pipe >= 0) {
    -			struct nv30_fragment_program_data *fpd;
    +			struct nvfx_fragment_program_data *fpd;
     
     			fp->consts = realloc(fp->consts, ++fp->nr_consts *
     					     sizeof(*fpd));
    @@ -158,7 +158,7 @@ emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
     static void
     emit_dst(struct nv30_fpc *fpc, struct nv30_sreg dst)
     {
    -	struct nv30_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     
     	switch (dst.type) {
    @@ -188,7 +188,7 @@ nv30_fp_arith(struct nv30_fpc *fpc, int sat, int op,
     	      struct nv30_sreg dst, int mask,
     	      struct nv30_sreg s0, struct nv30_sreg s1, struct nv30_sreg s2)
     {
    -	struct nv30_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw;
     
     	fpc->inst_offset = fp->insn_len;
    @@ -224,7 +224,7 @@ nv30_fp_tex(struct nv30_fpc *fpc, int sat, int op, int unit,
     	    struct nv30_sreg dst, int mask,
     	    struct nv30_sreg s0, struct nv30_sreg s1, struct nv30_sreg s2)
     {
    -	struct nv30_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     
     	nv30_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
     
    @@ -718,8 +718,8 @@ out_err:
     }
     
     static void
    -nv30_fragprog_translate(struct nv30_context *nv30,
    -			struct nv30_fragment_program *fp)
    +nv30_fragprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_fragment_program *fp)
     {
     	struct tgsi_parse_context parse;
     	struct nv30_fpc *fpc = NULL;
    @@ -778,10 +778,10 @@ out_err:
     }
     
     static void
    -nv30_fragprog_upload(struct nv30_context *nv30,
    -		     struct nv30_fragment_program *fp)
    +nv30_fragprog_upload(struct nvfx_context *nvfx,
    +		     struct nvfx_fragment_program *fp)
     {
    -	struct pipe_screen *pscreen = nv30->pipe.screen;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
     	const uint32_t le = 1;
     	uint32_t *map;
     	int i;
    @@ -812,12 +812,12 @@ nv30_fragprog_upload(struct nv30_context *nv30,
     }
     
     static boolean
    -nv30_fragprog_validate(struct nv30_context *nv30)
    +nv30_fragprog_validate(struct nvfx_context *nvfx)
     {
    -	struct nv30_fragment_program *fp = nv30->fragprog;
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
     	struct pipe_buffer *constbuf =
    -		nv30->constbuf[PIPE_SHADER_FRAGMENT];
    -	struct pipe_screen *pscreen = nv30->pipe.screen;
    +		nvfx->constbuf[PIPE_SHADER_FRAGMENT];
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
     	struct nouveau_stateobj *so;
     	boolean new_consts = FALSE;
     	int i;
    @@ -825,27 +825,27 @@ nv30_fragprog_validate(struct nv30_context *nv30)
     	if (fp->translated)
     		goto update_constants;
     
    -	/*nv30->fallback_swrast &= ~NV30_NEW_FRAGPROG;*/
    -	nv30_fragprog_translate(nv30, fp);
    +	/*nvfx->fallback_swrast &= ~NVFX_NEW_FRAGPROG;*/
    +	nv30_fragprog_translate(nvfx, fp);
     	if (!fp->translated) {
    -		/*nv30->fallback_swrast |= NV30_NEW_FRAGPROG;*/
    +		/*nvfx->fallback_swrast |= NVFX_NEW_FRAGPROG;*/
     		return FALSE;
     	}
     
     	fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
    -	nv30_fragprog_upload(nv30, fp);
    +	nv30_fragprog_upload(nvfx, fp);
     
     	so = so_new(4, 4, 1);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
     	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
     		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
     		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
     		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_FP_CONTROL, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_FP_REG_CONTROL, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_REG_CONTROL, 1);
     	so_data  (so, (1<<16)|0x4);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_TX_UNITS_ENABLE, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_UNITS_ENABLE, 1);
     	so_data  (so, fp->samplers);
     	so_ref(so, &fp->so);
     	so_ref(NULL, &so);
    @@ -857,7 +857,7 @@ update_constants:
     		map = pipe_buffer_map(pscreen, constbuf,
     				      PIPE_BUFFER_USAGE_CPU_READ);
     		for (i = 0; i < fp->nr_consts; i++) {
    -			struct nv30_fragment_program_data *fpd = &fp->consts[i];
    +			struct nvfx_fragment_program_data *fpd = &fp->consts[i];
     			uint32_t *p = &fp->insn[fpd->offset];
     			uint32_t *cb = (uint32_t *)&map[fpd->index * 4];
     
    @@ -869,11 +869,11 @@ update_constants:
     		pipe_buffer_unmap(pscreen, constbuf);
     
     		if (new_consts)
    -			nv30_fragprog_upload(nv30, fp);
    +			nv30_fragprog_upload(nvfx, fp);
     	}
     
    -	if (new_consts || fp->so != nv30->state.hw[NV30_STATE_FRAGPROG]) {
    -		so_ref(fp->so, &nv30->state.hw[NV30_STATE_FRAGPROG]);
    +	if (new_consts || fp->so != nvfx->state.hw[NVFX_STATE_FRAGPROG]) {
    +		so_ref(fp->so, &nvfx->state.hw[NVFX_STATE_FRAGPROG]);
     		return TRUE;
     	}
     
    @@ -881,8 +881,8 @@ update_constants:
     }
     
     void
    -nv30_fragprog_destroy(struct nv30_context *nv30,
    -		      struct nv30_fragment_program *fp)
    +nv30_fragprog_destroy(struct nvfx_context *nvfx,
    +		      struct nvfx_fragment_program *fp)
     {
     	if (fp->buffer)
     		pipe_buffer_reference(&fp->buffer, NULL);
    @@ -894,10 +894,10 @@ nv30_fragprog_destroy(struct nv30_context *nv30,
     		FREE(fp->insn);
     }
     
    -struct nv30_state_entry nv30_state_fragprog = {
    +struct nvfx_state_entry nv30_state_fragprog = {
     	.validate = nv30_fragprog_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_FRAGPROG,
    -		.hw = NV30_STATE_FRAGPROG
    +		.pipe = NVFX_NEW_FRAGPROG,
    +		.hw = NVFX_STATE_FRAGPROG
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    index 63b5015ed4..34e7dd5444 100644
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ b/src/gallium/drivers/nv30/nv30_fragtex.c
    @@ -58,10 +58,10 @@ nv30_fragtex_format(uint pipe_format)
     
     
     static struct nouveau_stateobj *
    -nv30_fragtex_build(struct nv30_context *nv30, int unit)
    +nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
     {
    -	struct nv30_sampler_state *ps = nv30->tex_sampler[unit];
    -	struct nv30_miptree *nv30mt = nv30->tex_miptree[unit];
    +	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    +	struct nvfx_miptree *nv30mt = nvfx->tex_miptree[unit];
     	struct pipe_texture *pt = &nv30mt->base;
     	struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
     	struct nv30_texture_format *tf;
    @@ -101,7 +101,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
     	txs = tf->swizzle;
     
     	so = so_new(1, 8, 2);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
     	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
     	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
     		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    @@ -117,10 +117,10 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit)
     }
     
     static boolean
    -nv30_fragtex_validate(struct nv30_context *nv30)
    +nv30_fragtex_validate(struct nvfx_context *nvfx)
     {
    -	struct nv30_fragment_program *fp = nv30->fragprog;
    -	struct nv30_state *state = &nv30->state;
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
    +	struct nvfx_state *state = &nvfx->state;
     	struct nouveau_stateobj *so;
     	unsigned samplers, unit;
     
    @@ -130,32 +130,32 @@ nv30_fragtex_validate(struct nv30_context *nv30)
     		samplers &= ~(1 << unit);
     
     		so = so_new(1, 1, 0);
    -		so_method(so, nv30->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
    +		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
     		so_data  (so, 0);
    -		so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
     		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
     	}
     
    -	samplers = nv30->dirty_samplers & fp->samplers;
    +	samplers = nvfx->dirty_samplers & fp->samplers;
     	while (samplers) {
     		unit = ffs(samplers) - 1;
     		samplers &= ~(1 << unit);
     
    -		so = nv30_fragtex_build(nv30, unit);
    -		so_ref(so, &nv30->state.hw[NV30_STATE_FRAGTEX0 + unit]);
    +		so = nv30_fragtex_build(nvfx, unit);
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
     		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NV30_STATE_FRAGTEX0 + unit));
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
     	}
     
    -	nv30->state.fp_samplers = fp->samplers;
    +	nvfx->state.fp_samplers = fp->samplers;
     	return FALSE;
     }
     
    -struct nv30_state_entry nv30_state_fragtex = {
    +struct nvfx_state_entry nv30_state_fragtex = {
     	.validate = nv30_fragtex_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_SAMPLER | NV30_NEW_FRAGPROG,
    +		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
     		.hw = 0
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
    index bfa27b632f..ada355a444 100644
    --- a/src/gallium/drivers/nv30/nv30_miptree.c
    +++ b/src/gallium/drivers/nv30/nv30_miptree.c
    @@ -8,7 +8,7 @@
     #include "../nouveau/nv04_surface_2d.h"
     
     static void
    -nv30_miptree_layout(struct nv30_miptree *nv30mt)
    +nv30_miptree_layout(struct nvfx_miptree *nv30mt)
     {
     	struct pipe_texture *pt = &nv30mt->base;
     	uint width = pt->width0;
    @@ -62,11 +62,11 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
     static struct pipe_texture *
     nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
     {
    -	struct nv30_miptree *mt;
    +	struct nvfx_miptree *mt;
     	unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
     	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
     
    -	mt = MALLOC(sizeof(struct nv30_miptree));
    +	mt = MALLOC(sizeof(struct nvfx_miptree));
     	if (!mt)
     		return NULL;
     	mt->base = *pt;
    @@ -132,14 +132,14 @@ static struct pipe_texture *
     nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
     		     const unsigned *stride, struct pipe_buffer *pb)
     {
    -	struct nv30_miptree *mt;
    +	struct nvfx_miptree *mt;
     
     	/* Only supports 2D, non-mipmapped textures for the moment */
     	if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
     	    pt->depth0 != 1)
     		return NULL;
     
    -	mt = CALLOC_STRUCT(nv30_miptree);
    +	mt = CALLOC_STRUCT(nvfx_miptree);
     	if (!mt)
     		return NULL;
     
    @@ -160,7 +160,7 @@ nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
     static void
     nv30_miptree_destroy(struct pipe_texture *pt)
     {
    -	struct nv30_miptree *mt = (struct nv30_miptree *)pt;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
     	int l;
     
     	pipe_buffer_reference(&mt->buffer, NULL);
    @@ -177,7 +177,7 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
     			 unsigned face, unsigned level, unsigned zslice,
     			 unsigned flags)
     {
    -	struct nv30_miptree *nv30mt = (struct nv30_miptree *)pt;
    +	struct nvfx_miptree *nv30mt = (struct nvfx_miptree *)pt;
     	struct nv04_surface *ns;
     
     	ns = CALLOC_STRUCT(nv04_surface);
    @@ -207,7 +207,7 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
     	 * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
     	 * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
     	if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
    -		return &nv04_surface_wrap_for_render(pscreen, ((struct nv30_screen*)pscreen)->eng2d, ns)->base;
    +		return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
     
     	return &ns->base;
     }
    @@ -218,7 +218,7 @@ nv30_miptree_surface_del(struct pipe_surface *ps)
     	struct nv04_surface* ns = (struct nv04_surface*)ps;
     	if(ns->backing)
     	{
    -		struct nv30_screen* screen = (struct nv30_screen*)ps->texture->screen;
    +		struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
     		if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
     			screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
     		nv30_miptree_surface_del(&ns->backing->base);
    diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
    index 21a5e8ad7c..53b11a8943 100644
    --- a/src/gallium/drivers/nv30/nv30_query.c
    +++ b/src/gallium/drivers/nv30/nv30_query.c
    @@ -39,9 +39,9 @@ nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
     static void
     nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nv30_query *q = nv30_query(pq);
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -56,9 +56,9 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     		pipe->get_query_result(pipe, pq, 1, &tmp);
     	}
     
    -	if (nouveau_resource_alloc(nv30->screen->query_heap, 1, NULL, &q->object))
    +	if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
     		assert(0);
    -	nouveau_notifier_reset(nv30->screen->query, q->object->start);
    +	nouveau_notifier_reset(nvfx->screen->query, q->object->start);
     
     	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
     	OUT_RING  (chan, 1);
    @@ -71,8 +71,8 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     static void
     nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	struct nv30_query *q = nv30_query(pq);
    @@ -87,7 +87,7 @@ static boolean
     nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     		  boolean wait, uint64_t *result)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nv30_query *q = nv30_query(pq);
     
     	assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    @@ -95,18 +95,18 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     	if (!q->ready) {
     		unsigned status;
     
    -		status = nouveau_notifier_status(nv30->screen->query,
    +		status = nouveau_notifier_status(nvfx->screen->query,
     						 q->object->start);
     		if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
     			if (wait == FALSE)
     				return FALSE;
     
    -			nouveau_notifier_wait_status(nv30->screen->query,
    +			nouveau_notifier_wait_status(nvfx->screen->query,
     					q->object->start,
     					NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
     		}
     
    -		q->result = nouveau_notifier_return_val(nv30->screen->query,
    +		q->result = nouveau_notifier_return_val(nvfx->screen->query,
     							q->object->start);
     		q->ready = TRUE;
     		nouveau_resource_free(&q->object);
    @@ -117,11 +117,11 @@ nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     }
     
     void
    -nv30_init_query_functions(struct nv30_context *nv30)
    +nv30_init_query_functions(struct nvfx_context *nvfx)
     {
    -	nv30->pipe.create_query = nv30_query_create;
    -	nv30->pipe.destroy_query = nv30_query_destroy;
    -	nv30->pipe.begin_query = nv30_query_begin;
    -	nv30->pipe.end_query = nv30_query_end;
    -	nv30->pipe.get_query_result = nv30_query_result;
    +	nvfx->pipe.create_query = nv30_query_create;
    +	nvfx->pipe.destroy_query = nv30_query_destroy;
    +	nvfx->pipe.begin_query = nv30_query_begin;
    +	nvfx->pipe.end_query = nv30_query_end;
    +	nvfx->pipe.get_query_result = nv30_query_result;
     }
    diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
    index 40193f2795..305dfa8386 100644
    --- a/src/gallium/drivers/nv30/nv30_screen.c
    +++ b/src/gallium/drivers/nv30/nv30_screen.c
    @@ -4,7 +4,7 @@
     #include "nouveau/nouveau_screen.h"
     
     #include "nv30_context.h"
    -#include "nv30_screen.h"
    +#include "nvfx_screen.h"
     
     #define NV30TCL_CHIPSET_3X_MASK 0x00000003
     #define NV34TCL_CHIPSET_3X_MASK 0x00000010
    @@ -156,7 +156,7 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
     static struct pipe_buffer *
     nv30_surface_buffer(struct pipe_surface *surf)
     {
    -	struct nv30_miptree *mt = (struct nv30_miptree *)surf->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
     
     	return mt->buffer;
     }
    @@ -164,10 +164,10 @@ nv30_surface_buffer(struct pipe_surface *surf)
     static void
     nv30_screen_destroy(struct pipe_screen *pscreen)
     {
    -	struct nv30_screen *screen = nv30_screen(pscreen);
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
     	unsigned i;
     
    -	for (i = 0; i < NV30_STATE_MAX; i++) {
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
     		if (screen->state[i])
     			so_ref(NULL, &screen->state[i]);
     	}
    @@ -188,7 +188,7 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
     struct pipe_screen *
     nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     {
    -	struct nv30_screen *screen = CALLOC_STRUCT(nv30_screen);
    +	struct nvfx_screen *screen = CALLOC_STRUCT(nvfx_screen);
     	struct nouveau_channel *chan;
     	struct pipe_screen *pscreen;
     	struct nouveau_stateobj *so;
    diff --git a/src/gallium/drivers/nv30/nv30_screen.h b/src/gallium/drivers/nv30/nv30_screen.h
    deleted file mode 100644
    index 69a94593f9..0000000000
    --- a/src/gallium/drivers/nv30/nv30_screen.h
    +++ /dev/null
    @@ -1,38 +0,0 @@
    -#ifndef __NV30_SCREEN_H__
    -#define __NV30_SCREEN_H__
    -
    -#include "nouveau/nouveau_screen.h"
    -
    -#include "nouveau/nv04_surface_2d.h"
    -
    -struct nv30_screen {
    -	struct nouveau_screen base;
    -
    -	struct nouveau_winsys *nvws;
    -
    -	struct nv30_context *cur_ctx;
    -
    -	/* HW graphics objects */
    -	struct nv04_surface_2d *eng2d;
    -	struct nouveau_grobj *eng3d;
    -	struct nouveau_notifier *sync;
    -
    -	/* Query object resources */
    -	struct nouveau_notifier *query;
    -	struct nouveau_resource *query_heap;
    -
    -	/* Vtxprog resources */
    -	struct nouveau_resource *vp_exec_heap;
    -	struct nouveau_resource *vp_data_heap;
    -
    -	/* Current 3D state of channel */
    -	struct nouveau_stateobj *state[NV30_STATE_MAX];
    -};
    -
    -static INLINE struct nv30_screen *
    -nv30_screen(struct pipe_screen *screen)
    -{
    -	return (struct nv30_screen *)screen;
    -}
    -
    -#endif
    diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
    index 330448000b..5263f894f2 100644
    --- a/src/gallium/drivers/nv30/nv30_state.c
    +++ b/src/gallium/drivers/nv30/nv30_state.c
    @@ -5,15 +5,15 @@
     #include "tgsi/tgsi_parse.h"
     
     #include "nv30_context.h"
    -#include "nv30_state.h"
    +#include "nvfx_state.h"
     
     static void *
     nv30_blend_state_create(struct pipe_context *pipe,
     			const struct pipe_blend_state *cso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    -	struct nv30_blend_state *bso = CALLOC(1, sizeof(*bso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
     	struct nouveau_stateobj *so = so_new(5, 8, 0);
     
     	if (cso->rt[0].blend_enable) {
    @@ -59,16 +59,16 @@ nv30_blend_state_create(struct pipe_context *pipe,
     static void
     nv30_blend_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->blend = hwcso;
    -	nv30->dirty |= NV30_NEW_BLEND;
    +	nvfx->blend = hwcso;
    +	nvfx->dirty |= NVFX_NEW_BLEND;
     }
     
     static void
     nv30_blend_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_blend_state *bso = hwcso;
    +	struct nvfx_blend_state *bso = hwcso;
     
     	so_ref(NULL, &bso->so);
     	FREE(bso);
    @@ -117,10 +117,10 @@ static void *
     nv30_sampler_state_create(struct pipe_context *pipe,
     			  const struct pipe_sampler_state *cso)
     {
    -	struct nv30_sampler_state *ps;
    +	struct nvfx_sampler_state *ps;
     	uint32_t filter = 0;
     
    -	ps = MALLOC(sizeof(struct nv30_sampler_state));
    +	ps = MALLOC(sizeof(struct nvfx_sampler_state));
     
     	ps->fmt = 0;
     	/* TODO: Not all RECTs formats have this bit set, bits 15-8 of format
    @@ -248,21 +248,21 @@ nv30_sampler_state_create(struct pipe_context *pipe,
     static void
     nv30_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned unit;
     
     	for (unit = 0; unit < nr; unit++) {
    -		nv30->tex_sampler[unit] = sampler[unit];
    -		nv30->dirty_samplers |= (1 << unit);
    +		nvfx->tex_sampler[unit] = sampler[unit];
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	for (unit = nr; unit < nv30->nr_samplers; unit++) {
    -		nv30->tex_sampler[unit] = NULL;
    -		nv30->dirty_samplers |= (1 << unit);
    +	for (unit = nr; unit < nvfx->nr_samplers; unit++) {
    +		nvfx->tex_sampler[unit] = NULL;
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	nv30->nr_samplers = nr;
    -	nv30->dirty |= NV30_NEW_SAMPLER;
    +	nvfx->nr_samplers = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
     }
     
     static void
    @@ -275,33 +275,33 @@ static void
     nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
     			 struct pipe_texture **miptree)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned unit;
     
     	for (unit = 0; unit < nr; unit++) {
     		pipe_texture_reference((struct pipe_texture **)
    -				       &nv30->tex_miptree[unit], miptree[unit]);
    -		nv30->dirty_samplers |= (1 << unit);
    +				       &nvfx->tex_miptree[unit], miptree[unit]);
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	for (unit = nr; unit < nv30->nr_textures; unit++) {
    +	for (unit = nr; unit < nvfx->nr_textures; unit++) {
     		pipe_texture_reference((struct pipe_texture **)
    -				       &nv30->tex_miptree[unit], NULL);
    -		nv30->dirty_samplers |= (1 << unit);
    +				       &nvfx->tex_miptree[unit], NULL);
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	nv30->nr_textures = nr;
    -	nv30->dirty |= NV30_NEW_SAMPLER;
    +	nvfx->nr_textures = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
     }
     
     static void *
     nv30_rasterizer_state_create(struct pipe_context *pipe,
     			     const struct pipe_rasterizer_state *cso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
     	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     
     	/*XXX: ignored:
     	 * 	light_twoside
    @@ -413,17 +413,17 @@ nv30_rasterizer_state_create(struct pipe_context *pipe,
     static void
     nv30_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->rasterizer = hwcso;
    -	nv30->dirty |= NV30_NEW_RAST;
    -	/*nv30->draw_dirty |= NV30_NEW_RAST;*/
    +	nvfx->rasterizer = hwcso;
    +	nvfx->dirty |= NVFX_NEW_RAST;
    +	/*nvfx->draw_dirty |= NVFX_NEW_RAST;*/
     }
     
     static void
     nv30_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_rasterizer_state *rsso = hwcso;
    +	struct nvfx_rasterizer_state *rsso = hwcso;
     
     	so_ref(NULL, &rsso->so);
     	FREE(rsso);
    @@ -433,10 +433,10 @@ static void *
     nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     			const struct pipe_depth_stencil_alpha_state *cso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
     	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     
     	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
     	so_data  (so, nvgl_comparison_op(cso->depth.func));
    @@ -487,16 +487,16 @@ nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     static void
     nv30_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->zsa = hwcso;
    -	nv30->dirty |= NV30_NEW_ZSA;
    +	nvfx->zsa = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ZSA;
     }
     
     static void
     nv30_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_zsa_state *zsaso = hwcso;
    +	struct nvfx_zsa_state *zsaso = hwcso;
     
     	so_ref(NULL, &zsaso->so);
     	FREE(zsaso);
    @@ -506,12 +506,12 @@ static void *
     nv30_vp_state_create(struct pipe_context *pipe,
     		     const struct pipe_shader_state *cso)
     {
    -	/*struct nv30_context *nv30 = nv30_context(pipe);*/
    -	struct nv30_vertex_program *vp;
    +	/*struct nvfx_context *nvfx = nvfx_context(pipe);*/
    +	struct nvfx_vertex_program *vp;
     
    -	vp = CALLOC(1, sizeof(struct nv30_vertex_program));
    +	vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
     	vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -	/*vp->draw = draw_create_vertex_shader(nv30->draw, &vp->pipe);*/
    +	/*vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);*/
     
     	return (void *)vp;
     }
    @@ -519,21 +519,21 @@ nv30_vp_state_create(struct pipe_context *pipe,
     static void
     nv30_vp_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->vertprog = hwcso;
    -	nv30->dirty |= NV30_NEW_VERTPROG;
    -	/*nv30->draw_dirty |= NV30_NEW_VERTPROG;*/
    +	nvfx->vertprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_VERTPROG;
    +	/*nvfx->draw_dirty |= NVFX_NEW_VERTPROG;*/
     }
     
     static void
     nv30_vp_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_vertex_program *vp = hwcso;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_vertex_program *vp = hwcso;
     
    -	/*draw_delete_vertex_shader(nv30->draw, vp->draw);*/
    -	nv30_vertprog_destroy(nv30, vp);
    +	/*draw_delete_vertex_shader(nvfx->draw, vp->draw);*/
    +	nv30_vertprog_destroy(nvfx, vp);
     	FREE((void*)vp->pipe.tokens);
     	FREE(vp);
     }
    @@ -542,9 +542,9 @@ static void *
     nv30_fp_state_create(struct pipe_context *pipe,
     		     const struct pipe_shader_state *cso)
     {
    -	struct nv30_fragment_program *fp;
    +	struct nvfx_fragment_program *fp;
     
    -	fp = CALLOC(1, sizeof(struct nv30_fragment_program));
    +	fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
     	fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
     
     	tgsi_scan_shader(fp->pipe.tokens, &fp->info);
    @@ -555,19 +555,19 @@ nv30_fp_state_create(struct pipe_context *pipe,
     static void
     nv30_fp_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->fragprog = hwcso;
    -	nv30->dirty |= NV30_NEW_FRAGPROG;
    +	nvfx->fragprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_FRAGPROG;
     }
     
     static void
     nv30_fp_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_fragment_program *fp = hwcso;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_fragment_program *fp = hwcso;
     
    -	nv30_fragprog_destroy(nv30, fp);
    +	nv30_fragprog_destroy(nvfx, fp);
     	FREE((void*)fp->pipe.tokens);
     	FREE(fp);
     }
    @@ -576,20 +576,20 @@ static void
     nv30_set_blend_color(struct pipe_context *pipe,
     		     const struct pipe_blend_color *bcol)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->blend_colour = *bcol;
    -	nv30->dirty |= NV30_NEW_BCOL;
    +	nvfx->blend_colour = *bcol;
    +	nvfx->dirty |= NVFX_NEW_BCOL;
     }
     
     static void
     nv30_set_stencil_ref(struct pipe_context *pipe,
     		     const struct pipe_stencil_ref *sr)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->stencil_ref = *sr;
    -	nv30->dirty |= NV30_NEW_SR;
    +	nvfx->stencil_ref = *sr;
    +	nvfx->dirty |= NVFX_NEW_SR;
     }
     
     static void
    @@ -602,16 +602,16 @@ static void
     nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
     			 struct pipe_buffer *buf )
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->constbuf[shader] = buf;
    -	nv30->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
    +	nvfx->constbuf[shader] = buf;
    +	nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
     
     	if (shader == PIPE_SHADER_VERTEX) {
    -		nv30->dirty |= NV30_NEW_VERTPROG;
    +		nvfx->dirty |= NVFX_NEW_VERTPROG;
     	} else
     	if (shader == PIPE_SHADER_FRAGMENT) {
    -		nv30->dirty |= NV30_NEW_FRAGPROG;
    +		nvfx->dirty |= NVFX_NEW_FRAGPROG;
     	}
     }
     
    @@ -619,54 +619,54 @@ static void
     nv30_set_framebuffer_state(struct pipe_context *pipe,
     			   const struct pipe_framebuffer_state *fb)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->framebuffer = *fb;
    -	nv30->dirty |= NV30_NEW_FB;
    +	nvfx->framebuffer = *fb;
    +	nvfx->dirty |= NVFX_NEW_FB;
     }
     
     static void
     nv30_set_polygon_stipple(struct pipe_context *pipe,
     			 const struct pipe_poly_stipple *stipple)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	memcpy(nv30->stipple, stipple->stipple, 4 * 32);
    -	nv30->dirty |= NV30_NEW_STIPPLE;
    +	memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
    +	nvfx->dirty |= NVFX_NEW_STIPPLE;
     }
     
     static void
     nv30_set_scissor_state(struct pipe_context *pipe,
     		       const struct pipe_scissor_state *s)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->scissor = *s;
    -	nv30->dirty |= NV30_NEW_SCISSOR;
    +	nvfx->scissor = *s;
    +	nvfx->dirty |= NVFX_NEW_SCISSOR;
     }
     
     static void
     nv30_set_viewport_state(struct pipe_context *pipe,
     			const struct pipe_viewport_state *vpt)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->viewport = *vpt;
    -	nv30->dirty |= NV30_NEW_VIEWPORT;
    -	/*nv30->draw_dirty |= NV30_NEW_VIEWPORT;*/
    +	nvfx->viewport = *vpt;
    +	nvfx->dirty |= NVFX_NEW_VIEWPORT;
    +	/*nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;*/
     }
     
     static void
     nv30_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
     			const struct pipe_vertex_buffer *vb)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	memcpy(nv30->vtxbuf, vb, sizeof(*vb) * count);
    -	nv30->vtxbuf_nr = count;
    +	memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
    +	nvfx->vtxbuf_nr = count;
     
    -	nv30->dirty |= NV30_NEW_ARRAYS;
    -	/*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
     }
     
     static void *
    @@ -674,7 +674,7 @@ nv30_vtxelts_state_create(struct pipe_context *pipe,
     			  unsigned num_elements,
     			  const struct pipe_vertex_element *elements)
     {
    -	struct nv30_vtxelt_state *cso = CALLOC_STRUCT(nv30_vtxelt_state);
    +	struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
     
     	assert(num_elements < 16); /* not doing fallbacks yet */
     	cso->num_elements = num_elements;
    @@ -694,57 +694,57 @@ nv30_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
     static void
     nv30_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv30->vtxelt = hwcso;
    -	nv30->dirty |= NV30_NEW_ARRAYS;
    -	/*nv30->draw_dirty |= NV30_NEW_ARRAYS;*/
    +	nvfx->vtxelt = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
     }
     
     void
    -nv30_init_state_functions(struct nv30_context *nv30)
    +nv30_init_state_functions(struct nvfx_context *nvfx)
     {
    -	nv30->pipe.create_blend_state = nv30_blend_state_create;
    -	nv30->pipe.bind_blend_state = nv30_blend_state_bind;
    -	nv30->pipe.delete_blend_state = nv30_blend_state_delete;
    +	nvfx->pipe.create_blend_state = nv30_blend_state_create;
    +	nvfx->pipe.bind_blend_state = nv30_blend_state_bind;
    +	nvfx->pipe.delete_blend_state = nv30_blend_state_delete;
     
    -	nv30->pipe.create_sampler_state = nv30_sampler_state_create;
    -	nv30->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind;
    -	nv30->pipe.delete_sampler_state = nv30_sampler_state_delete;
    -	nv30->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture;
    +	nvfx->pipe.create_sampler_state = nv30_sampler_state_create;
    +	nvfx->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind;
    +	nvfx->pipe.delete_sampler_state = nv30_sampler_state_delete;
    +	nvfx->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture;
     
    -	nv30->pipe.create_rasterizer_state = nv30_rasterizer_state_create;
    -	nv30->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind;
    -	nv30->pipe.delete_rasterizer_state = nv30_rasterizer_state_delete;
    +	nvfx->pipe.create_rasterizer_state = nv30_rasterizer_state_create;
    +	nvfx->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind;
    +	nvfx->pipe.delete_rasterizer_state = nv30_rasterizer_state_delete;
     
    -	nv30->pipe.create_depth_stencil_alpha_state =
    +	nvfx->pipe.create_depth_stencil_alpha_state =
     		nv30_depth_stencil_alpha_state_create;
    -	nv30->pipe.bind_depth_stencil_alpha_state =
    +	nvfx->pipe.bind_depth_stencil_alpha_state =
     		nv30_depth_stencil_alpha_state_bind;
    -	nv30->pipe.delete_depth_stencil_alpha_state =
    +	nvfx->pipe.delete_depth_stencil_alpha_state =
     		nv30_depth_stencil_alpha_state_delete;
     
    -	nv30->pipe.create_vs_state = nv30_vp_state_create;
    -	nv30->pipe.bind_vs_state = nv30_vp_state_bind;
    -	nv30->pipe.delete_vs_state = nv30_vp_state_delete;
    +	nvfx->pipe.create_vs_state = nv30_vp_state_create;
    +	nvfx->pipe.bind_vs_state = nv30_vp_state_bind;
    +	nvfx->pipe.delete_vs_state = nv30_vp_state_delete;
     
    -	nv30->pipe.create_fs_state = nv30_fp_state_create;
    -	nv30->pipe.bind_fs_state = nv30_fp_state_bind;
    -	nv30->pipe.delete_fs_state = nv30_fp_state_delete;
    +	nvfx->pipe.create_fs_state = nv30_fp_state_create;
    +	nvfx->pipe.bind_fs_state = nv30_fp_state_bind;
    +	nvfx->pipe.delete_fs_state = nv30_fp_state_delete;
     
    -	nv30->pipe.set_blend_color = nv30_set_blend_color;
    -        nv30->pipe.set_stencil_ref = nv30_set_stencil_ref;
    -	nv30->pipe.set_clip_state = nv30_set_clip_state;
    -	nv30->pipe.set_constant_buffer = nv30_set_constant_buffer;
    -	nv30->pipe.set_framebuffer_state = nv30_set_framebuffer_state;
    -	nv30->pipe.set_polygon_stipple = nv30_set_polygon_stipple;
    -	nv30->pipe.set_scissor_state = nv30_set_scissor_state;
    -	nv30->pipe.set_viewport_state = nv30_set_viewport_state;
    +	nvfx->pipe.set_blend_color = nv30_set_blend_color;
    +	nvfx->pipe.set_stencil_ref = nv30_set_stencil_ref;
    +	nvfx->pipe.set_clip_state = nv30_set_clip_state;
    +	nvfx->pipe.set_constant_buffer = nv30_set_constant_buffer;
    +	nvfx->pipe.set_framebuffer_state = nv30_set_framebuffer_state;
    +	nvfx->pipe.set_polygon_stipple = nv30_set_polygon_stipple;
    +	nvfx->pipe.set_scissor_state = nv30_set_scissor_state;
    +	nvfx->pipe.set_viewport_state = nv30_set_viewport_state;
     
    -	nv30->pipe.create_vertex_elements_state = nv30_vtxelts_state_create;
    -	nv30->pipe.delete_vertex_elements_state = nv30_vtxelts_state_delete;
    -	nv30->pipe.bind_vertex_elements_state = nv30_vtxelts_state_bind;
    +	nvfx->pipe.create_vertex_elements_state = nv30_vtxelts_state_create;
    +	nvfx->pipe.delete_vertex_elements_state = nv30_vtxelts_state_delete;
    +	nvfx->pipe.bind_vertex_elements_state = nv30_vtxelts_state_bind;
     
    -	nv30->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
    +	nvfx->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
     }
     
    diff --git a/src/gallium/drivers/nv30/nv30_state.h b/src/gallium/drivers/nv30/nv30_state.h
    deleted file mode 100644
    index b1c7f84a0a..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state.h
    +++ /dev/null
    @@ -1,86 +0,0 @@
    -#ifndef __NV30_STATE_H__
    -#define __NV30_STATE_H__
    -
    -#include "pipe/p_state.h"
    -#include "tgsi/tgsi_scan.h"
    -
    -struct nv30_sampler_state {
    -	uint32_t fmt;
    -	uint32_t wrap;
    -	uint32_t en;
    -	uint32_t filt;
    -	uint32_t bcol;
    -};
    -
    -struct nv30_vertex_program_exec {
    -	uint32_t data[4];
    -	boolean has_branch_offset;
    -	int const_index;
    -};
    -
    -struct nv30_vertex_program_data {
    -	int index; /* immediates == -1 */
    -	float value[4];
    -};
    -
    -struct nv30_vertex_program {
    -	struct pipe_shader_state pipe;
    -
    -	boolean translated;
    -
    -	struct nv30_vertex_program_exec *insns;
    -	unsigned nr_insns;
    -	struct nv30_vertex_program_data *consts;
    -	unsigned nr_consts;
    -
    -	struct nouveau_resource *exec;
    -	unsigned exec_start;
    -	struct nouveau_resource *data;
    -	unsigned data_start;
    -	unsigned data_start_min;
    -
    -	uint32_t ir;
    -	uint32_t or;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv30_fragment_program_data {
    -	unsigned offset;
    -	unsigned index;
    -};
    -
    -struct nv30_fragment_program {
    -	struct pipe_shader_state pipe;
    -	struct tgsi_shader_info info;
    -
    -	boolean translated;
    -	unsigned samplers;
    -
    -	uint32_t *insn;
    -	int       insn_len;
    -
    -	struct nv30_fragment_program_data *consts;
    -	unsigned nr_consts;
    -
    -	struct pipe_buffer *buffer;
    -
    -	uint32_t fp_control;
    -	struct nouveau_stateobj *so;
    -};
    -
    -#define NV30_MAX_TEXTURE_LEVELS  16
    -
    -struct nv30_miptree {
    -	struct pipe_texture base;
    -	struct nouveau_bo *bo;
    -
    -	struct pipe_buffer *buffer;
    -	uint total_size;
    -
    -	struct {
    -		uint pitch;
    -		uint *image_offset;
    -	} level[NV30_MAX_TEXTURE_LEVELS];
    -};
    -
    -#endif
    diff --git a/src/gallium/drivers/nv30/nv30_state_blend.c b/src/gallium/drivers/nv30/nv30_state_blend.c
    index eb0199cf65..de368e5bd7 100644
    --- a/src/gallium/drivers/nv30/nv30_state_blend.c
    +++ b/src/gallium/drivers/nv30/nv30_state_blend.c
    @@ -1,41 +1,41 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_blend_validate(struct nv30_context *nv30)
    +nv30_state_blend_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv30->blend->so, &nv30->state.hw[NV30_STATE_BLEND]);
    +	so_ref(nvfx->blend->so, &nvfx->state.hw[NVFX_STATE_BLEND]);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_blend = {
    +struct nvfx_state_entry nv30_state_blend = {
     	.validate = nv30_state_blend_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_BLEND,
    -		.hw = NV30_STATE_BLEND
    +		.pipe = NVFX_NEW_BLEND,
    +		.hw = NVFX_STATE_BLEND
     	}
     };
     
     static boolean
    -nv30_state_blend_colour_validate(struct nv30_context *nv30)
    +nv30_state_blend_colour_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *so = so_new(1, 1, 0);
    -	struct pipe_blend_color *bcol = &nv30->blend_colour;
    +	struct pipe_blend_color *bcol = &nvfx->blend_colour;
     
    -	so_method(so, nv30->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
     	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
     		       (float_to_ubyte(bcol->color[0]) << 16) |
     		       (float_to_ubyte(bcol->color[1]) <<  8) |
     		       (float_to_ubyte(bcol->color[2]) <<  0)));
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_BCOL]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_BCOL]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_blend_colour = {
    +struct nvfx_state_entry nv30_state_blend_colour = {
     	.validate = nv30_state_blend_colour_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_BCOL,
    -		.hw = NV30_STATE_BCOL
    +		.pipe = NVFX_NEW_BCOL,
    +		.hw = NVFX_STATE_BCOL
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c
    index deefe7fd8d..6df93618da 100644
    --- a/src/gallium/drivers/nv30/nv30_state_emit.c
    +++ b/src/gallium/drivers/nv30/nv30_state_emit.c
    @@ -1,7 +1,7 @@
     #include "nv30_context.h"
    -#include "nv30_state.h"
    +#include "nvfx_state.h"
     
    -static struct nv30_state_entry *render_states[] = {
    +static struct nvfx_state_entry *render_states[] = {
     	&nv30_state_framebuffer,
     	&nv30_state_rasterizer,
     	&nv30_state_scissor,
    @@ -19,49 +19,48 @@ static struct nv30_state_entry *render_states[] = {
     };
     
     static void
    -nv30_state_do_validate(struct nv30_context *nv30,
    -		       struct nv30_state_entry **states)
    +nv30_state_do_validate(struct nvfx_context *nvfx,
    +		       struct nvfx_state_entry **states)
     {
     	while (*states) {
    -		struct nv30_state_entry *e = *states;
    +		struct nvfx_state_entry *e = *states;
     
    -		if (nv30->dirty & e->dirty.pipe) {
    -			if (e->validate(nv30)) {
    -				nv30->state.dirty |= (1ULL << e->dirty.hw);
    -			}
    +		if (nvfx->dirty & e->dirty.pipe) {
    +			if (e->validate(nvfx))
    +				nvfx->state.dirty |= (1ULL << e->dirty.hw);
     		}
     
     		states++;
     	}
    -	nv30->dirty = 0;
    +	nvfx->dirty = 0;
     }
     
     void
    -nv30_state_emit(struct nv30_context *nv30)
    +nv30_state_emit(struct nvfx_context *nvfx)
     {
    -	struct nouveau_channel *chan = nv30->screen->base.channel;
    -	struct nv30_state *state = &nv30->state;
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nouveau_channel *chan = nvfx->screen->base.channel;
    +	struct nvfx_state *state = &nvfx->state;
    +	struct nvfx_screen *screen = nvfx->screen;
     	unsigned i;
     	uint64_t states;
     
     	/* XXX: racy!
     	 */
    -	if (nv30 != screen->cur_ctx) {
    -		for (i = 0; i < NV30_STATE_MAX; i++) {
    +	if (nvfx != screen->cur_ctx) {
    +		for (i = 0; i < NVFX_STATE_MAX; i++) {
     			if (state->hw[i] && screen->state[i] != state->hw[i])
     				state->dirty |= (1ULL << i);
     		}
     
    -		screen->cur_ctx = nv30;
    +		screen->cur_ctx = nvfx;
     	}
     
     	for (i = 0, states = state->dirty; states; i++) {
     		if (!(states & (1ULL << i)))
     			continue;
    -		so_ref (state->hw[i], &nv30->screen->state[i]);
    +		so_ref (state->hw[i], &nvfx->screen->state[i]);
     		if (state->hw[i])
    -			so_emit(chan, nv30->screen->state[i]);
    +			so_emit(chan, nvfx->screen->state[i]);
     		states &= ~(1ULL << i);
     	}
     
    @@ -71,48 +70,48 @@ nv30_state_emit(struct nv30_context *nv30)
     void
     nv30_state_flush_notify(struct nouveau_channel *chan)
     {
    -	struct nv30_context *nv30 = chan->user_private;
    -	struct nv30_state *state = &nv30->state;
    +	struct nvfx_context *nvfx = chan->user_private;
    +	struct nvfx_state *state = &nvfx->state;
     	unsigned i, samplers;
     
    -	so_emit_reloc_markers(chan, state->hw[NV30_STATE_FB]);
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
     	for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
     		if (!(samplers & (1 << i)))
     			continue;
     		so_emit_reloc_markers(chan,
    -				      state->hw[NV30_STATE_FRAGTEX0+i]);
    +				      state->hw[NVFX_STATE_FRAGTEX0+i]);
     		samplers &= ~(1ULL << i);
     	}
    -	so_emit_reloc_markers(chan, state->hw[NV30_STATE_FRAGPROG]);
    -	if (state->hw[NV30_STATE_VTXBUF] /*&& nv30->render_mode == HW*/)
    -		so_emit_reloc_markers(chan, state->hw[NV30_STATE_VTXBUF]);
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
    +	if (state->hw[NVFX_STATE_VTXBUF] /*&& nvfx->render_mode == HW*/)
    +		so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
     }
     
     boolean
    -nv30_state_validate(struct nv30_context *nv30)
    +nv30_state_validate(struct nvfx_context *nvfx)
     {
     #if 0
    -	boolean was_sw = nv30->fallback_swtnl ? TRUE : FALSE;
    +	boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
     
    -	if (nv30->render_mode != HW) {
    +	if (nvfx->render_mode != HW) {
     		/* Don't even bother trying to go back to hw if none
     		 * of the states that caused swtnl previously have changed.
     		 */
    -		if ((nv30->fallback_swtnl & nv30->dirty)
    -				!= nv30->fallback_swtnl)
    +		if ((nvfx->fallback_swtnl & nvfx->dirty)
    +				!= nvfx->fallback_swtnl)
     			return FALSE;
     
     		/* Attempt to go to hwtnl again */
    -		nv30->pipe.flush(&nv30->pipe, 0, NULL);
    -		nv30->dirty |= (NV30_NEW_VIEWPORT |
    -				NV30_NEW_VERTPROG |
    -				NV30_NEW_ARRAYS);
    -		nv30->render_mode = HW;
    +		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    +		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    +				NVFX_NEW_VERTPROG |
    +				NVFX_NEW_ARRAYS);
    +		nvfx->render_mode = HW;
     	}
     #endif
    -	nv30_state_do_validate(nv30, render_states);
    +	nv30_state_do_validate(nvfx, render_states);
     #if 0
    -	if (nv30->fallback_swtnl || nv30->fallback_swrast)
    +	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
     		return FALSE;
     	
     	if (was_sw)
    diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c
    index 23d17c0c60..e9e215dcce 100644
    --- a/src/gallium/drivers/nv30/nv30_state_fb.c
    +++ b/src/gallium/drivers/nv30/nv30_state_fb.c
    @@ -2,11 +2,11 @@
     #include "nouveau/nouveau_util.h"
     
     static boolean
    -nv30_state_framebuffer_validate(struct nv30_context *nv30)
    +nv30_state_framebuffer_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_framebuffer_state *fb = &nv30->framebuffer;
    -	struct nouveau_channel *chan = nv30->screen->base.channel;
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    +	struct pipe_framebuffer_state *fb = &nvfx->framebuffer;
    +	struct nouveau_channel *chan = nvfx->screen->base.channel;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     	struct nv04_surface *rt[2], *zeta = NULL;
     	uint32_t rt_enable = 0, rt_format = 0;
     	int i, colour_format = 0, zeta_format = 0, depth_only = 0;
    @@ -14,7 +14,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     	unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
     	unsigned w = fb->width;
     	unsigned h = fb->height;
    -	struct nv30_miptree *nv30mt;
    +	struct nvfx_miptree *nv30mt;
     	int colour_bits = 32, zeta_bits = 32;
     
     	for (i = 0; i < fb->nr_cbufs; i++) {
    @@ -109,7 +109,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     			pitch |= (pitch << 16);
     		}
     
    -		nv30mt = (struct nv30_miptree *) rt0->base.texture;
    +		nv30mt = (struct nvfx_miptree *) rt0->base.texture;
     		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    @@ -120,7 +120,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     	}
     
     	if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
    -		nv30mt = (struct nv30_miptree *)rt[1]->base.texture;
    +		nv30mt = (struct nvfx_miptree *)rt[1]->base.texture;
     		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    @@ -131,7 +131,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     	}
     
     	if (zeta_format) {
    -		nv30mt = (struct nv30_miptree *)zeta->base.texture;
    +		nv30mt = (struct nvfx_miptree *)zeta->base.texture;
     		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
     		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
     			      chan->vram->handle, chan->gart->handle);
    @@ -159,15 +159,15 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30)
     	so_method(so, eng3d, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
     	so_data  (so, 0);
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_FB]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_FB]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_framebuffer = {
    +struct nvfx_state_entry nv30_state_framebuffer = {
     	.validate = nv30_state_framebuffer_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_FB,
    -		.hw = NV30_STATE_FB
    +		.pipe = NVFX_NEW_FB,
    +		.hw = NVFX_STATE_FB
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_rasterizer.c b/src/gallium/drivers/nv30/nv30_state_rasterizer.c
    index 6d1b60e043..1a83da5204 100644
    --- a/src/gallium/drivers/nv30/nv30_state_rasterizer.c
    +++ b/src/gallium/drivers/nv30/nv30_state_rasterizer.c
    @@ -1,17 +1,17 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_rasterizer_validate(struct nv30_context *nv30)
    +nv30_state_rasterizer_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv30->rasterizer->so,
    -	       &nv30->state.hw[NV30_STATE_RAST]);
    +	so_ref(nvfx->rasterizer->so,
    +	       &nvfx->state.hw[NVFX_STATE_RAST]);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_rasterizer = {
    +struct nvfx_state_entry nv30_state_rasterizer = {
     	.validate = nv30_state_rasterizer_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_RAST,
    -		.hw = NV30_STATE_RAST
    +		.pipe = NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_RAST
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_scissor.c b/src/gallium/drivers/nv30/nv30_state_scissor.c
    index f58bb0161e..e91680e2d1 100644
    --- a/src/gallium/drivers/nv30/nv30_state_scissor.c
    +++ b/src/gallium/drivers/nv30/nv30_state_scissor.c
    @@ -1,20 +1,20 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_scissor_validate(struct nv30_context *nv30)
    +nv30_state_scissor_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_rasterizer_state *rast = &nv30->rasterizer->pipe;
    -	struct pipe_scissor_state *s = &nv30->scissor;
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct pipe_scissor_state *s = &nvfx->scissor;
     	struct nouveau_stateobj *so;
     
    -	if (nv30->state.hw[NV30_STATE_SCISSOR] &&
    -	    (rast->scissor == 0 && nv30->state.scissor_enabled == 0))
    +	if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
    +	    (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
     		return FALSE;
    -	nv30->state.scissor_enabled = rast->scissor;
    +	nvfx->state.scissor_enabled = rast->scissor;
     
     	so = so_new(1, 2, 0);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    -	if (nv30->state.scissor_enabled) {
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    +	if (nvfx->state.scissor_enabled) {
     		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
     		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
     	} else {
    @@ -22,15 +22,15 @@ nv30_state_scissor_validate(struct nv30_context *nv30)
     		so_data  (so, 4096 << 16);
     	}
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_SCISSOR]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_scissor = {
    +struct nvfx_state_entry nv30_state_scissor = {
     	.validate = nv30_state_scissor_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_SCISSOR | NV30_NEW_RAST,
    -		.hw = NV30_STATE_SCISSOR
    +		.pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_SCISSOR
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_stipple.c b/src/gallium/drivers/nv30/nv30_state_stipple.c
    index 46a6975438..eceb0c57f9 100644
    --- a/src/gallium/drivers/nv30/nv30_state_stipple.c
    +++ b/src/gallium/drivers/nv30/nv30_state_stipple.c
    @@ -1,14 +1,14 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_stipple_validate(struct nv30_context *nv30)
    +nv30_state_stipple_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_rasterizer_state *rast = &nv30->rasterizer->pipe;
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     	struct nouveau_stateobj *so;
     
    -	if (nv30->state.hw[NV30_STATE_STIPPLE] &&
    -	   (rast->poly_stipple_enable == 0 && nv30->state.stipple_enabled == 0))
    +	if (nvfx->state.hw[NVFX_STATE_STIPPLE] &&
    +	   (rast->poly_stipple_enable == 0 && nvfx->state.stipple_enabled == 0))
     		return FALSE;
     
     	if (rast->poly_stipple_enable) {
    @@ -19,22 +19,22 @@ nv30_state_stipple_validate(struct nv30_context *nv30)
     		so_data  (so, 1);
     		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
     		for (i = 0; i < 32; i++)
    -			so_data(so, nv30->stipple[i]);
    +			so_data(so, nvfx->stipple[i]);
     	} else {
     		so = so_new(1, 1, 0);
     		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_STIPPLE]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_STIPPLE]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_stipple = {
    +struct nvfx_state_entry nv30_state_stipple = {
     	.validate = nv30_state_stipple_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_STIPPLE | NV30_NEW_RAST,
    -		.hw = NV30_STATE_STIPPLE,
    +		.pipe = NVFX_NEW_STIPPLE | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_STIPPLE,
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_viewport.c b/src/gallium/drivers/nv30/nv30_state_viewport.c
    index 66fc112f3c..2e9d5b14c7 100644
    --- a/src/gallium/drivers/nv30/nv30_state_viewport.c
    +++ b/src/gallium/drivers/nv30/nv30_state_viewport.c
    @@ -1,17 +1,17 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_viewport_validate(struct nv30_context *nv30)
    +nv30_state_viewport_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_viewport_state *vpt = &nv30->viewport;
    +	struct pipe_viewport_state *vpt = &nvfx->viewport;
     	struct nouveau_stateobj *so;
     
    -	if (nv30->state.hw[NV30_STATE_VIEWPORT] &&
    -	    !(nv30->dirty & NV30_NEW_VIEWPORT))
    +	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
    +	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
     		return FALSE;
     
     	so = so_new(3, 10, 0);
    -	so_method(so, nv30->screen->eng3d,
    +	so_method(so, nvfx->screen->eng3d,
     		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
     	so_data  (so, fui(vpt->translate[0]));
     	so_data  (so, fui(vpt->translate[1]));
    @@ -21,22 +21,22 @@ nv30_state_viewport_validate(struct nv30_context *nv30)
     	so_data  (so, fui(vpt->scale[1]));
     	so_data  (so, fui(vpt->scale[2]));
     	so_data  (so, fui(vpt->scale[3]));
    -/*	so_method(so, nv30->screen->eng3d, 0x1d78, 1);
    +/*	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     */
     	/* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */
    -	so_method(so, nv30->screen->eng3d, 0x1d78, 1);
    +	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_VIEWPORT]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_viewport = {
    +struct nvfx_state_entry nv30_state_viewport = {
     	.validate = nv30_state_viewport_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_VIEWPORT | NV30_NEW_RAST,
    -		.hw = NV30_STATE_VIEWPORT
    +		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_VIEWPORT
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c
    index b0aac8ee46..0832408edf 100644
    --- a/src/gallium/drivers/nv30/nv30_state_zsa.c
    +++ b/src/gallium/drivers/nv30/nv30_state_zsa.c
    @@ -1,41 +1,41 @@
     #include "nv30_context.h"
     
     static boolean
    -nv30_state_zsa_validate(struct nv30_context *nv30)
    +nv30_state_zsa_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv30->zsa->so,
    -	       &nv30->state.hw[NV30_STATE_ZSA]);
    +	so_ref(nvfx->zsa->so,
    +	       &nvfx->state.hw[NVFX_STATE_ZSA]);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_zsa = {
    +struct nvfx_state_entry nv30_state_zsa = {
     	.validate = nv30_state_zsa_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_ZSA,
    -		.hw = NV30_STATE_ZSA
    +		.pipe = NVFX_NEW_ZSA,
    +		.hw = NVFX_STATE_ZSA
     	}
     };
     
     static boolean
    -nv30_state_sr_validate(struct nv30_context *nv30)
    +nv30_state_sr_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *so = so_new(2, 2, 0);
    -	struct pipe_stencil_ref *sr = &nv30->stencil_ref;
    +	struct pipe_stencil_ref *sr = &nvfx->stencil_ref;
     
    -	so_method(so, nv30->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nv30->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[1]);
     
    -	so_ref(so, &nv30->state.hw[NV30_STATE_SR]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SR]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv30_state_entry nv30_state_sr = {
    +struct nvfx_state_entry nv30_state_sr = {
     	.validate = nv30_state_sr_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_SR,
    -		.hw = NV30_STATE_SR
    +		.pipe = NVFX_NEW_SR,
    +		.hw = NVFX_STATE_SR
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_surface.c b/src/gallium/drivers/nv30/nv30_surface.c
    index bc18e577ee..613a9fa492 100644
    --- a/src/gallium/drivers/nv30/nv30_surface.c
    +++ b/src/gallium/drivers/nv30/nv30_surface.c
    @@ -37,8 +37,8 @@ nv30_surface_copy(struct pipe_context *pipe,
     		  struct pipe_surface *src, unsigned srcx, unsigned srcy,
     		  unsigned width, unsigned height)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv04_surface_2d *eng2d = nv30->screen->eng2d;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
     
     	eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
     }
    @@ -48,15 +48,15 @@ nv30_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
     		  unsigned destx, unsigned desty, unsigned width,
     		  unsigned height, unsigned value)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv04_surface_2d *eng2d = nv30->screen->eng2d;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
     
     	eng2d->fill(eng2d, dest, destx, desty, width, height, value);
     }
     
     void
    -nv30_init_surface_functions(struct nv30_context *nv30)
    +nv30_init_surface_functions(struct nvfx_context *nvfx)
     {
    -	nv30->pipe.surface_copy = nv30_surface_copy;
    -	nv30->pipe.surface_fill = nv30_surface_fill;
    +	nvfx->pipe.surface_copy = nv30_surface_copy;
    +	nvfx->pipe.surface_fill = nv30_surface_fill;
     }
    diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
    index cfc109bb74..3d71df52b9 100644
    --- a/src/gallium/drivers/nv30/nv30_transfer.c
    +++ b/src/gallium/drivers/nv30/nv30_transfer.c
    @@ -6,8 +6,8 @@
     #include "util/u_math.h"
     #include "nouveau/nouveau_winsys.h"
     #include "nv30_context.h"
    -#include "nv30_screen.h"
    -#include "nv30_state.h"
    +#include "nvfx_screen.h"
    +#include "nvfx_state.h"
     
     struct nv30_transfer {
     	struct pipe_transfer base;
    @@ -39,7 +39,7 @@ nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     		  unsigned x, unsigned y, unsigned w, unsigned h)
     {
             struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv30_miptree *mt = (struct nv30_miptree *)pt;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
     	struct nv30_transfer *tx;
     	struct pipe_texture tx_tex_template, *tx_tex;
     
    @@ -81,7 +81,7 @@ nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     		return NULL;
     	}
     
    -	tx->base.stride = ((struct nv30_miptree*)tx_tex)->level[0].pitch;
    +	tx->base.stride = ((struct nvfx_miptree*)tx_tex)->level[0].pitch;
     
     	tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
     	                                       0, 0, 0,
    @@ -97,7 +97,7 @@ nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     	}
     
     	if (usage & PIPE_TRANSFER_READ) {
    -		struct nv30_screen *nvscreen = nv30_screen(pscreen);
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
     		struct pipe_surface *src;
     
     		src = pscreen->get_tex_surface(pscreen, pt,
    @@ -125,7 +125,7 @@ nv30_transfer_del(struct pipe_context *pcontext,
     
     	if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
     		struct pipe_screen *pscreen = pcontext->screen;
    -		struct nv30_screen *nvscreen = nv30_screen(pscreen);
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
     		struct pipe_surface *dst;
     
     		dst = pscreen->get_tex_surface(pscreen, ptx->texture,
    @@ -152,7 +152,7 @@ nv30_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
             struct pipe_screen *pscreen = pcontext->screen;
     	struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
     	struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
    -	struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
     	void *map = pipe_buffer_map(pscreen, mt->buffer,
     	                            pipe_transfer_buffer_flags(ptx));
     
    @@ -167,16 +167,16 @@ nv30_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
     {
             struct pipe_screen *pscreen = pcontext->screen;
     	struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
    -	struct nv30_miptree *mt = (struct nv30_miptree *)tx->surface->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
     
     	pipe_buffer_unmap(pscreen, mt->buffer);
     }
     
     void
    -nv30_init_transfer_functions(struct nv30_context *nv30)
    +nv30_init_transfer_functions(struct nvfx_context *nvfx)
     {
    -	nv30->pipe.get_tex_transfer = nv30_transfer_new;
    -	nv30->pipe.tex_transfer_destroy = nv30_transfer_del;
    -	nv30->pipe.transfer_map = nv30_transfer_map;
    -	nv30->pipe.transfer_unmap = nv30_transfer_unmap;
    +	nvfx->pipe.get_tex_transfer = nv30_transfer_new;
    +	nvfx->pipe.tex_transfer_destroy = nv30_transfer_del;
    +	nvfx->pipe.transfer_map = nv30_transfer_map;
    +	nvfx->pipe.transfer_unmap = nv30_transfer_unmap;
     }
    diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
    index c7f119e90a..119fa59890 100644
    --- a/src/gallium/drivers/nv30/nv30_vbo.c
    +++ b/src/gallium/drivers/nv30/nv30_vbo.c
    @@ -4,7 +4,7 @@
     #include "util/u_format.h"
     
     #include "nv30_context.h"
    -#include "nv30_state.h"
    +#include "nvfx_state.h"
     
     #include "nouveau/nouveau_channel.h"
     #include "nouveau/nouveau_pushbuf.h"
    @@ -69,15 +69,15 @@ nv30_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
     }
     
     static boolean
    -nv30_vbo_set_idxbuf(struct nv30_context *nv30, struct pipe_buffer *ib,
    +nv30_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
     		    unsigned ib_size)
     {
    -	struct pipe_screen *pscreen = &nv30->screen->base.base;
    +	struct pipe_screen *pscreen = &nvfx->screen->base.base;
     	unsigned type;
     
     	if (!ib) {
    -		nv30->idxbuf = NULL;
    -		nv30->idxbuf_format = 0xdeadbeef;
    +		nvfx->idxbuf = NULL;
    +		nvfx->idxbuf_format = 0xdeadbeef;
     		return FALSE;
     	}
     
    @@ -95,23 +95,23 @@ nv30_vbo_set_idxbuf(struct nv30_context *nv30, struct pipe_buffer *ib,
     		return FALSE;
     	}
     
    -	if (ib != nv30->idxbuf ||
    -	    type != nv30->idxbuf_format) {
    -		nv30->dirty |= NV30_NEW_ARRAYS;
    -		nv30->idxbuf = ib;
    -		nv30->idxbuf_format = type;
    +	if (ib != nvfx->idxbuf ||
    +	    type != nvfx->idxbuf_format) {
    +		nvfx->dirty |= NVFX_NEW_ARRAYS;
    +		nvfx->idxbuf = ib;
    +		nvfx->idxbuf_format = type;
     	}
     
     	return TRUE;
     }
     
     static boolean
    -nv30_vbo_static_attrib(struct nv30_context *nv30, struct nouveau_stateobj *so,
    +nv30_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
     		       int attrib, struct pipe_vertex_element *ve,
     		       struct pipe_vertex_buffer *vb)
     {
    -	struct pipe_screen *pscreen = nv30->pipe.screen;
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     	unsigned type, ncomp;
     	void *map;
     
    @@ -168,14 +168,14 @@ void
     nv30_draw_arrays(struct pipe_context *pipe,
     		 unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart = 0;
     
    -	nv30_vbo_set_idxbuf(nv30, NULL, 0);
    -	if (FORCE_SWTNL || !nv30_state_validate(nv30)) {
    +	nv30_vbo_set_idxbuf(nvfx, NULL, 0);
    +	if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
     		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
     						mode, start, count);*/
     		return;
    @@ -184,7 +184,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
     	while (count) {
     		unsigned vc, nr;
     
    -		nv30_state_emit(nv30);
    +		nv30_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -227,10 +227,10 @@ nv30_draw_arrays(struct pipe_context *pipe,
     }
     
     static INLINE void
    -nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
    +nv30_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -238,7 +238,7 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     		uint8_t *elts = (uint8_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nv30);
    +		nv30_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -278,10 +278,10 @@ nv30_draw_elements_u08(struct nv30_context *nv30, void *ib,
     }
     
     static INLINE void
    -nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
    +nv30_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -289,7 +289,7 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     		uint16_t *elts = (uint16_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nv30);
    +		nv30_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -329,10 +329,10 @@ nv30_draw_elements_u16(struct nv30_context *nv30, void *ib,
     }
     
     static INLINE void
    -nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
    +nv30_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -340,7 +340,7 @@ nv30_draw_elements_u32(struct nv30_context *nv30, void *ib,
     		uint32_t *elts = (uint32_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nv30);
    +		nv30_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
     					mode, start, count, &restart);
    @@ -375,7 +375,7 @@ nv30_draw_elements_inline(struct pipe_context *pipe,
     			  struct pipe_buffer *ib, unsigned ib_size,
     			  unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct pipe_screen *pscreen = pipe->screen;
     	void *map;
     
    @@ -387,13 +387,13 @@ nv30_draw_elements_inline(struct pipe_context *pipe,
     
     	switch (ib_size) {
     	case 1:
    -		nv30_draw_elements_u08(nv30, map, mode, start, count);
    +		nv30_draw_elements_u08(nvfx, map, mode, start, count);
     		break;
     	case 2:
    -		nv30_draw_elements_u16(nv30, map, mode, start, count);
    +		nv30_draw_elements_u16(nvfx, map, mode, start, count);
     		break;
     	case 4:
    -		nv30_draw_elements_u32(nv30, map, mode, start, count);
    +		nv30_draw_elements_u32(nvfx, map, mode, start, count);
     		break;
     	default:
     		NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
    @@ -407,8 +407,8 @@ static void
     nv30_draw_elements_vbo(struct pipe_context *pipe,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    -	struct nv30_screen *screen = nv30->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart = 0;
    @@ -416,7 +416,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
     	while (count) {
     		unsigned nr, vc;
     
    -		nv30_state_emit(nv30);
    +		nv30_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -461,11 +461,11 @@ nv30_draw_elements(struct pipe_context *pipe,
     		   struct pipe_buffer *indexBuffer, unsigned indexSize,
     		   unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv30_context *nv30 = nv30_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	boolean idxbuf;
     
    -	idxbuf = nv30_vbo_set_idxbuf(nv30, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nv30_state_validate(nv30)) {
    +	idxbuf = nv30_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    +	if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
     		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
     						mode, start, count);*/
     		return;
    @@ -482,33 +482,33 @@ nv30_draw_elements(struct pipe_context *pipe,
     }
     
     static boolean
    -nv30_vbo_validate(struct nv30_context *nv30)
    +nv30_vbo_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *eng3d = nv30->screen->eng3d;
    -	struct pipe_buffer *ib = nv30->idxbuf;
    -	unsigned ib_format = nv30->idxbuf_format;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct pipe_buffer *ib = nvfx->idxbuf;
    +	unsigned ib_format = nvfx->idxbuf_format;
     	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
     	int hw;
     
     	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nv30->vtxelt->num_elements);
    +	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nvfx->vtxelt->num_elements);
     	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nv30->vtxelt->num_elements);
    +	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nvfx->vtxelt->num_elements);
     
    -	for (hw = 0; hw < nv30->vtxelt->num_elements; hw++) {
    +	for (hw = 0; hw < nvfx->vtxelt->num_elements; hw++) {
     		struct pipe_vertex_element *ve;
     		struct pipe_vertex_buffer *vb;
     		unsigned type, ncomp;
     
    -		ve = &nv30->vtxelt->pipe[hw];
    -		vb = &nv30->vtxbuf[ve->vertex_buffer_index];
    +		ve = &nvfx->vtxelt->pipe[hw];
    +		vb = &nvfx->vtxbuf[ve->vertex_buffer_index];
     
     		if (!vb->stride) {
     			if (!sattr)
     				sattr = so_new(16, 16 * 4, 0);
     
    -			if (nv30_vbo_static_attrib(nv30, sattr, hw, ve, vb)) {
    +			if (nv30_vbo_static_attrib(nvfx, sattr, hw, ve, vb)) {
     				so_data(vtxbuf, 0);
     				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
     				continue;
    @@ -516,7 +516,7 @@ nv30_vbo_validate(struct nv30_context *nv30)
     		}
     
     		if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp)) {
    -			/*nv30->fallback_swtnl |= NV30_NEW_ARRAYS;*/
    +			/*nvfx->fallback_swtnl |= NVFX_NEW_ARRAYS;*/
     			so_ref(NULL, &vtxbuf);
     			so_ref(NULL, &vtxfmt);
     			return FALSE;
    @@ -541,22 +541,22 @@ nv30_vbo_validate(struct nv30_context *nv30)
     	so_method(vtxbuf, eng3d, 0x1710, 1);
     	so_data  (vtxbuf, 0);
     
    -	so_ref(vtxbuf, &nv30->state.hw[NV30_STATE_VTXBUF]);
    +	so_ref(vtxbuf, &nvfx->state.hw[NVFX_STATE_VTXBUF]);
     	so_ref(NULL, &vtxbuf);
    -	nv30->state.dirty |= (1ULL << NV30_STATE_VTXBUF);
    -	so_ref(vtxfmt, &nv30->state.hw[NV30_STATE_VTXFMT]);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXBUF);
    +	so_ref(vtxfmt, &nvfx->state.hw[NVFX_STATE_VTXFMT]);
     	so_ref(NULL, &vtxfmt);
    -	nv30->state.dirty |= (1ULL << NV30_STATE_VTXFMT);
    -	so_ref(sattr, &nv30->state.hw[NV30_STATE_VTXATTR]);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXFMT);
    +	so_ref(sattr, &nvfx->state.hw[NVFX_STATE_VTXATTR]);
     	so_ref(NULL, &sattr);
    -	nv30->state.dirty |= (1ULL << NV30_STATE_VTXATTR);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXATTR);
     	return FALSE;
     }
     
    -struct nv30_state_entry nv30_state_vbo = {
    +struct nvfx_state_entry nv30_state_vbo = {
     	.validate = nv30_vbo_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_ARRAYS,
    +		.pipe = NVFX_NEW_ARRAYS,
     		.hw = 0,
     	}
     };
    diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
    index f0cecba4c4..cf910e34b1 100644
    --- a/src/gallium/drivers/nv30/nv30_vertprog.c
    +++ b/src/gallium/drivers/nv30/nv30_vertprog.c
    @@ -8,7 +8,7 @@
     #include "tgsi/tgsi_dump.h"
     
     #include "nv30_context.h"
    -#include "nv30_state.h"
    +#include "nvfx_state.h"
     
     /* TODO (at least...):
      *  1. Indexed consts  + ARL
    @@ -40,9 +40,9 @@
     #define abs(s) nv30_sr_abs((s))
     
     struct nv30_vpc {
    -	struct nv30_vertex_program *vp;
    +	struct nvfx_vertex_program *vp;
     
    -	struct nv30_vertex_program_exec *vpi;
    +	struct nvfx_vertex_program_exec *vpi;
     
     	unsigned output_map[PIPE_MAX_SHADER_OUTPUTS];
     
    @@ -66,8 +66,8 @@ temp(struct nv30_vpc *vpc)
     static struct nv30_sreg
     constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
     {
    -	struct nv30_vertex_program *vp = vpc->vp;
    -	struct nv30_vertex_program_data *vpd;
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program_data *vpd;
     	int idx;
     
     	if (pipe >= 0) {
    @@ -95,7 +95,7 @@ constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
     static void
     emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nv30_sreg src)
     {
    -	struct nv30_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t sr = 0;
     
     	switch (src.type) {
    @@ -166,7 +166,7 @@ emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nv30_sreg src)
     static void
     emit_dst(struct nv30_vpc *vpc, uint32_t *hw, int slot, struct nv30_sreg dst)
     {
    -	struct nv30_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     
     	switch (dst.type) {
     	case NV30SR_TEMP:
    @@ -211,7 +211,7 @@ nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
     	      struct nv30_sreg s0, struct nv30_sreg s1,
     	      struct nv30_sreg s2)
     {
    -	struct nv30_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t *hw;
     
     	vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
    @@ -572,8 +572,8 @@ nv30_vertprog_prepare(struct nv30_vpc *vpc)
     }
     
     static void
    -nv30_vertprog_translate(struct nv30_context *nv30,
    -			struct nv30_vertex_program *vp)
    +nv30_vertprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_vertex_program *vp)
     {
     	struct tgsi_parse_context parse;
     	struct nv30_vpc *vpc = NULL;
    @@ -647,36 +647,36 @@ out_err:
     }
     
     static boolean
    -nv30_vertprog_validate(struct nv30_context *nv30)
    +nv30_vertprog_validate(struct nvfx_context *nvfx)
     { 
    -	struct pipe_screen *pscreen = nv30->pipe.screen;
    -	struct nv30_screen *screen = nv30->screen;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
    -	struct nv30_vertex_program *vp;
    +	struct nvfx_vertex_program *vp;
     	struct pipe_buffer *constbuf;
     	boolean upload_code = FALSE, upload_data = FALSE;
     	int i;
     
    -	vp = nv30->vertprog;
    -	constbuf = nv30->constbuf[PIPE_SHADER_VERTEX];
    +	vp = nvfx->vertprog;
    +	constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
     
     	/* Translate TGSI shader into hw bytecode */
     	if (!vp->translated) {
    -		nv30_vertprog_translate(nv30, vp);
    +		nv30_vertprog_translate(nvfx, vp);
     		if (!vp->translated)
     			return FALSE;
     	}
     
     	/* Allocate hw vtxprog exec slots */
     	if (!vp->exec) {
    -		struct nouveau_resource *heap = nv30->screen->vp_exec_heap;
    +		struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
     		struct nouveau_stateobj *so;
     		uint vplen = vp->nr_insns;
     
     		if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
     			while (heap->next && heap->size < vplen) {
    -				struct nv30_vertex_program *evict;
    +				struct nvfx_vertex_program *evict;
     				
     				evict = heap->next->priv;
     				nouveau_resource_free(&evict->exec);
    @@ -697,11 +697,11 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     
     	/* Allocate hw vtxprog const slots */
     	if (vp->nr_consts && !vp->data) {
    -		struct nouveau_resource *heap = nv30->screen->vp_data_heap;
    +		struct nouveau_resource *heap = nvfx->screen->vp_data_heap;
     
     		if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
     			while (heap->next && heap->size < vp->nr_consts) {
    -				struct nv30_vertex_program *evict;
    +				struct nvfx_vertex_program *evict;
     				
     				evict = heap->next->priv;
     				nouveau_resource_free(&evict->data);
    @@ -725,7 +725,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     	 */
     	if (vp->exec_start != vp->exec->start) {
     		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nv30_vertex_program_exec *vpi = &vp->insns[i];
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
     
     			if (vpi->has_branch_offset) {
     				assert(0);
    @@ -737,7 +737,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     
     	if (vp->nr_consts && vp->data_start != vp->data->start) {
     		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nv30_vertex_program_exec *vpi = &vp->insns[i];
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
     
     			if (vpi->const_index >= 0) {
     				vpi->data[1] &= ~NV30_VP_INST_CONST_SRC_MASK;
    @@ -761,7 +761,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     		}
     
     		for (i = 0; i < vp->nr_consts; i++) {
    -			struct nv30_vertex_program_data *vpd = &vp->consts[i];
    +			struct nvfx_vertex_program_data *vpd = &vp->consts[i];
     
     			if (vpd->index >= 0) {
     				if (!upload_data &&
    @@ -798,8 +798,8 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     		}
     	}
     
    -	if (vp->so != nv30->state.hw[NV30_STATE_VERTPROG]) {
    -		so_ref(vp->so, &nv30->state.hw[NV30_STATE_VERTPROG]);
    +	if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
    +		so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
     		return TRUE;
     	}
     
    @@ -807,7 +807,7 @@ nv30_vertprog_validate(struct nv30_context *nv30)
     }
     
     void
    -nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp)
    +nv30_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
     {
     	vp->translated = FALSE;
     
    @@ -833,10 +833,10 @@ nv30_vertprog_destroy(struct nv30_context *nv30, struct nv30_vertex_program *vp)
     	so_ref(NULL, &vp->so);
     }
     
    -struct nv30_state_entry nv30_state_vertprog = {
    +struct nvfx_state_entry nv30_state_vertprog = {
     	.validate = nv30_vertprog_validate,
     	.dirty = {
    -		.pipe = NV30_NEW_VERTPROG /*| NV30_NEW_UCP*/,
    -		.hw = NV30_STATE_VERTPROG,
    +		.pipe = NVFX_NEW_VERTPROG /*| NVFX_NEW_UCP*/,
    +		.hw = NVFX_STATE_VERTPROG,
     	}
     };
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 0ecae2b491..50e5e72b4e 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -26,4 +26,6 @@ C_SOURCES = \
     	nv40_vbo.c \
     	nv40_vertprog.c
     
    +LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    +
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nv40/nv40_clear.c b/src/gallium/drivers/nv40/nv40_clear.c
    index ddf13addf3..79de90434d 100644
    --- a/src/gallium/drivers/nv40/nv40_clear.c
    +++ b/src/gallium/drivers/nv40/nv40_clear.c
    @@ -9,6 +9,6 @@ void
     nv40_clear(struct pipe_context *pipe, unsigned buffers,
                const float *rgba, double depth, unsigned stencil)
     {
    -	util_clear(pipe, &nv40_context(pipe)->framebuffer, buffers, rgba, depth,
    +	util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
     		   stencil);
     }
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index da35676fd5..721b513438 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -2,14 +2,14 @@
     #include "pipe/p_defines.h"
     
     #include "nv40_context.h"
    -#include "nv40_screen.h"
    +#include "nvfx_screen.h"
     
     static void
     nv40_flush(struct pipe_context *pipe, unsigned flags,
     	   struct pipe_fence_handle **fence)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -28,61 +28,61 @@ nv40_flush(struct pipe_context *pipe, unsigned flags,
     static void
     nv40_destroy(struct pipe_context *pipe)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned i;
     
    -	for (i = 0; i < NV40_STATE_MAX; i++) {
    -		if (nv40->state.hw[i])
    -			so_ref(NULL, &nv40->state.hw[i]);
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
    +		if (nvfx->state.hw[i])
    +			so_ref(NULL, &nvfx->state.hw[i]);
     	}
     
    -	if (nv40->draw)
    -		draw_destroy(nv40->draw);
    -	FREE(nv40);
    +	if (nvfx->draw)
    +		draw_destroy(nvfx->draw);
    +	FREE(nvfx);
     }
     
     struct pipe_context *
     nv40_create(struct pipe_screen *pscreen, void *priv)
     {
    -	struct nv40_screen *screen = nv40_screen(pscreen);
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
     	struct pipe_winsys *ws = pscreen->winsys;
    -	struct nv40_context *nv40;
    +	struct nvfx_context *nvfx;
     	struct nouveau_winsys *nvws = screen->nvws;
     
    -	nv40 = CALLOC(1, sizeof(struct nv40_context));
    -	if (!nv40)
    +	nvfx = CALLOC(1, sizeof(struct nvfx_context));
    +	if (!nvfx)
     		return NULL;
    -	nv40->screen = screen;
    +	nvfx->screen = screen;
     
    -	nv40->nvws = nvws;
    +	nvfx->nvws = nvws;
     
    -	nv40->pipe.winsys = ws;
    -	nv40->pipe.priv = priv;
    -	nv40->pipe.screen = pscreen;
    -	nv40->pipe.destroy = nv40_destroy;
    -	nv40->pipe.draw_arrays = nv40_draw_arrays;
    -	nv40->pipe.draw_elements = nv40_draw_elements;
    -	nv40->pipe.clear = nv40_clear;
    -	nv40->pipe.flush = nv40_flush;
    +	nvfx->pipe.winsys = ws;
    +	nvfx->pipe.priv = priv;
    +	nvfx->pipe.screen = pscreen;
    +	nvfx->pipe.destroy = nv40_destroy;
    +	nvfx->pipe.draw_arrays = nv40_draw_arrays;
    +	nvfx->pipe.draw_elements = nv40_draw_elements;
    +	nvfx->pipe.clear = nv40_clear;
    +	nvfx->pipe.flush = nv40_flush;
     
    -	nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    -	nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
    +	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    +	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
     
    -	screen->base.channel->user_private = nv40;
    +	screen->base.channel->user_private = nvfx;
     	screen->base.channel->flush_notify = nv40_state_flush_notify;
     
    -	nv40_init_query_functions(nv40);
    -	nv40_init_surface_functions(nv40);
    -	nv40_init_state_functions(nv40);
    -	nv40_init_transfer_functions(nv40);
    +	nv40_init_query_functions(nvfx);
    +	nv40_init_surface_functions(nvfx);
    +	nv40_init_state_functions(nvfx);
    +	nv40_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
    -	nv40->draw = draw_create();
    -	draw_wide_point_threshold(nv40->draw, 9999999.0);
    -	draw_wide_line_threshold(nv40->draw, 9999999.0);
    -	draw_enable_line_stipple(nv40->draw, FALSE);
    -	draw_enable_point_sprites(nv40->draw, FALSE);
    -	draw_set_rasterize_stage(nv40->draw, nv40_draw_render_stage(nv40));
    -
    -	return &nv40->pipe;
    +	nvfx->draw = draw_create();
    +	draw_wide_point_threshold(nvfx->draw, 9999999.0);
    +	draw_wide_line_threshold(nvfx->draw, 9999999.0);
    +	draw_enable_line_stipple(nvfx->draw, FALSE);
    +	draw_enable_point_sprites(nvfx->draw, FALSE);
    +	draw_set_rasterize_stage(nvfx->draw, nv40_draw_render_stage(nvfx));
    +
    +	return &nvfx->pipe;
     }
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index cb5d9e2d9d..7227c4a438 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -1,229 +1,52 @@
     #ifndef __NV40_CONTEXT_H__
     #define __NV40_CONTEXT_H__
     
    -#include 
    +#include "nvfx_context.h"
     
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "pipe/p_compiler.h"
    -
    -#include "util/u_memory.h"
    -#include "util/u_math.h"
    -#include "util/u_inlines.h"
    -
    -#include "draw/draw_vertex.h"
    -
    -#include "nouveau/nouveau_winsys.h"
    -#include "nouveau/nouveau_gldefs.h"
    -#include "nouveau/nouveau_context.h"
    -#include "nouveau/nouveau_stateobj.h"
    -
    -#include "nv40_state.h"
    -
    -#define NOUVEAU_ERR(fmt, args...) \
    -	fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
    -#define NOUVEAU_MSG(fmt, args...) \
    -	fprintf(stderr, "nouveau: "fmt, ##args);
    -
    -enum nv40_state_index {
    -	NV40_STATE_FB = 0,
    -	NV40_STATE_VIEWPORT = 1,
    -	NV40_STATE_BLEND = 2,
    -	NV40_STATE_RAST = 3,
    -	NV40_STATE_ZSA = 4,
    -	NV40_STATE_BCOL = 5,
    -	NV40_STATE_CLIP = 6,
    -	NV40_STATE_SCISSOR = 7,
    -	NV40_STATE_STIPPLE = 8,
    -	NV40_STATE_FRAGPROG = 9,
    -	NV40_STATE_VERTPROG = 10,
    -	NV40_STATE_FRAGTEX0 = 11,
    -	NV40_STATE_FRAGTEX1 = 12,
    -	NV40_STATE_FRAGTEX2 = 13,
    -	NV40_STATE_FRAGTEX3 = 14,
    -	NV40_STATE_FRAGTEX4 = 15,
    -	NV40_STATE_FRAGTEX5 = 16,
    -	NV40_STATE_FRAGTEX6 = 17,
    -	NV40_STATE_FRAGTEX7 = 18,
    -	NV40_STATE_FRAGTEX8 = 19,
    -	NV40_STATE_FRAGTEX9 = 20,
    -	NV40_STATE_FRAGTEX10 = 21,
    -	NV40_STATE_FRAGTEX11 = 22,
    -	NV40_STATE_FRAGTEX12 = 23,
    -	NV40_STATE_FRAGTEX13 = 24,
    -	NV40_STATE_FRAGTEX14 = 25,
    -	NV40_STATE_FRAGTEX15 = 26,
    -	NV40_STATE_VERTTEX0 = 27,
    -	NV40_STATE_VERTTEX1 = 28,
    -	NV40_STATE_VERTTEX2 = 29,
    -	NV40_STATE_VERTTEX3 = 30,
    -	NV40_STATE_VTXBUF = 31,
    -	NV40_STATE_VTXFMT = 32,
    -	NV40_STATE_VTXATTR = 33,
    -	NV40_STATE_SR = 34,
    -	NV40_STATE_MAX = 35
    -};
    -
    -#include "nv40_screen.h"
    -
    -#define NV40_NEW_BLEND		(1 <<  0)
    -#define NV40_NEW_RAST		(1 <<  1)
    -#define NV40_NEW_ZSA		(1 <<  2)
    -#define NV40_NEW_SAMPLER	(1 <<  3)
    -#define NV40_NEW_FB		(1 <<  4)
    -#define NV40_NEW_STIPPLE	(1 <<  5)
    -#define NV40_NEW_SCISSOR	(1 <<  6)
    -#define NV40_NEW_VIEWPORT	(1 <<  7)
    -#define NV40_NEW_BCOL		(1 <<  8)
    -#define NV40_NEW_VERTPROG	(1 <<  9)
    -#define NV40_NEW_FRAGPROG	(1 << 10)
    -#define NV40_NEW_ARRAYS		(1 << 11)
    -#define NV40_NEW_UCP		(1 << 12)
    -#define NV40_NEW_SR		(1 << 13)
    -
    -struct nv40_rasterizer_state {
    -	struct pipe_rasterizer_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv40_zsa_state {
    -	struct pipe_depth_stencil_alpha_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv40_blend_state {
    -	struct pipe_blend_state pipe;
    -	struct nouveau_stateobj *so;
    -};
    -
    -
    -struct nv40_state {
    -	unsigned scissor_enabled;
    -	unsigned stipple_enabled;
    -	unsigned fp_samplers;
    -
    -	uint64_t dirty;
    -	struct nouveau_stateobj *hw[NV40_STATE_MAX];
    -};
    -
    -
    -struct nv40_vtxelt_state {
    -	struct pipe_vertex_element pipe[16];
    -	unsigned num_elements;
    -};
    -
    -struct nv40_context {
    -	struct pipe_context pipe;
    -
    -	struct nouveau_winsys *nvws;
    -	struct nv40_screen *screen;
    -
    -	struct draw_context *draw;
    -
    -	/* HW state derived from pipe states */
    -	struct nv40_state state;
    -	struct {
    -		struct nv40_vertex_program *vertprog;
    -
    -		unsigned nr_attribs;
    -		unsigned hw[PIPE_MAX_SHADER_INPUTS];
    -		unsigned draw[PIPE_MAX_SHADER_INPUTS];
    -		unsigned emit[PIPE_MAX_SHADER_INPUTS];
    -	} swtnl;
    -
    -	enum {
    -		HW, SWTNL, SWRAST
    -	} render_mode;
    -	unsigned fallback_swtnl;
    -	unsigned fallback_swrast;
    -
    -	/* Context state */
    -	unsigned dirty, draw_dirty;
    -	struct pipe_scissor_state scissor;
    -	unsigned stipple[32];
    -	struct pipe_clip_state clip;
    -	struct nv40_vertex_program *vertprog;
    -	struct nv40_fragment_program *fragprog;
    -	struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
    -	unsigned constbuf_nr[PIPE_SHADER_TYPES];
    -	struct nv40_rasterizer_state *rasterizer;
    -	struct nv40_zsa_state *zsa;
    -	struct nv40_blend_state *blend;
    -	struct pipe_blend_color blend_colour;
    -	struct pipe_stencil_ref stencil_ref;
    -	struct pipe_viewport_state viewport;
    -	struct pipe_framebuffer_state framebuffer;
    -	struct pipe_buffer *idxbuf;
    -	unsigned idxbuf_format;
    -	struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
    -	struct nv40_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
    -	unsigned nr_samplers;
    -	unsigned nr_textures;
    -	unsigned dirty_samplers;
    -	struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
    -	unsigned vtxbuf_nr;
    -	struct nv40_vtxelt_state *vtxelt;
    -};
    -
    -static INLINE struct nv40_context *
    -nv40_context(struct pipe_context *pipe)
    -{
    -	return (struct nv40_context *)pipe;
    -}
    -
    -struct nv40_state_entry {
    -	boolean (*validate)(struct nv40_context *nv40);
    -	struct {
    -		unsigned pipe;
    -		unsigned hw;
    -	} dirty;
    -};
    -
    -extern void nv40_init_state_functions(struct nv40_context *nv40);
    -extern void nv40_init_surface_functions(struct nv40_context *nv40);
    -extern void nv40_init_query_functions(struct nv40_context *nv40);
    -extern void nv40_init_transfer_functions(struct nv40_context *nv40);
    +extern void nv40_init_state_functions(struct nvfx_context *nvfx);
    +extern void nv40_init_surface_functions(struct nvfx_context *nvfx);
    +extern void nv40_init_query_functions(struct nvfx_context *nvfx);
    +extern void nv40_init_transfer_functions(struct nvfx_context *nvfx);
     
     extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
     
     /* nv40_draw.c */
    -extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
    +extern struct draw_stage *nv40_draw_render_stage(struct nvfx_context *nvfx);
     extern void nv40_draw_elements_swtnl(struct pipe_context *pipe,
     					struct pipe_buffer *idxbuf,
     					unsigned ib_size, unsigned mode,
     					unsigned start, unsigned count);
     
     /* nv40_vertprog.c */
    -extern void nv40_vertprog_destroy(struct nv40_context *,
    -				  struct nv40_vertex_program *);
    +extern void nv40_vertprog_destroy(struct nvfx_context *,
    +				  struct nvfx_vertex_program *);
     
     /* nv40_fragprog.c */
    -extern void nv40_fragprog_destroy(struct nv40_context *,
    -				  struct nv40_fragment_program *);
    +extern void nv40_fragprog_destroy(struct nvfx_context *,
    +				  struct nvfx_fragment_program *);
     
     /* nv40_fragtex.c */
    -extern void nv40_fragtex_bind(struct nv40_context *);
    +extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern boolean nv40_state_validate(struct nv40_context *nv40);
    -extern boolean nv40_state_validate_swtnl(struct nv40_context *nv40);
    -extern void nv40_state_emit(struct nv40_context *nv40);
    +extern boolean nv40_state_validate(struct nvfx_context *nvfx);
    +extern boolean nv40_state_validate_swtnl(struct nvfx_context *nvfx);
    +extern void nv40_state_emit(struct nvfx_context *nvfx);
     extern void nv40_state_flush_notify(struct nouveau_channel *chan);
    -extern struct nv40_state_entry nv40_state_rasterizer;
    -extern struct nv40_state_entry nv40_state_scissor;
    -extern struct nv40_state_entry nv40_state_stipple;
    -extern struct nv40_state_entry nv40_state_fragprog;
    -extern struct nv40_state_entry nv40_state_vertprog;
    -extern struct nv40_state_entry nv40_state_blend;
    -extern struct nv40_state_entry nv40_state_blend_colour;
    -extern struct nv40_state_entry nv40_state_zsa;
    -extern struct nv40_state_entry nv40_state_viewport;
    -extern struct nv40_state_entry nv40_state_framebuffer;
    -extern struct nv40_state_entry nv40_state_fragtex;
    -extern struct nv40_state_entry nv40_state_vbo;
    -extern struct nv40_state_entry nv40_state_vtxfmt;
    -extern struct nv40_state_entry nv40_state_sr;
    +extern struct nvfx_state_entry nv40_state_rasterizer;
    +extern struct nvfx_state_entry nv40_state_scissor;
    +extern struct nvfx_state_entry nv40_state_stipple;
    +extern struct nvfx_state_entry nv40_state_fragprog;
    +extern struct nvfx_state_entry nv40_state_vertprog;
    +extern struct nvfx_state_entry nv40_state_blend;
    +extern struct nvfx_state_entry nv40_state_blend_colour;
    +extern struct nvfx_state_entry nv40_state_zsa;
    +extern struct nvfx_state_entry nv40_state_viewport;
    +extern struct nvfx_state_entry nv40_state_framebuffer;
    +extern struct nvfx_state_entry nv40_state_fragtex;
    +extern struct nvfx_state_entry nv40_state_vbo;
    +extern struct nvfx_state_entry nv40_state_vtxfmt;
    +extern struct nvfx_state_entry nv40_state_sr;
     
     /* nv40_vbo.c */
     extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
    @@ -238,7 +61,7 @@ extern void nv40_draw_elements(struct pipe_context *pipe,
     extern void nv40_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    -/* nv40_context.c */
    +/* nvfx_context.c */
     struct pipe_context *
     nv40_create(struct pipe_screen *pscreen, void *priv);
     
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    index 05d237d1bb..cce1c64621 100644
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ b/src/gallium/drivers/nv40/nv40_draw.c
    @@ -18,7 +18,7 @@
     
     struct nv40_render_stage {
     	struct draw_stage stage;
    -	struct nv40_context *nv40;
    +	struct nvfx_context *nvfx;
     	unsigned prim;
     };
     
    @@ -29,18 +29,18 @@ nv40_render_stage(struct draw_stage *stage)
     }
     
     static INLINE void
    -nv40_render_vertex(struct nv40_context *nv40, const struct vertex_header *v)
    +nv40_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
     {
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
     
    -	for (i = 0; i < nv40->swtnl.nr_attribs; i++) {
    -		unsigned idx = nv40->swtnl.draw[i];
    -		unsigned hw = nv40->swtnl.hw[i];
    +	for (i = 0; i < nvfx->swtnl.nr_attribs; i++) {
    +		unsigned idx = nvfx->swtnl.draw[i];
    +		unsigned hw = nvfx->swtnl.hw[i];
     
    -		switch (nv40->swtnl.emit[i]) {
    +		switch (nvfx->swtnl.emit[i]) {
     		case EMIT_OMIT:
     			break;
     		case EMIT_1F:
    @@ -84,9 +84,9 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     	       unsigned mode, unsigned count)
     {
     	struct nv40_render_stage *rs = nv40_render_stage(stage);
    -	struct nv40_context *nv40 = rs->nv40;
    +	struct nvfx_context *nvfx = rs->nvfx;
     
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
    @@ -98,7 +98,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     			assert(0);
     		}
     		FIRE_RING(chan);
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     	}
     
     	/* Switch primitive modes if necessary */
    @@ -115,7 +115,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     
     	/* Emit vertex data */
     	for (i = 0; i < count; i++)
    -		nv40_render_vertex(nv40, prim->v[i]);
    +		nv40_render_vertex(nvfx, prim->v[i]);
     
     	/* If it's likely we'll need to empty the push buffer soon, finish
     	 * off the primitive now.
    @@ -149,8 +149,8 @@ static void
     nv40_render_flush(struct draw_stage *draw, unsigned flags)
     {
     	struct nv40_render_stage *rs = nv40_render_stage(draw);
    -	struct nv40_context *nv40 = rs->nv40;
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_context *nvfx = rs->nvfx;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -173,13 +173,13 @@ nv40_render_destroy(struct draw_stage *draw)
     }
     
     static INLINE void
    -emit_mov(struct nv40_vertex_program *vp,
    +emit_mov(struct nvfx_vertex_program *vp,
     	 unsigned dst, unsigned src, unsigned vor, unsigned mask)
     {
    -	struct nv40_vertex_program_exec *inst;
    +	struct nvfx_vertex_program_exec *inst;
     
     	vp->insns = realloc(vp->insns,
    -			    sizeof(struct nv40_vertex_program_exec) *
    +			    sizeof(struct nvfx_vertex_program_exec) *
     			    ++vp->nr_insns);
     	inst = &vp->insns[vp->nr_insns - 1];
     
    @@ -195,10 +195,10 @@ emit_mov(struct nv40_vertex_program *vp,
     		vp->or |= (1 << vor);
     }
     
    -static struct nv40_vertex_program *
    -create_drawvp(struct nv40_context *nv40)
    +static struct nvfx_vertex_program *
    +create_drawvp(struct nvfx_context *nvfx)
     {
    -	struct nv40_vertex_program *vp = CALLOC_STRUCT(nv40_vertex_program);
    +	struct nvfx_vertex_program *vp = CALLOC_STRUCT(nvfx_vertex_program);
     	unsigned i;
     
     	emit_mov(vp, NV40_VP_INST_DEST_POS, 0, ~0, 0xf);
    @@ -216,15 +216,15 @@ create_drawvp(struct nv40_context *nv40)
     }
     
     struct draw_stage *
    -nv40_draw_render_stage(struct nv40_context *nv40)
    +nv40_draw_render_stage(struct nvfx_context *nvfx)
     {
     	struct nv40_render_stage *render = CALLOC_STRUCT(nv40_render_stage);
     
    -	if (!nv40->swtnl.vertprog)
    -		nv40->swtnl.vertprog = create_drawvp(nv40);
    +	if (!nvfx->swtnl.vertprog)
    +		nvfx->swtnl.vertprog = create_drawvp(nvfx);
     
    -	render->nv40 = nv40;
    -	render->stage.draw = nv40->draw;
    +	render->nvfx = nvfx;
    +	render->stage.draw = nvfx->draw;
     	render->stage.point = nv40_render_point;
     	render->stage.line = nv40_render_line;
     	render->stage.tri = nv40_render_tri;
    @@ -240,71 +240,71 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
     			 struct pipe_buffer *idxbuf, unsigned idxbuf_size,
     			 unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct pipe_screen *pscreen = pipe->screen;
     	unsigned i;
     	void *map;
     
    -	if (!nv40_state_validate_swtnl(nv40))
    +	if (!nv40_state_validate_swtnl(nvfx))
     		return;
    -	nv40->state.dirty &= ~(1ULL << NV40_STATE_VTXBUF);
    -	nv40_state_emit(nv40);
    +	nvfx->state.dirty &= ~(1ULL << NVFX_STATE_VTXBUF);
    +	nv40_state_emit(nvfx);
     
    -	for (i = 0; i < nv40->vtxbuf_nr; i++) {
    -		map = pipe_buffer_map(pscreen, nv40->vtxbuf[i].buffer,
    +	for (i = 0; i < nvfx->vtxbuf_nr; i++) {
    +		map = pipe_buffer_map(pscreen, nvfx->vtxbuf[i].buffer,
                                           PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_vertex_buffer(nv40->draw, i, map);
    +		draw_set_mapped_vertex_buffer(nvfx->draw, i, map);
     	}
     
     	if (idxbuf) {
     		map = pipe_buffer_map(pscreen, idxbuf,
     				      PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_element_buffer(nv40->draw, idxbuf_size, map);
    +		draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map);
     	} else {
    -		draw_set_mapped_element_buffer(nv40->draw, 0, NULL);
    +		draw_set_mapped_element_buffer(nvfx->draw, 0, NULL);
     	}
     
    -	if (nv40->constbuf[PIPE_SHADER_VERTEX]) {
    -		const unsigned nr = nv40->constbuf_nr[PIPE_SHADER_VERTEX];
    +	if (nvfx->constbuf[PIPE_SHADER_VERTEX]) {
    +		const unsigned nr = nvfx->constbuf_nr[PIPE_SHADER_VERTEX];
     
     		map = pipe_buffer_map(pscreen,
    -				      nv40->constbuf[PIPE_SHADER_VERTEX],
    +				      nvfx->constbuf[PIPE_SHADER_VERTEX],
     				      PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_constant_buffer(nv40->draw, PIPE_SHADER_VERTEX, 0,
    +		draw_set_mapped_constant_buffer(nvfx->draw, PIPE_SHADER_VERTEX, 0,
                                                     map, nr);
     	}
     
    -	draw_arrays(nv40->draw, mode, start, count);
    +	draw_arrays(nvfx->draw, mode, start, count);
     
    -	for (i = 0; i < nv40->vtxbuf_nr; i++)
    -		pipe_buffer_unmap(pscreen, nv40->vtxbuf[i].buffer);
    +	for (i = 0; i < nvfx->vtxbuf_nr; i++)
    +		pipe_buffer_unmap(pscreen, nvfx->vtxbuf[i].buffer);
     
     	if (idxbuf)
     		pipe_buffer_unmap(pscreen, idxbuf);
     
    -	if (nv40->constbuf[PIPE_SHADER_VERTEX])
    -		pipe_buffer_unmap(pscreen, nv40->constbuf[PIPE_SHADER_VERTEX]);
    +	if (nvfx->constbuf[PIPE_SHADER_VERTEX])
    +		pipe_buffer_unmap(pscreen, nvfx->constbuf[PIPE_SHADER_VERTEX]);
     
    -	draw_flush(nv40->draw);
    +	draw_flush(nvfx->draw);
     	pipe->flush(pipe, 0, NULL);
     }
     
     static INLINE void
    -emit_attrib(struct nv40_context *nv40, unsigned hw, unsigned emit,
    +emit_attrib(struct nvfx_context *nvfx, unsigned hw, unsigned emit,
     	    unsigned semantic, unsigned index)
     {
    -	unsigned draw_out = draw_find_shader_output(nv40->draw, semantic, index);
    -	unsigned a = nv40->swtnl.nr_attribs++;
    +	unsigned draw_out = draw_find_shader_output(nvfx->draw, semantic, index);
    +	unsigned a = nvfx->swtnl.nr_attribs++;
     
    -	nv40->swtnl.hw[a] = hw;
    -	nv40->swtnl.emit[a] = emit;
    -	nv40->swtnl.draw[a] = draw_out;
    +	nvfx->swtnl.hw[a] = hw;
    +	nvfx->swtnl.emit[a] = emit;
    +	nvfx->swtnl.draw[a] = draw_out;
     }
     
     static boolean
    -nv40_state_vtxfmt_validate(struct nv40_context *nv40)
    +nv40_state_vtxfmt_validate(struct nvfx_context *nvfx)
     {
    -	struct nv40_fragment_program *fp = nv40->fragprog;
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
     	unsigned colour = 0, texcoords = 0, fog = 0, i;
     
     	/* Determine needed fragprog inputs */
    @@ -326,34 +326,34 @@ nv40_state_vtxfmt_validate(struct nv40_context *nv40)
     		}
     	}
     
    -	nv40->swtnl.nr_attribs = 0;
    +	nvfx->swtnl.nr_attribs = 0;
     
     	/* Map draw vtxprog output to hw attribute IDs */
     	for (i = 0; i < 2; i++) {
     		if (!(colour & (1 << i)))
     			continue;
    -		emit_attrib(nv40, 3 + i, EMIT_4UB, TGSI_SEMANTIC_COLOR, i);
    +		emit_attrib(nvfx, 3 + i, EMIT_4UB, TGSI_SEMANTIC_COLOR, i);
     	}
     
     	for (i = 0; i < 8; i++) {
     		if (!(texcoords & (1 << i)))
     			continue;
    -		emit_attrib(nv40, 8 + i, EMIT_4F, TGSI_SEMANTIC_GENERIC, i);
    +		emit_attrib(nvfx, 8 + i, EMIT_4F, TGSI_SEMANTIC_GENERIC, i);
     	}
     
     	if (fog) {
    -		emit_attrib(nv40, 5, EMIT_1F, TGSI_SEMANTIC_FOG, 0);
    +		emit_attrib(nvfx, 5, EMIT_1F, TGSI_SEMANTIC_FOG, 0);
     	}
     
    -	emit_attrib(nv40, 0, EMIT_3F, TGSI_SEMANTIC_POSITION, 0);
    +	emit_attrib(nvfx, 0, EMIT_3F, TGSI_SEMANTIC_POSITION, 0);
     
     	return FALSE;
     }
     
    -struct nv40_state_entry nv40_state_vtxfmt = {
    +struct nvfx_state_entry nv40_state_vtxfmt = {
     	.validate = nv40_state_vtxfmt_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_ARRAYS | NV40_NEW_FRAGPROG,
    +		.pipe = NVFX_NEW_ARRAYS | NVFX_NEW_FRAGPROG,
     		.hw = 0
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
    index 3d08828bea..2a0ab0cf31 100644
    --- a/src/gallium/drivers/nv40/nv40_fragprog.c
    +++ b/src/gallium/drivers/nv40/nv40_fragprog.c
    @@ -30,7 +30,7 @@
     #define MAX_CONSTS 128
     #define MAX_IMM 32
     struct nv40_fpc {
    -	struct nv40_fragment_program *fp;
    +	struct nvfx_fragment_program *fp;
     
     	uint attrib_map[PIPE_MAX_SHADER_INPUTS];
     
    @@ -102,7 +102,7 @@ constant(struct nv40_fpc *fpc, int pipe, float vals[4])
     static void
     grow_insns(struct nv40_fpc *fpc, int size)
     {
    -	struct nv40_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     
     	fp->insn_len += size;
     	fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);
    @@ -111,7 +111,7 @@ grow_insns(struct nv40_fpc *fpc, int size)
     static void
     emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
     {
    -	struct nv40_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     	uint32_t sr = 0;
     
    @@ -135,7 +135,7 @@ emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
     
     		hw = &fp->insn[fpc->inst_offset];
     		if (fpc->consts[src.index].pipe >= 0) {
    -			struct nv40_fragment_program_data *fpd;
    +			struct nvfx_fragment_program_data *fpd;
     
     			fp->consts = realloc(fp->consts, ++fp->nr_consts *
     					     sizeof(*fpd));
    @@ -175,7 +175,7 @@ emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
     static void
     emit_dst(struct nv40_fpc *fpc, struct nv40_sreg dst)
     {
    -	struct nv40_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     
     	switch (dst.type) {
    @@ -205,7 +205,7 @@ nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
     	      struct nv40_sreg dst, int mask,
     	      struct nv40_sreg s0, struct nv40_sreg s1, struct nv40_sreg s2)
     {
    -	struct nv40_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw;
     
     	fpc->inst_offset = fp->insn_len;
    @@ -242,7 +242,7 @@ nv40_fp_tex(struct nv40_fpc *fpc, int sat, int op, int unit,
     	    struct nv40_sreg dst, int mask,
     	    struct nv40_sreg s0, struct nv40_sreg s1, struct nv40_sreg s2)
     {
    -	struct nv40_fragment_program *fp = fpc->fp;
    +	struct nvfx_fragment_program *fp = fpc->fp;
     
     	nv40_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
     
    @@ -803,8 +803,8 @@ out_err:
     }
     
     static void
    -nv40_fragprog_translate(struct nv40_context *nv40,
    -			struct nv40_fragment_program *fp)
    +nv40_fragprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_fragment_program *fp)
     {
     	struct tgsi_parse_context parse;
     	struct nv40_fpc *fpc = NULL;
    @@ -862,10 +862,10 @@ out_err:
     }
     
     static void
    -nv40_fragprog_upload(struct nv40_context *nv40,
    -		     struct nv40_fragment_program *fp)
    +nv40_fragprog_upload(struct nvfx_context *nvfx,
    +		     struct nvfx_fragment_program *fp)
     {
    -	struct pipe_screen *pscreen = nv40->pipe.screen;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
     	const uint32_t le = 1;
     	uint32_t *map;
     	int i;
    @@ -896,12 +896,12 @@ nv40_fragprog_upload(struct nv40_context *nv40,
     }
     
     static boolean
    -nv40_fragprog_validate(struct nv40_context *nv40)
    +nv40_fragprog_validate(struct nvfx_context *nvfx)
     {
    -	struct nv40_fragment_program *fp = nv40->fragprog;
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
     	struct pipe_buffer *constbuf =
    -		nv40->constbuf[PIPE_SHADER_FRAGMENT];
    -	struct pipe_screen *pscreen = nv40->pipe.screen;
    +		nvfx->constbuf[PIPE_SHADER_FRAGMENT];
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
     	struct nouveau_stateobj *so;
     	boolean new_consts = FALSE;
     	int i;
    @@ -909,23 +909,23 @@ nv40_fragprog_validate(struct nv40_context *nv40)
     	if (fp->translated)
     		goto update_constants;
     
    -	nv40->fallback_swrast &= ~NV40_NEW_FRAGPROG;
    -	nv40_fragprog_translate(nv40, fp);
    +	nvfx->fallback_swrast &= ~NVFX_NEW_FRAGPROG;
    +	nv40_fragprog_translate(nvfx, fp);
     	if (!fp->translated) {
    -		nv40->fallback_swrast |= NV40_NEW_FRAGPROG;
    +		nvfx->fallback_swrast |= NVFX_NEW_FRAGPROG;
     		return FALSE;
     	}
     
     	fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
    -	nv40_fragprog_upload(nv40, fp);
    +	nv40_fragprog_upload(nvfx, fp);
     
     	so = so_new(2, 2, 1);
    -	so_method(so, nv40->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
     	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
     		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
     		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
     		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nv40->screen->eng3d, NV34TCL_FP_CONTROL, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_CONTROL, 1);
     	so_data  (so, fp->fp_control);
     	so_ref(so, &fp->so);
     	so_ref(NULL, &so);
    @@ -937,7 +937,7 @@ update_constants:
     		map = pipe_buffer_map(pscreen, constbuf,
     				      PIPE_BUFFER_USAGE_CPU_READ);
     		for (i = 0; i < fp->nr_consts; i++) {
    -			struct nv40_fragment_program_data *fpd = &fp->consts[i];
    +			struct nvfx_fragment_program_data *fpd = &fp->consts[i];
     			uint32_t *p = &fp->insn[fpd->offset];
     			uint32_t *cb = (uint32_t *)&map[fpd->index * 4];
     
    @@ -949,11 +949,11 @@ update_constants:
     		pipe_buffer_unmap(pscreen, constbuf);
     
     		if (new_consts)
    -			nv40_fragprog_upload(nv40, fp);
    +			nv40_fragprog_upload(nvfx, fp);
     	}
     
    -	if (new_consts || fp->so != nv40->state.hw[NV40_STATE_FRAGPROG]) {
    -		so_ref(fp->so, &nv40->state.hw[NV40_STATE_FRAGPROG]);
    +	if (new_consts || fp->so != nvfx->state.hw[NVFX_STATE_FRAGPROG]) {
    +		so_ref(fp->so, &nvfx->state.hw[NVFX_STATE_FRAGPROG]);
     		return TRUE;
     	}
     
    @@ -961,8 +961,8 @@ update_constants:
     }
     
     void
    -nv40_fragprog_destroy(struct nv40_context *nv40,
    -		      struct nv40_fragment_program *fp)
    +nv40_fragprog_destroy(struct nvfx_context *nvfx,
    +		      struct nvfx_fragment_program *fp)
     {
     	if (fp->buffer)
     		pipe_buffer_reference(&fp->buffer, NULL);
    @@ -974,11 +974,11 @@ nv40_fragprog_destroy(struct nv40_context *nv40,
     		FREE(fp->insn);
     }
     
    -struct nv40_state_entry nv40_state_fragprog = {
    +struct nvfx_state_entry nv40_state_fragprog = {
     	.validate = nv40_fragprog_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_FRAGPROG,
    -		.hw = NV40_STATE_FRAGPROG
    +		.pipe = NVFX_NEW_FRAGPROG,
    +		.hw = NVFX_STATE_FRAGPROG
     	}
     };
     
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index 4c26f3cb12..0b46a5313b 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -61,10 +61,10 @@ nv40_fragtex_format(uint pipe_format)
     
     
     static struct nouveau_stateobj *
    -nv40_fragtex_build(struct nv40_context *nv40, int unit)
    +nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
     {
    -	struct nv40_sampler_state *ps = nv40->tex_sampler[unit];
    -	struct nv40_miptree *nv40mt = nv40->tex_miptree[unit];
    +	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    +	struct nvfx_miptree *nv40mt = nvfx->tex_miptree[unit];
     	struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
     	struct pipe_texture *pt = &nv40mt->base;
     	struct nv40_texture_format *tf;
    @@ -111,7 +111,7 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	txs = tf->swizzle;
     
     	so = so_new(2, 9, 2);
    -	so_method(so, nv40->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
     	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
     	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
     		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    @@ -122,17 +122,17 @@ nv40_fragtex_build(struct nv40_context *nv40, int unit)
     	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
     		       pt->height0);
     	so_data  (so, ps->bcol);
    -	so_method(so, nv40->screen->eng3d, NV40TCL_TEX_SIZE1(unit), 1);
    +	so_method(so, nvfx->screen->eng3d, NV40TCL_TEX_SIZE1(unit), 1);
     	so_data  (so, (pt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
     
     	return so;
     }
     
     static boolean
    -nv40_fragtex_validate(struct nv40_context *nv40)
    +nv40_fragtex_validate(struct nvfx_context *nvfx)
     {
    -	struct nv40_fragment_program *fp = nv40->fragprog;
    -	struct nv40_state *state = &nv40->state;
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
    +	struct nvfx_state *state = &nvfx->state;
     	struct nouveau_stateobj *so;
     	unsigned samplers, unit;
     
    @@ -142,31 +142,31 @@ nv40_fragtex_validate(struct nv40_context *nv40)
     		samplers &= ~(1 << unit);
     
     		so = so_new(1, 1, 0);
    -		so_method(so, nv40->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
    +		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
     		so_data  (so, 0);
    -		so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
    -		state->dirty |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
     	}
     
    -	samplers = nv40->dirty_samplers & fp->samplers;
    +	samplers = nvfx->dirty_samplers & fp->samplers;
     	while (samplers) {
     		unit = ffs(samplers) - 1;
     		samplers &= ~(1 << unit);
     
    -		so = nv40_fragtex_build(nv40, unit);
    -		so_ref(so, &nv40->state.hw[NV40_STATE_FRAGTEX0 + unit]);
    +		so = nv40_fragtex_build(nvfx, unit);
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
     		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NV40_STATE_FRAGTEX0 + unit));
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
     	}
     
    -	nv40->state.fp_samplers = fp->samplers;
    +	nvfx->state.fp_samplers = fp->samplers;
     	return FALSE;
     }
     
    -struct nv40_state_entry nv40_state_fragtex = {
    +struct nvfx_state_entry nv40_state_fragtex = {
     	.validate = nv40_fragtex_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_SAMPLER | NV40_NEW_FRAGPROG,
    +		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
     		.hw = 0
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
    index 62e97bcea4..caec47058f 100644
    --- a/src/gallium/drivers/nv40/nv40_miptree.c
    +++ b/src/gallium/drivers/nv40/nv40_miptree.c
    @@ -10,7 +10,7 @@
     
     
     static void
    -nv40_miptree_layout(struct nv40_miptree *mt)
    +nv40_miptree_layout(struct nvfx_miptree *mt)
     {
     	struct pipe_texture *pt = &mt->base;
     	uint width = pt->width0;
    @@ -64,11 +64,11 @@ nv40_miptree_layout(struct nv40_miptree *mt)
     static struct pipe_texture *
     nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
     {
    -	struct nv40_miptree *mt;
    +	struct nvfx_miptree *mt;
     	unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
     	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
     
    -	mt = MALLOC(sizeof(struct nv40_miptree));
    +	mt = MALLOC(sizeof(struct nvfx_miptree));
     	if (!mt)
     		return NULL;
     	mt->base = *pt;
    @@ -127,14 +127,14 @@ static struct pipe_texture *
     nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
     		     const unsigned *stride, struct pipe_buffer *pb)
     {
    -	struct nv40_miptree *mt;
    +	struct nvfx_miptree *mt;
     
     	/* Only supports 2D, non-mipmapped textures for the moment */
     	if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
     	    pt->depth0 != 1)
     		return NULL;
     
    -	mt = CALLOC_STRUCT(nv40_miptree);
    +	mt = CALLOC_STRUCT(nvfx_miptree);
     	if (!mt)
     		return NULL;
     
    @@ -155,7 +155,7 @@ nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
     static void
     nv40_miptree_destroy(struct pipe_texture *pt)
     {
    -	struct nv40_miptree *mt = (struct nv40_miptree *)pt;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
     	int l;
     
     	pipe_buffer_reference(&mt->buffer, NULL);
    @@ -172,7 +172,7 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
     			 unsigned face, unsigned level, unsigned zslice,
     			 unsigned flags)
     {
    -	struct nv40_miptree *mt = (struct nv40_miptree *)pt;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
     	struct nv04_surface *ns;
     
     	ns = CALLOC_STRUCT(nv04_surface);
    @@ -202,7 +202,7 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
     	 * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
     	 * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
     	if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
    -		return &nv04_surface_wrap_for_render(pscreen, ((struct nv40_screen*)pscreen)->eng2d, ns)->base;
    +		return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
     
     	return &ns->base;
     }
    @@ -213,7 +213,7 @@ nv40_miptree_surface_del(struct pipe_surface *ps)
     	struct nv04_surface* ns = (struct nv04_surface*)ps;
     	if(ns->backing)
     	{
    -		struct nv40_screen* screen = (struct nv40_screen*)ps->texture->screen;
    +		struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
     		if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
     			screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
     		nv40_miptree_surface_del(&ns->backing->base);
    diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c
    index 899a8dc0b2..48cfc4d593 100644
    --- a/src/gallium/drivers/nv40/nv40_query.c
    +++ b/src/gallium/drivers/nv40/nv40_query.c
    @@ -39,9 +39,9 @@ nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
     static void
     nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nv40_query *q = nv40_query(pq);
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -56,9 +56,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     		pipe->get_query_result(pipe, pq, 1, &tmp);
     	}
     
    -	if (nouveau_resource_alloc(nv40->screen->query_heap, 1, NULL, &q->object))
    +	if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
     		assert(0);
    -	nouveau_notifier_reset(nv40->screen->query, q->object->start);
    +	nouveau_notifier_reset(nvfx->screen->query, q->object->start);
     
     	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
     	OUT_RING  (chan, 1);
    @@ -71,9 +71,9 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
     static void
     nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nv40_query *q = nv40_query(pq);
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -87,7 +87,7 @@ static boolean
     nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     		  boolean wait, uint64_t *result)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nv40_query *q = nv40_query(pq);
     
     	assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    @@ -95,18 +95,18 @@ nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     	if (!q->ready) {
     		unsigned status;
     
    -		status = nouveau_notifier_status(nv40->screen->query,
    +		status = nouveau_notifier_status(nvfx->screen->query,
     						 q->object->start);
     		if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
     			if (wait == FALSE)
     				return FALSE;
    -			nouveau_notifier_wait_status(nv40->screen->query,
    +			nouveau_notifier_wait_status(nvfx->screen->query,
     					      q->object->start,
     					      NV_NOTIFY_STATE_STATUS_COMPLETED,
     					      0);
     		}
     
    -		q->result = nouveau_notifier_return_val(nv40->screen->query,
    +		q->result = nouveau_notifier_return_val(nvfx->screen->query,
     							q->object->start);
     		q->ready = TRUE;
     		nouveau_resource_free(&q->object);
    @@ -117,11 +117,11 @@ nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
     }
     
     void
    -nv40_init_query_functions(struct nv40_context *nv40)
    +nv40_init_query_functions(struct nvfx_context *nvfx)
     {
    -	nv40->pipe.create_query = nv40_query_create;
    -	nv40->pipe.destroy_query = nv40_query_destroy;
    -	nv40->pipe.begin_query = nv40_query_begin;
    -	nv40->pipe.end_query = nv40_query_end;
    -	nv40->pipe.get_query_result = nv40_query_result;
    +	nvfx->pipe.create_query = nv40_query_create;
    +	nvfx->pipe.destroy_query = nv40_query_destroy;
    +	nvfx->pipe.begin_query = nv40_query_begin;
    +	nvfx->pipe.end_query = nv40_query_end;
    +	nvfx->pipe.get_query_result = nv40_query_result;
     }
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    index 3c901c1c53..0fc8e18750 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ b/src/gallium/drivers/nv40/nv40_screen.c
    @@ -1,7 +1,7 @@
     #include "pipe/p_screen.h"
     
     #include "nv40_context.h"
    -#include "nv40_screen.h"
    +#include "nvfx_screen.h"
     
     #define NV4X_GRCLASS4097_CHIPSETS 0x00000baf
     #define NV4X_GRCLASS4497_CHIPSETS 0x00005450
    @@ -10,7 +10,7 @@
     static int
     nv40_screen_get_param(struct pipe_screen *pscreen, int param)
     {
    -	struct nv40_screen *screen = nv40_screen(pscreen);
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
     
     	switch (param) {
     	case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
    @@ -143,7 +143,7 @@ nv40_screen_surface_format_supported(struct pipe_screen *pscreen,
     static struct pipe_buffer *
     nv40_surface_buffer(struct pipe_surface *surf)
     {
    -	struct nv40_miptree *mt = (struct nv40_miptree *)surf->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
     
     	return mt->buffer;
     }
    @@ -151,10 +151,10 @@ nv40_surface_buffer(struct pipe_surface *surf)
     static void
     nv40_screen_destroy(struct pipe_screen *pscreen)
     {
    -	struct nv40_screen *screen = nv40_screen(pscreen);
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
     	unsigned i;
     
    -	for (i = 0; i < NV40_STATE_MAX; i++) {
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
     		if (screen->state[i])
     			so_ref(NULL, &screen->state[i]);
     	}
    @@ -175,7 +175,7 @@ nv40_screen_destroy(struct pipe_screen *pscreen)
     struct pipe_screen *
     nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     {
    -	struct nv40_screen *screen = CALLOC_STRUCT(nv40_screen);
    +	struct nvfx_screen *screen = CALLOC_STRUCT(nvfx_screen);
     	struct nouveau_channel *chan;
     	struct pipe_screen *pscreen;
     	struct nouveau_stateobj *so;
    diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
    deleted file mode 100644
    index ad0ee63da6..0000000000
    --- a/src/gallium/drivers/nv40/nv40_screen.h
    +++ /dev/null
    @@ -1,37 +0,0 @@
    -#ifndef __NV40_SCREEN_H__
    -#define __NV40_SCREEN_H__
    -
    -#include "nouveau/nouveau_screen.h"
    -#include "nouveau/nv04_surface_2d.h"
    -
    -struct nv40_screen {
    -	struct nouveau_screen base;
    -
    -	struct nouveau_winsys *nvws;
    -
    -	struct nv40_context *cur_ctx;
    -
    -	/* HW graphics objects */
    -	struct nv04_surface_2d *eng2d;
    -	struct nouveau_grobj *eng3d;
    -	struct nouveau_notifier *sync;
    -
    -	/* Query object resources */
    -	struct nouveau_notifier *query;
    -	struct nouveau_resource *query_heap;
    -
    -	/* Vtxprog resources */
    -	struct nouveau_resource *vp_exec_heap;
    -	struct nouveau_resource *vp_data_heap;
    -
    -	/* Current 3D state of channel */
    -	struct nouveau_stateobj *state[NV40_STATE_MAX];
    -};
    -
    -static INLINE struct nv40_screen *
    -nv40_screen(struct pipe_screen *screen)
    -{
    -	return (struct nv40_screen *)screen;
    -}
    -
    -#endif
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    index e8076e059b..a205342ac5 100644
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ b/src/gallium/drivers/nv40/nv40_state.c
    @@ -7,15 +7,15 @@
     #include "tgsi/tgsi_parse.h"
     
     #include "nv40_context.h"
    -#include "nv40_state.h"
    +#include "nvfx_state.h"
     
     static void *
     nv40_blend_state_create(struct pipe_context *pipe,
     			const struct pipe_blend_state *cso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    -	struct nv40_blend_state *bso = CALLOC(1, sizeof(*bso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
     	struct nouveau_stateobj *so = so_new(5, 8, 0);
     
     	if (cso->rt[0].blend_enable) {
    @@ -60,16 +60,16 @@ nv40_blend_state_create(struct pipe_context *pipe,
     static void
     nv40_blend_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->blend = hwcso;
    -	nv40->dirty |= NV40_NEW_BLEND;
    +	nvfx->blend = hwcso;
    +	nvfx->dirty |= NVFX_NEW_BLEND;
     }
     
     static void
     nv40_blend_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_blend_state *bso = hwcso;
    +	struct nvfx_blend_state *bso = hwcso;
     
     	so_ref(NULL, &bso->so);
     	FREE(bso);
    @@ -118,10 +118,10 @@ static void *
     nv40_sampler_state_create(struct pipe_context *pipe,
     			  const struct pipe_sampler_state *cso)
     {
    -	struct nv40_sampler_state *ps;
    +	struct nvfx_sampler_state *ps;
     	uint32_t filter = 0;
     
    -	ps = MALLOC(sizeof(struct nv40_sampler_state));
    +	ps = MALLOC(sizeof(struct nvfx_sampler_state));
     
     	ps->fmt = 0;
     	if (!cso->normalized_coords)
    @@ -258,21 +258,21 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     static void
     nv40_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned unit;
     
     	for (unit = 0; unit < nr; unit++) {
    -		nv40->tex_sampler[unit] = sampler[unit];
    -		nv40->dirty_samplers |= (1 << unit);
    +		nvfx->tex_sampler[unit] = sampler[unit];
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	for (unit = nr; unit < nv40->nr_samplers; unit++) {
    -		nv40->tex_sampler[unit] = NULL;
    -		nv40->dirty_samplers |= (1 << unit);
    +	for (unit = nr; unit < nvfx->nr_samplers; unit++) {
    +		nvfx->tex_sampler[unit] = NULL;
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	nv40->nr_samplers = nr;
    -	nv40->dirty |= NV40_NEW_SAMPLER;
    +	nvfx->nr_samplers = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
     }
     
     static void
    @@ -285,33 +285,33 @@ static void
     nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
     			 struct pipe_texture **miptree)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned unit;
     
     	for (unit = 0; unit < nr; unit++) {
     		pipe_texture_reference((struct pipe_texture **)
    -				       &nv40->tex_miptree[unit], miptree[unit]);
    -		nv40->dirty_samplers |= (1 << unit);
    +				       &nvfx->tex_miptree[unit], miptree[unit]);
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	for (unit = nr; unit < nv40->nr_textures; unit++) {
    +	for (unit = nr; unit < nvfx->nr_textures; unit++) {
     		pipe_texture_reference((struct pipe_texture **)
    -				       &nv40->tex_miptree[unit], NULL);
    -		nv40->dirty_samplers |= (1 << unit);
    +				       &nvfx->tex_miptree[unit], NULL);
    +		nvfx->dirty_samplers |= (1 << unit);
     	}
     
    -	nv40->nr_textures = nr;
    -	nv40->dirty |= NV40_NEW_SAMPLER;
    +	nvfx->nr_textures = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
     }
     
     static void *
     nv40_rasterizer_state_create(struct pipe_context *pipe,
     			     const struct pipe_rasterizer_state *cso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
     	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     
     	/*XXX: ignored:
     	 * 	light_twoside
    @@ -423,17 +423,17 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
     static void
     nv40_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->rasterizer = hwcso;
    -	nv40->dirty |= NV40_NEW_RAST;
    -	nv40->draw_dirty |= NV40_NEW_RAST;
    +	nvfx->rasterizer = hwcso;
    +	nvfx->dirty |= NVFX_NEW_RAST;
    +	nvfx->draw_dirty |= NVFX_NEW_RAST;
     }
     
     static void
     nv40_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_rasterizer_state *rsso = hwcso;
    +	struct nvfx_rasterizer_state *rsso = hwcso;
     
     	so_ref(NULL, &rsso->so);
     	FREE(rsso);
    @@ -443,10 +443,10 @@ static void *
     nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     			const struct pipe_depth_stencil_alpha_state *cso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
     	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     
     	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
     	so_data  (so, nvgl_comparison_op(cso->depth.func));
    @@ -497,16 +497,16 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
     static void
     nv40_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->zsa = hwcso;
    -	nv40->dirty |= NV40_NEW_ZSA;
    +	nvfx->zsa = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ZSA;
     }
     
     static void
     nv40_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_zsa_state *zsaso = hwcso;
    +	struct nvfx_zsa_state *zsaso = hwcso;
     
     	so_ref(NULL, &zsaso->so);
     	FREE(zsaso);
    @@ -516,12 +516,12 @@ static void *
     nv40_vp_state_create(struct pipe_context *pipe,
     		     const struct pipe_shader_state *cso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_vertex_program *vp;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_vertex_program *vp;
     
    -	vp = CALLOC(1, sizeof(struct nv40_vertex_program));
    +	vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
     	vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -	vp->draw = draw_create_vertex_shader(nv40->draw, &vp->pipe);
    +	vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);
     
     	return (void *)vp;
     }
    @@ -529,21 +529,21 @@ nv40_vp_state_create(struct pipe_context *pipe,
     static void
     nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->vertprog = hwcso;
    -	nv40->dirty |= NV40_NEW_VERTPROG;
    -	nv40->draw_dirty |= NV40_NEW_VERTPROG;
    +	nvfx->vertprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_VERTPROG;
    +	nvfx->draw_dirty |= NVFX_NEW_VERTPROG;
     }
     
     static void
     nv40_vp_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_vertex_program *vp = hwcso;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_vertex_program *vp = hwcso;
     
    -	draw_delete_vertex_shader(nv40->draw, vp->draw);
    -	nv40_vertprog_destroy(nv40, vp);
    +	draw_delete_vertex_shader(nvfx->draw, vp->draw);
    +	nv40_vertprog_destroy(nvfx, vp);
     	FREE((void*)vp->pipe.tokens);
     	FREE(vp);
     }
    @@ -552,9 +552,9 @@ static void *
     nv40_fp_state_create(struct pipe_context *pipe,
     		     const struct pipe_shader_state *cso)
     {
    -	struct nv40_fragment_program *fp;
    +	struct nvfx_fragment_program *fp;
     
    -	fp = CALLOC(1, sizeof(struct nv40_fragment_program));
    +	fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
     	fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
     
     	tgsi_scan_shader(fp->pipe.tokens, &fp->info);
    @@ -565,19 +565,19 @@ nv40_fp_state_create(struct pipe_context *pipe,
     static void
     nv40_fp_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->fragprog = hwcso;
    -	nv40->dirty |= NV40_NEW_FRAGPROG;
    +	nvfx->fragprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_FRAGPROG;
     }
     
     static void
     nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_fragment_program *fp = hwcso;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_fragment_program *fp = hwcso;
     
    -	nv40_fragprog_destroy(nv40, fp);
    +	nv40_fragprog_destroy(nvfx, fp);
     	FREE((void*)fp->pipe.tokens);
     	FREE(fp);
     }
    @@ -586,47 +586,47 @@ static void
     nv40_set_blend_color(struct pipe_context *pipe,
     		     const struct pipe_blend_color *bcol)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->blend_colour = *bcol;
    -	nv40->dirty |= NV40_NEW_BCOL;
    +	nvfx->blend_colour = *bcol;
    +	nvfx->dirty |= NVFX_NEW_BCOL;
     }
     
      static void
     nv40_set_stencil_ref(struct pipe_context *pipe,
     		     const struct pipe_stencil_ref *sr)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->stencil_ref = *sr;
    -	nv40->dirty |= NV40_NEW_SR;
    +	nvfx->stencil_ref = *sr;
    +	nvfx->dirty |= NVFX_NEW_SR;
     }
     
     static void
     nv40_set_clip_state(struct pipe_context *pipe,
     		    const struct pipe_clip_state *clip)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->clip = *clip;
    -	nv40->dirty |= NV40_NEW_UCP;
    -	nv40->draw_dirty |= NV40_NEW_UCP;
    +	nvfx->clip = *clip;
    +	nvfx->dirty |= NVFX_NEW_UCP;
    +	nvfx->draw_dirty |= NVFX_NEW_UCP;
     }
     
     static void
     nv40_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
     			 struct pipe_buffer *buf )
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->constbuf[shader] = buf;
    -	nv40->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
    +	nvfx->constbuf[shader] = buf;
    +	nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
     
     	if (shader == PIPE_SHADER_VERTEX) {
    -		nv40->dirty |= NV40_NEW_VERTPROG;
    +		nvfx->dirty |= NVFX_NEW_VERTPROG;
     	} else
     	if (shader == PIPE_SHADER_FRAGMENT) {
    -		nv40->dirty |= NV40_NEW_FRAGPROG;
    +		nvfx->dirty |= NVFX_NEW_FRAGPROG;
     	}
     }
     
    @@ -634,54 +634,54 @@ static void
     nv40_set_framebuffer_state(struct pipe_context *pipe,
     			   const struct pipe_framebuffer_state *fb)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->framebuffer = *fb;
    -	nv40->dirty |= NV40_NEW_FB;
    +	nvfx->framebuffer = *fb;
    +	nvfx->dirty |= NVFX_NEW_FB;
     }
     
     static void
     nv40_set_polygon_stipple(struct pipe_context *pipe,
     			 const struct pipe_poly_stipple *stipple)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	memcpy(nv40->stipple, stipple->stipple, 4 * 32);
    -	nv40->dirty |= NV40_NEW_STIPPLE;
    +	memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
    +	nvfx->dirty |= NVFX_NEW_STIPPLE;
     }
     
     static void
     nv40_set_scissor_state(struct pipe_context *pipe,
     		       const struct pipe_scissor_state *s)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->scissor = *s;
    -	nv40->dirty |= NV40_NEW_SCISSOR;
    +	nvfx->scissor = *s;
    +	nvfx->dirty |= NVFX_NEW_SCISSOR;
     }
     
     static void
     nv40_set_viewport_state(struct pipe_context *pipe,
     			const struct pipe_viewport_state *vpt)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->viewport = *vpt;
    -	nv40->dirty |= NV40_NEW_VIEWPORT;
    -	nv40->draw_dirty |= NV40_NEW_VIEWPORT;
    +	nvfx->viewport = *vpt;
    +	nvfx->dirty |= NVFX_NEW_VIEWPORT;
    +	nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;
     }
     
     static void
     nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
     			const struct pipe_vertex_buffer *vb)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	memcpy(nv40->vtxbuf, vb, sizeof(*vb) * count);
    -	nv40->vtxbuf_nr = count;
    +	memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
    +	nvfx->vtxbuf_nr = count;
     
    -	nv40->dirty |= NV40_NEW_ARRAYS;
    -	nv40->draw_dirty |= NV40_NEW_ARRAYS;
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
     }
     
     static void *
    @@ -689,7 +689,7 @@ nv40_vtxelts_state_create(struct pipe_context *pipe,
     			  unsigned num_elements,
     			  const struct pipe_vertex_element *elements)
     {
    -	struct nv40_vtxelt_state *cso = CALLOC_STRUCT(nv40_vtxelt_state);
    +	struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
     
     	assert(num_elements < 16); /* not doing fallbacks yet */
     	cso->num_elements = num_elements;
    @@ -709,57 +709,57 @@ nv40_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
     static void
     nv40_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     
    -	nv40->vtxelt = hwcso;
    -	nv40->dirty |= NV40_NEW_ARRAYS;
    -	nv40->draw_dirty |= NV40_NEW_ARRAYS;
    +	nvfx->vtxelt = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
     }
     
     void
    -nv40_init_state_functions(struct nv40_context *nv40)
    +nv40_init_state_functions(struct nvfx_context *nvfx)
     {
    -	nv40->pipe.create_blend_state = nv40_blend_state_create;
    -	nv40->pipe.bind_blend_state = nv40_blend_state_bind;
    -	nv40->pipe.delete_blend_state = nv40_blend_state_delete;
    +	nvfx->pipe.create_blend_state = nv40_blend_state_create;
    +	nvfx->pipe.bind_blend_state = nv40_blend_state_bind;
    +	nvfx->pipe.delete_blend_state = nv40_blend_state_delete;
     
    -	nv40->pipe.create_sampler_state = nv40_sampler_state_create;
    -	nv40->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
    -	nv40->pipe.delete_sampler_state = nv40_sampler_state_delete;
    -	nv40->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture;
    +	nvfx->pipe.create_sampler_state = nv40_sampler_state_create;
    +	nvfx->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
    +	nvfx->pipe.delete_sampler_state = nv40_sampler_state_delete;
    +	nvfx->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture;
     
    -	nv40->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
    -	nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
    -	nv40->pipe.delete_rasterizer_state = nv40_rasterizer_state_delete;
    +	nvfx->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
    +	nvfx->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
    +	nvfx->pipe.delete_rasterizer_state = nv40_rasterizer_state_delete;
     
    -	nv40->pipe.create_depth_stencil_alpha_state =
    +	nvfx->pipe.create_depth_stencil_alpha_state =
     		nv40_depth_stencil_alpha_state_create;
    -	nv40->pipe.bind_depth_stencil_alpha_state =
    +	nvfx->pipe.bind_depth_stencil_alpha_state =
     		nv40_depth_stencil_alpha_state_bind;
    -	nv40->pipe.delete_depth_stencil_alpha_state =
    +	nvfx->pipe.delete_depth_stencil_alpha_state =
     		nv40_depth_stencil_alpha_state_delete;
     
    -	nv40->pipe.create_vs_state = nv40_vp_state_create;
    -	nv40->pipe.bind_vs_state = nv40_vp_state_bind;
    -	nv40->pipe.delete_vs_state = nv40_vp_state_delete;
    +	nvfx->pipe.create_vs_state = nv40_vp_state_create;
    +	nvfx->pipe.bind_vs_state = nv40_vp_state_bind;
    +	nvfx->pipe.delete_vs_state = nv40_vp_state_delete;
     
    -	nv40->pipe.create_fs_state = nv40_fp_state_create;
    -	nv40->pipe.bind_fs_state = nv40_fp_state_bind;
    -	nv40->pipe.delete_fs_state = nv40_fp_state_delete;
    +	nvfx->pipe.create_fs_state = nv40_fp_state_create;
    +	nvfx->pipe.bind_fs_state = nv40_fp_state_bind;
    +	nvfx->pipe.delete_fs_state = nv40_fp_state_delete;
     
    -	nv40->pipe.set_blend_color = nv40_set_blend_color;
    -        nv40->pipe.set_stencil_ref = nv40_set_stencil_ref;
    -	nv40->pipe.set_clip_state = nv40_set_clip_state;
    -	nv40->pipe.set_constant_buffer = nv40_set_constant_buffer;
    -	nv40->pipe.set_framebuffer_state = nv40_set_framebuffer_state;
    -	nv40->pipe.set_polygon_stipple = nv40_set_polygon_stipple;
    -	nv40->pipe.set_scissor_state = nv40_set_scissor_state;
    -	nv40->pipe.set_viewport_state = nv40_set_viewport_state;
    +	nvfx->pipe.set_blend_color = nv40_set_blend_color;
    +	nvfx->pipe.set_stencil_ref = nv40_set_stencil_ref;
    +	nvfx->pipe.set_clip_state = nv40_set_clip_state;
    +	nvfx->pipe.set_constant_buffer = nv40_set_constant_buffer;
    +	nvfx->pipe.set_framebuffer_state = nv40_set_framebuffer_state;
    +	nvfx->pipe.set_polygon_stipple = nv40_set_polygon_stipple;
    +	nvfx->pipe.set_scissor_state = nv40_set_scissor_state;
    +	nvfx->pipe.set_viewport_state = nv40_set_viewport_state;
     
    -	nv40->pipe.create_vertex_elements_state = nv40_vtxelts_state_create;
    -	nv40->pipe.delete_vertex_elements_state = nv40_vtxelts_state_delete;
    -	nv40->pipe.bind_vertex_elements_state = nv40_vtxelts_state_bind;
    +	nvfx->pipe.create_vertex_elements_state = nv40_vtxelts_state_create;
    +	nvfx->pipe.delete_vertex_elements_state = nv40_vtxelts_state_delete;
    +	nvfx->pipe.bind_vertex_elements_state = nv40_vtxelts_state_bind;
     
    -	nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
    +	nvfx->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
     }
     
    diff --git a/src/gallium/drivers/nv40/nv40_state.h b/src/gallium/drivers/nv40/nv40_state.h
    deleted file mode 100644
    index e2e69420ea..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state.h
    +++ /dev/null
    @@ -1,91 +0,0 @@
    -#ifndef __NV40_STATE_H__
    -#define __NV40_STATE_H__
    -
    -#include "pipe/p_state.h"
    -#include "tgsi/tgsi_scan.h"
    -
    -struct nv40_sampler_state {
    -	uint32_t fmt;
    -	uint32_t wrap;
    -	uint32_t en;
    -	uint32_t filt;
    -	uint32_t bcol;
    -};
    -
    -struct nv40_vertex_program_exec {
    -	uint32_t data[4];
    -	boolean has_branch_offset;
    -	int const_index;
    -};
    -
    -struct nv40_vertex_program_data {
    -	int index; /* immediates == -1 */
    -	float value[4];
    -};
    -
    -struct nv40_vertex_program {
    -	struct pipe_shader_state pipe;
    -
    -	struct draw_vertex_shader *draw;
    -
    -	boolean translated;
    -
    -	struct pipe_clip_state ucp;
    -
    -	struct nv40_vertex_program_exec *insns;
    -	unsigned nr_insns;
    -	struct nv40_vertex_program_data *consts;
    -	unsigned nr_consts;
    -
    -	struct nouveau_resource *exec;
    -	unsigned exec_start;
    -	struct nouveau_resource *data;
    -	unsigned data_start;
    -	unsigned data_start_min;
    -
    -	uint32_t ir;
    -	uint32_t or;
    -	uint32_t clip_ctrl;
    -	struct nouveau_stateobj *so;
    -};
    -
    -struct nv40_fragment_program_data {
    -	unsigned offset;
    -	unsigned index;
    -};
    -
    -struct nv40_fragment_program {
    -	struct pipe_shader_state pipe;
    -	struct tgsi_shader_info info;
    -
    -	boolean translated;
    -	unsigned samplers;
    -
    -	uint32_t *insn;
    -	int       insn_len;
    -
    -	struct nv40_fragment_program_data *consts;
    -	unsigned nr_consts;
    -
    -	struct pipe_buffer *buffer;
    -
    -	uint32_t fp_control;
    -	struct nouveau_stateobj *so;
    -};
    -
    -#define NV40_MAX_TEXTURE_LEVELS  16
    -
    -struct nv40_miptree {
    -	struct pipe_texture base;
    -	struct nouveau_bo *bo;
    -
    -	struct pipe_buffer *buffer;
    -	uint total_size;
    -
    -	struct {
    -		uint pitch;
    -		uint *image_offset;
    -	} level[NV40_MAX_TEXTURE_LEVELS];
    -};
    -
    -#endif
    diff --git a/src/gallium/drivers/nv40/nv40_state_blend.c b/src/gallium/drivers/nv40/nv40_state_blend.c
    index 83202ec23c..bb06b4888d 100644
    --- a/src/gallium/drivers/nv40/nv40_state_blend.c
    +++ b/src/gallium/drivers/nv40/nv40_state_blend.c
    @@ -1,41 +1,41 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_blend_validate(struct nv40_context *nv40)
    +nv40_state_blend_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv40->blend->so, &nv40->state.hw[NV40_STATE_BLEND]);
    +	so_ref(nvfx->blend->so, &nvfx->state.hw[NVFX_STATE_BLEND]);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_blend = {
    +struct nvfx_state_entry nv40_state_blend = {
     	.validate = nv40_state_blend_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_BLEND,
    -		.hw = NV40_STATE_BLEND
    +		.pipe = NVFX_NEW_BLEND,
    +		.hw = NVFX_STATE_BLEND
     	}
     };
     
     static boolean
    -nv40_state_blend_colour_validate(struct nv40_context *nv40)
    +nv40_state_blend_colour_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *so = so_new(1, 1, 0);
    -	struct pipe_blend_color *bcol = &nv40->blend_colour;
    +	struct pipe_blend_color *bcol = &nvfx->blend_colour;
     
    -	so_method(so, nv40->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
     	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
     		       (float_to_ubyte(bcol->color[0]) << 16) |
     		       (float_to_ubyte(bcol->color[1]) <<  8) |
     		       (float_to_ubyte(bcol->color[2]) <<  0)));
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_BCOL]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_BCOL]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_blend_colour = {
    +struct nvfx_state_entry nv40_state_blend_colour = {
     	.validate = nv40_state_blend_colour_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_BCOL,
    -		.hw = NV40_STATE_BCOL
    +		.pipe = NVFX_NEW_BCOL,
    +		.hw = NVFX_STATE_BCOL
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c
    index 6ad7a8d4fd..5c437f9969 100644
    --- a/src/gallium/drivers/nv40/nv40_state_emit.c
    +++ b/src/gallium/drivers/nv40/nv40_state_emit.c
    @@ -1,8 +1,8 @@
     #include "nv40_context.h"
    -#include "nv40_state.h"
    +#include "nvfx_state.h"
     #include "draw/draw_context.h"
     
    -static struct nv40_state_entry *render_states[] = {
    +static struct nvfx_state_entry *render_states[] = {
     	&nv40_state_framebuffer,
     	&nv40_state_rasterizer,
     	&nv40_state_scissor,
    @@ -19,7 +19,7 @@ static struct nv40_state_entry *render_states[] = {
     	NULL
     };
     
    -static struct nv40_state_entry *swtnl_states[] = {
    +static struct nvfx_state_entry *swtnl_states[] = {
     	&nv40_state_framebuffer,
     	&nv40_state_rasterizer,
     	&nv40_state_scissor,
    @@ -37,27 +37,27 @@ static struct nv40_state_entry *swtnl_states[] = {
     };
     
     static void
    -nv40_state_do_validate(struct nv40_context *nv40,
    -		       struct nv40_state_entry **states)
    +nv40_state_do_validate(struct nvfx_context *nvfx,
    +		       struct nvfx_state_entry **states)
     {
     	while (*states) {
    -		struct nv40_state_entry *e = *states;
    +		struct nvfx_state_entry *e = *states;
     
    -		if (nv40->dirty & e->dirty.pipe) {
    -			if (e->validate(nv40))
    -				nv40->state.dirty |= (1ULL << e->dirty.hw);
    +		if (nvfx->dirty & e->dirty.pipe) {
    +			if (e->validate(nvfx))
    +				nvfx->state.dirty |= (1ULL << e->dirty.hw);
     		}
     
     		states++;
     	}
    -	nv40->dirty = 0;
    +	nvfx->dirty = 0;
     }
     
     void
    -nv40_state_emit(struct nv40_context *nv40)
    +nv40_state_emit(struct nvfx_context *nvfx)
     {
    -	struct nv40_state *state = &nv40->state;
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_state *state = &nvfx->state;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned i;
    @@ -65,26 +65,26 @@ nv40_state_emit(struct nv40_context *nv40)
     
     	/* XXX: race conditions
     	 */
    -	if (nv40 != screen->cur_ctx) {
    -		for (i = 0; i < NV40_STATE_MAX; i++) {
    +	if (nvfx != screen->cur_ctx) {
    +		for (i = 0; i < NVFX_STATE_MAX; i++) {
     			if (state->hw[i] && screen->state[i] != state->hw[i])
     				state->dirty |= (1ULL << i);
     		}
     
    -		screen->cur_ctx = nv40;
    +		screen->cur_ctx = nvfx;
     	}
     
     	for (i = 0, states = state->dirty; states; i++) {
     		if (!(states & (1ULL << i)))
     			continue;
    -		so_ref (state->hw[i], &nv40->screen->state[i]);
    +		so_ref (state->hw[i], &nvfx->screen->state[i]);
     		if (state->hw[i])
    -			so_emit(chan, nv40->screen->state[i]);
    +			so_emit(chan, nvfx->screen->state[i]);
     		states &= ~(1ULL << i);
     	}
     
    -	if (state->dirty & ((1ULL << NV40_STATE_FRAGPROG) |
    -			    (1ULL << NV40_STATE_FRAGTEX0))) {
    +	if (state->dirty & ((1ULL << NVFX_STATE_FRAGPROG) |
    +			    (1ULL << NVFX_STATE_FRAGTEX0))) {
     		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
     		OUT_RING  (chan, 2);
     		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
    @@ -97,46 +97,46 @@ nv40_state_emit(struct nv40_context *nv40)
     void
     nv40_state_flush_notify(struct nouveau_channel *chan)
     {
    -	struct nv40_context *nv40 = chan->user_private;
    -	struct nv40_state *state = &nv40->state;
    +	struct nvfx_context *nvfx = chan->user_private;
    +	struct nvfx_state *state = &nvfx->state;
     	unsigned i, samplers;
     
    -	so_emit_reloc_markers(chan, state->hw[NV40_STATE_FB]);
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
     	for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
     		if (!(samplers & (1 << i)))
     			continue;
     		so_emit_reloc_markers(chan,
    -				      state->hw[NV40_STATE_FRAGTEX0+i]);
    +				      state->hw[NVFX_STATE_FRAGTEX0+i]);
     		samplers &= ~(1ULL << i);
     	}
    -	so_emit_reloc_markers(chan, state->hw[NV40_STATE_FRAGPROG]);
    -	if (state->hw[NV40_STATE_VTXBUF] && nv40->render_mode == HW)
    -		so_emit_reloc_markers(chan, state->hw[NV40_STATE_VTXBUF]);
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
    +	if (state->hw[NVFX_STATE_VTXBUF] && nvfx->render_mode == HW)
    +		so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
     }
     
     boolean
    -nv40_state_validate(struct nv40_context *nv40)
    +nv40_state_validate(struct nvfx_context *nvfx)
     {
    -	boolean was_sw = nv40->fallback_swtnl ? TRUE : FALSE;
    +	boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
     
    -	if (nv40->render_mode != HW) {
    +	if (nvfx->render_mode != HW) {
     		/* Don't even bother trying to go back to hw if none
     		 * of the states that caused swtnl previously have changed.
     		 */
    -		if ((nv40->fallback_swtnl & nv40->dirty)
    -				!= nv40->fallback_swtnl)
    +		if ((nvfx->fallback_swtnl & nvfx->dirty)
    +				!= nvfx->fallback_swtnl)
     			return FALSE;
     
     		/* Attempt to go to hwtnl again */
    -		nv40->pipe.flush(&nv40->pipe, 0, NULL);
    -		nv40->dirty |= (NV40_NEW_VIEWPORT |
    -				NV40_NEW_VERTPROG |
    -				NV40_NEW_ARRAYS);
    -		nv40->render_mode = HW;
    +		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    +		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    +				NVFX_NEW_VERTPROG |
    +				NVFX_NEW_ARRAYS);
    +		nvfx->render_mode = HW;
     	}
     
    -	nv40_state_do_validate(nv40, render_states);
    -	if (nv40->fallback_swtnl || nv40->fallback_swrast)
    +	nv40_state_do_validate(nvfx, render_states);
    +	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
     		return FALSE;
     	
     	if (was_sw)
    @@ -146,44 +146,44 @@ nv40_state_validate(struct nv40_context *nv40)
     }
     
     boolean
    -nv40_state_validate_swtnl(struct nv40_context *nv40)
    +nv40_state_validate_swtnl(struct nvfx_context *nvfx)
     {
    -	struct draw_context *draw = nv40->draw;
    +	struct draw_context *draw = nvfx->draw;
     
     	/* Setup for swtnl */
    -	if (nv40->render_mode == HW) {
    -		NOUVEAU_ERR("hw->swtnl 0x%08x\n", nv40->fallback_swtnl);
    -		nv40->pipe.flush(&nv40->pipe, 0, NULL);
    -		nv40->dirty |= (NV40_NEW_VIEWPORT |
    -				NV40_NEW_VERTPROG |
    -				NV40_NEW_ARRAYS);
    -		nv40->render_mode = SWTNL;
    +	if (nvfx->render_mode == HW) {
    +		NOUVEAU_ERR("hw->swtnl 0x%08x\n", nvfx->fallback_swtnl);
    +		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    +		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    +				NVFX_NEW_VERTPROG |
    +				NVFX_NEW_ARRAYS);
    +		nvfx->render_mode = SWTNL;
     	}
     
    -	if (nv40->draw_dirty & NV40_NEW_VERTPROG)
    -		draw_bind_vertex_shader(draw, nv40->vertprog->draw);
    +	if (nvfx->draw_dirty & NVFX_NEW_VERTPROG)
    +		draw_bind_vertex_shader(draw, nvfx->vertprog->draw);
     
    -	if (nv40->draw_dirty & NV40_NEW_RAST)
    -		draw_set_rasterizer_state(draw, &nv40->rasterizer->pipe);
    +	if (nvfx->draw_dirty & NVFX_NEW_RAST)
    +		draw_set_rasterizer_state(draw, &nvfx->rasterizer->pipe);
     
    -	if (nv40->draw_dirty & NV40_NEW_UCP)
    -		draw_set_clip_state(draw, &nv40->clip);
    +	if (nvfx->draw_dirty & NVFX_NEW_UCP)
    +		draw_set_clip_state(draw, &nvfx->clip);
     
    -	if (nv40->draw_dirty & NV40_NEW_VIEWPORT)
    -		draw_set_viewport_state(draw, &nv40->viewport);
    +	if (nvfx->draw_dirty & NVFX_NEW_VIEWPORT)
    +		draw_set_viewport_state(draw, &nvfx->viewport);
     
    -	if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
    -		draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
    -		draw_set_vertex_elements(draw, nv40->vtxelt->num_elements, nv40->vtxelt->pipe);	
    +	if (nvfx->draw_dirty & NVFX_NEW_ARRAYS) {
    +		draw_set_vertex_buffers(draw, nvfx->vtxbuf_nr, nvfx->vtxbuf);
    +		draw_set_vertex_elements(draw, nvfx->vtxelt->num_elements, nvfx->vtxelt->pipe);
     	}
     
    -	nv40_state_do_validate(nv40, swtnl_states);
    -	if (nv40->fallback_swrast) {
    -		NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nv40->fallback_swrast);
    +	nv40_state_do_validate(nvfx, swtnl_states);
    +	if (nvfx->fallback_swrast) {
    +		NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nvfx->fallback_swrast);
     		return FALSE;
     	}
     
    -	nv40->draw_dirty = 0;
    +	nvfx->draw_dirty = 0;
     	return TRUE;
     }
     
    diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c
    index 207b70923e..95735e40a3 100644
    --- a/src/gallium/drivers/nv40/nv40_state_fb.c
    +++ b/src/gallium/drivers/nv40/nv40_state_fb.c
    @@ -4,18 +4,18 @@
     static struct pipe_buffer *
     nv40_do_surface_buffer(struct pipe_surface *surface)
     {
    -	struct nv40_miptree *mt = (struct nv40_miptree *)surface->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)surface->texture;
     	return mt->buffer;
     }
     
     #define nv40_surface_buffer(ps) nouveau_bo(nv40_do_surface_buffer(ps))
     
     static boolean
    -nv40_state_framebuffer_validate(struct nv40_context *nv40)
    +nv40_state_framebuffer_validate(struct nvfx_context *nvfx)
     {
    -	struct nouveau_channel *chan = nv40->screen->base.channel;
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    -	struct pipe_framebuffer_state *fb = &nv40->framebuffer;
    +	struct nouveau_channel *chan = nvfx->screen->base.channel;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct pipe_framebuffer_state *fb = &nvfx->framebuffer;
     	struct nv04_surface *rt[4], *zeta;
     	uint32_t rt_enable, rt_format;
     	int i, colour_format = 0, zeta_format = 0;
    @@ -161,15 +161,15 @@ nv40_state_framebuffer_validate(struct nv40_context *nv40)
     	so_method(so, eng3d, 0x1d88, 1);
     	so_data  (so, (1 << 12) | h);
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_FB]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_FB]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_framebuffer = {
    +struct nvfx_state_entry nv40_state_framebuffer = {
     	.validate = nv40_state_framebuffer_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_FB,
    -		.hw = NV40_STATE_FB
    +		.pipe = NVFX_NEW_FB,
    +		.hw = NVFX_STATE_FB
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_rasterizer.c b/src/gallium/drivers/nv40/nv40_state_rasterizer.c
    index 9ecda5990f..d6136a26eb 100644
    --- a/src/gallium/drivers/nv40/nv40_state_rasterizer.c
    +++ b/src/gallium/drivers/nv40/nv40_state_rasterizer.c
    @@ -1,17 +1,17 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_rasterizer_validate(struct nv40_context *nv40)
    +nv40_state_rasterizer_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv40->rasterizer->so,
    -	       &nv40->state.hw[NV40_STATE_RAST]);
    +	so_ref(nvfx->rasterizer->so,
    +	       &nvfx->state.hw[NVFX_STATE_RAST]);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_rasterizer = {
    +struct nvfx_state_entry nv40_state_rasterizer = {
     	.validate = nv40_state_rasterizer_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_RAST,
    -		.hw = NV40_STATE_RAST
    +		.pipe = NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_RAST
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
    index dcb068d059..11ec5c0878 100644
    --- a/src/gallium/drivers/nv40/nv40_state_scissor.c
    +++ b/src/gallium/drivers/nv40/nv40_state_scissor.c
    @@ -1,20 +1,20 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_scissor_validate(struct nv40_context *nv40)
    +nv40_state_scissor_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
    -	struct pipe_scissor_state *s = &nv40->scissor;
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct pipe_scissor_state *s = &nvfx->scissor;
     	struct nouveau_stateobj *so;
     
    -	if (nv40->state.hw[NV40_STATE_SCISSOR] &&
    -	    (rast->scissor == 0 && nv40->state.scissor_enabled == 0))
    +	if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
    +	    (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
     		return FALSE;
    -	nv40->state.scissor_enabled = rast->scissor;
    +	nvfx->state.scissor_enabled = rast->scissor;
     
     	so = so_new(1, 2, 0);
    -	so_method(so, nv40->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    -	if (nv40->state.scissor_enabled) {
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    +	if (nvfx->state.scissor_enabled) {
     		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
     		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
     	} else {
    @@ -22,15 +22,15 @@ nv40_state_scissor_validate(struct nv40_context *nv40)
     		so_data  (so, 4096 << 16);
     	}
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_SCISSOR]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_scissor = {
    +struct nvfx_state_entry nv40_state_scissor = {
     	.validate = nv40_state_scissor_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_SCISSOR | NV40_NEW_RAST,
    -		.hw = NV40_STATE_SCISSOR
    +		.pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_SCISSOR
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_stipple.c b/src/gallium/drivers/nv40/nv40_state_stipple.c
    index 4514618772..e537e08e1d 100644
    --- a/src/gallium/drivers/nv40/nv40_state_stipple.c
    +++ b/src/gallium/drivers/nv40/nv40_state_stipple.c
    @@ -1,14 +1,14 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_stipple_validate(struct nv40_context *nv40)
    +nv40_state_stipple_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_rasterizer_state *rast = &nv40->rasterizer->pipe;
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     	struct nouveau_stateobj *so;
     
    -	if (nv40->state.hw[NV40_STATE_STIPPLE] &&
    -	   (rast->poly_stipple_enable == 0 && nv40->state.stipple_enabled == 0))
    +	if (nvfx->state.hw[NVFX_STATE_STIPPLE] &&
    +	   (rast->poly_stipple_enable == 0 && nvfx->state.stipple_enabled == 0))
     		return FALSE;
     
     	if (rast->poly_stipple_enable) {
    @@ -19,21 +19,21 @@ nv40_state_stipple_validate(struct nv40_context *nv40)
     		so_data  (so, 1);
     		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
     		for (i = 0; i < 32; i++)
    -			so_data(so, nv40->stipple[i]);
    +			so_data(so, nvfx->stipple[i]);
     	} else {
     		so = so_new(1, 1, 0);
     		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
     		so_data  (so, 0);
     	}
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_STIPPLE]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_STIPPLE]);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_stipple = {
    +struct nvfx_state_entry nv40_state_stipple = {
     	.validate = nv40_state_stipple_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_STIPPLE | NV40_NEW_RAST,
    -		.hw = NV40_STATE_STIPPLE,
    +		.pipe = NVFX_NEW_STIPPLE | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_STIPPLE,
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c
    index 43cf6e5a0a..bf73e1119e 100644
    --- a/src/gallium/drivers/nv40/nv40_state_viewport.c
    +++ b/src/gallium/drivers/nv40/nv40_state_viewport.c
    @@ -1,17 +1,17 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_viewport_validate(struct nv40_context *nv40)
    +nv40_state_viewport_validate(struct nvfx_context *nvfx)
     {
    -	struct pipe_viewport_state *vpt = &nv40->viewport;
    +	struct pipe_viewport_state *vpt = &nvfx->viewport;
     	struct nouveau_stateobj *so;
     
    -	if (nv40->state.hw[NV40_STATE_VIEWPORT] &&
    -	    !(nv40->dirty & NV40_NEW_VIEWPORT))
    +	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
    +	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
     		return FALSE;
     
     	so = so_new(2, 9, 0);
    -	so_method(so, nv40->screen->eng3d,
    +	so_method(so, nvfx->screen->eng3d,
     		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
     	so_data  (so, fui(vpt->translate[0]));
     	so_data  (so, fui(vpt->translate[1]));
    @@ -21,18 +21,18 @@ nv40_state_viewport_validate(struct nv40_context *nv40)
     	so_data  (so, fui(vpt->scale[1]));
     	so_data  (so, fui(vpt->scale[2]));
     	so_data  (so, fui(vpt->scale[3]));
    -	so_method(so, nv40->screen->eng3d, 0x1d78, 1);
    +	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
     	so_data  (so, 1);
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_VIEWPORT]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_viewport = {
    +struct nvfx_state_entry nv40_state_viewport = {
     	.validate = nv40_state_viewport_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_VIEWPORT | NV40_NEW_RAST,
    -		.hw = NV40_STATE_VIEWPORT
    +		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_VIEWPORT
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c
    index cb56948a1b..00facd520a 100644
    --- a/src/gallium/drivers/nv40/nv40_state_zsa.c
    +++ b/src/gallium/drivers/nv40/nv40_state_zsa.c
    @@ -1,41 +1,41 @@
     #include "nv40_context.h"
     
     static boolean
    -nv40_state_zsa_validate(struct nv40_context *nv40)
    +nv40_state_zsa_validate(struct nvfx_context *nvfx)
     {
    -	so_ref(nv40->zsa->so,
    -	       &nv40->state.hw[NV40_STATE_ZSA]);
    +	so_ref(nvfx->zsa->so,
    +	       &nvfx->state.hw[NVFX_STATE_ZSA]);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_zsa = {
    +struct nvfx_state_entry nv40_state_zsa = {
     	.validate = nv40_state_zsa_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_ZSA,
    -		.hw = NV40_STATE_ZSA
    +		.pipe = NVFX_NEW_ZSA,
    +		.hw = NVFX_STATE_ZSA
     	}
     };
     
     static boolean
    -nv40_state_sr_validate(struct nv40_context *nv40)
    +nv40_state_sr_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *so = so_new(2, 2, 0);
    -	struct pipe_stencil_ref *sr = &nv40->stencil_ref;
    +	struct pipe_stencil_ref *sr = &nvfx->stencil_ref;
     
    -	so_method(so, nv40->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nv40->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
     	so_data  (so, sr->ref_value[1]);
     
    -	so_ref(so, &nv40->state.hw[NV40_STATE_SR]);
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SR]);
     	so_ref(NULL, &so);
     	return TRUE;
     }
     
    -struct nv40_state_entry nv40_state_sr = {
    +struct nvfx_state_entry nv40_state_sr = {
     	.validate = nv40_state_sr_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_SR,
    -		.hw = NV40_STATE_SR
    +		.pipe = NVFX_NEW_SR,
    +		.hw = NVFX_STATE_SR
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c
    index 02ecfd7bbb..328c23b8b4 100644
    --- a/src/gallium/drivers/nv40/nv40_surface.c
    +++ b/src/gallium/drivers/nv40/nv40_surface.c
    @@ -39,8 +39,8 @@ nv40_surface_copy(struct pipe_context *pipe,
     		  struct pipe_surface *src, unsigned srcx, unsigned srcy,
     		  unsigned width, unsigned height)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv04_surface_2d *eng2d = nv40->screen->eng2d;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
     
     	eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
     }
    @@ -50,15 +50,15 @@ nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
     		  unsigned destx, unsigned desty, unsigned width,
     		  unsigned height, unsigned value)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv04_surface_2d *eng2d = nv40->screen->eng2d;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
     
     	eng2d->fill(eng2d, dest, destx, desty, width, height, value);
     }
     
     void
    -nv40_init_surface_functions(struct nv40_context *nv40)
    +nv40_init_surface_functions(struct nvfx_context *nvfx)
     {
    -	nv40->pipe.surface_copy = nv40_surface_copy;
    -	nv40->pipe.surface_fill = nv40_surface_fill;
    +	nvfx->pipe.surface_copy = nv40_surface_copy;
    +	nvfx->pipe.surface_fill = nv40_surface_fill;
     }
    diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
    index c552a68113..3d8c8e8c78 100644
    --- a/src/gallium/drivers/nv40/nv40_transfer.c
    +++ b/src/gallium/drivers/nv40/nv40_transfer.c
    @@ -6,8 +6,8 @@
     #include "util/u_math.h"
     #include "nouveau/nouveau_winsys.h"
     #include "nv40_context.h"
    -#include "nv40_screen.h"
    -#include "nv40_state.h"
    +#include "nvfx_screen.h"
    +#include "nvfx_state.h"
     
     struct nv40_transfer {
     	struct pipe_transfer base;
    @@ -39,7 +39,7 @@ nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     		  unsigned x, unsigned y, unsigned w, unsigned h)
     {
             struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv40_miptree *mt = (struct nv40_miptree *)pt;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
     	struct nv40_transfer *tx;
     	struct pipe_texture tx_tex_template, *tx_tex;
     
    @@ -81,7 +81,7 @@ nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     		return NULL;
     	}
     
    -	tx->base.stride = ((struct nv40_miptree*)tx_tex)->level[0].pitch;
    +	tx->base.stride = ((struct nvfx_miptree*)tx_tex)->level[0].pitch;
     
     	tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
     	                                       0, 0, 0,
    @@ -97,7 +97,7 @@ nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
     	}
     
     	if (usage & PIPE_TRANSFER_READ) {
    -		struct nv40_screen *nvscreen = nv40_screen(pscreen);
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
     		struct pipe_surface *src;
     
     		src = pscreen->get_tex_surface(pscreen, pt,
    @@ -124,7 +124,7 @@ nv40_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx)
     
     	if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
     		struct pipe_screen *pscreen = pcontext->screen;
    -		struct nv40_screen *nvscreen = nv40_screen(pscreen);
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
     		struct pipe_surface *dst;
     
     		dst = pscreen->get_tex_surface(pscreen, ptx->texture,
    @@ -151,7 +151,7 @@ nv40_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
             struct pipe_screen *pscreen = pcontext->screen;
     	struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
     	struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
    -	struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
     	void *map = pipe_buffer_map(pscreen, mt->buffer,
     	                            pipe_transfer_buffer_flags(ptx));
     
    @@ -166,16 +166,16 @@ nv40_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
     {
             struct pipe_screen *pscreen = pcontext->screen;
     	struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
    -	struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
     
     	pipe_buffer_unmap(pscreen, mt->buffer);
     }
     
     void
    -nv40_init_transfer_functions(struct nv40_context *nv40)
    +nv40_init_transfer_functions(struct nvfx_context *nvfx)
     {
    -	nv40->pipe.get_tex_transfer = nv40_transfer_new;
    -	nv40->pipe.tex_transfer_destroy = nv40_transfer_del;
    -	nv40->pipe.transfer_map = nv40_transfer_map;
    -	nv40->pipe.transfer_unmap = nv40_transfer_unmap;
    +	nvfx->pipe.get_tex_transfer = nv40_transfer_new;
    +	nvfx->pipe.tex_transfer_destroy = nv40_transfer_del;
    +	nvfx->pipe.transfer_map = nv40_transfer_map;
    +	nvfx->pipe.transfer_unmap = nv40_transfer_unmap;
     }
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    index b77c9e924b..0738d5c93b 100644
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ b/src/gallium/drivers/nv40/nv40_vbo.c
    @@ -4,7 +4,7 @@
     #include "util/u_format.h"
     
     #include "nv40_context.h"
    -#include "nv40_state.h"
    +#include "nvfx_state.h"
     
     #include "nouveau/nouveau_channel.h"
     #include "nouveau/nouveau_pushbuf.h"
    @@ -69,15 +69,15 @@ nv40_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
     }
     
     static boolean
    -nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
    +nv40_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
     		    unsigned ib_size)
     {
    -	struct pipe_screen *pscreen = &nv40->screen->base.base;
    +	struct pipe_screen *pscreen = &nvfx->screen->base.base;
     	unsigned type;
     
     	if (!ib) {
    -		nv40->idxbuf = NULL;
    -		nv40->idxbuf_format = 0xdeadbeef;
    +		nvfx->idxbuf = NULL;
    +		nvfx->idxbuf_format = 0xdeadbeef;
     		return FALSE;
     	}
     
    @@ -95,23 +95,23 @@ nv40_vbo_set_idxbuf(struct nv40_context *nv40, struct pipe_buffer *ib,
     		return FALSE;
     	}
     
    -	if (ib != nv40->idxbuf ||
    -	    type != nv40->idxbuf_format) {
    -		nv40->dirty |= NV40_NEW_ARRAYS;
    -		nv40->idxbuf = ib;
    -		nv40->idxbuf_format = type;
    +	if (ib != nvfx->idxbuf ||
    +	    type != nvfx->idxbuf_format) {
    +		nvfx->dirty |= NVFX_NEW_ARRAYS;
    +		nvfx->idxbuf = ib;
    +		nvfx->idxbuf_format = type;
     	}
     
     	return TRUE;
     }
     
     static boolean
    -nv40_vbo_static_attrib(struct nv40_context *nv40, struct nouveau_stateobj *so,
    +nv40_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
     		       int attrib, struct pipe_vertex_element *ve,
     		       struct pipe_vertex_buffer *vb)
     {
    -	struct pipe_screen *pscreen = nv40->pipe.screen;
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
     	unsigned type, ncomp;
     	void *map;
     
    @@ -169,14 +169,14 @@ void
     nv40_draw_arrays(struct pipe_context *pipe,
     		 unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart;
     
    -	nv40_vbo_set_idxbuf(nv40, NULL, 0);
    -	if (FORCE_SWTNL || !nv40_state_validate(nv40)) {
    +	nv40_vbo_set_idxbuf(nvfx, NULL, 0);
    +	if (FORCE_SWTNL || !nv40_state_validate(nvfx)) {
     		nv40_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
    @@ -185,7 +185,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
     	while (count) {
     		unsigned vc, nr;
     
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -228,10 +228,10 @@ nv40_draw_arrays(struct pipe_context *pipe,
     }
     
     static INLINE void
    -nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
    +nv40_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -239,7 +239,7 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     		uint8_t *elts = (uint8_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -279,10 +279,10 @@ nv40_draw_elements_u08(struct nv40_context *nv40, void *ib,
     }
     
     static INLINE void
    -nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
    +nv40_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -290,7 +290,7 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     		uint16_t *elts = (uint16_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -330,10 +330,10 @@ nv40_draw_elements_u16(struct nv40_context *nv40, void *ib,
     }
     
     static INLINE void
    -nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
    +nv40_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     
    @@ -341,7 +341,7 @@ nv40_draw_elements_u32(struct nv40_context *nv40, void *ib,
     		uint32_t *elts = (uint32_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
     					mode, start, count, &restart);
    @@ -376,7 +376,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
     			  struct pipe_buffer *ib, unsigned ib_size,
     			  unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct pipe_screen *pscreen = pipe->screen;
     	void *map;
     
    @@ -388,13 +388,13 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
     
     	switch (ib_size) {
     	case 1:
    -		nv40_draw_elements_u08(nv40, map, mode, start, count);
    +		nv40_draw_elements_u08(nvfx, map, mode, start, count);
     		break;
     	case 2:
    -		nv40_draw_elements_u16(nv40, map, mode, start, count);
    +		nv40_draw_elements_u16(nvfx, map, mode, start, count);
     		break;
     	case 4:
    -		nv40_draw_elements_u32(nv40, map, mode, start, count);
    +		nv40_draw_elements_u32(nvfx, map, mode, start, count);
     		break;
     	default:
     		NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
    @@ -408,8 +408,8 @@ static void
     nv40_draw_elements_vbo(struct pipe_context *pipe,
     		       unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    -	struct nv40_screen *screen = nv40->screen;
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
     	unsigned restart;
    @@ -417,7 +417,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     	while (count) {
     		unsigned nr, vc;
     
    -		nv40_state_emit(nv40);
    +		nv40_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -462,11 +462,11 @@ nv40_draw_elements(struct pipe_context *pipe,
     		   struct pipe_buffer *indexBuffer, unsigned indexSize,
     		   unsigned mode, unsigned start, unsigned count)
     {
    -	struct nv40_context *nv40 = nv40_context(pipe);
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
     	boolean idxbuf;
     
    -	idxbuf = nv40_vbo_set_idxbuf(nv40, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nv40_state_validate(nv40)) {
    +	idxbuf = nv40_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    +	if (FORCE_SWTNL || !nv40_state_validate(nvfx)) {
     		nv40_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
    @@ -483,33 +483,33 @@ nv40_draw_elements(struct pipe_context *pipe,
     }
     
     static boolean
    -nv40_vbo_validate(struct nv40_context *nv40)
    +nv40_vbo_validate(struct nvfx_context *nvfx)
     {
     	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *eng3d = nv40->screen->eng3d;
    -	struct pipe_buffer *ib = nv40->idxbuf;
    -	unsigned ib_format = nv40->idxbuf_format;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct pipe_buffer *ib = nvfx->idxbuf;
    +	unsigned ib_format = nvfx->idxbuf_format;
     	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
     	int hw;
     
     	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
    +	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nvfx->vtxelt->num_elements);
     	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nv40->vtxelt->num_elements);
    +	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nvfx->vtxelt->num_elements);
     
    -	for (hw = 0; hw < nv40->vtxelt->num_elements; hw++) {
    +	for (hw = 0; hw < nvfx->vtxelt->num_elements; hw++) {
     		struct pipe_vertex_element *ve;
     		struct pipe_vertex_buffer *vb;
     		unsigned type, ncomp;
     
    -		ve = &nv40->vtxelt->pipe[hw];
    -		vb = &nv40->vtxbuf[ve->vertex_buffer_index];
    +		ve = &nvfx->vtxelt->pipe[hw];
    +		vb = &nvfx->vtxbuf[ve->vertex_buffer_index];
     
     		if (!vb->stride) {
     			if (!sattr)
     				sattr = so_new(16, 16 * 4, 0);
     
    -			if (nv40_vbo_static_attrib(nv40, sattr, hw, ve, vb)) {
    +			if (nv40_vbo_static_attrib(nvfx, sattr, hw, ve, vb)) {
     				so_data(vtxbuf, 0);
     				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
     				continue;
    @@ -517,7 +517,7 @@ nv40_vbo_validate(struct nv40_context *nv40)
     		}
     
     		if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp)) {
    -			nv40->fallback_swtnl |= NV40_NEW_ARRAYS;
    +			nvfx->fallback_swtnl |= NVFX_NEW_ARRAYS;
     			so_ref(NULL, &vtxbuf);
     			so_ref(NULL, &vtxfmt);
     			return FALSE;
    @@ -543,22 +543,22 @@ nv40_vbo_validate(struct nv40_context *nv40)
     	so_method(vtxbuf, eng3d, 0x1710, 1);
     	so_data  (vtxbuf, 0);
     
    -	so_ref(vtxbuf, &nv40->state.hw[NV40_STATE_VTXBUF]);
    +	so_ref(vtxbuf, &nvfx->state.hw[NVFX_STATE_VTXBUF]);
     	so_ref(NULL, &vtxbuf);
    -	nv40->state.dirty |= (1ULL << NV40_STATE_VTXBUF);
    -	so_ref(vtxfmt, &nv40->state.hw[NV40_STATE_VTXFMT]);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXBUF);
    +	so_ref(vtxfmt, &nvfx->state.hw[NVFX_STATE_VTXFMT]);
     	so_ref(NULL, &vtxfmt);
    -	nv40->state.dirty |= (1ULL << NV40_STATE_VTXFMT);
    -	so_ref(sattr, &nv40->state.hw[NV40_STATE_VTXATTR]);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXFMT);
    +	so_ref(sattr, &nvfx->state.hw[NVFX_STATE_VTXATTR]);
     	so_ref(NULL, &sattr);
    -	nv40->state.dirty |= (1ULL << NV40_STATE_VTXATTR);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXATTR);
     	return FALSE;
     }
     
    -struct nv40_state_entry nv40_state_vbo = {
    +struct nvfx_state_entry nv40_state_vbo = {
     	.validate = nv40_vbo_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_ARRAYS,
    +		.pipe = NVFX_NEW_ARRAYS,
     		.hw = 0,
     	}
     };
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    index 96f2743429..a199f0766e 100644
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ b/src/gallium/drivers/nv40/nv40_vertprog.c
    @@ -8,7 +8,7 @@
     #include "tgsi/tgsi_util.h"
     
     #include "nv40_context.h"
    -#include "nv40_state.h"
    +#include "nvfx_state.h"
     
     /* TODO (at least...):
      *  1. Indexed consts  + ARL
    @@ -41,9 +41,9 @@
     #define NV40_VP_INST_DEST_CLIP(n) ((~0 - 6) + (n))
     
     struct nv40_vpc {
    -	struct nv40_vertex_program *vp;
    +	struct nvfx_vertex_program *vp;
     
    -	struct nv40_vertex_program_exec *vpi;
    +	struct nvfx_vertex_program_exec *vpi;
     
     	unsigned r_temps;
     	unsigned r_temps_discard;
    @@ -83,8 +83,8 @@ release_temps(struct nv40_vpc *vpc)
     static struct nv40_sreg
     constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
     {
    -	struct nv40_vertex_program *vp = vpc->vp;
    -	struct nv40_vertex_program_data *vpd;
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program_data *vpd;
     	int idx;
     
     	if (pipe >= 0) {
    @@ -112,7 +112,7 @@ constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
     static void
     emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nv40_sreg src)
     {
    -	struct nv40_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t sr = 0;
     
     	switch (src.type) {
    @@ -176,7 +176,7 @@ emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nv40_sreg src)
     static void
     emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nv40_sreg dst)
     {
    -	struct nv40_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     
     	switch (dst.type) {
     	case NV40SR_TEMP:
    @@ -259,7 +259,7 @@ nv40_vp_arith(struct nv40_vpc *vpc, int slot, int op,
     	      struct nv40_sreg s0, struct nv40_sreg s1,
     	      struct nv40_sreg s2)
     {
    -	struct nv40_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t *hw;
     
     	vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
    @@ -723,8 +723,8 @@ nv40_vertprog_prepare(struct nv40_vpc *vpc)
     }
     
     static void
    -nv40_vertprog_translate(struct nv40_context *nv40,
    -			struct nv40_vertex_program *vp)
    +nv40_vertprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_vertex_program *vp)
     {
     	struct tgsi_parse_context parse;
     	struct nv40_vpc *vpc = NULL;
    @@ -798,10 +798,10 @@ nv40_vertprog_translate(struct nv40_context *nv40,
     		struct nv40_sreg cdst = nv40_sr(NV40SR_OUTPUT,
     						NV40_VP_INST_DEST_CLIP(i));
     		struct nv40_sreg ceqn = constant(vpc, -1,
    -						 nv40->clip.ucp[i][0],
    -						 nv40->clip.ucp[i][1],
    -						 nv40->clip.ucp[i][2],
    -						 nv40->clip.ucp[i][3]);
    +						 nvfx->clip.ucp[i][0],
    +						 nvfx->clip.ucp[i][1],
    +						 nvfx->clip.ucp[i][2],
    +						 nvfx->clip.ucp[i][3]);
     		struct nv40_sreg htmp = vpc->r_result[vpc->hpos_idx];
     		unsigned mask;
     
    @@ -831,28 +831,28 @@ out_err:
     }
     
     static boolean
    -nv40_vertprog_validate(struct nv40_context *nv40)
    +nv40_vertprog_validate(struct nvfx_context *nvfx)
     { 
    -	struct pipe_screen *pscreen = nv40->pipe.screen;
    -	struct nv40_screen *screen = nv40->screen;
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nvfx_screen *screen = nvfx->screen;
     	struct nouveau_channel *chan = screen->base.channel;
     	struct nouveau_grobj *eng3d = screen->eng3d;
    -	struct nv40_vertex_program *vp;
    +	struct nvfx_vertex_program *vp;
     	struct pipe_buffer *constbuf;
     	boolean upload_code = FALSE, upload_data = FALSE;
     	int i;
     
    -	if (nv40->render_mode == HW) {
    -		vp = nv40->vertprog;
    -		constbuf = nv40->constbuf[PIPE_SHADER_VERTEX];
    +	if (nvfx->render_mode == HW) {
    +		vp = nvfx->vertprog;
    +		constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
     
    -		if ((nv40->dirty & NV40_NEW_UCP) ||
    -		    memcmp(&nv40->clip, &vp->ucp, sizeof(vp->ucp))) {
    -			nv40_vertprog_destroy(nv40, vp);
    -			memcpy(&vp->ucp, &nv40->clip, sizeof(vp->ucp));
    +		if ((nvfx->dirty & NVFX_NEW_UCP) ||
    +		    memcmp(&nvfx->clip, &vp->ucp, sizeof(vp->ucp))) {
    +			nv40_vertprog_destroy(nvfx, vp);
    +			memcpy(&vp->ucp, &nvfx->clip, sizeof(vp->ucp));
     		}
     	} else {
    -		vp = nv40->swtnl.vertprog;
    +		vp = nvfx->swtnl.vertprog;
     		constbuf = NULL;
     	}
     
    @@ -860,23 +860,23 @@ nv40_vertprog_validate(struct nv40_context *nv40)
     	if (vp->translated)
     		goto check_gpu_resources;
     
    -	nv40->fallback_swtnl &= ~NV40_NEW_VERTPROG;
    -	nv40_vertprog_translate(nv40, vp);
    +	nvfx->fallback_swtnl &= ~NVFX_NEW_VERTPROG;
    +	nv40_vertprog_translate(nvfx, vp);
     	if (!vp->translated) {
    -		nv40->fallback_swtnl |= NV40_NEW_VERTPROG;
    +		nvfx->fallback_swtnl |= NVFX_NEW_VERTPROG;
     		return FALSE;
     	}
     
     check_gpu_resources:
     	/* Allocate hw vtxprog exec slots */
     	if (!vp->exec) {
    -		struct nouveau_resource *heap = nv40->screen->vp_exec_heap;
    +		struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
     		struct nouveau_stateobj *so;
     		uint vplen = vp->nr_insns;
     
     		if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
     			while (heap->next && heap->size < vplen) {
    -				struct nv40_vertex_program *evict;
    +				struct nvfx_vertex_program *evict;
     				
     				evict = heap->next->priv;
     				nouveau_resource_free(&evict->exec);
    @@ -902,11 +902,11 @@ check_gpu_resources:
     
     	/* Allocate hw vtxprog const slots */
     	if (vp->nr_consts && !vp->data) {
    -		struct nouveau_resource *heap = nv40->screen->vp_data_heap;
    +		struct nouveau_resource *heap = nvfx->screen->vp_data_heap;
     
     		if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
     			while (heap->next && heap->size < vp->nr_consts) {
    -				struct nv40_vertex_program *evict;
    +				struct nvfx_vertex_program *evict;
     				
     				evict = heap->next->priv;
     				nouveau_resource_free(&evict->data);
    @@ -929,7 +929,7 @@ check_gpu_resources:
     	 */
     	if (vp->exec_start != vp->exec->start) {
     		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nv40_vertex_program_exec *vpi = &vp->insns[i];
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
     
     			if (vpi->has_branch_offset) {
     				assert(0);
    @@ -941,7 +941,7 @@ check_gpu_resources:
     
     	if (vp->nr_consts && vp->data_start != vp->data->start) {
     		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nv40_vertex_program_exec *vpi = &vp->insns[i];
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
     
     			if (vpi->const_index >= 0) {
     				vpi->data[1] &= ~NV40_VP_INST_CONST_SRC_MASK;
    @@ -965,7 +965,7 @@ check_gpu_resources:
     		}
     
     		for (i = 0; i < vp->nr_consts; i++) {
    -			struct nv40_vertex_program_data *vpd = &vp->consts[i];
    +			struct nvfx_vertex_program_data *vpd = &vp->consts[i];
     
     			if (vpd->index >= 0) {
     				if (!upload_data &&
    @@ -1003,8 +1003,8 @@ check_gpu_resources:
     		}
     	}
     
    -	if (vp->so != nv40->state.hw[NV40_STATE_VERTPROG]) {
    -		so_ref(vp->so, &nv40->state.hw[NV40_STATE_VERTPROG]);
    +	if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
    +		so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
     		return TRUE;
     	}
     
    @@ -1012,7 +1012,7 @@ check_gpu_resources:
     }
     
     void
    -nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp)
    +nv40_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
     {
     	vp->translated = FALSE;
     
    @@ -1038,11 +1038,11 @@ nv40_vertprog_destroy(struct nv40_context *nv40, struct nv40_vertex_program *vp)
     	so_ref(NULL, &vp->so);
     }
     
    -struct nv40_state_entry nv40_state_vertprog = {
    +struct nvfx_state_entry nv40_state_vertprog = {
     	.validate = nv40_vertprog_validate,
     	.dirty = {
    -		.pipe = NV40_NEW_VERTPROG | NV40_NEW_UCP,
    -		.hw = NV40_STATE_VERTPROG,
    +		.pipe = NVFX_NEW_VERTPROG | NVFX_NEW_UCP,
    +		.hw = NVFX_STATE_VERTPROG,
     	}
     };
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    new file mode 100644
    index 0000000000..9e89d8409f
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -0,0 +1,182 @@
    +#ifndef __NVFX_CONTEXT_H__
    +#define __NVFX_CONTEXT_H__
    +
    +#include 
    +
    +#include "pipe/p_context.h"
    +#include "pipe/p_defines.h"
    +#include "pipe/p_state.h"
    +#include "pipe/p_compiler.h"
    +
    +#include "util/u_memory.h"
    +#include "util/u_math.h"
    +#include "util/u_inlines.h"
    +
    +#include "draw/draw_vertex.h"
    +
    +#include "nouveau/nouveau_winsys.h"
    +#include "nouveau/nouveau_gldefs.h"
    +#include "nouveau/nouveau_context.h"
    +#include "nouveau/nouveau_stateobj.h"
    +
    +#include "nvfx_state.h"
    +
    +#define NOUVEAU_ERR(fmt, args...) \
    +	fprintf(stderr, "%s:%d -  "fmt, __func__, __LINE__, ##args);
    +#define NOUVEAU_MSG(fmt, args...) \
    +	fprintf(stderr, "nouveau: "fmt, ##args);
    +
    +enum nvfx_state_index {
    +	NVFX_STATE_FB = 0,
    +	NVFX_STATE_VIEWPORT = 1,
    +	NVFX_STATE_BLEND = 2,
    +	NVFX_STATE_RAST = 3,
    +	NVFX_STATE_ZSA = 4,
    +	NVFX_STATE_BCOL = 5,
    +	NVFX_STATE_CLIP = 6,
    +	NVFX_STATE_SCISSOR = 7,
    +	NVFX_STATE_STIPPLE = 8,
    +	NVFX_STATE_FRAGPROG = 9,
    +	NVFX_STATE_VERTPROG = 10,
    +	NVFX_STATE_FRAGTEX0 = 11,
    +	NVFX_STATE_FRAGTEX1 = 12,
    +	NVFX_STATE_FRAGTEX2 = 13,
    +	NVFX_STATE_FRAGTEX3 = 14,
    +	NVFX_STATE_FRAGTEX4 = 15,
    +	NVFX_STATE_FRAGTEX5 = 16,
    +	NVFX_STATE_FRAGTEX6 = 17,
    +	NVFX_STATE_FRAGTEX7 = 18,
    +	NVFX_STATE_FRAGTEX8 = 19,
    +	NVFX_STATE_FRAGTEX9 = 20,
    +	NVFX_STATE_FRAGTEX10 = 21,
    +	NVFX_STATE_FRAGTEX11 = 22,
    +	NVFX_STATE_FRAGTEX12 = 23,
    +	NVFX_STATE_FRAGTEX13 = 24,
    +	NVFX_STATE_FRAGTEX14 = 25,
    +	NVFX_STATE_FRAGTEX15 = 26,
    +	NVFX_STATE_VERTTEX0 = 27,
    +	NVFX_STATE_VERTTEX1 = 28,
    +	NVFX_STATE_VERTTEX2 = 29,
    +	NVFX_STATE_VERTTEX3 = 30,
    +	NVFX_STATE_VTXBUF = 31,
    +	NVFX_STATE_VTXFMT = 32,
    +	NVFX_STATE_VTXATTR = 33,
    +	NVFX_STATE_SR = 34,
    +	NVFX_STATE_MAX = 35
    +};
    +
    +#include "nvfx_screen.h"
    +
    +#define NVFX_NEW_BLEND		(1 <<  0)
    +#define NVFX_NEW_RAST		(1 <<  1)
    +#define NVFX_NEW_ZSA		(1 <<  2)
    +#define NVFX_NEW_SAMPLER	(1 <<  3)
    +#define NVFX_NEW_FB		(1 <<  4)
    +#define NVFX_NEW_STIPPLE	(1 <<  5)
    +#define NVFX_NEW_SCISSOR	(1 <<  6)
    +#define NVFX_NEW_VIEWPORT	(1 <<  7)
    +#define NVFX_NEW_BCOL		(1 <<  8)
    +#define NVFX_NEW_VERTPROG	(1 <<  9)
    +#define NVFX_NEW_FRAGPROG	(1 << 10)
    +#define NVFX_NEW_ARRAYS		(1 << 11)
    +#define NVFX_NEW_UCP		(1 << 12)
    +#define NVFX_NEW_SR		(1 << 13)
    +
    +struct nvfx_rasterizer_state {
    +	struct pipe_rasterizer_state pipe;
    +	struct nouveau_stateobj *so;
    +};
    +
    +struct nvfx_zsa_state {
    +	struct pipe_depth_stencil_alpha_state pipe;
    +	struct nouveau_stateobj *so;
    +};
    +
    +struct nvfx_blend_state {
    +	struct pipe_blend_state pipe;
    +	struct nouveau_stateobj *so;
    +};
    +
    +
    +struct nvfx_state {
    +	unsigned scissor_enabled;
    +	unsigned stipple_enabled;
    +	unsigned fp_samplers;
    +
    +	uint64_t dirty;
    +	struct nouveau_stateobj *hw[NVFX_STATE_MAX];
    +};
    +
    +struct nvfx_vtxelt_state {
    +	struct pipe_vertex_element pipe[16];
    +	unsigned num_elements;
    +};
    +
    +struct nvfx_context {
    +	struct pipe_context pipe;
    +
    +	struct nouveau_winsys *nvws;
    +	struct nvfx_screen *screen;
    +
    +	struct draw_context *draw;
    +
    +	/* HW state derived from pipe states */
    +	struct nvfx_state state;
    +	struct {
    +		struct nvfx_vertex_program *vertprog;
    +
    +		unsigned nr_attribs;
    +		unsigned hw[PIPE_MAX_SHADER_INPUTS];
    +		unsigned draw[PIPE_MAX_SHADER_INPUTS];
    +		unsigned emit[PIPE_MAX_SHADER_INPUTS];
    +	} swtnl;
    +
    +	enum {
    +		HW, SWTNL, SWRAST
    +	} render_mode;
    +	unsigned fallback_swtnl;
    +	unsigned fallback_swrast;
    +
    +	/* Context state */
    +	unsigned dirty, draw_dirty;
    +	struct pipe_scissor_state scissor;
    +	unsigned stipple[32];
    +	struct pipe_clip_state clip;
    +	struct nvfx_vertex_program *vertprog;
    +	struct nvfx_fragment_program *fragprog;
    +	struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
    +	unsigned constbuf_nr[PIPE_SHADER_TYPES];
    +	struct nvfx_rasterizer_state *rasterizer;
    +	struct nvfx_zsa_state *zsa;
    +	struct nvfx_blend_state *blend;
    +	struct pipe_blend_color blend_colour;
    +	struct pipe_stencil_ref stencil_ref;
    +	struct pipe_viewport_state viewport;
    +	struct pipe_framebuffer_state framebuffer;
    +	struct pipe_buffer *idxbuf;
    +	unsigned idxbuf_format;
    +	struct nvfx_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
    +	struct nvfx_miptree *tex_miptree[PIPE_MAX_SAMPLERS];
    +	unsigned nr_samplers;
    +	unsigned nr_textures;
    +	unsigned dirty_samplers;
    +	struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
    +	unsigned vtxbuf_nr;
    +	struct nvfx_vtxelt_state *vtxelt;
    +};
    +
    +static INLINE struct nvfx_context *
    +nvfx_context(struct pipe_context *pipe)
    +{
    +	return (struct nvfx_context *)pipe;
    +}
    +
    +struct nvfx_state_entry {
    +	boolean (*validate)(struct nvfx_context *nvfx);
    +	struct {
    +		unsigned pipe;
    +		unsigned hw;
    +	} dirty;
    +};
    +
    +#endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h
    new file mode 100644
    index 0000000000..b56f2d4b3f
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.h
    @@ -0,0 +1,37 @@
    +#ifndef __NVFX_SCREEN_H__
    +#define __NVFX_SCREEN_H__
    +
    +#include "nouveau/nouveau_screen.h"
    +#include "nouveau/nv04_surface_2d.h"
    +
    +struct nvfx_screen {
    +	struct nouveau_screen base;
    +
    +	struct nouveau_winsys *nvws;
    +
    +	struct nvfx_context *cur_ctx;
    +
    +	/* HW graphics objects */
    +	struct nv04_surface_2d *eng2d;
    +	struct nouveau_grobj *eng3d;
    +	struct nouveau_notifier *sync;
    +
    +	/* Query object resources */
    +	struct nouveau_notifier *query;
    +	struct nouveau_resource *query_heap;
    +
    +	/* Vtxprog resources */
    +	struct nouveau_resource *vp_exec_heap;
    +	struct nouveau_resource *vp_data_heap;
    +
    +	/* Current 3D state of channel */
    +	struct nouveau_stateobj *state[NVFX_STATE_MAX];
    +};
    +
    +static INLINE struct nvfx_screen *
    +nvfx_screen(struct pipe_screen *screen)
    +{
    +	return (struct nvfx_screen *)screen;
    +}
    +
    +#endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_state.h b/src/gallium/drivers/nvfx/nvfx_state.h
    new file mode 100644
    index 0000000000..b243b1020f
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state.h
    @@ -0,0 +1,91 @@
    +#ifndef __NVFX_STATE_H__
    +#define __NVFX_STATE_H__
    +
    +#include "pipe/p_state.h"
    +#include "tgsi/tgsi_scan.h"
    +
    +struct nvfx_sampler_state {
    +	uint32_t fmt;
    +	uint32_t wrap;
    +	uint32_t en;
    +	uint32_t filt;
    +	uint32_t bcol;
    +};
    +
    +struct nvfx_vertex_program_exec {
    +	uint32_t data[4];
    +	boolean has_branch_offset;
    +	int const_index;
    +};
    +
    +struct nvfx_vertex_program_data {
    +	int index; /* immediates == -1 */
    +	float value[4];
    +};
    +
    +struct nvfx_vertex_program {
    +	struct pipe_shader_state pipe;
    +
    +	struct draw_vertex_shader *draw;
    +
    +	boolean translated;
    +
    +	struct pipe_clip_state ucp;
    +
    +	struct nvfx_vertex_program_exec *insns;
    +	unsigned nr_insns;
    +	struct nvfx_vertex_program_data *consts;
    +	unsigned nr_consts;
    +
    +	struct nouveau_resource *exec;
    +	unsigned exec_start;
    +	struct nouveau_resource *data;
    +	unsigned data_start;
    +	unsigned data_start_min;
    +
    +	uint32_t ir;
    +	uint32_t or;
    +	uint32_t clip_ctrl;
    +	struct nouveau_stateobj *so;
    +};
    +
    +struct nvfx_fragment_program_data {
    +	unsigned offset;
    +	unsigned index;
    +};
    +
    +struct nvfx_fragment_program {
    +	struct pipe_shader_state pipe;
    +	struct tgsi_shader_info info;
    +
    +	boolean translated;
    +	unsigned samplers;
    +
    +	uint32_t *insn;
    +	int       insn_len;
    +
    +	struct nvfx_fragment_program_data *consts;
    +	unsigned nr_consts;
    +
    +	struct pipe_buffer *buffer;
    +
    +	uint32_t fp_control;
    +	struct nouveau_stateobj *so;
    +};
    +
    +#define NVFX_MAX_TEXTURE_LEVELS  16
    +
    +struct nvfx_miptree {
    +	struct pipe_texture base;
    +	struct nouveau_bo *bo;
    +
    +	struct pipe_buffer *buffer;
    +	uint total_size;
    +
    +	struct {
    +		uint pitch;
    +		uint *image_offset;
    +	} level[NVFX_MAX_TEXTURE_LEVELS];
    +};
    +
    +#endif
    -- 
    cgit v1.2.3
    
    
    From 6518a1c853e82a42b28027b1304babd4f02f98ef Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 13:40:49 +0100
    Subject: nv30, nv40: add is_nv4x member to context and screen structs
    
    This will make it faster to check for nv40.
    ---
     src/gallium/drivers/nv30/nv30_context.c | 2 ++
     src/gallium/drivers/nv40/nv40_context.c | 2 ++
     src/gallium/drivers/nv40/nv40_screen.c  | 3 +++
     src/gallium/drivers/nvfx/nvfx_context.h | 2 ++
     src/gallium/drivers/nvfx/nvfx_screen.h  | 2 ++
     5 files changed, 11 insertions(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 628b50d8dc..afed8bb952 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -71,6 +71,8 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	screen->base.channel->user_private = nvfx;
     	screen->base.channel->flush_notify = nv30_state_flush_notify;
     
    +	nvfx->is_nv4x = screen->is_nv4x;
    +
     	nv30_init_query_functions(nvfx);
     	nv30_init_surface_functions(nvfx);
     	nv30_init_state_functions(nvfx);
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 721b513438..6cc3a339e6 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -71,6 +71,8 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	screen->base.channel->user_private = nvfx;
     	screen->base.channel->flush_notify = nv40_state_flush_notify;
     
    +	nvfx->is_nv4x = screen->is_nv4x;
    +
     	nv40_init_query_functions(nvfx);
     	nv40_init_surface_functions(nvfx);
     	nv40_init_state_functions(nvfx);
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    index 0fc8e18750..c64864d58d 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ b/src/gallium/drivers/nv40/nv40_screen.c
    @@ -184,6 +184,9 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     
     	if (!screen)
     		return NULL;
    +
    +	screen->is_nv4x = ~0;
    +
     	pscreen = &screen->base.base;
     
     	ret = nouveau_screen_init(&screen->base, dev);
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 9e89d8409f..87bad54e63 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -118,6 +118,8 @@ struct nvfx_context {
     	struct nouveau_winsys *nvws;
     	struct nvfx_screen *screen;
     
    +	unsigned is_nv4x; /* either 0 or ~0 */
    +
     	struct draw_context *draw;
     
     	/* HW state derived from pipe states */
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h
    index b56f2d4b3f..e076b876b0 100644
    --- a/src/gallium/drivers/nvfx/nvfx_screen.h
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.h
    @@ -11,6 +11,8 @@ struct nvfx_screen {
     
     	struct nvfx_context *cur_ctx;
     
    +	unsigned is_nv4x; /* either 0 or ~0 */
    +
     	/* HW graphics objects */
     	struct nv04_surface_2d *eng2d;
     	struct nouveau_grobj *eng3d;
    -- 
    cgit v1.2.3
    
    
    From 6321a183319fdcb2ebee757b7f0922efe3f919db Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 19:52:22 +0100
    Subject: nvfx: add nvfx directory to build system
    
    Will be used to hold source files unified between nv30 and nv40.
    
    Eventually all nv30 and nv40 code will be moved there and the
    nv30 and nv40 directories will be removed.
    ---
     configure.ac                                 |  2 +-
     src/gallium/drivers/nvfx/Makefile            | 11 +++++++++++
     src/gallium/winsys/drm/nouveau/dri/Makefile  |  7 +++++++
     src/gallium/winsys/drm/nouveau/egl/Makefile  |  7 +++++++
     src/gallium/winsys/drm/nouveau/xorg/Makefile |  7 +++++++
     5 files changed, 33 insertions(+), 1 deletion(-)
     create mode 100644 src/gallium/drivers/nvfx/Makefile
    
    (limited to 'src/gallium')
    
    diff --git a/configure.ac b/configure.ac
    index 35fbcd9d85..eb271e9d51 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -1360,7 +1360,7 @@ AC_ARG_ENABLE([gallium-nouveau],
         [enable_gallium_nouveau=no])
     if test "x$enable_gallium_nouveau" = xyes; then
         GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
    -    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv30 nv40 nv50"
    +    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv30 nv40 nv50"
     fi
     
     dnl
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    new file mode 100644
    index 0000000000..05cdda0cc0
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -0,0 +1,11 @@
    +TOP = ../../../..
    +include $(TOP)/configs/current
    +
    +LIBNAME = nvfx
    +
    +nvfx_dummy.c:
    +	touch nvfx_dummy.c
    +
    +C_SOURCES = nvfx_dummy.c
    +
    +include ../../Makefile.template
    diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
    index 7e95f79d03..0cc60395ff 100644
    --- a/src/gallium/winsys/drm/nouveau/dri/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
    @@ -3,11 +3,18 @@ include $(TOP)/configs/current
     
     LIBNAME = nouveau_dri.so
     
    +# hideous hack
    +-Wl,--start-group:
    +-Wl,--end-group:
    +
     PIPE_DRIVERS = \
     	$(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    +	-Wl,--start-group \
     	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
     	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
    +	$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
    +	-Wl,--end-group \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a
     
    diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile
    index 2c35260332..0f5e6d64aa 100644
    --- a/src/gallium/winsys/drm/nouveau/egl/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile
    @@ -5,10 +5,17 @@ EGL_DRIVER_NAME = nouveau
     EGL_DRIVER_SOURCES = dummy.c
     EGL_DRIVER_LIBS = -ldrm_nouveau
     
    +# hideous hack
    +-Wl,--start-group:
    +-Wl,--end-group:
    +
     EGL_DRIVER_PIPES = \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    +	-Wl,--start-group \
     	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
     	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
    +	$(TOP)/src/gallium/drivers/nv40/libnvfx.a \
    +	-Wl,--end-group \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
     	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
    diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile
    index 179b50230b..0607d82a6e 100644
    --- a/src/gallium/winsys/drm/nouveau/xorg/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile
    @@ -15,11 +15,18 @@ INCLUDES = \
     	-I$(TOP)/include \
     	-I$(TOP)/src/egl/main
     
    +# hideous hack
    +-Wl,--start-group:
    +-Wl,--end-group:
    +
     LIBS = \
     	$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    +	--Wl,--start-group \
     	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
     	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
    +	$(TOP)/src/gallium/drivers/nv40/libnvfx.a \
    +	--Wl,--end-group \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
     	$(GALLIUM_AUXILIARIES)
    -- 
    cgit v1.2.3
    
    
    From c5c7b69bda3fb49fd88b846feb6e65289a04488a Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 20:04:54 +0100
    Subject: nv30, nv40: unify identical nv[34]0_clear.c
    
    ---
     src/gallium/drivers/nv30/Makefile       |  1 -
     src/gallium/drivers/nv30/nv30_clear.c   | 14 --------------
     src/gallium/drivers/nv30/nv30_context.c |  2 +-
     src/gallium/drivers/nv30/nv30_context.h |  4 ----
     src/gallium/drivers/nv40/Makefile       |  1 -
     src/gallium/drivers/nv40/nv40_clear.c   | 14 --------------
     src/gallium/drivers/nv40/nv40_context.c |  2 +-
     src/gallium/drivers/nv40/nv40_context.h |  4 ----
     src/gallium/drivers/nvfx/Makefile       |  6 ++----
     src/gallium/drivers/nvfx/nvfx_clear.c   | 14 ++++++++++++++
     src/gallium/drivers/nvfx/nvfx_context.h |  4 ++++
     11 files changed, 22 insertions(+), 44 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_clear.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_clear.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_clear.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index ed02075d13..27f19da75c 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -4,7 +4,6 @@ include $(TOP)/configs/current
     LIBNAME = nv30
     
     C_SOURCES = \
    -	nv30_clear.c \
     	nv30_context.c \
     	nv30_draw.c \
     	nv30_fragprog.c \
    diff --git a/src/gallium/drivers/nv30/nv30_clear.c b/src/gallium/drivers/nv30/nv30_clear.c
    deleted file mode 100644
    index e7ba73de7c..0000000000
    --- a/src/gallium/drivers/nv30/nv30_clear.c
    +++ /dev/null
    @@ -1,14 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_clear.h"
    -
    -#include "nv30_context.h"
    -
    -void
    -nv30_clear(struct pipe_context *pipe, unsigned buffers,
    -           const float *rgba, double depth, unsigned stencil)
    -{
    -	util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
    -		   stencil);
    -}
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index afed8bb952..74be578705 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -62,7 +62,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.destroy = nv30_destroy;
     	nvfx->pipe.draw_arrays = nv30_draw_arrays;
     	nvfx->pipe.draw_elements = nv30_draw_elements;
    -	nvfx->pipe.clear = nv30_clear;
    +	nvfx->pipe.clear = nvfx_clear;
     	nvfx->pipe.flush = nv30_flush;
     
     	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 2fc148cded..8032bcd979 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -51,10 +51,6 @@ extern void nv30_draw_elements(struct pipe_context *pipe,
     				  unsigned mode, unsigned start,
     				  unsigned count);
     
    -/* nv30_clear.c */
    -extern void nv30_clear(struct pipe_context *pipe, unsigned buffers,
    -		       const float *rgba, double depth, unsigned stencil);
    -
     /* nvfx_context.c */
     struct pipe_context *
     nv30_create(struct pipe_screen *pscreen, void *priv);
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 50e5e72b4e..031c943de5 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -4,7 +4,6 @@ include $(TOP)/configs/current
     LIBNAME = nv40
     
     C_SOURCES = \
    -	nv40_clear.c \
     	nv40_context.c \
     	nv40_draw.c \
     	nv40_fragprog.c \
    diff --git a/src/gallium/drivers/nv40/nv40_clear.c b/src/gallium/drivers/nv40/nv40_clear.c
    deleted file mode 100644
    index 79de90434d..0000000000
    --- a/src/gallium/drivers/nv40/nv40_clear.c
    +++ /dev/null
    @@ -1,14 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_clear.h"
    -
    -#include "nv40_context.h"
    -
    -void
    -nv40_clear(struct pipe_context *pipe, unsigned buffers,
    -           const float *rgba, double depth, unsigned stencil)
    -{
    -	util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
    -		   stencil);
    -}
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 6cc3a339e6..cb249dd5d7 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -62,7 +62,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.destroy = nv40_destroy;
     	nvfx->pipe.draw_arrays = nv40_draw_arrays;
     	nvfx->pipe.draw_elements = nv40_draw_elements;
    -	nvfx->pipe.clear = nv40_clear;
    +	nvfx->pipe.clear = nvfx_clear;
     	nvfx->pipe.flush = nv40_flush;
     
     	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 7227c4a438..f9c0a9eb29 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -57,10 +57,6 @@ extern void nv40_draw_elements(struct pipe_context *pipe,
     				  unsigned mode, unsigned start,
     				  unsigned count);
     
    -/* nv40_clear.c */
    -extern void nv40_clear(struct pipe_context *pipe, unsigned buffers,
    -		       const float *rgba, double depth, unsigned stencil);
    -
     /* nvfx_context.c */
     struct pipe_context *
     nv40_create(struct pipe_screen *pscreen, void *priv);
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 05cdda0cc0..6959efa390 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -3,9 +3,7 @@ include $(TOP)/configs/current
     
     LIBNAME = nvfx
     
    -nvfx_dummy.c:
    -	touch nvfx_dummy.c
    -
    -C_SOURCES = nvfx_dummy.c
    +C_SOURCES = \
    +	nvfx_clear.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_clear.c b/src/gallium/drivers/nvfx/nvfx_clear.c
    new file mode 100644
    index 0000000000..2be70fcee4
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_clear.c
    @@ -0,0 +1,14 @@
    +#include "pipe/p_context.h"
    +#include "pipe/p_defines.h"
    +#include "pipe/p_state.h"
    +#include "util/u_clear.h"
    +
    +#include "nvfx_context.h"
    +
    +void
    +nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    +           const float *rgba, double depth, unsigned stencil)
    +{
    +	util_clear(pipe, &nvfx_context(pipe)->framebuffer, buffers, rgba, depth,
    +		   stencil);
    +}
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 87bad54e63..0aaa4964e2 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -181,4 +181,8 @@ struct nvfx_state_entry {
     	} dirty;
     };
     
    +/* nvfx_clear.c */
    +extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    +		       const float *rgba, double depth, unsigned stencil);
    +
     #endif
    -- 
    cgit v1.2.3
    
    
    From d084d189d03dc89a3161a131f1b386840c06ad61 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 20:07:10 +0100
    Subject: nv30, nv40: unify identical nv[34]0_transfer.c
    
    ---
     src/gallium/drivers/nv30/Makefile        |   1 -
     src/gallium/drivers/nv30/nv30_context.c  |   2 +-
     src/gallium/drivers/nv30/nv30_context.h  |   1 -
     src/gallium/drivers/nv30/nv30_transfer.c | 182 -------------------------------
     src/gallium/drivers/nv40/Makefile        |   1 -
     src/gallium/drivers/nv40/nv40_context.c  |   2 +-
     src/gallium/drivers/nv40/nv40_context.h  |   1 -
     src/gallium/drivers/nvfx/Makefile        |   3 +-
     src/gallium/drivers/nvfx/nvfx_context.h  |   3 +
     src/gallium/drivers/nvfx/nvfx_transfer.c | 182 +++++++++++++++++++++++++++++++
     10 files changed, 189 insertions(+), 189 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_transfer.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_transfer.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 27f19da75c..f18295cefc 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -21,7 +21,6 @@ C_SOURCES = \
     	nv30_state_viewport.c \
     	nv30_state_zsa.c \
     	nv30_surface.c \
    -	nv30_transfer.c \
     	nv30_vbo.c \
     	nv30_vertprog.c
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 74be578705..ee2c465bc6 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -76,7 +76,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	nv30_init_query_functions(nvfx);
     	nv30_init_surface_functions(nvfx);
     	nv30_init_state_functions(nvfx);
    -	nv30_init_transfer_functions(nvfx);
    +	nvfx_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
     	nvfx->draw = draw_create();
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 8032bcd979..9f28d49706 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -6,7 +6,6 @@
     extern void nv30_init_state_functions(struct nvfx_context *nvfx);
     extern void nv30_init_surface_functions(struct nvfx_context *nvfx);
     extern void nv30_init_query_functions(struct nvfx_context *nvfx);
    -extern void nv30_init_transfer_functions(struct nvfx_context *nvfx);
     
     extern void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen);
     
    diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
    deleted file mode 100644
    index 3d71df52b9..0000000000
    --- a/src/gallium/drivers/nv30/nv30_transfer.c
    +++ /dev/null
    @@ -1,182 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -#include "util/u_memory.h"
    -#include "util/u_math.h"
    -#include "nouveau/nouveau_winsys.h"
    -#include "nv30_context.h"
    -#include "nvfx_screen.h"
    -#include "nvfx_state.h"
    -
    -struct nv30_transfer {
    -	struct pipe_transfer base;
    -	struct pipe_surface *surface;
    -	boolean direct;
    -};
    -
    -static void
    -nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
    -                             struct pipe_texture *template)
    -{
    -	memset(template, 0, sizeof(struct pipe_texture));
    -	template->target = pt->target;
    -	template->format = pt->format;
    -	template->width0 = width;
    -	template->height0 = height;
    -	template->depth0 = 1;
    -	template->last_level = 0;
    -	template->nr_samples = pt->nr_samples;
    -
    -	template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
    -	                      NOUVEAU_TEXTURE_USAGE_LINEAR;
    -}
    -
    -static struct pipe_transfer *
    -nv30_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
    -		  unsigned face, unsigned level, unsigned zslice,
    -		  enum pipe_transfer_usage usage,
    -		  unsigned x, unsigned y, unsigned w, unsigned h)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    -	struct nv30_transfer *tx;
    -	struct pipe_texture tx_tex_template, *tx_tex;
    -
    -	tx = CALLOC_STRUCT(nv30_transfer);
    -	if (!tx)
    -		return NULL;
    -
    -	pipe_texture_reference(&tx->base.texture, pt);
    -	tx->base.x = x;
    -	tx->base.y = y;
    -	tx->base.width = w;
    -	tx->base.height = h;
    -	tx->base.stride = mt->level[level].pitch;
    -	tx->base.usage = usage;
    -	tx->base.face = face;
    -	tx->base.level = level;
    -	tx->base.zslice = zslice;
    -
    -	/* Direct access to texture */
    -	if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC ||
    -	     debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) &&
    -	    pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
    -	{
    -		tx->direct = true;
    -		tx->surface = pscreen->get_tex_surface(pscreen, pt,
    -	                                               face, level, zslice,
    -	                                               pipe_transfer_buffer_flags(&tx->base));
    -		return &tx->base;
    -	}
    -
    -	tx->direct = false;
    -
    -	nv30_compatible_transfer_tex(pt, w, h, &tx_tex_template);
    -
    -	tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
    -	if (!tx_tex)
    -	{
    -		FREE(tx);
    -		return NULL;
    -	}
    -
    -	tx->base.stride = ((struct nvfx_miptree*)tx_tex)->level[0].pitch;
    -
    -	tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
    -	                                       0, 0, 0,
    -	                                       pipe_transfer_buffer_flags(&tx->base));
    -
    -	pipe_texture_reference(&tx_tex, NULL);
    -
    -	if (!tx->surface)
    -	{
    -		pipe_surface_reference(&tx->surface, NULL);
    -		FREE(tx);
    -		return NULL;
    -	}
    -
    -	if (usage & PIPE_TRANSFER_READ) {
    -		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    -		struct pipe_surface *src;
    -
    -		src = pscreen->get_tex_surface(pscreen, pt,
    -	                                       face, level, zslice,
    -	                                       PIPE_BUFFER_USAGE_GPU_READ);
    -
    -		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    -		/* TODO: Check if SIFM can un-swizzle */
    -		nvscreen->eng2d->copy(nvscreen->eng2d,
    -		                      tx->surface, 0, 0,
    -		                      src, x, y,
    -		                      w, h);
    -
    -		pipe_surface_reference(&src, NULL);
    -	}
    -
    -	return &tx->base;
    -}
    -
    -static void
    -nv30_transfer_del(struct pipe_context *pcontext,
    -                  struct pipe_transfer *ptx)
    -{
    -	struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
    -
    -	if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
    -		struct pipe_screen *pscreen = pcontext->screen;
    -		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    -		struct pipe_surface *dst;
    -
    -		dst = pscreen->get_tex_surface(pscreen, ptx->texture,
    -	                                       ptx->face, ptx->level, ptx->zslice,
    -	                                       PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
    -
    -		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    -		nvscreen->eng2d->copy(nvscreen->eng2d,
    -		                      dst, tx->base.x, tx->base.y,
    -		                      tx->surface, 0, 0,
    -		                      tx->base.width, tx->base.height);
    -
    -		pipe_surface_reference(&dst, NULL);
    -	}
    -
    -	pipe_surface_reference(&tx->surface, NULL);
    -	pipe_texture_reference(&ptx->texture, NULL);
    -	FREE(ptx);
    -}
    -
    -static void *
    -nv30_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
    -	struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    -	void *map = pipe_buffer_map(pscreen, mt->buffer,
    -	                            pipe_transfer_buffer_flags(ptx));
    -
    -	if(!tx->direct)
    -		return map + ns->base.offset;
    -	else
    -		return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
    -}
    -
    -static void
    -nv30_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    -
    -	pipe_buffer_unmap(pscreen, mt->buffer);
    -}
    -
    -void
    -nv30_init_transfer_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.get_tex_transfer = nv30_transfer_new;
    -	nvfx->pipe.tex_transfer_destroy = nv30_transfer_del;
    -	nvfx->pipe.transfer_map = nv30_transfer_map;
    -	nvfx->pipe.transfer_unmap = nv30_transfer_unmap;
    -}
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 031c943de5..8d09ef807f 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -21,7 +21,6 @@ C_SOURCES = \
     	nv40_state_viewport.c \
     	nv40_state_zsa.c \
     	nv40_surface.c \
    -	nv40_transfer.c \
     	nv40_vbo.c \
     	nv40_vertprog.c
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index cb249dd5d7..9934b582ee 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -76,7 +76,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	nv40_init_query_functions(nvfx);
     	nv40_init_surface_functions(nvfx);
     	nv40_init_state_functions(nvfx);
    -	nv40_init_transfer_functions(nvfx);
    +	nvfx_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
     	nvfx->draw = draw_create();
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index f9c0a9eb29..e7c6d5ad86 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -6,7 +6,6 @@
     extern void nv40_init_state_functions(struct nvfx_context *nvfx);
     extern void nv40_init_surface_functions(struct nvfx_context *nvfx);
     extern void nv40_init_query_functions(struct nvfx_context *nvfx);
    -extern void nv40_init_transfer_functions(struct nvfx_context *nvfx);
     
     extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
     
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 6959efa390..699cbedbc8 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -4,6 +4,7 @@ include $(TOP)/configs/current
     LIBNAME = nvfx
     
     C_SOURCES = \
    -	nvfx_clear.c
    +	nvfx_clear.c \
    +	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 0aaa4964e2..38d1142ff9 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -185,4 +185,7 @@ struct nvfx_state_entry {
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    +/* nvfx_transfer.c */
    +extern void nvfx_init_transfer_functions(struct nvfx_context *nvfx);
    +
     #endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.c b/src/gallium/drivers/nvfx/nvfx_transfer.c
    new file mode 100644
    index 0000000000..409b354d58
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_transfer.c
    @@ -0,0 +1,182 @@
    +#include "pipe/p_state.h"
    +#include "pipe/p_defines.h"
    +#include "util/u_inlines.h"
    +#include "util/u_format.h"
    +#include "util/u_memory.h"
    +#include "util/u_math.h"
    +#include "nouveau/nouveau_winsys.h"
    +#include "nvfx_context.h"
    +#include "nvfx_screen.h"
    +#include "nvfx_state.h"
    +
    +struct nvfx_transfer {
    +	struct pipe_transfer base;
    +	struct pipe_surface *surface;
    +	boolean direct;
    +};
    +
    +static void
    +nvfx_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
    +                             struct pipe_texture *template)
    +{
    +	memset(template, 0, sizeof(struct pipe_texture));
    +	template->target = pt->target;
    +	template->format = pt->format;
    +	template->width0 = width;
    +	template->height0 = height;
    +	template->depth0 = 1;
    +	template->last_level = 0;
    +	template->nr_samples = pt->nr_samples;
    +
    +	template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
    +	                      NOUVEAU_TEXTURE_USAGE_LINEAR;
    +}
    +
    +static struct pipe_transfer *
    +nvfx_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
    +		  unsigned face, unsigned level, unsigned zslice,
    +		  enum pipe_transfer_usage usage,
    +		  unsigned x, unsigned y, unsigned w, unsigned h)
    +{
    +        struct pipe_screen *pscreen = pcontext->screen;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    +	struct nvfx_transfer *tx;
    +	struct pipe_texture tx_tex_template, *tx_tex;
    +
    +	tx = CALLOC_STRUCT(nvfx_transfer);
    +	if (!tx)
    +		return NULL;
    +
    +	pipe_texture_reference(&tx->base.texture, pt);
    +	tx->base.x = x;
    +	tx->base.y = y;
    +	tx->base.width = w;
    +	tx->base.height = h;
    +	tx->base.stride = mt->level[level].pitch;
    +	tx->base.usage = usage;
    +	tx->base.face = face;
    +	tx->base.level = level;
    +	tx->base.zslice = zslice;
    +
    +	/* Direct access to texture */
    +	if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC ||
    +	     debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) &&
    +	    pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
    +	{
    +		tx->direct = true;
    +		tx->surface = pscreen->get_tex_surface(pscreen, pt,
    +	                                               face, level, zslice,
    +	                                               pipe_transfer_buffer_flags(&tx->base));
    +		return &tx->base;
    +	}
    +
    +	tx->direct = false;
    +
    +	nvfx_compatible_transfer_tex(pt, w, h, &tx_tex_template);
    +
    +	tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
    +	if (!tx_tex)
    +	{
    +		FREE(tx);
    +		return NULL;
    +	}
    +
    +	tx->base.stride = ((struct nvfx_miptree*)tx_tex)->level[0].pitch;
    +
    +	tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
    +	                                       0, 0, 0,
    +	                                       pipe_transfer_buffer_flags(&tx->base));
    +
    +	pipe_texture_reference(&tx_tex, NULL);
    +
    +	if (!tx->surface)
    +	{
    +		pipe_surface_reference(&tx->surface, NULL);
    +		FREE(tx);
    +		return NULL;
    +	}
    +
    +	if (usage & PIPE_TRANSFER_READ) {
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    +		struct pipe_surface *src;
    +
    +		src = pscreen->get_tex_surface(pscreen, pt,
    +	                                       face, level, zslice,
    +	                                       PIPE_BUFFER_USAGE_GPU_READ);
    +
    +		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    +		/* TODO: Check if SIFM can un-swizzle */
    +		nvscreen->eng2d->copy(nvscreen->eng2d,
    +		                      tx->surface, 0, 0,
    +		                      src, x, y,
    +		                      w, h);
    +
    +		pipe_surface_reference(&src, NULL);
    +	}
    +
    +	return &tx->base;
    +}
    +
    +static void
    +nvfx_transfer_del(struct pipe_context *pcontext,
    +                  struct pipe_transfer *ptx)
    +{
    +	struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
    +
    +	if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
    +		struct pipe_screen *pscreen = pcontext->screen;
    +		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    +		struct pipe_surface *dst;
    +
    +		dst = pscreen->get_tex_surface(pscreen, ptx->texture,
    +	                                       ptx->face, ptx->level, ptx->zslice,
    +	                                       PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
    +
    +		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    +		nvscreen->eng2d->copy(nvscreen->eng2d,
    +		                      dst, tx->base.x, tx->base.y,
    +		                      tx->surface, 0, 0,
    +		                      tx->base.width, tx->base.height);
    +
    +		pipe_surface_reference(&dst, NULL);
    +	}
    +
    +	pipe_surface_reference(&tx->surface, NULL);
    +	pipe_texture_reference(&ptx->texture, NULL);
    +	FREE(ptx);
    +}
    +
    +static void *
    +nvfx_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    +{
    +        struct pipe_screen *pscreen = pcontext->screen;
    +	struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
    +	struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    +	void *map = pipe_buffer_map(pscreen, mt->buffer,
    +	                            pipe_transfer_buffer_flags(ptx));
    +
    +	if(!tx->direct)
    +		return map + ns->base.offset;
    +	else
    +		return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
    +}
    +
    +static void
    +nvfx_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    +{
    +	struct pipe_screen *pscreen = pcontext->screen;
    +	struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    +
    +	pipe_buffer_unmap(pscreen, mt->buffer);
    +}
    +
    +void
    +nvfx_init_transfer_functions(struct nvfx_context *nvfx)
    +{
    +	nvfx->pipe.get_tex_transfer = nvfx_transfer_new;
    +	nvfx->pipe.tex_transfer_destroy = nvfx_transfer_del;
    +	nvfx->pipe.transfer_map = nvfx_transfer_map;
    +	nvfx->pipe.transfer_unmap = nvfx_transfer_unmap;
    +}
    -- 
    cgit v1.2.3
    
    
    From 778c64da97272e7508dbcdf0bffdb699d1b04ce0 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 11:33:15 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_state_emit.c
    
    The files are the same except for swtnl support on nv40 and for
    texture cache flushing on nv40.
    
    Unify them, and use a macro to define 4 versions of render_states,
    for all combinations of nvfx and hwtnl/swtnl.
    ---
     src/gallium/drivers/nv30/Makefile          |   1 -
     src/gallium/drivers/nv30/nv30_context.c    |   2 +-
     src/gallium/drivers/nv30/nv30_context.h    |   3 -
     src/gallium/drivers/nv30/nv30_state_emit.c | 121 ------------------
     src/gallium/drivers/nv30/nv30_vbo.c        |  14 +--
     src/gallium/drivers/nv40/Makefile          |   1 -
     src/gallium/drivers/nv40/nv40_context.c    |   2 +-
     src/gallium/drivers/nv40/nv40_context.h    |   4 -
     src/gallium/drivers/nv40/nv40_draw.c       |   6 +-
     src/gallium/drivers/nv40/nv40_state_emit.c | 189 -----------------------------
     src/gallium/drivers/nv40/nv40_vbo.c        |  14 +--
     src/gallium/drivers/nvfx/Makefile          |   1 +
     src/gallium/drivers/nvfx/nvfx_context.h    |   6 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c | 188 ++++++++++++++++++++++++++++
     14 files changed, 214 insertions(+), 338 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_emit.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_emit.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_emit.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index f18295cefc..3067e45062 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_blend.c \
    -	nv30_state_emit.c \
     	nv30_state_fb.c \
     	nv30_state_rasterizer.c \
     	nv30_state_scissor.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index ee2c465bc6..6fe8cb3e32 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -69,7 +69,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
     
     	screen->base.channel->user_private = nvfx;
    -	screen->base.channel->flush_notify = nv30_state_flush_notify;
    +	screen->base.channel->flush_notify = nvfx_state_flush_notify;
     
     	nvfx->is_nv4x = screen->is_nv4x;
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 9f28d49706..a6767da4dc 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -24,9 +24,6 @@ extern void nv30_fragprog_destroy(struct nvfx_context *,
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern boolean nv30_state_validate(struct nvfx_context *nvfx);
    -extern void nv30_state_emit(struct nvfx_context *nvfx);
    -extern void nv30_state_flush_notify(struct nouveau_channel *chan);
     extern struct nvfx_state_entry nv30_state_rasterizer;
     extern struct nvfx_state_entry nv30_state_scissor;
     extern struct nvfx_state_entry nv30_state_stipple;
    diff --git a/src/gallium/drivers/nv30/nv30_state_emit.c b/src/gallium/drivers/nv30/nv30_state_emit.c
    deleted file mode 100644
    index 6df93618da..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_emit.c
    +++ /dev/null
    @@ -1,121 +0,0 @@
    -#include "nv30_context.h"
    -#include "nvfx_state.h"
    -
    -static struct nvfx_state_entry *render_states[] = {
    -	&nv30_state_framebuffer,
    -	&nv30_state_rasterizer,
    -	&nv30_state_scissor,
    -	&nv30_state_stipple,
    -	&nv30_state_fragprog,
    -	&nv30_state_fragtex,
    -	&nv30_state_vertprog,
    -	&nv30_state_blend,
    -	&nv30_state_blend_colour,
    -	&nv30_state_zsa,
    -	&nv30_state_sr,
    -	&nv30_state_viewport,
    -	&nv30_state_vbo,
    -	NULL
    -};
    -
    -static void
    -nv30_state_do_validate(struct nvfx_context *nvfx,
    -		       struct nvfx_state_entry **states)
    -{
    -	while (*states) {
    -		struct nvfx_state_entry *e = *states;
    -
    -		if (nvfx->dirty & e->dirty.pipe) {
    -			if (e->validate(nvfx))
    -				nvfx->state.dirty |= (1ULL << e->dirty.hw);
    -		}
    -
    -		states++;
    -	}
    -	nvfx->dirty = 0;
    -}
    -
    -void
    -nv30_state_emit(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_channel *chan = nvfx->screen->base.channel;
    -	struct nvfx_state *state = &nvfx->state;
    -	struct nvfx_screen *screen = nvfx->screen;
    -	unsigned i;
    -	uint64_t states;
    -
    -	/* XXX: racy!
    -	 */
    -	if (nvfx != screen->cur_ctx) {
    -		for (i = 0; i < NVFX_STATE_MAX; i++) {
    -			if (state->hw[i] && screen->state[i] != state->hw[i])
    -				state->dirty |= (1ULL << i);
    -		}
    -
    -		screen->cur_ctx = nvfx;
    -	}
    -
    -	for (i = 0, states = state->dirty; states; i++) {
    -		if (!(states & (1ULL << i)))
    -			continue;
    -		so_ref (state->hw[i], &nvfx->screen->state[i]);
    -		if (state->hw[i])
    -			so_emit(chan, nvfx->screen->state[i]);
    -		states &= ~(1ULL << i);
    -	}
    -
    -	state->dirty = 0;
    -}
    -
    -void
    -nv30_state_flush_notify(struct nouveau_channel *chan)
    -{
    -	struct nvfx_context *nvfx = chan->user_private;
    -	struct nvfx_state *state = &nvfx->state;
    -	unsigned i, samplers;
    -
    -	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
    -	for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
    -		if (!(samplers & (1 << i)))
    -			continue;
    -		so_emit_reloc_markers(chan,
    -				      state->hw[NVFX_STATE_FRAGTEX0+i]);
    -		samplers &= ~(1ULL << i);
    -	}
    -	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
    -	if (state->hw[NVFX_STATE_VTXBUF] /*&& nvfx->render_mode == HW*/)
    -		so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
    -}
    -
    -boolean
    -nv30_state_validate(struct nvfx_context *nvfx)
    -{
    -#if 0
    -	boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
    -
    -	if (nvfx->render_mode != HW) {
    -		/* Don't even bother trying to go back to hw if none
    -		 * of the states that caused swtnl previously have changed.
    -		 */
    -		if ((nvfx->fallback_swtnl & nvfx->dirty)
    -				!= nvfx->fallback_swtnl)
    -			return FALSE;
    -
    -		/* Attempt to go to hwtnl again */
    -		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    -		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    -				NVFX_NEW_VERTPROG |
    -				NVFX_NEW_ARRAYS);
    -		nvfx->render_mode = HW;
    -	}
    -#endif
    -	nv30_state_do_validate(nvfx, render_states);
    -#if 0
    -	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
    -		return FALSE;
    -	
    -	if (was_sw)
    -		NOUVEAU_ERR("swtnl->hw\n");
    -#endif
    -	return TRUE;
    -}
    diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
    index 119fa59890..2b4401e533 100644
    --- a/src/gallium/drivers/nv30/nv30_vbo.c
    +++ b/src/gallium/drivers/nv30/nv30_vbo.c
    @@ -175,7 +175,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
     	unsigned restart = 0;
     
     	nv30_vbo_set_idxbuf(nvfx, NULL, 0);
    -	if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
     		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
     						mode, start, count);*/
     		return;
    @@ -184,7 +184,7 @@ nv30_draw_arrays(struct pipe_context *pipe,
     	while (count) {
     		unsigned vc, nr;
     
    -		nv30_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -238,7 +238,7 @@ nv30_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
     		uint8_t *elts = (uint8_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -289,7 +289,7 @@ nv30_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
     		uint16_t *elts = (uint16_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -340,7 +340,7 @@ nv30_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
     		uint32_t *elts = (uint32_t *)ib + start;
     		unsigned vc, push, restart = 0;
     
    -		nv30_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
     					mode, start, count, &restart);
    @@ -416,7 +416,7 @@ nv30_draw_elements_vbo(struct pipe_context *pipe,
     	while (count) {
     		unsigned nr, vc;
     
    -		nv30_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -465,7 +465,7 @@ nv30_draw_elements(struct pipe_context *pipe,
     	boolean idxbuf;
     
     	idxbuf = nv30_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nv30_state_validate(nvfx)) {
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
     		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
     						mode, start, count);*/
     		return;
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 8d09ef807f..b0c0c09d51 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_blend.c \
    -	nv40_state_emit.c \
     	nv40_state_fb.c \
     	nv40_state_rasterizer.c \
     	nv40_state_scissor.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 9934b582ee..12f57377cd 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -69,7 +69,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
     
     	screen->base.channel->user_private = nvfx;
    -	screen->base.channel->flush_notify = nv40_state_flush_notify;
    +	screen->base.channel->flush_notify = nvfx_state_flush_notify;
     
     	nvfx->is_nv4x = screen->is_nv4x;
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index e7c6d5ad86..0b875bcb06 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -28,10 +28,6 @@ extern void nv40_fragprog_destroy(struct nvfx_context *,
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern boolean nv40_state_validate(struct nvfx_context *nvfx);
    -extern boolean nv40_state_validate_swtnl(struct nvfx_context *nvfx);
    -extern void nv40_state_emit(struct nvfx_context *nvfx);
    -extern void nv40_state_flush_notify(struct nouveau_channel *chan);
     extern struct nvfx_state_entry nv40_state_rasterizer;
     extern struct nvfx_state_entry nv40_state_scissor;
     extern struct nvfx_state_entry nv40_state_stipple;
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    index cce1c64621..87d2689d54 100644
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ b/src/gallium/drivers/nv40/nv40_draw.c
    @@ -98,7 +98,7 @@ nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
     			assert(0);
     		}
     		FIRE_RING(chan);
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     	}
     
     	/* Switch primitive modes if necessary */
    @@ -245,10 +245,10 @@ nv40_draw_elements_swtnl(struct pipe_context *pipe,
     	unsigned i;
     	void *map;
     
    -	if (!nv40_state_validate_swtnl(nvfx))
    +	if (!nvfx_state_validate_swtnl(nvfx))
     		return;
     	nvfx->state.dirty &= ~(1ULL << NVFX_STATE_VTXBUF);
    -	nv40_state_emit(nvfx);
    +	nvfx_state_emit(nvfx);
     
     	for (i = 0; i < nvfx->vtxbuf_nr; i++) {
     		map = pipe_buffer_map(pscreen, nvfx->vtxbuf[i].buffer,
    diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c
    deleted file mode 100644
    index 5c437f9969..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_emit.c
    +++ /dev/null
    @@ -1,189 +0,0 @@
    -#include "nv40_context.h"
    -#include "nvfx_state.h"
    -#include "draw/draw_context.h"
    -
    -static struct nvfx_state_entry *render_states[] = {
    -	&nv40_state_framebuffer,
    -	&nv40_state_rasterizer,
    -	&nv40_state_scissor,
    -	&nv40_state_stipple,
    -	&nv40_state_fragprog,
    -	&nv40_state_fragtex,
    -	&nv40_state_vertprog,
    -	&nv40_state_blend,
    -	&nv40_state_blend_colour,
    -	&nv40_state_zsa,
    -	&nv40_state_sr,
    -	&nv40_state_viewport,
    -	&nv40_state_vbo,
    -	NULL
    -};
    -
    -static struct nvfx_state_entry *swtnl_states[] = {
    -	&nv40_state_framebuffer,
    -	&nv40_state_rasterizer,
    -	&nv40_state_scissor,
    -	&nv40_state_stipple,
    -	&nv40_state_fragprog,
    -	&nv40_state_fragtex,
    -	&nv40_state_vertprog,
    -	&nv40_state_blend,
    -	&nv40_state_blend_colour,
    -	&nv40_state_zsa,
    -	&nv40_state_sr,
    -	&nv40_state_viewport,
    -	&nv40_state_vtxfmt,
    -	NULL
    -};
    -
    -static void
    -nv40_state_do_validate(struct nvfx_context *nvfx,
    -		       struct nvfx_state_entry **states)
    -{
    -	while (*states) {
    -		struct nvfx_state_entry *e = *states;
    -
    -		if (nvfx->dirty & e->dirty.pipe) {
    -			if (e->validate(nvfx))
    -				nvfx->state.dirty |= (1ULL << e->dirty.hw);
    -		}
    -
    -		states++;
    -	}
    -	nvfx->dirty = 0;
    -}
    -
    -void
    -nv40_state_emit(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_state *state = &nvfx->state;
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned i;
    -	uint64_t states;
    -
    -	/* XXX: race conditions
    -	 */
    -	if (nvfx != screen->cur_ctx) {
    -		for (i = 0; i < NVFX_STATE_MAX; i++) {
    -			if (state->hw[i] && screen->state[i] != state->hw[i])
    -				state->dirty |= (1ULL << i);
    -		}
    -
    -		screen->cur_ctx = nvfx;
    -	}
    -
    -	for (i = 0, states = state->dirty; states; i++) {
    -		if (!(states & (1ULL << i)))
    -			continue;
    -		so_ref (state->hw[i], &nvfx->screen->state[i]);
    -		if (state->hw[i])
    -			so_emit(chan, nvfx->screen->state[i]);
    -		states &= ~(1ULL << i);
    -	}
    -
    -	if (state->dirty & ((1ULL << NVFX_STATE_FRAGPROG) |
    -			    (1ULL << NVFX_STATE_FRAGTEX0))) {
    -		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
    -		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
    -		OUT_RING  (chan, 1);
    -	}
    -
    -	state->dirty = 0;
    -}
    -
    -void
    -nv40_state_flush_notify(struct nouveau_channel *chan)
    -{
    -	struct nvfx_context *nvfx = chan->user_private;
    -	struct nvfx_state *state = &nvfx->state;
    -	unsigned i, samplers;
    -
    -	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
    -	for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
    -		if (!(samplers & (1 << i)))
    -			continue;
    -		so_emit_reloc_markers(chan,
    -				      state->hw[NVFX_STATE_FRAGTEX0+i]);
    -		samplers &= ~(1ULL << i);
    -	}
    -	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
    -	if (state->hw[NVFX_STATE_VTXBUF] && nvfx->render_mode == HW)
    -		so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
    -}
    -
    -boolean
    -nv40_state_validate(struct nvfx_context *nvfx)
    -{
    -	boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
    -
    -	if (nvfx->render_mode != HW) {
    -		/* Don't even bother trying to go back to hw if none
    -		 * of the states that caused swtnl previously have changed.
    -		 */
    -		if ((nvfx->fallback_swtnl & nvfx->dirty)
    -				!= nvfx->fallback_swtnl)
    -			return FALSE;
    -
    -		/* Attempt to go to hwtnl again */
    -		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    -		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    -				NVFX_NEW_VERTPROG |
    -				NVFX_NEW_ARRAYS);
    -		nvfx->render_mode = HW;
    -	}
    -
    -	nv40_state_do_validate(nvfx, render_states);
    -	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
    -		return FALSE;
    -	
    -	if (was_sw)
    -		NOUVEAU_ERR("swtnl->hw\n");
    -
    -	return TRUE;
    -}
    -
    -boolean
    -nv40_state_validate_swtnl(struct nvfx_context *nvfx)
    -{
    -	struct draw_context *draw = nvfx->draw;
    -
    -	/* Setup for swtnl */
    -	if (nvfx->render_mode == HW) {
    -		NOUVEAU_ERR("hw->swtnl 0x%08x\n", nvfx->fallback_swtnl);
    -		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    -		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    -				NVFX_NEW_VERTPROG |
    -				NVFX_NEW_ARRAYS);
    -		nvfx->render_mode = SWTNL;
    -	}
    -
    -	if (nvfx->draw_dirty & NVFX_NEW_VERTPROG)
    -		draw_bind_vertex_shader(draw, nvfx->vertprog->draw);
    -
    -	if (nvfx->draw_dirty & NVFX_NEW_RAST)
    -		draw_set_rasterizer_state(draw, &nvfx->rasterizer->pipe);
    -
    -	if (nvfx->draw_dirty & NVFX_NEW_UCP)
    -		draw_set_clip_state(draw, &nvfx->clip);
    -
    -	if (nvfx->draw_dirty & NVFX_NEW_VIEWPORT)
    -		draw_set_viewport_state(draw, &nvfx->viewport);
    -
    -	if (nvfx->draw_dirty & NVFX_NEW_ARRAYS) {
    -		draw_set_vertex_buffers(draw, nvfx->vtxbuf_nr, nvfx->vtxbuf);
    -		draw_set_vertex_elements(draw, nvfx->vtxelt->num_elements, nvfx->vtxelt->pipe);
    -	}
    -
    -	nv40_state_do_validate(nvfx, swtnl_states);
    -	if (nvfx->fallback_swrast) {
    -		NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nvfx->fallback_swrast);
    -		return FALSE;
    -	}
    -
    -	nvfx->draw_dirty = 0;
    -	return TRUE;
    -}
    -
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    index 0738d5c93b..456b508d43 100644
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ b/src/gallium/drivers/nv40/nv40_vbo.c
    @@ -176,7 +176,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
     	unsigned restart;
     
     	nv40_vbo_set_idxbuf(nvfx, NULL, 0);
    -	if (FORCE_SWTNL || !nv40_state_validate(nvfx)) {
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
     		nv40_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
    @@ -185,7 +185,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
     	while (count) {
     		unsigned vc, nr;
     
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -239,7 +239,7 @@ nv40_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
     		uint8_t *elts = (uint8_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -290,7 +290,7 @@ nv40_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
     		uint16_t *elts = (uint16_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
     					mode, start, count, &restart);
    @@ -341,7 +341,7 @@ nv40_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
     		uint32_t *elts = (uint32_t *)ib + start;
     		unsigned vc, push, restart;
     
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
     					mode, start, count, &restart);
    @@ -417,7 +417,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
     	while (count) {
     		unsigned nr, vc;
     
    -		nv40_state_emit(nvfx);
    +		nvfx_state_emit(nvfx);
     
     		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
     					mode, start, count, &restart);
    @@ -466,7 +466,7 @@ nv40_draw_elements(struct pipe_context *pipe,
     	boolean idxbuf;
     
     	idxbuf = nv40_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nv40_state_validate(nvfx)) {
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
     		nv40_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 699cbedbc8..0eb1bebeb3 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -5,6 +5,7 @@ LIBNAME = nvfx
     
     C_SOURCES = \
     	nvfx_clear.c \
    +	nvfx_state_emit.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 38d1142ff9..3d4bc6bbc9 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -185,6 +185,12 @@ struct nvfx_state_entry {
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    +/* nvfx_state_emit.c */
    +extern void nvfx_state_flush_notify(struct nouveau_channel *chan);
    +extern boolean nvfx_state_validate(struct nvfx_context *nvfx);
    +extern boolean nvfx_state_validate_swtnl(struct nvfx_context *nvfx);
    +extern void nvfx_state_emit(struct nvfx_context *nvfx);
    +
     /* nvfx_transfer.c */
     extern void nvfx_init_transfer_functions(struct nvfx_context *nvfx);
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    new file mode 100644
    index 0000000000..9582ba9648
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -0,0 +1,188 @@
    +#include "nv30/nv30_context.h"
    +#include "nv40/nv40_context.h"
    +#include "nvfx_state.h"
    +#include "draw/draw_context.h"
    +
    +#define RENDER_STATES(name, nvxx, vbo) \
    +static struct nvfx_state_entry *name##_render_states[] = { \
    +	&nvxx##_state_framebuffer, \
    +	&nvxx##_state_rasterizer, \
    +	&nvxx##_state_scissor, \
    +	&nvxx##_state_stipple, \
    +	&nvxx##_state_fragprog, \
    +	&nvxx##_state_fragtex, \
    +	&nvxx##_state_vertprog, \
    +	&nvxx##_state_blend, \
    +	&nvxx##_state_blend_colour, \
    +	&nvxx##_state_zsa, \
    +	&nvxx##_state_sr, \
    +	&nvxx##_state_viewport, \
    +	&nvxx##_state_##vbo, \
    +	NULL \
    +}
    +
    +RENDER_STATES(nv30, nv30, vbo);
    +RENDER_STATES(nv30_swtnl, nv30, vbo); /* TODO: replace with vtxfmt once draw is unified */
    +RENDER_STATES(nv40, nv40, vbo);
    +RENDER_STATES(nv40_swtnl, nv40, vtxfmt);
    +
    +static void
    +nvfx_state_do_validate(struct nvfx_context *nvfx,
    +		       struct nvfx_state_entry **states)
    +{
    +	while (*states) {
    +		struct nvfx_state_entry *e = *states;
    +
    +		if (nvfx->dirty & e->dirty.pipe) {
    +			if (e->validate(nvfx))
    +				nvfx->state.dirty |= (1ULL << e->dirty.hw);
    +		}
    +
    +		states++;
    +	}
    +	nvfx->dirty = 0;
    +}
    +
    +void
    +nvfx_state_emit(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_state *state = &nvfx->state;
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	unsigned i;
    +	uint64_t states;
    +
    +	/* XXX: race conditions
    +	 */
    +	if (nvfx != screen->cur_ctx) {
    +		for (i = 0; i < NVFX_STATE_MAX; i++) {
    +			if (state->hw[i] && screen->state[i] != state->hw[i])
    +				state->dirty |= (1ULL << i);
    +		}
    +
    +		screen->cur_ctx = nvfx;
    +	}
    +
    +	for (i = 0, states = state->dirty; states; i++) {
    +		if (!(states & (1ULL << i)))
    +			continue;
    +		so_ref (state->hw[i], &nvfx->screen->state[i]);
    +		if (state->hw[i])
    +			so_emit(chan, nvfx->screen->state[i]);
    +		states &= ~(1ULL << i);
    +	}
    +
    +	/* TODO: could nv30 need this or something similar too? */
    +	if(nvfx->is_nv4x) {
    +		if (state->dirty & ((1ULL << NVFX_STATE_FRAGPROG) |
    +				    (1ULL << NVFX_STATE_FRAGTEX0))) {
    +			BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
    +			OUT_RING  (chan, 2);
    +			BEGIN_RING(chan, eng3d, NV40TCL_TEX_CACHE_CTL, 1);
    +			OUT_RING  (chan, 1);
    +		}
    +	}
    +	state->dirty = 0;
    +}
    +
    +void
    +nvfx_state_flush_notify(struct nouveau_channel *chan)
    +{
    +	struct nvfx_context *nvfx = chan->user_private;
    +	struct nvfx_state *state = &nvfx->state;
    +	unsigned i, samplers;
    +
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FB]);
    +	for (i = 0, samplers = state->fp_samplers; i < 16 && samplers; i++) {
    +		if (!(samplers & (1 << i)))
    +			continue;
    +		so_emit_reloc_markers(chan,
    +				      state->hw[NVFX_STATE_FRAGTEX0+i]);
    +		samplers &= ~(1ULL << i);
    +	}
    +	so_emit_reloc_markers(chan, state->hw[NVFX_STATE_FRAGPROG]);
    +	if (state->hw[NVFX_STATE_VTXBUF] && nvfx->render_mode == HW)
    +		so_emit_reloc_markers(chan, state->hw[NVFX_STATE_VTXBUF]);
    +}
    +
    +boolean
    +nvfx_state_validate(struct nvfx_context *nvfx)
    +{
    +	boolean was_sw = nvfx->fallback_swtnl ? TRUE : FALSE;
    +
    +	if (nvfx->render_mode != HW) {
    +		/* Don't even bother trying to go back to hw if none
    +		 * of the states that caused swtnl previously have changed.
    +		 */
    +		if ((nvfx->fallback_swtnl & nvfx->dirty)
    +				!= nvfx->fallback_swtnl)
    +			return FALSE;
    +
    +		/* Attempt to go to hwtnl again */
    +		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    +		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    +				NVFX_NEW_VERTPROG |
    +				NVFX_NEW_ARRAYS);
    +		nvfx->render_mode = HW;
    +	}
    +
    +	if(!nvfx->is_nv4x)
    +		nvfx_state_do_validate(nvfx, nv30_render_states);
    +	else
    +		nvfx_state_do_validate(nvfx, nv40_render_states);
    +
    +	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
    +		return FALSE;
    +
    +	if (was_sw)
    +		NOUVEAU_ERR("swtnl->hw\n");
    +
    +	return TRUE;
    +}
    +
    +boolean
    +nvfx_state_validate_swtnl(struct nvfx_context *nvfx)
    +{
    +	struct draw_context *draw = nvfx->draw;
    +
    +	/* Setup for swtnl */
    +	if (nvfx->render_mode == HW) {
    +		NOUVEAU_ERR("hw->swtnl 0x%08x\n", nvfx->fallback_swtnl);
    +		nvfx->pipe.flush(&nvfx->pipe, 0, NULL);
    +		nvfx->dirty |= (NVFX_NEW_VIEWPORT |
    +				NVFX_NEW_VERTPROG |
    +				NVFX_NEW_ARRAYS);
    +		nvfx->render_mode = SWTNL;
    +	}
    +
    +	if (nvfx->draw_dirty & NVFX_NEW_VERTPROG)
    +		draw_bind_vertex_shader(draw, nvfx->vertprog->draw);
    +
    +	if (nvfx->draw_dirty & NVFX_NEW_RAST)
    +		draw_set_rasterizer_state(draw, &nvfx->rasterizer->pipe);
    +
    +	if (nvfx->draw_dirty & NVFX_NEW_UCP)
    +		draw_set_clip_state(draw, &nvfx->clip);
    +
    +	if (nvfx->draw_dirty & NVFX_NEW_VIEWPORT)
    +		draw_set_viewport_state(draw, &nvfx->viewport);
    +
    +	if (nvfx->draw_dirty & NVFX_NEW_ARRAYS) {
    +		draw_set_vertex_buffers(draw, nvfx->vtxbuf_nr, nvfx->vtxbuf);
    +		draw_set_vertex_elements(draw, nvfx->vtxelt->num_elements, nvfx->vtxelt->pipe);
    +	}
    +
    +	if(!nvfx->is_nv4x)
    +		nvfx_state_do_validate(nvfx, nv30_swtnl_render_states);
    +	else
    +		nvfx_state_do_validate(nvfx, nv40_swtnl_render_states);
    +
    +	if (nvfx->fallback_swrast) {
    +		NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nvfx->fallback_swrast);
    +		return FALSE;
    +	}
    +
    +	nvfx->draw_dirty = 0;
    +	return TRUE;
    +}
    -- 
    cgit v1.2.3
    
    
    From 0b55e1cd17801a03d6fbb7ce46f25aa2b086bff4 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 20:37:17 +0100
    Subject: nv30, nv40: unify identical nv[34]0_state_blend.c
    
    ---
     src/gallium/drivers/nv30/Makefile           |  1 -
     src/gallium/drivers/nv30/nv30_context.h     |  2 --
     src/gallium/drivers/nv30/nv30_state_blend.c | 41 -----------------------------
     src/gallium/drivers/nv40/Makefile           |  1 -
     src/gallium/drivers/nv40/nv40_context.h     |  2 --
     src/gallium/drivers/nv40/nv40_state_blend.c | 41 -----------------------------
     src/gallium/drivers/nvfx/Makefile           |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h     |  3 +++
     src/gallium/drivers/nvfx/nvfx_state_blend.c | 41 +++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_state_emit.c  |  4 +--
     10 files changed, 47 insertions(+), 90 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_blend.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_blend.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_blend.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 3067e45062..66dad8f358 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -12,7 +12,6 @@ C_SOURCES = \
     	nv30_query.c \
     	nv30_screen.c \
     	nv30_state.c \
    -	nv30_state_blend.c \
     	nv30_state_fb.c \
     	nv30_state_rasterizer.c \
     	nv30_state_scissor.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index a6767da4dc..e6194b23f5 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -29,8 +29,6 @@ extern struct nvfx_state_entry nv30_state_scissor;
     extern struct nvfx_state_entry nv30_state_stipple;
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
    -extern struct nvfx_state_entry nv30_state_blend;
    -extern struct nvfx_state_entry nv30_state_blend_colour;
     extern struct nvfx_state_entry nv30_state_zsa;
     extern struct nvfx_state_entry nv30_state_viewport;
     extern struct nvfx_state_entry nv30_state_framebuffer;
    diff --git a/src/gallium/drivers/nv30/nv30_state_blend.c b/src/gallium/drivers/nv30/nv30_state_blend.c
    deleted file mode 100644
    index de368e5bd7..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_blend.c
    +++ /dev/null
    @@ -1,41 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_blend_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->blend->so, &nvfx->state.hw[NVFX_STATE_BLEND]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_blend = {
    -	.validate = nv30_state_blend_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_BLEND,
    -		.hw = NVFX_STATE_BLEND
    -	}
    -};
    -
    -static boolean
    -nv30_state_blend_colour_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *so = so_new(1, 1, 0);
    -	struct pipe_blend_color *bcol = &nvfx->blend_colour;
    -
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
    -	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
    -		       (float_to_ubyte(bcol->color[0]) << 16) |
    -		       (float_to_ubyte(bcol->color[1]) <<  8) |
    -		       (float_to_ubyte(bcol->color[2]) <<  0)));
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_BCOL]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_blend_colour = {
    -	.validate = nv30_state_blend_colour_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_BCOL,
    -		.hw = NVFX_STATE_BCOL
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index b0c0c09d51..739ca43387 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -12,7 +12,6 @@ C_SOURCES = \
     	nv40_query.c \
     	nv40_screen.c \
     	nv40_state.c \
    -	nv40_state_blend.c \
     	nv40_state_fb.c \
     	nv40_state_rasterizer.c \
     	nv40_state_scissor.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 0b875bcb06..28a79e4ecf 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -33,8 +33,6 @@ extern struct nvfx_state_entry nv40_state_scissor;
     extern struct nvfx_state_entry nv40_state_stipple;
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
    -extern struct nvfx_state_entry nv40_state_blend;
    -extern struct nvfx_state_entry nv40_state_blend_colour;
     extern struct nvfx_state_entry nv40_state_zsa;
     extern struct nvfx_state_entry nv40_state_viewport;
     extern struct nvfx_state_entry nv40_state_framebuffer;
    diff --git a/src/gallium/drivers/nv40/nv40_state_blend.c b/src/gallium/drivers/nv40/nv40_state_blend.c
    deleted file mode 100644
    index bb06b4888d..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_blend.c
    +++ /dev/null
    @@ -1,41 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_blend_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->blend->so, &nvfx->state.hw[NVFX_STATE_BLEND]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_blend = {
    -	.validate = nv40_state_blend_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_BLEND,
    -		.hw = NVFX_STATE_BLEND
    -	}
    -};
    -
    -static boolean
    -nv40_state_blend_colour_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *so = so_new(1, 1, 0);
    -	struct pipe_blend_color *bcol = &nvfx->blend_colour;
    -
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
    -	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
    -		       (float_to_ubyte(bcol->color[0]) << 16) |
    -		       (float_to_ubyte(bcol->color[1]) <<  8) |
    -		       (float_to_ubyte(bcol->color[2]) <<  0)));
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_BCOL]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_blend_colour = {
    -	.validate = nv40_state_blend_colour_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_BCOL,
    -		.hw = NVFX_STATE_BCOL
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 0eb1bebeb3..d124de89ec 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -6,6 +6,7 @@ LIBNAME = nvfx
     C_SOURCES = \
     	nvfx_clear.c \
     	nvfx_state_emit.c \
    +	nvfx_state_blend.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 3d4bc6bbc9..bbffb8a18d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -181,6 +181,9 @@ struct nvfx_state_entry {
     	} dirty;
     };
     
    +extern struct nvfx_state_entry nvfx_state_blend;
    +extern struct nvfx_state_entry nvfx_state_blend_colour;
    +
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_blend.c b/src/gallium/drivers/nvfx/nvfx_state_blend.c
    new file mode 100644
    index 0000000000..03b6ef8117
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_blend.c
    @@ -0,0 +1,41 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_blend_validate(struct nvfx_context *nvfx)
    +{
    +	so_ref(nvfx->blend->so, &nvfx->state.hw[NVFX_STATE_BLEND]);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_blend = {
    +	.validate = nvfx_state_blend_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_BLEND,
    +		.hw = NVFX_STATE_BLEND
    +	}
    +};
    +
    +static boolean
    +nvfx_state_blend_colour_validate(struct nvfx_context *nvfx)
    +{
    +	struct nouveau_stateobj *so = so_new(1, 1, 0);
    +	struct pipe_blend_color *bcol = &nvfx->blend_colour;
    +
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_BLEND_COLOR, 1);
    +	so_data  (so, ((float_to_ubyte(bcol->color[3]) << 24) |
    +		       (float_to_ubyte(bcol->color[0]) << 16) |
    +		       (float_to_ubyte(bcol->color[1]) <<  8) |
    +		       (float_to_ubyte(bcol->color[2]) <<  0)));
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_BCOL]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_blend_colour = {
    +	.validate = nvfx_state_blend_colour_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_BCOL,
    +		.hw = NVFX_STATE_BCOL
    +	}
    +};
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 9582ba9648..059bbb14b7 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -12,8 +12,8 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvxx##_state_fragprog, \
     	&nvxx##_state_fragtex, \
     	&nvxx##_state_vertprog, \
    -	&nvxx##_state_blend, \
    -	&nvxx##_state_blend_colour, \
    +	&nvfx_state_blend, \
    +	&nvfx_state_blend_colour, \
     	&nvxx##_state_zsa, \
     	&nvxx##_state_sr, \
     	&nvxx##_state_viewport, \
    -- 
    cgit v1.2.3
    
    
    From ada801222b3c984c260165415864a8f511145251 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 23:16:01 +0100
    Subject: nv30, nv40: unify identical nv[34]0_state_rasterizer.c
    
    ---
     src/gallium/drivers/nv30/Makefile                |  1 -
     src/gallium/drivers/nv30/nv30_context.h          |  1 -
     src/gallium/drivers/nv30/nv30_state_rasterizer.c | 17 -----------------
     src/gallium/drivers/nv40/Makefile                |  1 -
     src/gallium/drivers/nv40/nv40_context.h          |  1 -
     src/gallium/drivers/nv40/nv40_state_rasterizer.c | 17 -----------------
     src/gallium/drivers/nvfx/Makefile                |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h          |  1 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c       |  2 +-
     src/gallium/drivers/nvfx/nvfx_state_rasterizer.c | 17 +++++++++++++++++
     10 files changed, 20 insertions(+), 39 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_rasterizer.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_rasterizer.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 66dad8f358..668f5965b1 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_fb.c \
    -	nv30_state_rasterizer.c \
     	nv30_state_scissor.c \
     	nv30_state_stipple.c \
     	nv30_state_viewport.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index e6194b23f5..fbafbec383 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -24,7 +24,6 @@ extern void nv30_fragprog_destroy(struct nvfx_context *,
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern struct nvfx_state_entry nv30_state_rasterizer;
     extern struct nvfx_state_entry nv30_state_scissor;
     extern struct nvfx_state_entry nv30_state_stipple;
     extern struct nvfx_state_entry nv30_state_fragprog;
    diff --git a/src/gallium/drivers/nv30/nv30_state_rasterizer.c b/src/gallium/drivers/nv30/nv30_state_rasterizer.c
    deleted file mode 100644
    index 1a83da5204..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_rasterizer.c
    +++ /dev/null
    @@ -1,17 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_rasterizer_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->rasterizer->so,
    -	       &nvfx->state.hw[NVFX_STATE_RAST]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_rasterizer = {
    -	.validate = nv30_state_rasterizer_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_RAST
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 739ca43387..25ad2974bf 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_fb.c \
    -	nv40_state_rasterizer.c \
     	nv40_state_scissor.c \
     	nv40_state_stipple.c \
     	nv40_state_viewport.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 28a79e4ecf..fc8b06bd0f 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -28,7 +28,6 @@ extern void nv40_fragprog_destroy(struct nvfx_context *,
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern struct nvfx_state_entry nv40_state_rasterizer;
     extern struct nvfx_state_entry nv40_state_scissor;
     extern struct nvfx_state_entry nv40_state_stipple;
     extern struct nvfx_state_entry nv40_state_fragprog;
    diff --git a/src/gallium/drivers/nv40/nv40_state_rasterizer.c b/src/gallium/drivers/nv40/nv40_state_rasterizer.c
    deleted file mode 100644
    index d6136a26eb..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_rasterizer.c
    +++ /dev/null
    @@ -1,17 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_rasterizer_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->rasterizer->so,
    -	       &nvfx->state.hw[NVFX_STATE_RAST]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_rasterizer = {
    -	.validate = nv40_state_rasterizer_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_RAST
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index d124de89ec..f1843b61df 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -7,6 +7,7 @@ C_SOURCES = \
     	nvfx_clear.c \
     	nvfx_state_emit.c \
     	nvfx_state_blend.c \
    +	nvfx_state_rasterizer.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index bbffb8a18d..c7ce17ab38 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -183,6 +183,7 @@ struct nvfx_state_entry {
     
     extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
    +extern struct nvfx_state_entry nvfx_state_rasterizer;
     
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 059bbb14b7..60df50aa1c 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -6,7 +6,7 @@
     #define RENDER_STATES(name, nvxx, vbo) \
     static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvxx##_state_framebuffer, \
    -	&nvxx##_state_rasterizer, \
    +	&nvfx_state_rasterizer, \
     	&nvxx##_state_scissor, \
     	&nvxx##_state_stipple, \
     	&nvxx##_state_fragprog, \
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c b/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
    new file mode 100644
    index 0000000000..0d35ecbf20
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_rasterizer.c
    @@ -0,0 +1,17 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_rasterizer_validate(struct nvfx_context *nvfx)
    +{
    +	so_ref(nvfx->rasterizer->so,
    +	       &nvfx->state.hw[NVFX_STATE_RAST]);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_rasterizer = {
    +	.validate = nvfx_state_rasterizer_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_RAST
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From 938c6905cfa4e25c8e898c8d91ee0fe8174abe0b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 23:17:41 +0100
    Subject: nv30, nv40: unify identical nv[34]0_state_scissor.c
    
    ---
     src/gallium/drivers/nv30/Makefile             |  1 -
     src/gallium/drivers/nv30/nv30_context.h       |  1 -
     src/gallium/drivers/nv30/nv30_state_scissor.c | 36 ---------------------------
     src/gallium/drivers/nv40/Makefile             |  1 -
     src/gallium/drivers/nv40/nv40_context.h       |  1 -
     src/gallium/drivers/nv40/nv40_state_scissor.c | 36 ---------------------------
     src/gallium/drivers/nvfx/Makefile             |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h       |  1 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c    |  2 +-
     src/gallium/drivers/nvfx/nvfx_state_scissor.c | 36 +++++++++++++++++++++++++++
     10 files changed, 39 insertions(+), 77 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_scissor.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_scissor.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_scissor.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 668f5965b1..bbfca55e49 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_fb.c \
    -	nv30_state_scissor.c \
     	nv30_state_stipple.c \
     	nv30_state_viewport.c \
     	nv30_state_zsa.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index fbafbec383..5a5311e5a9 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -24,7 +24,6 @@ extern void nv30_fragprog_destroy(struct nvfx_context *,
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern struct nvfx_state_entry nv30_state_scissor;
     extern struct nvfx_state_entry nv30_state_stipple;
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
    diff --git a/src/gallium/drivers/nv30/nv30_state_scissor.c b/src/gallium/drivers/nv30/nv30_state_scissor.c
    deleted file mode 100644
    index e91680e2d1..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_scissor.c
    +++ /dev/null
    @@ -1,36 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_scissor_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    -	struct pipe_scissor_state *s = &nvfx->scissor;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
    -	    (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
    -		return FALSE;
    -	nvfx->state.scissor_enabled = rast->scissor;
    -
    -	so = so_new(1, 2, 0);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    -	if (nvfx->state.scissor_enabled) {
    -		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
    -		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    -	} else {
    -		so_data  (so, 4096 << 16);
    -		so_data  (so, 4096 << 16);
    -	}
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_scissor = {
    -	.validate = nv30_state_scissor_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_SCISSOR
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 25ad2974bf..02bbb15f81 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_fb.c \
    -	nv40_state_scissor.c \
     	nv40_state_stipple.c \
     	nv40_state_viewport.c \
     	nv40_state_zsa.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index fc8b06bd0f..d3464ad7a3 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -28,7 +28,6 @@ extern void nv40_fragprog_destroy(struct nvfx_context *,
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern struct nvfx_state_entry nv40_state_scissor;
     extern struct nvfx_state_entry nv40_state_stipple;
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
    diff --git a/src/gallium/drivers/nv40/nv40_state_scissor.c b/src/gallium/drivers/nv40/nv40_state_scissor.c
    deleted file mode 100644
    index 11ec5c0878..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_scissor.c
    +++ /dev/null
    @@ -1,36 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_scissor_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    -	struct pipe_scissor_state *s = &nvfx->scissor;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
    -	    (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
    -		return FALSE;
    -	nvfx->state.scissor_enabled = rast->scissor;
    -
    -	so = so_new(1, 2, 0);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    -	if (nvfx->state.scissor_enabled) {
    -		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
    -		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    -	} else {
    -		so_data  (so, 4096 << 16);
    -		so_data  (so, 4096 << 16);
    -	}
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_scissor = {
    -	.validate = nv40_state_scissor_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_SCISSOR
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index f1843b61df..8f4edb6543 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -8,6 +8,7 @@ C_SOURCES = \
     	nvfx_state_emit.c \
     	nvfx_state_blend.c \
     	nvfx_state_rasterizer.c \
    +	nvfx_state_scissor.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index c7ce17ab38..d5817ac5f8 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -184,6 +184,7 @@ struct nvfx_state_entry {
     extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
    +extern struct nvfx_state_entry nvfx_state_scissor;
     
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 60df50aa1c..cf73f81fb2 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -7,7 +7,7 @@
     static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvxx##_state_framebuffer, \
     	&nvfx_state_rasterizer, \
    -	&nvxx##_state_scissor, \
    +	&nvfx_state_scissor, \
     	&nvxx##_state_stipple, \
     	&nvxx##_state_fragprog, \
     	&nvxx##_state_fragtex, \
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_scissor.c b/src/gallium/drivers/nvfx/nvfx_state_scissor.c
    new file mode 100644
    index 0000000000..940d8cb5c0
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_scissor.c
    @@ -0,0 +1,36 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_scissor_validate(struct nvfx_context *nvfx)
    +{
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct pipe_scissor_state *s = &nvfx->scissor;
    +	struct nouveau_stateobj *so;
    +
    +	if (nvfx->state.hw[NVFX_STATE_SCISSOR] &&
    +	    (rast->scissor == 0 && nvfx->state.scissor_enabled == 0))
    +		return FALSE;
    +	nvfx->state.scissor_enabled = rast->scissor;
    +
    +	so = so_new(1, 2, 0);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_SCISSOR_HORIZ, 2);
    +	if (nvfx->state.scissor_enabled) {
    +		so_data  (so, ((s->maxx - s->minx) << 16) | s->minx);
    +		so_data  (so, ((s->maxy - s->miny) << 16) | s->miny);
    +	} else {
    +		so_data  (so, 4096 << 16);
    +		so_data  (so, 4096 << 16);
    +	}
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SCISSOR]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_scissor = {
    +	.validate = nvfx_state_scissor_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_SCISSOR | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_SCISSOR
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From 64d882637dc97b332eb3c0f457376f86b75c8c5f Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 23:19:40 +0100
    Subject: nv30, nv40: unify identical nv[34]0_state_zsa.c
    
    ---
     src/gallium/drivers/nv30/Makefile          |  1 -
     src/gallium/drivers/nv30/nv30_context.h    |  2 --
     src/gallium/drivers/nv30/nv30_state_zsa.c  | 41 ------------------------------
     src/gallium/drivers/nv40/Makefile          |  1 -
     src/gallium/drivers/nv40/nv40_context.h    |  2 --
     src/gallium/drivers/nv40/nv40_state_zsa.c  | 41 ------------------------------
     src/gallium/drivers/nvfx/Makefile          |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h    |  2 ++
     src/gallium/drivers/nvfx/nvfx_state_emit.c |  4 +--
     src/gallium/drivers/nvfx/nvfx_state_zsa.c  | 41 ++++++++++++++++++++++++++++++
     10 files changed, 46 insertions(+), 90 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_zsa.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_zsa.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_zsa.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index bbfca55e49..8f198ff2b7 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -15,7 +15,6 @@ C_SOURCES = \
     	nv30_state_fb.c \
     	nv30_state_stipple.c \
     	nv30_state_viewport.c \
    -	nv30_state_zsa.c \
     	nv30_surface.c \
     	nv30_vbo.c \
     	nv30_vertprog.c
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 5a5311e5a9..2ee12ef5d8 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -27,12 +27,10 @@ extern void nv30_fragtex_bind(struct nvfx_context *);
     extern struct nvfx_state_entry nv30_state_stipple;
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
    -extern struct nvfx_state_entry nv30_state_zsa;
     extern struct nvfx_state_entry nv30_state_viewport;
     extern struct nvfx_state_entry nv30_state_framebuffer;
     extern struct nvfx_state_entry nv30_state_fragtex;
     extern struct nvfx_state_entry nv30_state_vbo;
    -extern struct nvfx_state_entry nv30_state_sr;
     
     /* nv30_vbo.c */
     extern void nv30_draw_arrays(struct pipe_context *, unsigned mode,
    diff --git a/src/gallium/drivers/nv30/nv30_state_zsa.c b/src/gallium/drivers/nv30/nv30_state_zsa.c
    deleted file mode 100644
    index 0832408edf..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_zsa.c
    +++ /dev/null
    @@ -1,41 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_zsa_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->zsa->so,
    -	       &nvfx->state.hw[NVFX_STATE_ZSA]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_zsa = {
    -	.validate = nv30_state_zsa_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_ZSA,
    -		.hw = NVFX_STATE_ZSA
    -	}
    -};
    -
    -static boolean
    -nv30_state_sr_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *so = so_new(2, 2, 0);
    -	struct pipe_stencil_ref *sr = &nvfx->stencil_ref;
    -
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    -	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    -	so_data  (so, sr->ref_value[1]);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_SR]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_sr = {
    -	.validate = nv30_state_sr_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SR,
    -		.hw = NVFX_STATE_SR
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 02bbb15f81..1cad9409ed 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -15,7 +15,6 @@ C_SOURCES = \
     	nv40_state_fb.c \
     	nv40_state_stipple.c \
     	nv40_state_viewport.c \
    -	nv40_state_zsa.c \
     	nv40_surface.c \
     	nv40_vbo.c \
     	nv40_vertprog.c
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index d3464ad7a3..3dcbbae30b 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -31,13 +31,11 @@ extern void nv40_fragtex_bind(struct nvfx_context *);
     extern struct nvfx_state_entry nv40_state_stipple;
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
    -extern struct nvfx_state_entry nv40_state_zsa;
     extern struct nvfx_state_entry nv40_state_viewport;
     extern struct nvfx_state_entry nv40_state_framebuffer;
     extern struct nvfx_state_entry nv40_state_fragtex;
     extern struct nvfx_state_entry nv40_state_vbo;
     extern struct nvfx_state_entry nv40_state_vtxfmt;
    -extern struct nvfx_state_entry nv40_state_sr;
     
     /* nv40_vbo.c */
     extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
    diff --git a/src/gallium/drivers/nv40/nv40_state_zsa.c b/src/gallium/drivers/nv40/nv40_state_zsa.c
    deleted file mode 100644
    index 00facd520a..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_zsa.c
    +++ /dev/null
    @@ -1,41 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_zsa_validate(struct nvfx_context *nvfx)
    -{
    -	so_ref(nvfx->zsa->so,
    -	       &nvfx->state.hw[NVFX_STATE_ZSA]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_zsa = {
    -	.validate = nv40_state_zsa_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_ZSA,
    -		.hw = NVFX_STATE_ZSA
    -	}
    -};
    -
    -static boolean
    -nv40_state_sr_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *so = so_new(2, 2, 0);
    -	struct pipe_stencil_ref *sr = &nvfx->stencil_ref;
    -
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    -	so_data  (so, sr->ref_value[0]);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    -	so_data  (so, sr->ref_value[1]);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_SR]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_sr = {
    -	.validate = nv40_state_sr_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SR,
    -		.hw = NVFX_STATE_SR
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 8f4edb6543..b077713b04 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,7 @@ C_SOURCES = \
     	nvfx_state_blend.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
    +	nvfx_state_zsa.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index d5817ac5f8..d97cf30a1d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -185,6 +185,8 @@ extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
    +extern struct nvfx_state_entry nvfx_state_sr;
    +extern struct nvfx_state_entry nvfx_state_zsa;
     
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index cf73f81fb2..a30af174e3 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -14,8 +14,8 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvxx##_state_vertprog, \
     	&nvfx_state_blend, \
     	&nvfx_state_blend_colour, \
    -	&nvxx##_state_zsa, \
    -	&nvxx##_state_sr, \
    +	&nvfx_state_zsa, \
    +	&nvfx_state_sr, \
     	&nvxx##_state_viewport, \
     	&nvxx##_state_##vbo, \
     	NULL \
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_zsa.c b/src/gallium/drivers/nvfx/nvfx_state_zsa.c
    new file mode 100644
    index 0000000000..c84fd041c1
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_zsa.c
    @@ -0,0 +1,41 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_zsa_validate(struct nvfx_context *nvfx)
    +{
    +	so_ref(nvfx->zsa->so,
    +	       &nvfx->state.hw[NVFX_STATE_ZSA]);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_zsa = {
    +	.validate = nvfx_state_zsa_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_ZSA,
    +		.hw = NVFX_STATE_ZSA
    +	}
    +};
    +
    +static boolean
    +nvfx_state_sr_validate(struct nvfx_context *nvfx)
    +{
    +	struct nouveau_stateobj *so = so_new(2, 2, 0);
    +	struct pipe_stencil_ref *sr = &nvfx->stencil_ref;
    +
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_FRONT_FUNC_REF, 1);
    +	so_data  (so, sr->ref_value[0]);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_STENCIL_BACK_FUNC_REF, 1);
    +	so_data  (so, sr->ref_value[1]);
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_SR]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_sr = {
    +	.validate = nvfx_state_sr_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_SR,
    +		.hw = NVFX_STATE_SR
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From e392e0b148d6b499322e58a84f300e2e0be49e29 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 19:22:57 +0100
    Subject: nv30, nv40: unify nv[34]0_state_stipple.c
    
    The files are identical, except for the fact that the nv40 version
    forgets to unreference the stateobj.
    
    Unified to the correct nv30 version.
    ---
     src/gallium/drivers/nv30/Makefile             |  1 -
     src/gallium/drivers/nv30/nv30_context.h       |  1 -
     src/gallium/drivers/nv30/nv30_state_stipple.c | 40 ---------------------------
     src/gallium/drivers/nv40/Makefile             |  1 -
     src/gallium/drivers/nv40/nv40_context.h       |  1 -
     src/gallium/drivers/nv40/nv40_state_stipple.c | 39 --------------------------
     src/gallium/drivers/nvfx/Makefile             |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h       |  1 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c    |  2 +-
     src/gallium/drivers/nvfx/nvfx_state_stipple.c | 40 +++++++++++++++++++++++++++
     10 files changed, 43 insertions(+), 84 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_stipple.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_stipple.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_stipple.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 8f198ff2b7..5541a36618 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_fb.c \
    -	nv30_state_stipple.c \
     	nv30_state_viewport.c \
     	nv30_surface.c \
     	nv30_vbo.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 2ee12ef5d8..1c2572aa86 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -24,7 +24,6 @@ extern void nv30_fragprog_destroy(struct nvfx_context *,
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern struct nvfx_state_entry nv30_state_stipple;
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
     extern struct nvfx_state_entry nv30_state_viewport;
    diff --git a/src/gallium/drivers/nv30/nv30_state_stipple.c b/src/gallium/drivers/nv30/nv30_state_stipple.c
    deleted file mode 100644
    index eceb0c57f9..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_stipple.c
    +++ /dev/null
    @@ -1,40 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_stipple_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_STIPPLE] &&
    -	   (rast->poly_stipple_enable == 0 && nvfx->state.stipple_enabled == 0))
    -		return FALSE;
    -
    -	if (rast->poly_stipple_enable) {
    -		unsigned i;
    -
    -		so = so_new(2, 33, 0);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -		so_data  (so, 1);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    -		for (i = 0; i < 32; i++)
    -			so_data(so, nvfx->stipple[i]);
    -	} else {
    -		so = so_new(1, 1, 0);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_STIPPLE]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_stipple = {
    -	.validate = nv30_state_stipple_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_STIPPLE | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_STIPPLE,
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 1cad9409ed..a101cfc80c 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -13,7 +13,6 @@ C_SOURCES = \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_fb.c \
    -	nv40_state_stipple.c \
     	nv40_state_viewport.c \
     	nv40_surface.c \
     	nv40_vbo.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 3dcbbae30b..127502dd5f 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -28,7 +28,6 @@ extern void nv40_fragprog_destroy(struct nvfx_context *,
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern struct nvfx_state_entry nv40_state_stipple;
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
     extern struct nvfx_state_entry nv40_state_viewport;
    diff --git a/src/gallium/drivers/nv40/nv40_state_stipple.c b/src/gallium/drivers/nv40/nv40_state_stipple.c
    deleted file mode 100644
    index e537e08e1d..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_stipple.c
    +++ /dev/null
    @@ -1,39 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_stipple_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_STIPPLE] &&
    -	   (rast->poly_stipple_enable == 0 && nvfx->state.stipple_enabled == 0))
    -		return FALSE;
    -
    -	if (rast->poly_stipple_enable) {
    -		unsigned i;
    -
    -		so = so_new(2, 33, 0);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -		so_data  (so, 1);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    -		for (i = 0; i < 32; i++)
    -			so_data(so, nvfx->stipple[i]);
    -	} else {
    -		so = so_new(1, 1, 0);
    -		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_STIPPLE]);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_stipple = {
    -	.validate = nv40_state_stipple_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_STIPPLE | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_STIPPLE,
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index b077713b04..e96c9aa6bc 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,7 @@ C_SOURCES = \
     	nvfx_state_blend.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
    +        nvfx_state_stipple.c \
     	nvfx_state_zsa.c \
     	nvfx_transfer.c
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index d97cf30a1d..8f5013a9d6 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -186,6 +186,7 @@ extern struct nvfx_state_entry nvfx_state_blend_colour;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
    +extern struct nvfx_state_entry nvfx_state_stipple;
     extern struct nvfx_state_entry nvfx_state_zsa;
     
     /* nvfx_clear.c */
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index a30af174e3..04c0429ce1 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -8,7 +8,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvxx##_state_framebuffer, \
     	&nvfx_state_rasterizer, \
     	&nvfx_state_scissor, \
    -	&nvxx##_state_stipple, \
    +	&nvfx_state_stipple, \
     	&nvxx##_state_fragprog, \
     	&nvxx##_state_fragtex, \
     	&nvxx##_state_vertprog, \
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_stipple.c b/src/gallium/drivers/nvfx/nvfx_state_stipple.c
    new file mode 100644
    index 0000000000..57cd3c936a
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_stipple.c
    @@ -0,0 +1,40 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_stipple_validate(struct nvfx_context *nvfx)
    +{
    +	struct pipe_rasterizer_state *rast = &nvfx->rasterizer->pipe;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct nouveau_stateobj *so;
    +
    +	if (nvfx->state.hw[NVFX_STATE_STIPPLE] &&
    +	   (rast->poly_stipple_enable == 0 && nvfx->state.stipple_enabled == 0))
    +		return FALSE;
    +
    +	if (rast->poly_stipple_enable) {
    +		unsigned i;
    +
    +		so = so_new(2, 33, 0);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_data  (so, 1);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_PATTERN(0), 32);
    +		for (i = 0; i < 32; i++)
    +			so_data(so, nvfx->stipple[i]);
    +	} else {
    +		so = so_new(1, 1, 0);
    +		so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_STIPPLE]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_stipple = {
    +	.validate = nvfx_state_stipple_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_STIPPLE | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_STIPPLE,
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From 8611a31bb401fcc2bdc0b3624859fffff7236c4b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 19:32:29 +0100
    Subject: nv30, nv40: unify nv[34]0_miptree.c
    
    The only difference between nv30 and nv40 is that nv30 allowed swizzling
    for more texture types.
    
    This patch preserves the existing behavior, using conditional code.
    
    Note however that this does not make sense, since all texture types can
    be swizzled on nv40 and probably on nv30 too.
    
    However, the handling of swizzled surfaces in the current 2D code is
    partially broken, so it's best not to touch this.
    
    A whole rewrite of the 2D code will be submitted, which will solve this
    problem.
    ---
     src/gallium/drivers/nv30/Makefile       |   1 -
     src/gallium/drivers/nv30/nv30_context.h |   2 -
     src/gallium/drivers/nv30/nv30_miptree.c | 240 -------------------------------
     src/gallium/drivers/nv30/nv30_screen.c  |   2 +-
     src/gallium/drivers/nv40/Makefile       |   1 -
     src/gallium/drivers/nv40/nv40_context.h |   2 -
     src/gallium/drivers/nv40/nv40_miptree.c | 236 ------------------------------
     src/gallium/drivers/nv40/nv40_screen.c  |   2 +-
     src/gallium/drivers/nvfx/Makefile       |   1 +
     src/gallium/drivers/nvfx/nvfx_miptree.c | 247 ++++++++++++++++++++++++++++++++
     10 files changed, 250 insertions(+), 484 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_miptree.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_miptree.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_miptree.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 5541a36618..d8de297f12 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -8,7 +8,6 @@ C_SOURCES = \
     	nv30_draw.c \
     	nv30_fragprog.c \
     	nv30_fragtex.c \
    -	nv30_miptree.c \
     	nv30_query.c \
     	nv30_screen.c \
     	nv30_state.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 1c2572aa86..46b36ee2e5 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -7,8 +7,6 @@ extern void nv30_init_state_functions(struct nvfx_context *nvfx);
     extern void nv30_init_surface_functions(struct nvfx_context *nvfx);
     extern void nv30_init_query_functions(struct nvfx_context *nvfx);
     
    -extern void nv30_screen_init_miptree_functions(struct pipe_screen *pscreen);
    -
     /* nv30_draw.c */
     extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
     
    diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
    deleted file mode 100644
    index ada355a444..0000000000
    --- a/src/gallium/drivers/nv30/nv30_miptree.c
    +++ /dev/null
    @@ -1,240 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -#include "util/u_math.h"
    -
    -#include "nv30_context.h"
    -#include "../nouveau/nv04_surface_2d.h"
    -
    -static void
    -nv30_miptree_layout(struct nvfx_miptree *nv30mt)
    -{
    -	struct pipe_texture *pt = &nv30mt->base;
    -	uint width = pt->width0;
    -	uint offset = 0;
    -	int nr_faces, l, f;
    -	uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
    -		                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
    -		                           PIPE_TEXTURE_USAGE_RENDER_TARGET |
    -		                           PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    -		                           PIPE_TEXTURE_USAGE_SCANOUT);
    -
    -	if (pt->target == PIPE_TEXTURE_CUBE) {
    -		nr_faces = 6;
    -	} else
    -	if (pt->target == PIPE_TEXTURE_3D) {
    -		nr_faces = pt->depth0;
    -	} else {
    -		nr_faces = 1;
    -	}
    -
    -	for (l = 0; l <= pt->last_level; l++) {
    -		if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
    -			nv30mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
    -		else
    -			nv30mt->level[l].pitch = util_format_get_stride(pt->format, width);
    -
    -		nv30mt->level[l].image_offset =
    -			CALLOC(nr_faces, sizeof(unsigned));
    -
    -		width  = u_minify(width, 1);
    -	}
    -
    -	for (f = 0; f < nr_faces; f++) {
    -		for (l = 0; l < pt->last_level; l++) {
    -			nv30mt->level[l].image_offset[f] = offset;
    -
    -			if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
    -			    u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
    -				offset += align(nv30mt->level[l].pitch * u_minify(pt->height0, l), 64);
    -			else
    -				offset += nv30mt->level[l].pitch * u_minify(pt->height0, l);
    -		}
    -
    -		nv30mt->level[l].image_offset[f] = offset;
    -		offset += nv30mt->level[l].pitch * u_minify(pt->height0, l);
    -	}
    -
    -	nv30mt->total_size = offset;
    -}
    -
    -static struct pipe_texture *
    -nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
    -{
    -	struct nvfx_miptree *mt;
    -	unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
    -	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
    -
    -	mt = MALLOC(sizeof(struct nvfx_miptree));
    -	if (!mt)
    -		return NULL;
    -	mt->base = *pt;
    -	pipe_reference_init(&mt->base.reference, 1);
    -	mt->base.screen = pscreen;
    -
    -	/* Swizzled textures must be POT */
    -	if (pt->width0 & (pt->width0 - 1) ||
    -	    pt->height0 & (pt->height0 - 1))
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else
    -	if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
    -	                     PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    -	                     PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else {
    -		switch (pt->format) {
    -		/* TODO: Figure out which formats can be swizzled */
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		case PIPE_FORMAT_R16_SNORM:
    -		case PIPE_FORMAT_B5G6R5_UNORM:
    -		case PIPE_FORMAT_L8A8_UNORM:
    -		case PIPE_FORMAT_A8_UNORM:
    -		case PIPE_FORMAT_L8_UNORM:
    -		case PIPE_FORMAT_I8_UNORM:
    -		{
    -			if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
    -				mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    - 			break;
    -		}
    -		default:
    -			mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -		}
    -	}
    -
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    -		buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    -
    -	/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
    -	 * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
    -	 * This also happens for small mipmaps of large textures. */
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -
    -	nv30_miptree_layout(mt);
    -
    -	mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage,
    -				       mt->total_size);
    -	if (!mt->buffer) {
    -		FREE(mt);
    -		return NULL;
    -	}
    -	mt->bo = nouveau_bo(mt->buffer);
    -
    -	return &mt->base;
    -}
    -
    -static struct pipe_texture *
    -nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
    -		     const unsigned *stride, struct pipe_buffer *pb)
    -{
    -	struct nvfx_miptree *mt;
    -
    -	/* Only supports 2D, non-mipmapped textures for the moment */
    -	if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
    -	    pt->depth0 != 1)
    -		return NULL;
    -
    -	mt = CALLOC_STRUCT(nvfx_miptree);
    -	if (!mt)
    -		return NULL;
    -
    -	mt->base = *pt;
    -	pipe_reference_init(&mt->base.reference, 1);
    -	mt->base.screen = pscreen;
    -	mt->level[0].pitch = stride[0];
    -	mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
    -
    -	/* Assume whoever created this buffer expects it to be linear for now */
    -	mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -
    -	pipe_buffer_reference(&mt->buffer, pb);
    -	mt->bo = nouveau_bo(mt->buffer);
    -	return &mt->base;
    -}
    -
    -static void
    -nv30_miptree_destroy(struct pipe_texture *pt)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    -	int l;
    -
    -	pipe_buffer_reference(&mt->buffer, NULL);
    -	for (l = 0; l <= pt->last_level; l++) {
    -		if (mt->level[l].image_offset)
    -			FREE(mt->level[l].image_offset);
    -	}
    -
    -	FREE(mt);
    -}
    -
    -static struct pipe_surface *
    -nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
    -			 unsigned face, unsigned level, unsigned zslice,
    -			 unsigned flags)
    -{
    -	struct nvfx_miptree *nv30mt = (struct nvfx_miptree *)pt;
    -	struct nv04_surface *ns;
    -
    -	ns = CALLOC_STRUCT(nv04_surface);
    -	if (!ns)
    -		return NULL;
    -	pipe_texture_reference(&ns->base.texture, pt);
    -	ns->base.format = pt->format;
    -	ns->base.width = u_minify(pt->width0, level);
    -	ns->base.height = u_minify(pt->height0, level);
    -	ns->base.usage = flags;
    -	pipe_reference_init(&ns->base.reference, 1);
    -	ns->base.face = face;
    -	ns->base.level = level;
    -	ns->base.zslice = zslice;
    -	ns->pitch = nv30mt->level[level].pitch;
    -
    -	if (pt->target == PIPE_TEXTURE_CUBE) {
    -		ns->base.offset = nv30mt->level[level].image_offset[face];
    -	} else
    -	if (pt->target == PIPE_TEXTURE_3D) {
    -		ns->base.offset = nv30mt->level[level].image_offset[zslice];
    -	} else {
    -		ns->base.offset = nv30mt->level[level].image_offset[0];
    -	}
    -
    -	/* create a linear temporary that we can render into if necessary.
    -	 * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
    -	 * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
    -	if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
    -		return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
    -
    -	return &ns->base;
    -}
    -
    -static void
    -nv30_miptree_surface_del(struct pipe_surface *ps)
    -{
    -	struct nv04_surface* ns = (struct nv04_surface*)ps;
    -	if(ns->backing)
    -	{
    -		struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
    -		if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
    -			screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
    -		nv30_miptree_surface_del(&ns->backing->base);
    -	}
    -
    -	pipe_texture_reference(&ps->texture, NULL);
    -	FREE(ps);
    -}
    -
    -void
    -nv30_screen_init_miptree_functions(struct pipe_screen *pscreen)
    -{
    -	pscreen->texture_create = nv30_miptree_create;
    -	pscreen->texture_destroy = nv30_miptree_destroy;
    -	pscreen->get_tex_surface = nv30_miptree_surface_new;
    -	pscreen->tex_surface_destroy = nv30_miptree_surface_del;
    -
    -	nouveau_screen(pscreen)->texture_blanket = nv30_miptree_blanket;
    -}
    diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
    index 305dfa8386..3a48255c18 100644
    --- a/src/gallium/drivers/nv30/nv30_screen.c
    +++ b/src/gallium/drivers/nv30/nv30_screen.c
    @@ -213,7 +213,7 @@ nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	pscreen->is_format_supported = nv30_screen_surface_format_supported;
     	pscreen->context_create = nv30_create;
     
    -	nv30_screen_init_miptree_functions(pscreen);
    +	nvfx_screen_init_miptree_functions(pscreen);
     
     	/* 3D object */
     	switch (dev->chipset & 0xf0) {
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index a101cfc80c..bf68338e3f 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -8,7 +8,6 @@ C_SOURCES = \
     	nv40_draw.c \
     	nv40_fragprog.c \
     	nv40_fragtex.c \
    -	nv40_miptree.c \
     	nv40_query.c \
     	nv40_screen.c \
     	nv40_state.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 127502dd5f..fe44452f81 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -7,8 +7,6 @@ extern void nv40_init_state_functions(struct nvfx_context *nvfx);
     extern void nv40_init_surface_functions(struct nvfx_context *nvfx);
     extern void nv40_init_query_functions(struct nvfx_context *nvfx);
     
    -extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
    -
     /* nv40_draw.c */
     extern struct draw_stage *nv40_draw_render_stage(struct nvfx_context *nvfx);
     extern void nv40_draw_elements_swtnl(struct pipe_context *pipe,
    diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
    deleted file mode 100644
    index caec47058f..0000000000
    --- a/src/gallium/drivers/nv40/nv40_miptree.c
    +++ /dev/null
    @@ -1,236 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -#include "util/u_math.h"
    -
    -#include "nv40_context.h"
    -#include "../nouveau/nv04_surface_2d.h"
    -
    -
    -
    -static void
    -nv40_miptree_layout(struct nvfx_miptree *mt)
    -{
    -	struct pipe_texture *pt = &mt->base;
    -	uint width = pt->width0;
    -	uint offset = 0;
    -	int nr_faces, l, f;
    -	uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
    -		                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
    -		                           PIPE_TEXTURE_USAGE_RENDER_TARGET |
    -		                           PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    -		                           PIPE_TEXTURE_USAGE_SCANOUT);
    -
    -	if (pt->target == PIPE_TEXTURE_CUBE) {
    -		nr_faces = 6;
    -	} else
    -	if (pt->target == PIPE_TEXTURE_3D) {
    -		nr_faces = pt->depth0;
    -	} else {
    -		nr_faces = 1;
    -	}
    -
    -	for (l = 0; l <= pt->last_level; l++) {
    -		if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
    -			mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
    -		else
    -			mt->level[l].pitch = util_format_get_stride(pt->format, width);
    -
    -		mt->level[l].image_offset =
    -			CALLOC(nr_faces, sizeof(unsigned));
    -
    -		width  = u_minify(width, 1);
    -	}
    -
    -	for (f = 0; f < nr_faces; f++) {
    -		for (l = 0; l < pt->last_level; l++) {
    -			mt->level[l].image_offset[f] = offset;
    -
    -			if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
    -			    u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
    -				offset += align(mt->level[l].pitch * u_minify(pt->height0, l), 64);
    -			else
    -				offset += mt->level[l].pitch * u_minify(pt->height0, l);
    -		}
    -
    -		mt->level[l].image_offset[f] = offset;
    -		offset += mt->level[l].pitch * u_minify(pt->height0, l);
    -	}
    -
    -	mt->total_size = offset;
    -}
    -
    -static struct pipe_texture *
    -nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
    -{
    -	struct nvfx_miptree *mt;
    -	unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
    -	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
    -
    -	mt = MALLOC(sizeof(struct nvfx_miptree));
    -	if (!mt)
    -		return NULL;
    -	mt->base = *pt;
    -	pipe_reference_init(&mt->base.reference, 1);
    -	mt->base.screen = pscreen;
    -
    -	/* Swizzled textures must be POT */
    -	if (pt->width0 & (pt->width0 - 1) ||
    -	    pt->height0 & (pt->height0 - 1))
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else
    -	if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
    -	                     PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    -	                     PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	else {
    -		switch (pt->format) {
    -		/* TODO: Figure out which formats can be swizzled */
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		case PIPE_FORMAT_R16_SNORM:
    -		{
    -			if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
    -				mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -			break;
    -		}
    -		default:
    -			mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -		}
    -	}
    -
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    -		buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    -
    -	/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
    -	 * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
    -	 * This also happens for small mipmaps of large textures. */
    -	if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
    -		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -
    -	nv40_miptree_layout(mt);
    -
    -	mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
    -	if (!mt->buffer) {
    -		FREE(mt);
    -		return NULL;
    -	}
    -	mt->bo = nouveau_bo(mt->buffer);
    -	return &mt->base;
    -}
    -
    -static struct pipe_texture *
    -nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
    -		     const unsigned *stride, struct pipe_buffer *pb)
    -{
    -	struct nvfx_miptree *mt;
    -
    -	/* Only supports 2D, non-mipmapped textures for the moment */
    -	if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
    -	    pt->depth0 != 1)
    -		return NULL;
    -
    -	mt = CALLOC_STRUCT(nvfx_miptree);
    -	if (!mt)
    -		return NULL;
    -
    -	mt->base = *pt;
    -	pipe_reference_init(&mt->base.reference, 1);
    -	mt->base.screen = pscreen;
    -	mt->level[0].pitch = stride[0];
    -	mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
    -
    -	/* Assume whoever created this buffer expects it to be linear for now */
    -	mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    -
    -	pipe_buffer_reference(&mt->buffer, pb);
    -	mt->bo = nouveau_bo(mt->buffer);
    -	return &mt->base;
    -}
    -
    -static void
    -nv40_miptree_destroy(struct pipe_texture *pt)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    -	int l;
    -
    -	pipe_buffer_reference(&mt->buffer, NULL);
    -	for (l = 0; l <= pt->last_level; l++) {
    -		if (mt->level[l].image_offset)
    -			FREE(mt->level[l].image_offset);
    -	}
    -
    -	FREE(mt);
    -}
    -
    -static struct pipe_surface *
    -nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
    -			 unsigned face, unsigned level, unsigned zslice,
    -			 unsigned flags)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    -	struct nv04_surface *ns;
    -
    -	ns = CALLOC_STRUCT(nv04_surface);
    -	if (!ns)
    -		return NULL;
    -	pipe_texture_reference(&ns->base.texture, pt);
    -	ns->base.format = pt->format;
    -	ns->base.width = u_minify(pt->width0, level);
    -	ns->base.height = u_minify(pt->height0, level);
    -	ns->base.usage = flags;
    -	pipe_reference_init(&ns->base.reference, 1);
    -	ns->base.face = face;
    -	ns->base.level = level;
    -	ns->base.zslice = zslice;
    -	ns->pitch = mt->level[level].pitch;
    -
    -	if (pt->target == PIPE_TEXTURE_CUBE) {
    -		ns->base.offset = mt->level[level].image_offset[face];
    -	} else
    -	if (pt->target == PIPE_TEXTURE_3D) {
    -		ns->base.offset = mt->level[level].image_offset[zslice];
    -	} else {
    -		ns->base.offset = mt->level[level].image_offset[0];
    -	}
    -
    -	/* create a linear temporary that we can render into if necessary.
    -	 * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
    -	 * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
    -	if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
    -		return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
    -
    -	return &ns->base;
    -}
    -
    -static void
    -nv40_miptree_surface_del(struct pipe_surface *ps)
    -{
    -	struct nv04_surface* ns = (struct nv04_surface*)ps;
    -	if(ns->backing)
    -	{
    -		struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
    -		if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
    -			screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
    -		nv40_miptree_surface_del(&ns->backing->base);
    -	}
    -
    -	pipe_texture_reference(&ps->texture, NULL);
    -	FREE(ps);
    -}
    -
    -void
    -nv40_screen_init_miptree_functions(struct pipe_screen *pscreen)
    -{
    -	pscreen->texture_create = nv40_miptree_create;
    -	pscreen->texture_destroy = nv40_miptree_destroy;
    -	pscreen->get_tex_surface = nv40_miptree_surface_new;
    -	pscreen->tex_surface_destroy = nv40_miptree_surface_del;
    -
    -	nouveau_screen(pscreen)->texture_blanket = nv40_miptree_blanket;
    -}
    -
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    index c64864d58d..0603b7d1c1 100644
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ b/src/gallium/drivers/nv40/nv40_screen.c
    @@ -203,7 +203,7 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	pscreen->is_format_supported = nv40_screen_surface_format_supported;
     	pscreen->context_create = nv40_create;
     
    -	nv40_screen_init_miptree_functions(pscreen);
    +	nvfx_screen_init_miptree_functions(pscreen);
     
     	/* 3D object */
     	switch (dev->chipset & 0xf0) {
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index e96c9aa6bc..5073168604 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -6,6 +6,7 @@ LIBNAME = nvfx
     C_SOURCES = \
     	nvfx_clear.c \
     	nvfx_state_emit.c \
    +	nvfx_miptree.c \
     	nvfx_state_blend.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c
    new file mode 100644
    index 0000000000..5dced8dae4
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_miptree.c
    @@ -0,0 +1,247 @@
    +#include "pipe/p_state.h"
    +#include "pipe/p_defines.h"
    +#include "util/u_inlines.h"
    +#include "util/u_format.h"
    +#include "util/u_math.h"
    +
    +#include "nvfx_context.h"
    +#include "../nouveau/nv04_surface_2d.h"
    +
    +
    +
    +static void
    +nvfx_miptree_layout(struct nvfx_miptree *mt)
    +{
    +	struct pipe_texture *pt = &mt->base;
    +	uint width = pt->width0;
    +	uint offset = 0;
    +	int nr_faces, l, f;
    +	uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
    +		                           PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
    +		                           PIPE_TEXTURE_USAGE_RENDER_TARGET |
    +		                           PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    +		                           PIPE_TEXTURE_USAGE_SCANOUT);
    +
    +	if (pt->target == PIPE_TEXTURE_CUBE) {
    +		nr_faces = 6;
    +	} else
    +	if (pt->target == PIPE_TEXTURE_3D) {
    +		nr_faces = pt->depth0;
    +	} else {
    +		nr_faces = 1;
    +	}
    +
    +	for (l = 0; l <= pt->last_level; l++) {
    +		if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
    +			mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
    +		else
    +			mt->level[l].pitch = util_format_get_stride(pt->format, width);
    +
    +		mt->level[l].image_offset =
    +			CALLOC(nr_faces, sizeof(unsigned));
    +
    +		width  = u_minify(width, 1);
    +	}
    +
    +	for (f = 0; f < nr_faces; f++) {
    +		for (l = 0; l < pt->last_level; l++) {
    +			mt->level[l].image_offset[f] = offset;
    +
    +			if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
    +			    u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
    +				offset += align(mt->level[l].pitch * u_minify(pt->height0, l), 64);
    +			else
    +				offset += mt->level[l].pitch * u_minify(pt->height0, l);
    +		}
    +
    +		mt->level[l].image_offset[f] = offset;
    +		offset += mt->level[l].pitch * u_minify(pt->height0, l);
    +	}
    +
    +	mt->total_size = offset;
    +}
    +
    +static struct pipe_texture *
    +nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
    +{
    +	struct nvfx_miptree *mt;
    +	unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
    +	                     NOUVEAU_BUFFER_USAGE_TEXTURE;
    +
    +	mt = MALLOC(sizeof(struct nvfx_miptree));
    +	if (!mt)
    +		return NULL;
    +	mt->base = *pt;
    +	pipe_reference_init(&mt->base.reference, 1);
    +	mt->base.screen = pscreen;
    +
    +	/* Swizzled textures must be POT */
    +	if (pt->width0 & (pt->width0 - 1) ||
    +	    pt->height0 & (pt->height0 - 1))
    +		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +	else
    +	if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
    +	                     PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
    +	                     PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
    +		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +	else
    +	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    +		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +	else {
    +		switch (pt->format) {
    +		case PIPE_FORMAT_B5G6R5_UNORM:
    +		case PIPE_FORMAT_L8A8_UNORM:
    +		case PIPE_FORMAT_A8_UNORM:
    +		case PIPE_FORMAT_L8_UNORM:
    +		case PIPE_FORMAT_I8_UNORM:
    +			/* TODO: we can actually swizzle these formats on nv40, we
    +				are just preserving the pre-unification behavior.
    +				The whole 2D code is going to be rewritten anyway. */
    +			if(nvfx_screen(pscreen)->is_nv4x) {
    +				mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +				break;
    +			}
    +		/* TODO: Figure out which formats can be swizzled */
    +		case PIPE_FORMAT_B8G8R8A8_UNORM:
    +		case PIPE_FORMAT_B8G8R8X8_UNORM:
    +		case PIPE_FORMAT_R16_SNORM:
    +		{
    +			if (debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE))
    +				mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +			break;
    +		}
    +		default:
    +			mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +		}
    +	}
    +
    +	if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
    +		buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
    +
    +	/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
    +	 * If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
    +	 * This also happens for small mipmaps of large textures. */
    +	if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
    +		mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +
    +	nvfx_miptree_layout(mt);
    +
    +	mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
    +	if (!mt->buffer) {
    +		FREE(mt);
    +		return NULL;
    +	}
    +	mt->bo = nouveau_bo(mt->buffer);
    +	return &mt->base;
    +}
    +
    +static struct pipe_texture *
    +nvfx_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
    +		     const unsigned *stride, struct pipe_buffer *pb)
    +{
    +	struct nvfx_miptree *mt;
    +
    +	/* Only supports 2D, non-mipmapped textures for the moment */
    +	if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
    +	    pt->depth0 != 1)
    +		return NULL;
    +
    +	mt = CALLOC_STRUCT(nvfx_miptree);
    +	if (!mt)
    +		return NULL;
    +
    +	mt->base = *pt;
    +	pipe_reference_init(&mt->base.reference, 1);
    +	mt->base.screen = pscreen;
    +	mt->level[0].pitch = stride[0];
    +	mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
    +
    +	/* Assume whoever created this buffer expects it to be linear for now */
    +	mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
    +
    +	pipe_buffer_reference(&mt->buffer, pb);
    +	mt->bo = nouveau_bo(mt->buffer);
    +	return &mt->base;
    +}
    +
    +static void
    +nvfx_miptree_destroy(struct pipe_texture *pt)
    +{
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    +	int l;
    +
    +	pipe_buffer_reference(&mt->buffer, NULL);
    +	for (l = 0; l <= pt->last_level; l++) {
    +		if (mt->level[l].image_offset)
    +			FREE(mt->level[l].image_offset);
    +	}
    +
    +	FREE(mt);
    +}
    +
    +static struct pipe_surface *
    +nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
    +			 unsigned face, unsigned level, unsigned zslice,
    +			 unsigned flags)
    +{
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    +	struct nv04_surface *ns;
    +
    +	ns = CALLOC_STRUCT(nv04_surface);
    +	if (!ns)
    +		return NULL;
    +	pipe_texture_reference(&ns->base.texture, pt);
    +	ns->base.format = pt->format;
    +	ns->base.width = u_minify(pt->width0, level);
    +	ns->base.height = u_minify(pt->height0, level);
    +	ns->base.usage = flags;
    +	pipe_reference_init(&ns->base.reference, 1);
    +	ns->base.face = face;
    +	ns->base.level = level;
    +	ns->base.zslice = zslice;
    +	ns->pitch = mt->level[level].pitch;
    +
    +	if (pt->target == PIPE_TEXTURE_CUBE) {
    +		ns->base.offset = mt->level[level].image_offset[face];
    +	} else
    +	if (pt->target == PIPE_TEXTURE_3D) {
    +		ns->base.offset = mt->level[level].image_offset[zslice];
    +	} else {
    +		ns->base.offset = mt->level[level].image_offset[0];
    +	}
    +
    +	/* create a linear temporary that we can render into if necessary.
    +	 * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
    +	 * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
    +	if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
    +		return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
    +
    +	return &ns->base;
    +}
    +
    +static void
    +nvfx_miptree_surface_del(struct pipe_surface *ps)
    +{
    +	struct nv04_surface* ns = (struct nv04_surface*)ps;
    +	if(ns->backing)
    +	{
    +		struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
    +		if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
    +			screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
    +		nvfx_miptree_surface_del(&ns->backing->base);
    +	}
    +
    +	pipe_texture_reference(&ps->texture, NULL);
    +	FREE(ps);
    +}
    +
    +void
    +nvfx_screen_init_miptree_functions(struct pipe_screen *pscreen)
    +{
    +	pscreen->texture_create = nvfx_miptree_create;
    +	pscreen->texture_destroy = nvfx_miptree_destroy;
    +	pscreen->get_tex_surface = nvfx_miptree_surface_new;
    +	pscreen->tex_surface_destroy = nvfx_miptree_surface_del;
    +
    +	nouveau_screen(pscreen)->texture_blanket = nvfx_miptree_blanket;
    +}
    -- 
    cgit v1.2.3
    
    
    From 9937116c7b15468088a224da478d927347a76f32 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 19:39:24 +0100
    Subject: nv30, nv40: unify nv[34]0_query.c
    
    The files are identical except formatting.
    ---
     src/gallium/drivers/nv30/Makefile       |   2 -
     src/gallium/drivers/nv30/nv30_context.c |   4 +-
     src/gallium/drivers/nv30/nv30_context.h |   2 -
     src/gallium/drivers/nv30/nv30_query.c   | 127 --------------------------------
     src/gallium/drivers/nv30/nv30_surface.c |  62 ----------------
     src/gallium/drivers/nv40/Makefile       |   2 -
     src/gallium/drivers/nv40/nv40_context.c |   4 +-
     src/gallium/drivers/nv40/nv40_context.h |   2 -
     src/gallium/drivers/nv40/nv40_query.c   | 127 --------------------------------
     src/gallium/drivers/nv40/nv40_surface.c |  64 ----------------
     src/gallium/drivers/nvfx/Makefile       |   2 +
     src/gallium/drivers/nvfx/nvfx_context.h |   3 +
     src/gallium/drivers/nvfx/nvfx_query.c   | 127 ++++++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_surface.c |  62 ++++++++++++++++
     14 files changed, 198 insertions(+), 392 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_query.c
     delete mode 100644 src/gallium/drivers/nv30/nv30_surface.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_query.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_surface.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_query.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_surface.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index d8de297f12..4f9798de0c 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -8,12 +8,10 @@ C_SOURCES = \
     	nv30_draw.c \
     	nv30_fragprog.c \
     	nv30_fragtex.c \
    -	nv30_query.c \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_fb.c \
     	nv30_state_viewport.c \
    -	nv30_surface.c \
     	nv30_vbo.c \
     	nv30_vertprog.c
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 6fe8cb3e32..f13458d50a 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -73,8 +73,8 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     
     	nvfx->is_nv4x = screen->is_nv4x;
     
    -	nv30_init_query_functions(nvfx);
    -	nv30_init_surface_functions(nvfx);
    +	nvfx_init_query_functions(nvfx);
    +	nvfx_init_surface_functions(nvfx);
     	nv30_init_state_functions(nvfx);
     	nvfx_init_transfer_functions(nvfx);
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 46b36ee2e5..a0a1c335ec 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -4,8 +4,6 @@
     #include "nvfx_context.h"
     
     extern void nv30_init_state_functions(struct nvfx_context *nvfx);
    -extern void nv30_init_surface_functions(struct nvfx_context *nvfx);
    -extern void nv30_init_query_functions(struct nvfx_context *nvfx);
     
     /* nv30_draw.c */
     extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
    diff --git a/src/gallium/drivers/nv30/nv30_query.c b/src/gallium/drivers/nv30/nv30_query.c
    deleted file mode 100644
    index 53b11a8943..0000000000
    --- a/src/gallium/drivers/nv30/nv30_query.c
    +++ /dev/null
    @@ -1,127 +0,0 @@
    -#include "pipe/p_context.h"
    -
    -#include "nv30_context.h"
    -
    -struct nv30_query {
    -	struct nouveau_resource *object;
    -	unsigned type;
    -	boolean ready;
    -	uint64_t result;
    -};
    -
    -static INLINE struct nv30_query *
    -nv30_query(struct pipe_query *pipe)
    -{
    -	return (struct nv30_query *)pipe;
    -}
    -
    -static struct pipe_query *
    -nv30_query_create(struct pipe_context *pipe, unsigned query_type)
    -{
    -	struct nv30_query *q;
    -
    -	q = CALLOC(1, sizeof(struct nv30_query));
    -	q->type = query_type;
    -
    -	return (struct pipe_query *)q;
    -}
    -
    -static void
    -nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nv30_query *q = nv30_query(pq);
    -
    -	if (q->object)
    -		nouveau_resource_free(&q->object);
    -	FREE(q);
    -}
    -
    -static void
    -nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv30_query *q = nv30_query(pq);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    -
    -	/* Happens when end_query() is called, then another begin_query()
    -	 * without querying the result in-between.  For now we'll wait for
    -	 * the existing query to notify completion, but it could be better.
    -	 */
    -	if (q->object) {
    -		uint64_t tmp;
    -		pipe->get_query_result(pipe, pq, 1, &tmp);
    -	}
    -
    -	if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
    -		assert(0);
    -	nouveau_notifier_reset(nvfx->screen->query, q->object->start);
    -
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
    -	OUT_RING  (chan, 1);
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
    -	OUT_RING  (chan, 1);
    -
    -	q->ready = FALSE;
    -}
    -
    -static void
    -nv30_query_end(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	struct nv30_query *q = nv30_query(pq);
    -
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
    -	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
    -		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
    -	FIRE_RING(chan);
    -}
    -
    -static boolean
    -nv30_query_result(struct pipe_context *pipe, struct pipe_query *pq,
    -		  boolean wait, uint64_t *result)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv30_query *q = nv30_query(pq);
    -
    -	assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    -
    -	if (!q->ready) {
    -		unsigned status;
    -
    -		status = nouveau_notifier_status(nvfx->screen->query,
    -						 q->object->start);
    -		if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
    -			if (wait == FALSE)
    -				return FALSE;
    -
    -			nouveau_notifier_wait_status(nvfx->screen->query,
    -					q->object->start,
    -					NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
    -		}
    -
    -		q->result = nouveau_notifier_return_val(nvfx->screen->query,
    -							q->object->start);
    -		q->ready = TRUE;
    -		nouveau_resource_free(&q->object);
    -	}
    -
    -	*result = q->result;
    -	return TRUE;
    -}
    -
    -void
    -nv30_init_query_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.create_query = nv30_query_create;
    -	nvfx->pipe.destroy_query = nv30_query_destroy;
    -	nvfx->pipe.begin_query = nv30_query_begin;
    -	nvfx->pipe.end_query = nv30_query_end;
    -	nvfx->pipe.get_query_result = nv30_query_result;
    -}
    diff --git a/src/gallium/drivers/nv30/nv30_surface.c b/src/gallium/drivers/nv30/nv30_surface.c
    deleted file mode 100644
    index 613a9fa492..0000000000
    --- a/src/gallium/drivers/nv30/nv30_surface.c
    +++ /dev/null
    @@ -1,62 +0,0 @@
    -
    -/**************************************************************************
    - * 
    - * Copyright 2003 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 "nv30_context.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -#include "util/u_tile.h"
    -
    -static void
    -nv30_surface_copy(struct pipe_context *pipe,
    -		  struct pipe_surface *dest, unsigned destx, unsigned desty,
    -		  struct pipe_surface *src, unsigned srcx, unsigned srcy,
    -		  unsigned width, unsigned height)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    -
    -	eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
    -}
    -
    -static void
    -nv30_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
    -		  unsigned destx, unsigned desty, unsigned width,
    -		  unsigned height, unsigned value)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    -
    -	eng2d->fill(eng2d, dest, destx, desty, width, height, value);
    -}
    -
    -void
    -nv30_init_surface_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.surface_copy = nv30_surface_copy;
    -	nvfx->pipe.surface_fill = nv30_surface_fill;
    -}
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index bf68338e3f..0b3607be89 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -8,12 +8,10 @@ C_SOURCES = \
     	nv40_draw.c \
     	nv40_fragprog.c \
     	nv40_fragtex.c \
    -	nv40_query.c \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_fb.c \
     	nv40_state_viewport.c \
    -	nv40_surface.c \
     	nv40_vbo.c \
     	nv40_vertprog.c
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 12f57377cd..441b038b05 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -73,8 +73,8 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     
     	nvfx->is_nv4x = screen->is_nv4x;
     
    -	nv40_init_query_functions(nvfx);
    -	nv40_init_surface_functions(nvfx);
    +	nvfx_init_query_functions(nvfx);
    +	nvfx_init_surface_functions(nvfx);
     	nv40_init_state_functions(nvfx);
     	nvfx_init_transfer_functions(nvfx);
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index fe44452f81..4353d78cd2 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -4,8 +4,6 @@
     #include "nvfx_context.h"
     
     extern void nv40_init_state_functions(struct nvfx_context *nvfx);
    -extern void nv40_init_surface_functions(struct nvfx_context *nvfx);
    -extern void nv40_init_query_functions(struct nvfx_context *nvfx);
     
     /* nv40_draw.c */
     extern struct draw_stage *nv40_draw_render_stage(struct nvfx_context *nvfx);
    diff --git a/src/gallium/drivers/nv40/nv40_query.c b/src/gallium/drivers/nv40/nv40_query.c
    deleted file mode 100644
    index 48cfc4d593..0000000000
    --- a/src/gallium/drivers/nv40/nv40_query.c
    +++ /dev/null
    @@ -1,127 +0,0 @@
    -#include "pipe/p_context.h"
    -
    -#include "nv40_context.h"
    -
    -struct nv40_query {
    -	struct nouveau_resource *object;
    -	unsigned type;
    -	boolean ready;
    -	uint64_t result;
    -};
    -
    -static INLINE struct nv40_query *
    -nv40_query(struct pipe_query *pipe)
    -{
    -	return (struct nv40_query *)pipe;
    -}
    -
    -static struct pipe_query *
    -nv40_query_create(struct pipe_context *pipe, unsigned query_type)
    -{
    -	struct nv40_query *q;
    -
    -	q = CALLOC(1, sizeof(struct nv40_query));
    -	q->type = query_type;
    -
    -	return (struct pipe_query *)q;
    -}
    -
    -static void
    -nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nv40_query *q = nv40_query(pq);
    -
    -	if (q->object)
    -		nouveau_resource_free(&q->object);
    -	FREE(q);
    -}
    -
    -static void
    -nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv40_query *q = nv40_query(pq);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    -
    -	/* Happens when end_query() is called, then another begin_query()
    -	 * without querying the result in-between.  For now we'll wait for
    -	 * the existing query to notify completion, but it could be better.
    -	 */
    -	if (q->object) {
    -		uint64_t tmp;
    -		pipe->get_query_result(pipe, pq, 1, &tmp);
    -	}
    -
    -	if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
    -		assert(0);
    -	nouveau_notifier_reset(nvfx->screen->query, q->object->start);
    -
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
    -	OUT_RING  (chan, 1);
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
    -	OUT_RING  (chan, 1);
    -
    -	q->ready = FALSE;
    -}
    -
    -static void
    -nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv40_query *q = nv40_query(pq);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
    -	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
    -		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
    -	FIRE_RING(chan);
    -}
    -
    -static boolean
    -nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
    -		  boolean wait, uint64_t *result)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv40_query *q = nv40_query(pq);
    -
    -	assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    -
    -	if (!q->ready) {
    -		unsigned status;
    -
    -		status = nouveau_notifier_status(nvfx->screen->query,
    -						 q->object->start);
    -		if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
    -			if (wait == FALSE)
    -				return FALSE;
    -			nouveau_notifier_wait_status(nvfx->screen->query,
    -					      q->object->start,
    -					      NV_NOTIFY_STATE_STATUS_COMPLETED,
    -					      0);
    -		}
    -
    -		q->result = nouveau_notifier_return_val(nvfx->screen->query,
    -							q->object->start);
    -		q->ready = TRUE;
    -		nouveau_resource_free(&q->object);
    -	}
    -
    -	*result = q->result;
    -	return TRUE;
    -}
    -
    -void
    -nv40_init_query_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.create_query = nv40_query_create;
    -	nvfx->pipe.destroy_query = nv40_query_destroy;
    -	nvfx->pipe.begin_query = nv40_query_begin;
    -	nvfx->pipe.end_query = nv40_query_end;
    -	nvfx->pipe.get_query_result = nv40_query_result;
    -}
    diff --git a/src/gallium/drivers/nv40/nv40_surface.c b/src/gallium/drivers/nv40/nv40_surface.c
    deleted file mode 100644
    index 328c23b8b4..0000000000
    --- a/src/gallium/drivers/nv40/nv40_surface.c
    +++ /dev/null
    @@ -1,64 +0,0 @@
    -
    -/**************************************************************************
    - * 
    - * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
    - * All Rights Reserved.
    - * 
    - * Permission is hereby granted, free of charge, to any person obtaining a
    - * copy of this software and associated documentation files (the
    - * "Software"), to deal in the Software without restriction, including
    - * without limitation the rights to use, copy, modify, merge, publish,
    - * distribute, sub license, and/or sell copies of the Software, and to
    - * permit persons to whom the Software is furnished to do so, subject to
    - * the following conditions:
    - * 
    - * The above copyright notice and this permission notice (including the
    - * next paragraph) shall be included in all copies or substantial portions
    - * of the Software.
    - * 
    - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
    - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
    - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    - * 
    - **************************************************************************/
    -
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -
    -#include "util/u_tile.h"
    -
    -#include "nv40_context.h"
    -
    -static void
    -nv40_surface_copy(struct pipe_context *pipe,
    -		  struct pipe_surface *dest, unsigned destx, unsigned desty,
    -		  struct pipe_surface *src, unsigned srcx, unsigned srcy,
    -		  unsigned width, unsigned height)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    -
    -	eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
    -}
    -
    -static void
    -nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
    -		  unsigned destx, unsigned desty, unsigned width,
    -		  unsigned height, unsigned value)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    -
    -	eng2d->fill(eng2d, dest, destx, desty, width, height, value);
    -}
    -
    -void
    -nv40_init_surface_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.surface_copy = nv40_surface_copy;
    -	nvfx->pipe.surface_fill = nv40_surface_fill;
    -}
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 5073168604..f51ab1856b 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -7,11 +7,13 @@ C_SOURCES = \
     	nvfx_clear.c \
     	nvfx_state_emit.c \
     	nvfx_miptree.c \
    +	nvfx_query.c \
     	nvfx_state_blend.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
             nvfx_state_stipple.c \
     	nvfx_state_zsa.c \
    +	nvfx_surface.c \
     	nvfx_transfer.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 8f5013a9d6..5f61d4450d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -189,6 +189,9 @@ extern struct nvfx_state_entry nvfx_state_sr;
     extern struct nvfx_state_entry nvfx_state_stipple;
     extern struct nvfx_state_entry nvfx_state_zsa;
     
    +extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
    +extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
    +
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
    diff --git a/src/gallium/drivers/nvfx/nvfx_query.c b/src/gallium/drivers/nvfx/nvfx_query.c
    new file mode 100644
    index 0000000000..acbaf75a23
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_query.c
    @@ -0,0 +1,127 @@
    +#include "pipe/p_context.h"
    +
    +#include "nvfx_context.h"
    +
    +struct nvfx_query {
    +	struct nouveau_resource *object;
    +	unsigned type;
    +	boolean ready;
    +	uint64_t result;
    +};
    +
    +static INLINE struct nvfx_query *
    +nvfx_query(struct pipe_query *pipe)
    +{
    +	return (struct nvfx_query *)pipe;
    +}
    +
    +static struct pipe_query *
    +nvfx_query_create(struct pipe_context *pipe, unsigned query_type)
    +{
    +	struct nvfx_query *q;
    +
    +	q = CALLOC(1, sizeof(struct nvfx_query));
    +	q->type = query_type;
    +
    +	return (struct pipe_query *)q;
    +}
    +
    +static void
    +nvfx_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
    +{
    +	struct nvfx_query *q = nvfx_query(pq);
    +
    +	if (q->object)
    +		nouveau_resource_free(&q->object);
    +	FREE(q);
    +}
    +
    +static void
    +nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_query *q = nvfx_query(pq);
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    +
    +	/* Happens when end_query() is called, then another begin_query()
    +	 * without querying the result in-between.  For now we'll wait for
    +	 * the existing query to notify completion, but it could be better.
    +	 */
    +	if (q->object) {
    +		uint64_t tmp;
    +		pipe->get_query_result(pipe, pq, 1, &tmp);
    +	}
    +
    +	if (nouveau_resource_alloc(nvfx->screen->query_heap, 1, NULL, &q->object))
    +		assert(0);
    +	nouveau_notifier_reset(nvfx->screen->query, q->object->start);
    +
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
    +	OUT_RING  (chan, 1);
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
    +	OUT_RING  (chan, 1);
    +
    +	q->ready = FALSE;
    +}
    +
    +static void
    +nvfx_query_end(struct pipe_context *pipe, struct pipe_query *pq)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	struct nvfx_query *q = nvfx_query(pq);
    +
    +	BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
    +	OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
    +		   ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
    +	FIRE_RING(chan);
    +}
    +
    +static boolean
    +nvfx_query_result(struct pipe_context *pipe, struct pipe_query *pq,
    +		  boolean wait, uint64_t *result)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_query *q = nvfx_query(pq);
    +
    +	assert(q->object && q->type == PIPE_QUERY_OCCLUSION_COUNTER);
    +
    +	if (!q->ready) {
    +		unsigned status;
    +
    +		status = nouveau_notifier_status(nvfx->screen->query,
    +						 q->object->start);
    +		if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
    +			if (wait == FALSE)
    +				return FALSE;
    +
    +			nouveau_notifier_wait_status(nvfx->screen->query,
    +					q->object->start,
    +					NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
    +		}
    +
    +		q->result = nouveau_notifier_return_val(nvfx->screen->query,
    +							q->object->start);
    +		q->ready = TRUE;
    +		nouveau_resource_free(&q->object);
    +	}
    +
    +	*result = q->result;
    +	return TRUE;
    +}
    +
    +void
    +nvfx_init_query_functions(struct nvfx_context *nvfx)
    +{
    +	nvfx->pipe.create_query = nvfx_query_create;
    +	nvfx->pipe.destroy_query = nvfx_query_destroy;
    +	nvfx->pipe.begin_query = nvfx_query_begin;
    +	nvfx->pipe.end_query = nvfx_query_end;
    +	nvfx->pipe.get_query_result = nvfx_query_result;
    +}
    diff --git a/src/gallium/drivers/nvfx/nvfx_surface.c b/src/gallium/drivers/nvfx/nvfx_surface.c
    new file mode 100644
    index 0000000000..8a05ad0a57
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_surface.c
    @@ -0,0 +1,62 @@
    +
    +/**************************************************************************
    + *
    + * Copyright 2003 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 "nvfx_context.h"
    +#include "pipe/p_defines.h"
    +#include "util/u_inlines.h"
    +#include "util/u_tile.h"
    +
    +static void
    +nvfx_surface_copy(struct pipe_context *pipe,
    +		  struct pipe_surface *dest, unsigned destx, unsigned desty,
    +		  struct pipe_surface *src, unsigned srcx, unsigned srcy,
    +		  unsigned width, unsigned height)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    +
    +	eng2d->copy(eng2d, dest, destx, desty, src, srcx, srcy, width, height);
    +}
    +
    +static void
    +nvfx_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
    +		  unsigned destx, unsigned desty, unsigned width,
    +		  unsigned height, unsigned value)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nv04_surface_2d *eng2d = nvfx->screen->eng2d;
    +
    +	eng2d->fill(eng2d, dest, destx, desty, width, height, value);
    +}
    +
    +void
    +nvfx_init_surface_functions(struct nvfx_context *nvfx)
    +{
    +	nvfx->pipe.surface_copy = nvfx_surface_copy;
    +	nvfx->pipe.surface_fill = nvfx_surface_fill;
    +}
    -- 
    cgit v1.2.3
    
    
    From 4d93ef1a015c8ec7341b0793e87ec375014436b3 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 20 Feb 2010 23:30:59 +0100
    Subject: nv30, nv40: unify nv[34]0_state_viewport.c
    
    The files are identical, except for an extra comment in nv30.
    ---
     src/gallium/drivers/nv30/Makefile              |  1 -
     src/gallium/drivers/nv30/nv30_context.h        |  1 -
     src/gallium/drivers/nv30/nv30_state_viewport.c | 42 --------------------------
     src/gallium/drivers/nv40/Makefile              |  1 -
     src/gallium/drivers/nv40/nv40_context.h        |  1 -
     src/gallium/drivers/nv40/nv40_state_viewport.c | 38 -----------------------
     src/gallium/drivers/nvfx/Makefile              |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h        |  1 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c     |  2 +-
     src/gallium/drivers/nvfx/nvfx_state_viewport.c | 38 +++++++++++++++++++++++
     10 files changed, 41 insertions(+), 85 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_viewport.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_viewport.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_viewport.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 4f9798de0c..6ee0d8f248 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -11,7 +11,6 @@ C_SOURCES = \
     	nv30_screen.c \
     	nv30_state.c \
     	nv30_state_fb.c \
    -	nv30_state_viewport.c \
     	nv30_vbo.c \
     	nv30_vertprog.c
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index a0a1c335ec..37def47b61 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -22,7 +22,6 @@ extern void nv30_fragtex_bind(struct nvfx_context *);
     /* nv30_state.c and friends */
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
    -extern struct nvfx_state_entry nv30_state_viewport;
     extern struct nvfx_state_entry nv30_state_framebuffer;
     extern struct nvfx_state_entry nv30_state_fragtex;
     extern struct nvfx_state_entry nv30_state_vbo;
    diff --git a/src/gallium/drivers/nv30/nv30_state_viewport.c b/src/gallium/drivers/nv30/nv30_state_viewport.c
    deleted file mode 100644
    index 2e9d5b14c7..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_viewport.c
    +++ /dev/null
    @@ -1,42 +0,0 @@
    -#include "nv30_context.h"
    -
    -static boolean
    -nv30_state_viewport_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_viewport_state *vpt = &nvfx->viewport;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
    -	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
    -		return FALSE;
    -
    -	so = so_new(3, 10, 0);
    -	so_method(so, nvfx->screen->eng3d,
    -		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
    -	so_data  (so, fui(vpt->translate[0]));
    -	so_data  (so, fui(vpt->translate[1]));
    -	so_data  (so, fui(vpt->translate[2]));
    -	so_data  (so, fui(vpt->translate[3]));
    -	so_data  (so, fui(vpt->scale[0]));
    -	so_data  (so, fui(vpt->scale[1]));
    -	so_data  (so, fui(vpt->scale[2]));
    -	so_data  (so, fui(vpt->scale[3]));
    -/*	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    -	so_data  (so, 1);
    -*/
    -	/* TODO/FIXME: never saw value 0x0110 in renouveau dumps, only 0x0001 */
    -	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    -	so_data  (so, 1);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_viewport = {
    -	.validate = nv30_state_viewport_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_VIEWPORT
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 0b3607be89..85d6ce9886 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -11,7 +11,6 @@ C_SOURCES = \
     	nv40_screen.c \
     	nv40_state.c \
     	nv40_state_fb.c \
    -	nv40_state_viewport.c \
     	nv40_vbo.c \
     	nv40_vertprog.c
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 4353d78cd2..a3000eeca0 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -26,7 +26,6 @@ extern void nv40_fragtex_bind(struct nvfx_context *);
     /* nv40_state.c and friends */
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
    -extern struct nvfx_state_entry nv40_state_viewport;
     extern struct nvfx_state_entry nv40_state_framebuffer;
     extern struct nvfx_state_entry nv40_state_fragtex;
     extern struct nvfx_state_entry nv40_state_vbo;
    diff --git a/src/gallium/drivers/nv40/nv40_state_viewport.c b/src/gallium/drivers/nv40/nv40_state_viewport.c
    deleted file mode 100644
    index bf73e1119e..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_viewport.c
    +++ /dev/null
    @@ -1,38 +0,0 @@
    -#include "nv40_context.h"
    -
    -static boolean
    -nv40_state_viewport_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_viewport_state *vpt = &nvfx->viewport;
    -	struct nouveau_stateobj *so;
    -
    -	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
    -	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
    -		return FALSE;
    -
    -	so = so_new(2, 9, 0);
    -	so_method(so, nvfx->screen->eng3d,
    -		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
    -	so_data  (so, fui(vpt->translate[0]));
    -	so_data  (so, fui(vpt->translate[1]));
    -	so_data  (so, fui(vpt->translate[2]));
    -	so_data  (so, fui(vpt->translate[3]));
    -	so_data  (so, fui(vpt->scale[0]));
    -	so_data  (so, fui(vpt->scale[1]));
    -	so_data  (so, fui(vpt->scale[2]));
    -	so_data  (so, fui(vpt->scale[3]));
    -	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    -	so_data  (so, 1);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_viewport = {
    -	.validate = nv40_state_viewport_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    -		.hw = NVFX_STATE_VIEWPORT
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index f51ab1856b..2f198d9d1a 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -12,6 +12,7 @@ C_SOURCES = \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
             nvfx_state_stipple.c \
    +	nvfx_state_viewport.c \
     	nvfx_state_zsa.c \
     	nvfx_surface.c \
     	nvfx_transfer.c
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 5f61d4450d..b6e6cf8fd9 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -187,6 +187,7 @@ extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
     extern struct nvfx_state_entry nvfx_state_stipple;
    +extern struct nvfx_state_entry nvfx_state_viewport;
     extern struct nvfx_state_entry nvfx_state_zsa;
     
     extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 04c0429ce1..b86cb44936 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -16,7 +16,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_blend_colour, \
     	&nvfx_state_zsa, \
     	&nvfx_state_sr, \
    -	&nvxx##_state_viewport, \
    +	&nvfx_state_viewport, \
     	&nvxx##_state_##vbo, \
     	NULL \
     }
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_viewport.c b/src/gallium/drivers/nvfx/nvfx_state_viewport.c
    new file mode 100644
    index 0000000000..72057a80f8
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_viewport.c
    @@ -0,0 +1,38 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_state_viewport_validate(struct nvfx_context *nvfx)
    +{
    +	struct pipe_viewport_state *vpt = &nvfx->viewport;
    +	struct nouveau_stateobj *so;
    +
    +	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
    +	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
    +		return FALSE;
    +
    +	so = so_new(2, 9, 0);
    +	so_method(so, nvfx->screen->eng3d,
    +		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
    +	so_data  (so, fui(vpt->translate[0]));
    +	so_data  (so, fui(vpt->translate[1]));
    +	so_data  (so, fui(vpt->translate[2]));
    +	so_data  (so, fui(vpt->translate[3]));
    +	so_data  (so, fui(vpt->scale[0]));
    +	so_data  (so, fui(vpt->scale[1]));
    +	so_data  (so, fui(vpt->scale[2]));
    +	so_data  (so, fui(vpt->scale[3]));
    +	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    +	so_data  (so, 1);
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_viewport = {
    +	.validate = nvfx_state_viewport_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    +		.hw = NVFX_STATE_VIEWPORT
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From cd0d03adab65a9586e0c5d60e9ee487677914f3b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 00:59:30 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_state_fb.c
    
    The files are significantly different due to:
    1. nv30 support 2 render targets, nv40 4
    2. z-buffer pitch is set differently
    3. nv30 has a limitation of colour_bits >= zeta_bits. This may not
       actually exist in the driver though
    4. nv30 points color0 at depth in the depth-only case
    5. nv30 sets NV34TCL_VIEWPORT_TX_ORIGIN to 0. This is probably
       unnecessary
    
    This patch attempts to unify the two files and preserve the existing
    behavior.
    ---
     src/gallium/drivers/nv30/Makefile          |   1 -
     src/gallium/drivers/nv30/nv30_context.h    |   1 -
     src/gallium/drivers/nv30/nv30_state_fb.c   | 173 ---------------------
     src/gallium/drivers/nv40/Makefile          |   1 -
     src/gallium/drivers/nv40/nv40_context.h    |   1 -
     src/gallium/drivers/nv40/nv40_state_fb.c   | 175 ---------------------
     src/gallium/drivers/nvfx/Makefile          |   1 +
     src/gallium/drivers/nvfx/nvfx_context.h    |   1 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c |   2 +-
     src/gallium/drivers/nvfx/nvfx_state_fb.c   | 234 +++++++++++++++++++++++++++++
     10 files changed, 237 insertions(+), 353 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state_fb.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state_fb.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state_fb.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 6ee0d8f248..b5728a34f8 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -10,7 +10,6 @@ C_SOURCES = \
     	nv30_fragtex.c \
     	nv30_screen.c \
     	nv30_state.c \
    -	nv30_state_fb.c \
     	nv30_vbo.c \
     	nv30_vertprog.c
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 37def47b61..c203425cc9 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -22,7 +22,6 @@ extern void nv30_fragtex_bind(struct nvfx_context *);
     /* nv30_state.c and friends */
     extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
    -extern struct nvfx_state_entry nv30_state_framebuffer;
     extern struct nvfx_state_entry nv30_state_fragtex;
     extern struct nvfx_state_entry nv30_state_vbo;
     
    diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c
    deleted file mode 100644
    index e9e215dcce..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state_fb.c
    +++ /dev/null
    @@ -1,173 +0,0 @@
    -#include "nv30_context.h"
    -#include "nouveau/nouveau_util.h"
    -
    -static boolean
    -nv30_state_framebuffer_validate(struct nvfx_context *nvfx)
    -{
    -	struct pipe_framebuffer_state *fb = &nvfx->framebuffer;
    -	struct nouveau_channel *chan = nvfx->screen->base.channel;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct nv04_surface *rt[2], *zeta = NULL;
    -	uint32_t rt_enable = 0, rt_format = 0;
    -	int i, colour_format = 0, zeta_format = 0, depth_only = 0;
    -	struct nouveau_stateobj *so = so_new(12, 18, 10);
    -	unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
    -	unsigned w = fb->width;
    -	unsigned h = fb->height;
    -	struct nvfx_miptree *nv30mt;
    -	int colour_bits = 32, zeta_bits = 32;
    -
    -	for (i = 0; i < fb->nr_cbufs; i++) {
    -		if (colour_format) {
    -			assert(colour_format == fb->cbufs[i]->format);
    -		} else {
    -			colour_format = fb->cbufs[i]->format;
    -			rt_enable |= (NV34TCL_RT_ENABLE_COLOR0 << i);
    -			rt[i] = (struct nv04_surface *)fb->cbufs[i];
    -		}
    -	}
    -
    -	if (rt_enable & NV34TCL_RT_ENABLE_COLOR1)
    -		rt_enable |= NV34TCL_RT_ENABLE_MRT;
    -
    -	if (fb->zsbuf) {
    -		zeta_format = fb->zsbuf->format;
    -		zeta = (struct nv04_surface *)fb->zsbuf;
    -	}
    -
    -	if (rt_enable & (NV34TCL_RT_ENABLE_COLOR0|NV34TCL_RT_ENABLE_COLOR1)) {
    -		/* Render to at least a colour buffer */
    -		if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    -			assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
    -			for (i = 1; i < fb->nr_cbufs; i++)
    -				assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
    -
    -			rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    -				(log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
    -				(log2i(rt[0]->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
    -		}
    -		else
    -			rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
    -	} else if (fb->zsbuf) {
    -		depth_only = 1;
    -
    -		/* Render to depth buffer only */
    -		if (!(zeta->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    -			assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
    -
    -			rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    -				(log2i(zeta->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
    -				(log2i(zeta->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
    -		}
    -		else
    -			rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
    -	} else {
    -		return FALSE;
    -	}
    -
    -	switch (colour_format) {
    -	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8;
    -		break;
    -	case PIPE_FORMAT_B8G8R8A8_UNORM:
    -	case 0:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8;
    -		break;
    -	case PIPE_FORMAT_B5G6R5_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
    -		colour_bits = 16;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	switch (zeta_format) {
    -	case PIPE_FORMAT_Z16_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
    -		zeta_bits = 16;
    -		break;
    -	case PIPE_FORMAT_S8Z24_UNORM:
    -	case PIPE_FORMAT_X8Z24_UNORM:
    -	case 0:
    -		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (colour_bits > zeta_bits) {
    -		return FALSE;
    -	}
    -
    -	if (depth_only || (rt_enable & NV34TCL_RT_ENABLE_COLOR0)) {
    -		struct nv04_surface *rt0 = (depth_only ? zeta : rt[0]);
    -		uint32_t pitch = rt0->pitch;
    -
    -		if (zeta) {
    -			pitch |= (zeta->pitch << 16);
    -		} else {
    -			pitch |= (pitch << 16);
    -		}
    -
    -		nv30mt = (struct nvfx_miptree *) rt0->base.texture;
    -		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_COLOR0_PITCH, 2);
    -		so_data  (so, pitch);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), rt0->base.offset,
    -			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
    -	}
    -
    -	if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
    -		nv30mt = (struct nvfx_miptree *)rt[1]->base.texture;
    -		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_COLOR1_OFFSET, 2);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), rt[1]->base.offset,
    -			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
    -		so_data  (so, rt[1]->pitch);
    -	}
    -
    -	if (zeta_format) {
    -		nv30mt = (struct nvfx_miptree *)zeta->base.texture;
    -		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), 0, rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_ZETA_OFFSET, 1);
    -		so_reloc (so, nouveau_bo(nv30mt->buffer), zeta->base.offset,
    -			      rt_flags | NOUVEAU_BO_LOW, 0, 0);
    -		/* TODO: allocate LMA depth buffer */
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_RT_ENABLE, 1);
    -	so_data  (so, rt_enable);
    -	so_method(so, eng3d, NV34TCL_RT_HORIZ, 3);
    -	so_data  (so, (w << 16) | 0);
    -	so_data  (so, (h << 16) | 0);
    -	so_data  (so, rt_format);
    -	so_method(so, eng3d, NV34TCL_VIEWPORT_HORIZ, 2);
    -	so_data  (so, (w << 16) | 0);
    -	so_data  (so, (h << 16) | 0);
    -	so_method(so, eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    -	so_data  (so, ((w - 1) << 16) | 0);
    -	so_data  (so, ((h - 1) << 16) | 0);
    -	so_method(so, eng3d, 0x1d88, 1);
    -	so_data  (so, (1 << 12) | h);
    -	/* Wonder why this is needed, context should all be set to zero on init */
    -	so_method(so, eng3d, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
    -	so_data  (so, 0);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_FB]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv30_state_framebuffer = {
    -	.validate = nv30_state_framebuffer_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_FB,
    -		.hw = NVFX_STATE_FB
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 85d6ce9886..f78e81ac4b 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -10,7 +10,6 @@ C_SOURCES = \
     	nv40_fragtex.c \
     	nv40_screen.c \
     	nv40_state.c \
    -	nv40_state_fb.c \
     	nv40_vbo.c \
     	nv40_vertprog.c
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index a3000eeca0..3840134ce6 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -26,7 +26,6 @@ extern void nv40_fragtex_bind(struct nvfx_context *);
     /* nv40_state.c and friends */
     extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
    -extern struct nvfx_state_entry nv40_state_framebuffer;
     extern struct nvfx_state_entry nv40_state_fragtex;
     extern struct nvfx_state_entry nv40_state_vbo;
     extern struct nvfx_state_entry nv40_state_vtxfmt;
    diff --git a/src/gallium/drivers/nv40/nv40_state_fb.c b/src/gallium/drivers/nv40/nv40_state_fb.c
    deleted file mode 100644
    index 95735e40a3..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state_fb.c
    +++ /dev/null
    @@ -1,175 +0,0 @@
    -#include "nv40_context.h"
    -#include "nouveau/nouveau_util.h"
    -
    -static struct pipe_buffer *
    -nv40_do_surface_buffer(struct pipe_surface *surface)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)surface->texture;
    -	return mt->buffer;
    -}
    -
    -#define nv40_surface_buffer(ps) nouveau_bo(nv40_do_surface_buffer(ps))
    -
    -static boolean
    -nv40_state_framebuffer_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_channel *chan = nvfx->screen->base.channel;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct pipe_framebuffer_state *fb = &nvfx->framebuffer;
    -	struct nv04_surface *rt[4], *zeta;
    -	uint32_t rt_enable, rt_format;
    -	int i, colour_format = 0, zeta_format = 0;
    -	struct nouveau_stateobj *so = so_new(18, 24, 10);
    -	unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
    -	unsigned w = fb->width;
    -	unsigned h = fb->height;
    -
    -	rt_enable = 0;
    -	for (i = 0; i < fb->nr_cbufs; i++) {
    -		if (colour_format) {
    -			assert(colour_format == fb->cbufs[i]->format);
    -		} else {
    -			colour_format = fb->cbufs[i]->format;
    -			rt_enable |= (NV40TCL_RT_ENABLE_COLOR0 << i);
    -			rt[i] = (struct nv04_surface *)fb->cbufs[i];
    -		}
    -	}
    -
    -	if (rt_enable & (NV40TCL_RT_ENABLE_COLOR1 | NV40TCL_RT_ENABLE_COLOR2 |
    -			 NV40TCL_RT_ENABLE_COLOR3))
    -		rt_enable |= NV40TCL_RT_ENABLE_MRT;
    -
    -	if (fb->zsbuf) {
    -		zeta_format = fb->zsbuf->format;
    -		zeta = (struct nv04_surface *)fb->zsbuf;
    -	}
    -
    -	if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    -		assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
    -		for (i = 1; i < fb->nr_cbufs; i++)
    -			assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
    -
    -		rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    -		            log2i(fb->width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT |
    -		            log2i(fb->height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT;
    -	}
    -	else
    -		rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
    -
    -	switch (colour_format) {
    -	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8;
    -		break;
    -	case PIPE_FORMAT_B8G8R8A8_UNORM:
    -	case 0:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8;
    -		break;
    -	case PIPE_FORMAT_B5G6R5_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	switch (zeta_format) {
    -	case PIPE_FORMAT_Z16_UNORM:
    -		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
    -		break;
    -	case PIPE_FORMAT_S8Z24_UNORM:
    -	case PIPE_FORMAT_X8Z24_UNORM:
    -	case 0:
    -		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
    -		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[0]->base), 0,
    -			      rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_COLOR0_PITCH, 2);
    -		so_data  (so, rt[0]->pitch);
    -		so_reloc (so, nv40_surface_buffer(&rt[0]->base),
    -			      rt[0]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    -			      0, 0);
    -	}
    -
    -	if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
    -		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[1]->base), 0,
    -			      rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_COLOR1_OFFSET, 2);
    -		so_reloc (so, nv40_surface_buffer(&rt[1]->base),
    -			      rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    -			      0, 0);
    -		so_data  (so, rt[1]->pitch);
    -	}
    -
    -	if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
    -		so_method(so, eng3d, NV40TCL_DMA_COLOR2, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[2]->base), 0,
    -			      rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV40TCL_COLOR2_OFFSET, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[2]->base),
    -			      rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    -			      0, 0);
    -		so_method(so, eng3d, NV40TCL_COLOR2_PITCH, 1);
    -		so_data  (so, rt[2]->pitch);
    -	}
    -
    -	if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
    -		so_method(so, eng3d, NV40TCL_DMA_COLOR3, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[3]->base), 0,
    -			      rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV40TCL_COLOR3_OFFSET, 1);
    -		so_reloc (so, nv40_surface_buffer(&rt[3]->base),
    -			      rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    -			      0, 0);
    -		so_method(so, eng3d, NV40TCL_COLOR3_PITCH, 1);
    -		so_data  (so, rt[3]->pitch);
    -	}
    -
    -	if (zeta_format) {
    -		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
    -		so_reloc (so, nv40_surface_buffer(&zeta->base), 0,
    -			      rt_flags | NOUVEAU_BO_OR,
    -			      chan->vram->handle, chan->gart->handle);
    -		so_method(so, eng3d, NV34TCL_ZETA_OFFSET, 1);
    -		so_reloc (so, nv40_surface_buffer(&zeta->base),
    -			      zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0);
    -		so_method(so, eng3d, NV40TCL_ZETA_PITCH, 1);
    -		so_data  (so, zeta->pitch);
    -	}
    -
    -	so_method(so, eng3d, NV40TCL_RT_ENABLE, 1);
    -	so_data  (so, rt_enable);
    -	so_method(so, eng3d, NV34TCL_RT_HORIZ, 3);
    -	so_data  (so, (w << 16) | 0);
    -	so_data  (so, (h << 16) | 0);
    -	so_data  (so, rt_format);
    -	so_method(so, eng3d, NV34TCL_VIEWPORT_HORIZ, 2);
    -	so_data  (so, (w << 16) | 0);
    -	so_data  (so, (h << 16) | 0);
    -	so_method(so, eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    -	so_data  (so, ((w - 1) << 16) | 0);
    -	so_data  (so, ((h - 1) << 16) | 0);
    -	so_method(so, eng3d, 0x1d88, 1);
    -	so_data  (so, (1 << 12) | h);
    -
    -	so_ref(so, &nvfx->state.hw[NVFX_STATE_FB]);
    -	so_ref(NULL, &so);
    -	return TRUE;
    -}
    -
    -struct nvfx_state_entry nv40_state_framebuffer = {
    -	.validate = nv40_state_framebuffer_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_FB,
    -		.hw = NVFX_STATE_FB
    -	}
    -};
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 2f198d9d1a..2f80681e5c 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,7 @@ C_SOURCES = \
     	nvfx_miptree.c \
     	nvfx_query.c \
     	nvfx_state_blend.c \
    +	nvfx_state_fb.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
             nvfx_state_stipple.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index b6e6cf8fd9..28daa1d2e7 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -183,6 +183,7 @@ struct nvfx_state_entry {
     
     extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
    +extern struct nvfx_state_entry nvfx_state_framebuffer;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index b86cb44936..d3088e4211 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -5,7 +5,7 @@
     
     #define RENDER_STATES(name, nvxx, vbo) \
     static struct nvfx_state_entry *name##_render_states[] = { \
    -	&nvxx##_state_framebuffer, \
    +	&nvfx_state_framebuffer, \
     	&nvfx_state_rasterizer, \
     	&nvfx_state_scissor, \
     	&nvfx_state_stipple, \
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_fb.c b/src/gallium/drivers/nvfx/nvfx_state_fb.c
    new file mode 100644
    index 0000000000..dd64ba4193
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state_fb.c
    @@ -0,0 +1,234 @@
    +#include "nvfx_context.h"
    +#include "nouveau/nouveau_util.h"
    +
    +static struct pipe_buffer *
    +nvfx_do_surface_buffer(struct pipe_surface *surface)
    +{
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)surface->texture;
    +	return mt->buffer;
    +}
    +
    +#define nvfx_surface_buffer(ps) nouveau_bo(nvfx_do_surface_buffer(ps))
    +
    +static boolean
    +nvfx_state_framebuffer_validate(struct nvfx_context *nvfx)
    +{
    +	struct pipe_framebuffer_state *fb = &nvfx->framebuffer;
    +	struct nouveau_channel *chan = nvfx->screen->base.channel;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct nv04_surface *rt[4], *zeta = NULL;
    +	uint32_t rt_enable = 0, rt_format = 0;
    +	int i, colour_format = 0, zeta_format = 0;
    +	int depth_only = 0;
    +	struct nouveau_stateobj *so = so_new(18, 24, 10);
    +	unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM;
    +	unsigned w = fb->width;
    +	unsigned h = fb->height;
    +	int colour_bits = 32, zeta_bits = 32;
    +
    +	if(!nvfx->is_nv4x)
    +		assert(fb->nr_cbufs <= 2);
    +	else
    +		assert(fb->nr_cbufs <= 4);
    +
    +	for (i = 0; i < fb->nr_cbufs; i++) {
    +		if (colour_format) {
    +			assert(colour_format == fb->cbufs[i]->format);
    +		} else {
    +			colour_format = fb->cbufs[i]->format;
    +			rt_enable |= (NV34TCL_RT_ENABLE_COLOR0 << i);
    +			rt[i] = (struct nv04_surface *)fb->cbufs[i];
    +		}
    +	}
    +
    +	if (rt_enable & (NV34TCL_RT_ENABLE_COLOR1 |
    +			 NV40TCL_RT_ENABLE_COLOR2 | NV40TCL_RT_ENABLE_COLOR3))
    +		rt_enable |= NV34TCL_RT_ENABLE_MRT;
    +
    +	if (fb->zsbuf) {
    +		zeta_format = fb->zsbuf->format;
    +		zeta = (struct nv04_surface *)fb->zsbuf;
    +	}
    +
    +	if (rt_enable & (NV34TCL_RT_ENABLE_COLOR0 | NV34TCL_RT_ENABLE_COLOR1 |
    +		NV40TCL_RT_ENABLE_COLOR2 | NV40TCL_RT_ENABLE_COLOR3)) {
    +		/* Render to at least a colour buffer */
    +		if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    +			assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
    +			for (i = 1; i < fb->nr_cbufs; i++)
    +				assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
    +
    +			rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    +				(log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
    +				(log2i(rt[0]->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
    +		}
    +		else
    +			rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
    +	} else if (fb->zsbuf) {
    +		depth_only = 1;
    +
    +		/* Render to depth buffer only */
    +		if (!(zeta->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    +			assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
    +
    +			rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
    +				(log2i(zeta->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
    +				(log2i(zeta->base.height) << NV34TCL_RT_FORMAT_LOG2_HEIGHT_SHIFT);
    +		}
    +		else
    +			rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR;
    +	} else {
    +		return FALSE;
    +	}
    +
    +	switch (colour_format) {
    +	case PIPE_FORMAT_B8G8R8X8_UNORM:
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_X8R8G8B8;
    +		break;
    +	case PIPE_FORMAT_B8G8R8A8_UNORM:
    +	case 0:
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_A8R8G8B8;
    +		break;
    +	case PIPE_FORMAT_B5G6R5_UNORM:
    +		rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
    +		colour_bits = 16;
    +		break;
    +	default:
    +		assert(0);
    +	}
    +
    +	switch (zeta_format) {
    +	case PIPE_FORMAT_Z16_UNORM:
    +		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16;
    +		zeta_bits = 16;
    +		break;
    +	case PIPE_FORMAT_S8Z24_UNORM:
    +	case PIPE_FORMAT_X8Z24_UNORM:
    +	case 0:
    +		rt_format |= NV34TCL_RT_FORMAT_ZETA_Z24S8;
    +		break;
    +	default:
    +		assert(0);
    +	}
    +
    +	if ((!nvfx->is_nv4x) && colour_bits > zeta_bits) {
    +		/* TODO: does this limitation really exist?
    +		   TODO: can it be worked around somehow? */
    +		return FALSE;
    +	}
    +
    +	if ((rt_enable & NV34TCL_RT_ENABLE_COLOR0)
    +		|| ((!nvfx->is_nv4x) && depth_only)) {
    +		struct nv04_surface *rt0 = (depth_only ? zeta : rt[0]);
    +		uint32_t pitch = rt0->pitch;
    +
    +		if(!nvfx->is_nv4x)
    +		{
    +			if (zeta) {
    +				pitch |= (zeta->pitch << 16);
    +			} else {
    +				pitch |= (pitch << 16);
    +			}
    +		}
    +
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR0, 1);
    +		so_reloc (so, nvfx_surface_buffer(&rt0->base), 0,
    +			      rt_flags | NOUVEAU_BO_OR,
    +			      chan->vram->handle, chan->gart->handle);
    +		so_method(so, eng3d, NV34TCL_COLOR0_PITCH, 2);
    +		so_data  (so, pitch);
    +		so_reloc (so, nvfx_surface_buffer(&rt[0]->base),
    +			      rt0->base.offset, rt_flags | NOUVEAU_BO_LOW,
    +			      0, 0);
    +	}
    +
    +	if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
    +		so_method(so, eng3d, NV34TCL_DMA_COLOR1, 1);
    +		so_reloc (so, nvfx_surface_buffer(&rt[1]->base), 0,
    +			      rt_flags | NOUVEAU_BO_OR,
    +			      chan->vram->handle, chan->gart->handle);
    +		so_method(so, eng3d, NV34TCL_COLOR1_OFFSET, 2);
    +		so_reloc (so, nvfx_surface_buffer(&rt[1]->base),
    +			      rt[1]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    +			      0, 0);
    +		so_data  (so, rt[1]->pitch);
    +	}
    +
    +	if(nvfx->is_nv4x)
    +	{
    +		if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
    +			so_method(so, eng3d, NV40TCL_DMA_COLOR2, 1);
    +			so_reloc (so, nvfx_surface_buffer(&rt[2]->base), 0,
    +				      rt_flags | NOUVEAU_BO_OR,
    +				      chan->vram->handle, chan->gart->handle);
    +			so_method(so, eng3d, NV40TCL_COLOR2_OFFSET, 1);
    +			so_reloc (so, nvfx_surface_buffer(&rt[2]->base),
    +				      rt[2]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    +				      0, 0);
    +			so_method(so, eng3d, NV40TCL_COLOR2_PITCH, 1);
    +			so_data  (so, rt[2]->pitch);
    +		}
    +
    +		if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
    +			so_method(so, eng3d, NV40TCL_DMA_COLOR3, 1);
    +			so_reloc (so, nvfx_surface_buffer(&rt[3]->base), 0,
    +				      rt_flags | NOUVEAU_BO_OR,
    +				      chan->vram->handle, chan->gart->handle);
    +			so_method(so, eng3d, NV40TCL_COLOR3_OFFSET, 1);
    +			so_reloc (so, nvfx_surface_buffer(&rt[3]->base),
    +				      rt[3]->base.offset, rt_flags | NOUVEAU_BO_LOW,
    +				      0, 0);
    +			so_method(so, eng3d, NV40TCL_COLOR3_PITCH, 1);
    +			so_data  (so, rt[3]->pitch);
    +		}
    +	}
    +
    +	if (zeta_format) {
    +		so_method(so, eng3d, NV34TCL_DMA_ZETA, 1);
    +		so_reloc (so, nvfx_surface_buffer(&zeta->base), 0,
    +			      rt_flags | NOUVEAU_BO_OR,
    +			      chan->vram->handle, chan->gart->handle);
    +		so_method(so, eng3d, NV34TCL_ZETA_OFFSET, 1);
    +		/* TODO: reverse engineer LMA */
    +		so_reloc (so, nvfx_surface_buffer(&zeta->base),
    +			      zeta->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0);
    +	        if(nvfx->is_nv4x) {
    +			so_method(so, eng3d, NV40TCL_ZETA_PITCH, 1);
    +			so_data  (so, zeta->pitch);
    +		}
    +	}
    +
    +	so_method(so, eng3d, NV34TCL_RT_ENABLE, 1);
    +	so_data  (so, rt_enable);
    +	so_method(so, eng3d, NV34TCL_RT_HORIZ, 3);
    +	so_data  (so, (w << 16) | 0);
    +	so_data  (so, (h << 16) | 0);
    +	so_data  (so, rt_format);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_HORIZ, 2);
    +	so_data  (so, (w << 16) | 0);
    +	so_data  (so, (h << 16) | 0);
    +	so_method(so, eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(0), 2);
    +	so_data  (so, ((w - 1) << 16) | 0);
    +	so_data  (so, ((h - 1) << 16) | 0);
    +	so_method(so, eng3d, 0x1d88, 1);
    +	so_data  (so, (1 << 12) | h);
    +
    +	if(!nvfx->is_nv4x) {
    +		/* Wonder why this is needed, context should all be set to zero on init */
    +		/* TODO: we can most likely remove this, after putting it in context init */
    +		so_method(so, eng3d, NV34TCL_VIEWPORT_TX_ORIGIN, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_ref(so, &nvfx->state.hw[NVFX_STATE_FB]);
    +	so_ref(NULL, &so);
    +	return TRUE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_framebuffer = {
    +	.validate = nvfx_state_framebuffer_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_FB,
    +		.hw = NVFX_STATE_FB
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From d9e396ce4a124529fa92ad967f2b3ff72534079b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 02:26:25 +0100
    Subject: nv30, nv40: non-trivially partially unify nv[34]0_shader.h
    
    shader.h is similar, except for the following differences:
    1. The instruction sets are not exactly the same, but mostly similar
    2. Vertex program fields are in different bit positions
    
    This patch unifies all parts of nv[34]0_shader.h except the vertex
    program fields.
    
    Vertex opcodes are also changed so that the constant names includes
    SCA if it is a scalar opcode and VEC if it is a vector opcode.
    ---
     src/gallium/drivers/nv30/nv30_fragprog.c | 172 ++++++-------
     src/gallium/drivers/nv30/nv30_shader.h   | 323 +-----------------------
     src/gallium/drivers/nv30/nv30_vertprog.c | 134 +++++-----
     src/gallium/drivers/nv40/nv40_draw.c     |   2 +-
     src/gallium/drivers/nv40/nv40_fragprog.c | 160 ++++++------
     src/gallium/drivers/nv40/nv40_shader.h   | 380 +----------------------------
     src/gallium/drivers/nv40/nv40_vertprog.c | 166 ++++++-------
     src/gallium/drivers/nvfx/nvfx_shader.h   | 407 +++++++++++++++++++++++++++++++
     8 files changed, 726 insertions(+), 1018 deletions(-)
     create mode 100644 src/gallium/drivers/nvfx/nvfx_shader.h
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
    index ae246ffd64..4ce16b8f0e 100644
    --- a/src/gallium/drivers/nv30/nv30_fragprog.c
    +++ b/src/gallium/drivers/nv30/nv30_fragprog.c
    @@ -19,14 +19,14 @@
     #define MASK_Z 4
     #define MASK_W 8
     #define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE NV30_FP_OP_DST_SCALE_1X
    -#define DEF_CTEST NV30_FP_OP_COND_TR
    -#include "nv30_shader.h"
    +#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    +#define DEF_CTEST NVFX_FP_OP_COND_TR
    +#include "nvfx_shader.h"
     
    -#define swz(s,x,y,z,w) nv30_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nv30_sr_neg((s))
    -#define abs(s) nv30_sr_abs((s))
    -#define scale(s,v) nv30_sr_scale((s), NV30_FP_OP_DST_SCALE_##v)
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
    +#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
     
     #define MAX_CONSTS 128
     #define MAX_IMM 32
    @@ -50,21 +50,21 @@ struct nv30_fpc {
     	} consts[MAX_CONSTS];
     	int nr_consts;
     
    -	struct nv30_sreg imm[MAX_IMM];
    +	struct nvfx_sreg imm[MAX_IMM];
     	unsigned nr_imm;
     };
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     temp(struct nv30_fpc *fpc)
     {
     	int idx;
     
     	idx  = fpc->temp_temp_count++;
     	idx += fpc->high_temp + 1;
    -	return nv30_sr(NV30SR_TEMP, idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
     }
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     constant(struct nv30_fpc *fpc, int pipe, float vals[4])
     {
     	int idx;
    @@ -76,14 +76,14 @@ constant(struct nv30_fpc *fpc, int pipe, float vals[4])
     	fpc->consts[idx].pipe = pipe;
     	if (pipe == -1)
     		memcpy(fpc->consts[idx].vals, vals, 4 * sizeof(float));
    -	return nv30_sr(NV30SR_CONST, idx);
    +	return nvfx_sr(NVFXSR_CONST, idx);
     }
     
     #define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv30_fp_arith((cc), (s), NV30_FP_OP_OPCODE_##o, \
    +	nv30_fp_arith((cc), (s), NVFX_FP_OP_OPCODE_##o, \
     			(d), (m), (s0), (s1), (s2))
     #define tex(cc,s,o,u,d,m,s0,s1,s2) \
    -	nv30_fp_tex((cc), (s), NV30_FP_OP_OPCODE_##o, (u), \
    +	nv30_fp_tex((cc), (s), NVFX_FP_OP_OPCODE_##o, (u), \
     		    (d), (m), (s0), none, none)
     
     static void
    @@ -96,25 +96,25 @@ grow_insns(struct nv30_fpc *fpc, int size)
     }
     
     static void
    -emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
    +emit_src(struct nv30_fpc *fpc, int pos, struct nvfx_sreg src)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     	uint32_t sr = 0;
     
     	switch (src.type) {
    -	case NV30SR_INPUT:
    -		sr |= (NV30_FP_REG_TYPE_INPUT << NV30_FP_REG_TYPE_SHIFT);
    -		hw[0] |= (src.index << NV30_FP_OP_INPUT_SRC_SHIFT);
    +	case NVFXSR_INPUT:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    +		hw[0] |= (src.index << NVFX_FP_OP_INPUT_SRC_SHIFT);
     		break;
    -	case NV30SR_OUTPUT:
    -		sr |= NV30_FP_REG_SRC_HALF;
    +	case NVFXSR_OUTPUT:
    +		sr |= NVFX_FP_REG_SRC_HALF;
     		/* fall-through */
    -	case NV30SR_TEMP:
    -		sr |= (NV30_FP_REG_TYPE_TEMP << NV30_FP_REG_TYPE_SHIFT);
    -		sr |= (src.index << NV30_FP_REG_SRC_SHIFT);
    +	case NVFXSR_TEMP:
    +		sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);
    +		sr |= (src.index << NVFX_FP_REG_SRC_SHIFT);
     		break;
    -	case NV30SR_CONST:
    +	case NVFXSR_CONST:
     		grow_insns(fpc, 4);
     		hw = &fp->insn[fpc->inst_offset];
     		if (fpc->consts[src.index].pipe >= 0) {
    @@ -132,61 +132,61 @@ emit_src(struct nv30_fpc *fpc, int pos, struct nv30_sreg src)
     				sizeof(uint32_t) * 4);
     		}
     
    -		sr |= (NV30_FP_REG_TYPE_CONST << NV30_FP_REG_TYPE_SHIFT);
    +		sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);
     		break;
    -	case NV30SR_NONE:
    -		sr |= (NV30_FP_REG_TYPE_INPUT << NV30_FP_REG_TYPE_SHIFT);
    +	case NVFXSR_NONE:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
     		break;
     	default:
     		assert(0);
     	}
     
     	if (src.negate)
    -		sr |= NV30_FP_REG_NEGATE;
    +		sr |= NVFX_FP_REG_NEGATE;
     
     	if (src.abs)
     		hw[1] |= (1 << (29 + pos));
     
    -	sr |= ((src.swz[0] << NV30_FP_REG_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NV30_FP_REG_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NV30_FP_REG_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NV30_FP_REG_SWZ_W_SHIFT));
    +	sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |
    +	       (src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |
    +	       (src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |
    +	       (src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));
     
     	hw[pos + 1] |= sr;
     }
     
     static void
    -emit_dst(struct nv30_fpc *fpc, struct nv30_sreg dst)
    +emit_dst(struct nv30_fpc *fpc, struct nvfx_sreg dst)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     
     	switch (dst.type) {
    -	case NV30SR_TEMP:
    +	case NVFXSR_TEMP:
     		if (fpc->num_regs < (dst.index + 1))
     			fpc->num_regs = dst.index + 1;
     		break;
    -	case NV30SR_OUTPUT:
    +	case NVFXSR_OUTPUT:
     		if (dst.index == 1) {
     			fp->fp_control |= 0xe;
     		} else {
    -			hw[0] |= NV30_FP_OP_OUT_REG_HALF;
    +			hw[0] |= NVFX_FP_OP_OUT_REG_HALF;
     		}
     		break;
    -	case NV30SR_NONE:
    +	case NVFXSR_NONE:
     		hw[0] |= (1 << 30);
     		break;
     	default:
     		assert(0);
     	}
     
    -	hw[0] |= (dst.index << NV30_FP_OP_OUT_REG_SHIFT);
    +	hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);
     }
     
     static void
     nv30_fp_arith(struct nv30_fpc *fpc, int sat, int op,
    -	      struct nv30_sreg dst, int mask,
    -	      struct nv30_sreg s0, struct nv30_sreg s1, struct nv30_sreg s2)
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw;
    @@ -196,22 +196,22 @@ nv30_fp_arith(struct nv30_fpc *fpc, int sat, int op,
     	hw = &fp->insn[fpc->inst_offset];
     	memset(hw, 0, sizeof(uint32_t) * 4);
     
    -	if (op == NV30_FP_OP_OPCODE_KIL)
    +	if (op == NVFX_FP_OP_OPCODE_KIL)
     		fp->fp_control |= NV34TCL_FP_CONTROL_USES_KIL;
    -	hw[0] |= (op << NV30_FP_OP_OPCODE_SHIFT);
    -	hw[0] |= (mask << NV30_FP_OP_OUTMASK_SHIFT);
    -	hw[2] |= (dst.dst_scale << NV30_FP_OP_DST_SCALE_SHIFT);
    +	hw[0] |= (op << NVFX_FP_OP_OPCODE_SHIFT);
    +	hw[0] |= (mask << NVFX_FP_OP_OUTMASK_SHIFT);
    +	hw[2] |= (dst.dst_scale << NVFX_FP_OP_DST_SCALE_SHIFT);
     
     	if (sat)
    -		hw[0] |= NV30_FP_OP_OUT_SAT;
    +		hw[0] |= NVFX_FP_OP_OUT_SAT;
     
     	if (dst.cc_update)
    -		hw[0] |= NV30_FP_OP_COND_WRITE_ENABLE;
    -	hw[1] |= (dst.cc_test << NV30_FP_OP_COND_SHIFT);
    -	hw[1] |= ((dst.cc_swz[0] << NV30_FP_OP_COND_SWZ_X_SHIFT) |
    -		  (dst.cc_swz[1] << NV30_FP_OP_COND_SWZ_Y_SHIFT) |
    -		  (dst.cc_swz[2] << NV30_FP_OP_COND_SWZ_Z_SHIFT) |
    -		  (dst.cc_swz[3] << NV30_FP_OP_COND_SWZ_W_SHIFT));
    +		hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;
    +	hw[1] |= (dst.cc_test << NVFX_FP_OP_COND_SHIFT);
    +	hw[1] |= ((dst.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |
    +		  (dst.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |
    +		  (dst.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |
    +		  (dst.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));
     
     	emit_dst(fpc, dst);
     	emit_src(fpc, 0, s0);
    @@ -221,25 +221,25 @@ nv30_fp_arith(struct nv30_fpc *fpc, int sat, int op,
     
     static void
     nv30_fp_tex(struct nv30_fpc *fpc, int sat, int op, int unit,
    -	    struct nv30_sreg dst, int mask,
    -	    struct nv30_sreg s0, struct nv30_sreg s1, struct nv30_sreg s2)
    +	    struct nvfx_sreg dst, int mask,
    +	    struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     
     	nv30_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
     
    -	fp->insn[fpc->inst_offset] |= (unit << NV30_FP_OP_TEX_UNIT_SHIFT);
    +	fp->insn[fpc->inst_offset] |= (unit << NVFX_FP_OP_TEX_UNIT_SHIFT);
     	fp->samplers |= (1 << unit);
     }
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     {
    -	struct nv30_sreg src;
    +	struct nvfx_sreg src;
     
     	switch (fsrc->Register.File) {
     	case TGSI_FILE_INPUT:
    -		src = nv30_sr(NV30SR_INPUT,
    +		src = nvfx_sr(NVFXSR_INPUT,
     			      fpc->attrib_map[fsrc->Register.Index]);
     		break;
     	case TGSI_FILE_CONSTANT:
    @@ -250,7 +250,7 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     		src = fpc->imm[fsrc->Register.Index];
     		break;
     	case TGSI_FILE_TEMPORARY:
    -		src = nv30_sr(NV30SR_TEMP, fsrc->Register.Index + 1);
    +		src = nvfx_sr(NVFXSR_TEMP, fsrc->Register.Index + 1);
     		if (fpc->high_temp < src.index)
     			fpc->high_temp = src.index;
     		break;
    @@ -259,9 +259,9 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     	 */
     	case TGSI_FILE_OUTPUT:
     		if (fsrc->Register.Index == fpc->colour_id)
    -			return nv30_sr(NV30SR_OUTPUT, 0);
    +			return nvfx_sr(NVFXSR_OUTPUT, 0);
     		else
    -			return nv30_sr(NV30SR_OUTPUT, 1);
    +			return nvfx_sr(NVFXSR_OUTPUT, 1);
     		break;
     	default:
     		NOUVEAU_ERR("bad src file\n");
    @@ -277,27 +277,27 @@ tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     	return src;
     }
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     tgsi_dst(struct nv30_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
     	int idx;
     
     	switch (fdst->Register.File) {
     	case TGSI_FILE_OUTPUT:
     		if (fdst->Register.Index == fpc->colour_id)
    -			return nv30_sr(NV30SR_OUTPUT, 0);
    +			return nvfx_sr(NVFXSR_OUTPUT, 0);
     		else
    -			return nv30_sr(NV30SR_OUTPUT, 1);
    +			return nvfx_sr(NVFXSR_OUTPUT, 1);
     		break;
     	case TGSI_FILE_TEMPORARY:
     		idx = fdst->Register.Index + 1;
     		if (fpc->high_temp < idx)
     			fpc->high_temp = idx;
    -		return nv30_sr(NV30SR_TEMP, idx);
    +		return nvfx_sr(NVFXSR_TEMP, idx);
     	case TGSI_FILE_NULL:
    -		return nv30_sr(NV30SR_NONE, 0);
    +		return nvfx_sr(NVFXSR_NONE, 0);
     	default:
     		NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
    -		return nv30_sr(NV30SR_NONE, 0);
    +		return nvfx_sr(NVFXSR_NONE, 0);
     	}
     }
     
    @@ -315,10 +315,10 @@ tgsi_mask(uint tgsi)
     
     static boolean
     src_native_swz(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nv30_sreg *src)
    +	       struct nvfx_sreg *src)
     {
    -	const struct nv30_sreg none = nv30_sr(NV30SR_NONE, 0);
    -	struct nv30_sreg tgsi = tgsi_src(fpc, fsrc);
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
     	uint mask = 0;
     	uint c;
     
    @@ -350,8 +350,8 @@ static boolean
     nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     				const struct tgsi_full_instruction *finst)
     {
    -	const struct nv30_sreg none = nv30_sr(NV30SR_NONE, 0);
    -	struct nv30_sreg src[3], dst, tmp;
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg src[3], dst, tmp;
     	int mask, sat, unit = 0;
     	int ai = -1, ci = -1;
     	int i;
    @@ -435,12 +435,12 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     		arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_CMP:
    -		tmp = nv30_sr(NV30SR_NONE, 0);
    +		tmp = nvfx_sr(NVFXSR_NONE, 0);
     		tmp.cc_update = 1;
     		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    -		dst.cc_test = NV30_VP_INST_COND_GE;
    +		dst.cc_test = NVFX_VP_INST_COND_GE;
     		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    -		dst.cc_test = NV30_VP_INST_COND_LT;
    +		dst.cc_test = NVFX_VP_INST_COND_LT;
     		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
     		break;
     	case TGSI_OPCODE_COS:
    @@ -474,10 +474,10 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     		arith(fpc, 0, KIL, none, 0, none, none, none);
     		break;
     	case TGSI_OPCODE_KIL:
    -		dst = nv30_sr(NV30SR_NONE, 0);
    +		dst = nvfx_sr(NVFXSR_NONE, 0);
     		dst.cc_update = 1;
     		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    -		dst.cc_update = 0; dst.cc_test = NV30_FP_OP_COND_LT;
    +		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
     		arith(fpc, 0, KIL, dst, 0, none, none, none);
     		break;
     	case TGSI_OPCODE_LG2:
    @@ -485,7 +485,7 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     		break;
     //	case TGSI_OPCODE_LIT:
     	case TGSI_OPCODE_LRP:
    -		arith(fpc, sat, LRP, dst, mask, src[0], src[1], src[2]);
    +		arith(fpc, sat, LRP_NV30, dst, mask, src[0], src[1], src[2]);
     		break;
     	case TGSI_OPCODE_MAD:
     		arith(fpc, sat, MAD, dst, mask, src[0], src[1], src[2]);
    @@ -503,7 +503,7 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     		arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_POW:
    -		arith(fpc, sat, POW, dst, mask, src[0], src[1], none);
    +		arith(fpc, sat, POW_NV30, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_RCP:
     		arith(fpc, sat, RCP, dst, mask, src[0], none, none);
    @@ -512,10 +512,10 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
     		assert(0);
     		break;
     	case TGSI_OPCODE_RFL:
    -		arith(fpc, 0, RFL, dst, mask, src[0], src[1], none);
    +		arith(fpc, 0, RFL_NV30, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_RSQ:
    -		arith(fpc, sat, RSQ, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
    +		arith(fpc, sat, RSQ_NV30, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
     		break;
     	case TGSI_OPCODE_SCS:
     		/* avoid overwriting the source */
    @@ -590,25 +590,25 @@ nv30_fragprog_parse_decl_attrib(struct nv30_fpc *fpc,
     
     	switch (fdec->Semantic.Name) {
     	case TGSI_SEMANTIC_POSITION:
    -		hw = NV30_FP_OP_INPUT_SRC_POSITION;
    +		hw = NVFX_FP_OP_INPUT_SRC_POSITION;
     		break;
     	case TGSI_SEMANTIC_COLOR:
     		if (fdec->Semantic.Index == 0) {
    -			hw = NV30_FP_OP_INPUT_SRC_COL0;
    +			hw = NVFX_FP_OP_INPUT_SRC_COL0;
     		} else
     		if (fdec->Semantic.Index == 1) {
    -			hw = NV30_FP_OP_INPUT_SRC_COL1;
    +			hw = NVFX_FP_OP_INPUT_SRC_COL1;
     		} else {
     			NOUVEAU_ERR("bad colour semantic index\n");
     			return FALSE;
     		}
     		break;
     	case TGSI_SEMANTIC_FOG:
    -		hw = NV30_FP_OP_INPUT_SRC_FOGC;
    +		hw = NVFX_FP_OP_INPUT_SRC_FOGC;
     		break;
     	case TGSI_SEMANTIC_GENERIC:
     		if (fdec->Semantic.Index <= 7) {
    -			hw = NV30_FP_OP_INPUT_SRC_TC(fdec->Semantic.
    +			hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.
     						     Index);
     		} else {
     			NOUVEAU_ERR("bad generic semantic index\n");
    @@ -702,7 +702,7 @@ nv30_fragprog_prepare(struct nv30_fpc *fpc)
     	tgsi_parse_free(&p);
     
     	/*if (++high_temp) {
    -		fpc->r_temp = CALLOC(high_temp, sizeof(struct nv30_sreg));
    +		fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
     		for (i = 0; i < high_temp; i++)
     			fpc->r_temp[i] = temp(fpc);
     		fpc->r_temps_discard = 0;
    diff --git a/src/gallium/drivers/nv30/nv30_shader.h b/src/gallium/drivers/nv30/nv30_shader.h
    index dd3a36f78f..f19efb5aa4 100644
    --- a/src/gallium/drivers/nv30/nv30_shader.h
    +++ b/src/gallium/drivers/nv30/nv30_shader.h
    @@ -72,14 +72,6 @@
     #define NV30_VP_INST_COND_TEST_ENABLE        (1<<14)
     #define NV30_VP_INST_COND_SHIFT          11
     #define NV30_VP_INST_COND_MASK          (0x07 << 11)
    -#  define NV30_VP_INST_COND_FL  0 /* guess */  
    -#  define NV30_VP_INST_COND_LT  1  
    -#  define NV30_VP_INST_COND_EQ  2
    -#  define NV30_VP_INST_COND_LE  3
    -#  define NV30_VP_INST_COND_GT  4
    -#  define NV30_VP_INST_COND_NE  5
    -#  define NV30_VP_INST_COND_GE  6
    -#  define NV30_VP_INST_COND_TR  7 /* guess */
     #define NV30_VP_INST_COND_SWZ_X_SHIFT        9
     #define NV30_VP_INST_COND_SWZ_X_MASK        (0x03 <<  9)
     #define NV30_VP_INST_COND_SWZ_Y_SHIFT        7
    @@ -98,59 +90,12 @@
     /* DWORD 1 */
     #define NV30_VP_INST_SCA_OPCODEL_SHIFT        28
     #define NV30_VP_INST_SCA_OPCODEL_MASK        (0x0F << 28)
    -#  define NV30_VP_INST_OP_NOP  0x00
    -#  define NV30_VP_INST_OP_RCP  0x02
    -#  define NV30_VP_INST_OP_RCC  0x03
    -#  define NV30_VP_INST_OP_RSQ  0x04
    -#  define NV30_VP_INST_OP_EXP  0x05
    -#  define NV30_VP_INST_OP_LOG  0x06
    -#  define NV30_VP_INST_OP_LIT  0x07
    -#  define NV30_VP_INST_OP_BRA  0x09
    -#  define NV30_VP_INST_OP_CAL  0x0B
    -#  define NV30_VP_INST_OP_RET  0x0C
    -#  define NV30_VP_INST_OP_LG2  0x0D
    -#  define NV30_VP_INST_OP_EX2  0x0E
    -#  define NV30_VP_INST_OP_SIN  0x0F
    -#  define NV30_VP_INST_OP_COS  0x10
     #define NV30_VP_INST_VEC_OPCODE_SHIFT        23
     #define NV30_VP_INST_VEC_OPCODE_MASK        (0x1F << 23)
    -#  define NV30_VP_INST_OP_NOPV  0x00
    -#  define NV30_VP_INST_OP_MOV  0x01
    -#  define NV30_VP_INST_OP_MUL  0x02
    -#  define NV30_VP_INST_OP_ADD  0x03
    -#  define NV30_VP_INST_OP_MAD  0x04
    -#  define NV30_VP_INST_OP_DP3  0x05
    -#  define NV30_VP_INST_OP_DP4  0x07
    -#  define NV30_VP_INST_OP_DPH  0x06
    -#  define NV30_VP_INST_OP_DST  0x08
    -#  define NV30_VP_INST_OP_MIN  0x09
    -#  define NV30_VP_INST_OP_MAX  0x0A
    -#  define NV30_VP_INST_OP_SLT  0x0B
    -#  define NV30_VP_INST_OP_SGE  0x0C
    -#  define NV30_VP_INST_OP_ARL  0x0D
    -#  define NV30_VP_INST_OP_FRC  0x0E
    -#  define NV30_VP_INST_OP_FLR  0x0F
    -#  define NV30_VP_INST_OP_SEQ  0x10
    -#  define NV30_VP_INST_OP_SFL  0x11
    -#  define NV30_VP_INST_OP_SGT  0x12
    -#  define NV30_VP_INST_OP_SLE  0x13
    -#  define NV30_VP_INST_OP_SNE  0x14
    -#  define NV30_VP_INST_OP_STR  0x15
    -#  define NV30_VP_INST_OP_SSG  0x16
    -#  define NV30_VP_INST_OP_ARR  0x17
    -#  define NV30_VP_INST_OP_ARA  0x18
     #define NV30_VP_INST_CONST_SRC_SHIFT        14
     #define NV30_VP_INST_CONST_SRC_MASK        (0xFF << 14)
     #define NV30_VP_INST_INPUT_SRC_SHIFT        9    /*NV20*/
     #define NV30_VP_INST_INPUT_SRC_MASK        (0x0F <<  9)  /*NV20*/
    -#  define NV30_VP_INST_IN_POS  0    /* These seem to match the bindings specified in */
    -#  define NV30_VP_INST_IN_WEIGHT  1    /* the ARB_v_p spec (2.14.3.1) */
    -#  define NV30_VP_INST_IN_NORMAL  2    
    -#  define NV30_VP_INST_IN_COL0  3    /* Should probably confirm them all though */
    -#  define NV30_VP_INST_IN_COL1  4
    -#  define NV30_VP_INST_IN_FOGC  5
    -#  define NV30_VP_INST_IN_TC0  8
    -#  define NV30_VP_INST_IN_TC(n)  (8+n)
     #define NV30_VP_INST_SRC0H_SHIFT        0    /*NV20*/
     #define NV30_VP_INST_SRC0H_MASK          (0x1FF << 0)  /*NV20*/
     
    @@ -190,8 +135,6 @@
     #  define NV30_VP_INST_DEST_PSZ   6
     #  define NV30_VP_INST_DEST_TC(n)  (8+n)
     
    -#define NV30_VP_INST_LAST                           (1 << 0)
    -
     /* Useful to split the source selection regs into their pieces */
     #define NV30_VP_SRC0_HIGH_SHIFT                                                6
     #define NV30_VP_SRC0_HIGH_MASK                                        0x00007FC0
    @@ -221,270 +164,6 @@
     #define NV30_VP_SRC_REG_TYPE_INPUT  2
     #define NV30_VP_SRC_REG_TYPE_CONST  3 /* guess */
     
    -/*
    - * Each fragment program opcode appears to be comprised of 4 32-bit values.
    - *
    - *   0 - Opcode, output reg/mask, ATTRIB source
    - *   1 - Source 0
    - *   2 - Source 1
    - *   3 - Source 2
    - *
    - * There appears to be no special difference between result regs and temp regs.
    - *     result.color == R0.xyzw
    - *     result.depth == R1.z
    - * When the fragprog contains instructions to write depth, NV30_TCL_PRIMITIVE_3D_UNK1D78=0
    - * otherwise it is set to 1.
    - *
    - * Constants are inserted directly after the instruction that uses them.
    - * 
    - * It appears that it's not possible to use two input registers in one
    - * instruction as the input sourcing is done in the instruction dword
    - * and not the source selection dwords.  As such instructions such as:
    - * 
    - *     ADD result.color, fragment.color, fragment.texcoord[0];
    - *
    - * must be split into two MOV's and then an ADD (nvidia does this) but
    - * I'm not sure why it's not just one MOV and then source the second input
    - * in the ADD instruction..
    - *
    - * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
    - * negation requires multiplication with a const.
    - *
    - * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO/SWIZZLE_ONE
    - * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as SWIZZLE_ZERO
    - * is implemented simply by not writing to the relevant components of the destination.
    - *
    - * Conditional execution
    - *   TODO
    - * 
    - * Non-native instructions:
    - *   LIT
    - *   LRP - MAD+MAD
    - *   SUB - ADD, negate second source
    - *   RSQ - LG2 + EX2
    - *   POW - LG2 + MUL + EX2
    - *   SCS - COS + SIN
    - *   XPD
    - */
    -
    -//== Opcode / Destination selection ==
    -#define NV30_FP_OP_PROGRAM_END          (1 << 0)
    -#define NV30_FP_OP_OUT_REG_SHIFT        1
    -#define NV30_FP_OP_OUT_REG_MASK          (31 << 1)  /* uncertain */
    -/* Needs to be set when writing outputs to get expected result.. */
    -#define NV30_FP_OP_OUT_REG_HALF          (1 << 7)
    -#define NV30_FP_OP_COND_WRITE_ENABLE        (1 << 8)
    -#define NV30_FP_OP_OUTMASK_SHIFT        9
    -#define NV30_FP_OP_OUTMASK_MASK          (0xF << 9)
    -#  define NV30_FP_OP_OUT_X  (1<<9)
    -#  define NV30_FP_OP_OUT_Y  (1<<10)
    -#  define NV30_FP_OP_OUT_Z  (1<<11)
    -#  define NV30_FP_OP_OUT_W  (1<<12)
    -/* Uncertain about these, especially the input_src values.. it's possible that
    - * they can be dynamically changed.
    - */
    -#define NV30_FP_OP_INPUT_SRC_SHIFT        13
    -#define NV30_FP_OP_INPUT_SRC_MASK        (15 << 13)
    -#  define NV30_FP_OP_INPUT_SRC_POSITION  0x0
    -#  define NV30_FP_OP_INPUT_SRC_COL0  0x1
    -#  define NV30_FP_OP_INPUT_SRC_COL1  0x2
    -#  define NV30_FP_OP_INPUT_SRC_FOGC  0x3
    -#  define NV30_FP_OP_INPUT_SRC_TC0    0x4
    -#  define NV30_FP_OP_INPUT_SRC_TC(n)  (0x4 + n)
    -#define NV30_FP_OP_TEX_UNIT_SHIFT        17
    -#define NV30_FP_OP_TEX_UNIT_MASK        (0xF << 17) /* guess */
    -#define NV30_FP_OP_PRECISION_SHIFT        22
    -#define NV30_FP_OP_PRECISION_MASK        (3 << 22)
    -#   define NV30_FP_PRECISION_FP32  0
    -#   define NV30_FP_PRECISION_FP16  1
    -#   define NV30_FP_PRECISION_FX12  2
    -#define NV30_FP_OP_OPCODE_SHIFT          24
    -#define NV30_FP_OP_OPCODE_MASK          (0x3F << 24)
    -#  define NV30_FP_OP_OPCODE_NOP  0x00
    -#  define NV30_FP_OP_OPCODE_MOV  0x01
    -#  define NV30_FP_OP_OPCODE_MUL  0x02
    -#  define NV30_FP_OP_OPCODE_ADD  0x03
    -#  define NV30_FP_OP_OPCODE_MAD  0x04
    -#  define NV30_FP_OP_OPCODE_DP3  0x05
    -#  define NV30_FP_OP_OPCODE_DP4  0x06
    -#  define NV30_FP_OP_OPCODE_DST  0x07
    -#  define NV30_FP_OP_OPCODE_MIN  0x08
    -#  define NV30_FP_OP_OPCODE_MAX  0x09
    -#  define NV30_FP_OP_OPCODE_SLT  0x0A
    -#  define NV30_FP_OP_OPCODE_SGE  0x0B
    -#  define NV30_FP_OP_OPCODE_SLE  0x0C
    -#  define NV30_FP_OP_OPCODE_SGT  0x0D
    -#  define NV30_FP_OP_OPCODE_SNE  0x0E
    -#  define NV30_FP_OP_OPCODE_SEQ  0x0F
    -#  define NV30_FP_OP_OPCODE_FRC  0x10
    -#  define NV30_FP_OP_OPCODE_FLR  0x11
    -#  define NV30_FP_OP_OPCODE_KIL  0x12
    -#  define NV30_FP_OP_OPCODE_PK4B   0x13
    -#  define NV30_FP_OP_OPCODE_UP4B   0x14
    -#  define NV30_FP_OP_OPCODE_DDX  0x15 /* can only write XY */
    -#  define NV30_FP_OP_OPCODE_DDY  0x16 /* can only write XY */
    -#  define NV30_FP_OP_OPCODE_TEX  0x17
    -#  define NV30_FP_OP_OPCODE_TXP  0x18
    -#  define NV30_FP_OP_OPCODE_TXD  0x19
    -#  define NV30_FP_OP_OPCODE_RCP  0x1A
    -#  define NV30_FP_OP_OPCODE_RSQ  0x1B
    -#  define NV30_FP_OP_OPCODE_EX2  0x1C
    -#  define NV30_FP_OP_OPCODE_LG2  0x1D
    -#  define NV30_FP_OP_OPCODE_LIT  0x1E
    -#  define NV30_FP_OP_OPCODE_LRP  0x1F
    -#  define NV30_FP_OP_OPCODE_STR  0x20 
    -#  define NV30_FP_OP_OPCODE_SFL  0x21
    -#  define NV30_FP_OP_OPCODE_COS  0x22
    -#  define NV30_FP_OP_OPCODE_SIN  0x23
    -#  define NV30_FP_OP_OPCODE_PK2H   0x24
    -#  define NV30_FP_OP_OPCODE_UP2H   0x25
    -#  define NV30_FP_OP_OPCODE_POW  0x26
    -#  define NV30_FP_OP_OPCODE_PK4UB  0x27
    -#  define NV30_FP_OP_OPCODE_UP4UB  0x28
    -#  define NV30_FP_OP_OPCODE_PK2US  0x29
    -#  define NV30_FP_OP_OPCODE_UP2US  0x2A
    -#  define NV30_FP_OP_OPCODE_DP2A   0x2E
    -#  define NV30_FP_OP_OPCODE_TXB  0x31
    -#  define NV30_FP_OP_OPCODE_RFL  0x36
    -#  define NV30_FP_OP_OPCODE_DIV  0x3A
    -#define NV30_FP_OP_OUT_SAT          (1 << 31)
    -
    -/* high order bits of SRC0 */
    -#define NV30_FP_OP_OUT_ABS          (1 << 29)
    -#define NV30_FP_OP_COND_SWZ_W_SHIFT        27
    -#define NV30_FP_OP_COND_SWZ_W_MASK        (3 << 27)
    -#define NV30_FP_OP_COND_SWZ_Z_SHIFT        25
    -#define NV30_FP_OP_COND_SWZ_Z_MASK        (3 << 25)
    -#define NV30_FP_OP_COND_SWZ_Y_SHIFT        23
    -#define NV30_FP_OP_COND_SWZ_Y_MASK        (3 << 23)
    -#define NV30_FP_OP_COND_SWZ_X_SHIFT        21
    -#define NV30_FP_OP_COND_SWZ_X_MASK        (3 << 21)
    -#define NV30_FP_OP_COND_SWZ_ALL_SHIFT        21
    -#define NV30_FP_OP_COND_SWZ_ALL_MASK        (0xFF << 21)
    -#define NV30_FP_OP_COND_SHIFT          18
    -#define NV30_FP_OP_COND_MASK          (0x07 << 18)
    -#  define NV30_FP_OP_COND_FL  0
    -#  define NV30_FP_OP_COND_LT  1
    -#  define NV30_FP_OP_COND_EQ  2
    -#  define NV30_FP_OP_COND_LE  3
    -#  define NV30_FP_OP_COND_GT  4
    -#  define NV30_FP_OP_COND_NE  5
    -#  define NV30_FP_OP_COND_GE  6
    -#  define NV30_FP_OP_COND_TR  7
    -
    -/* high order bits of SRC1 */
    -#define NV30_FP_OP_DST_SCALE_SHIFT        28
    -#define NV30_FP_OP_DST_SCALE_MASK        (3 << 28)
    -#define NV30_FP_OP_DST_SCALE_1X                                                0
    -#define NV30_FP_OP_DST_SCALE_2X                                                1
    -#define NV30_FP_OP_DST_SCALE_4X                                                2
    -#define NV30_FP_OP_DST_SCALE_8X                                                3
    -#define NV30_FP_OP_DST_SCALE_INV_2X                                            5
    -#define NV30_FP_OP_DST_SCALE_INV_4X                                            6
    -#define NV30_FP_OP_DST_SCALE_INV_8X                                            7
    -
    -
    -/* high order bits of SRC2 */
    -#define NV30_FP_OP_INDEX_INPUT          (1 << 30)
    -
    -//== Register selection ==
    -#define NV30_FP_REG_TYPE_SHIFT          0
    -#define NV30_FP_REG_TYPE_MASK          (3 << 0)
    -#  define NV30_FP_REG_TYPE_TEMP  0
    -#  define NV30_FP_REG_TYPE_INPUT  1
    -#  define NV30_FP_REG_TYPE_CONST  2
    -#define NV30_FP_REG_SRC_SHIFT          2 /* uncertain */
    -#define NV30_FP_REG_SRC_MASK          (31 << 2)
    -#define NV30_FP_REG_SRC_HALF          (1 << 8)
    -#define NV30_FP_REG_SWZ_ALL_SHIFT        9
    -#define NV30_FP_REG_SWZ_ALL_MASK        (255 << 9)
    -#define NV30_FP_REG_SWZ_X_SHIFT          9
    -#define NV30_FP_REG_SWZ_X_MASK          (3 << 9)
    -#define NV30_FP_REG_SWZ_Y_SHIFT          11
    -#define NV30_FP_REG_SWZ_Y_MASK          (3 << 11)
    -#define NV30_FP_REG_SWZ_Z_SHIFT          13
    -#define NV30_FP_REG_SWZ_Z_MASK          (3 << 13)
    -#define NV30_FP_REG_SWZ_W_SHIFT          15
    -#define NV30_FP_REG_SWZ_W_MASK          (3 << 15)
    -#  define NV30_FP_SWIZZLE_X  0
    -#  define NV30_FP_SWIZZLE_Y  1
    -#  define NV30_FP_SWIZZLE_Z  2
    -#  define NV30_FP_SWIZZLE_W  3
    -#define NV30_FP_REG_NEGATE          (1 << 17)
    -
    -#define NV30SR_NONE	0
    -#define NV30SR_OUTPUT	1
    -#define NV30SR_INPUT	2
    -#define NV30SR_TEMP	3
    -#define NV30SR_CONST	4
    -
    -struct nv30_sreg {
    -	int type;
    -	int index;
    -
    -	int dst_scale;
    -
    -	int negate;
    -	int abs;
    -	int swz[4];
    -
    -	int cc_update;
    -	int cc_update_reg;
    -	int cc_test;
    -	int cc_test_reg;
    -	int cc_swz[4];
    -};
    -
    -static INLINE struct nv30_sreg
    -nv30_sr(int type, int index)
    -{
    -	struct nv30_sreg temp = {
    -		.type = type,
    -		.index = index,
    -		.dst_scale = DEF_SCALE,
    -		.abs = 0,
    -		.negate = 0,
    -		.swz = { 0, 1, 2, 3 },
    -		.cc_update = 0,
    -		.cc_update_reg = 0,
    -		.cc_test = DEF_CTEST,
    -		.cc_test_reg = 0,
    -		.cc_swz = { 0, 1, 2, 3 },
    -	};
    -	return temp;
    -}
    -
    -static INLINE struct nv30_sreg
    -nv30_sr_swz(struct nv30_sreg src, int x, int y, int z, int w)
    -{
    -	struct nv30_sreg dst = src;
    -
    -	dst.swz[SWZ_X] = src.swz[x];
    -	dst.swz[SWZ_Y] = src.swz[y];
    -	dst.swz[SWZ_Z] = src.swz[z];
    -	dst.swz[SWZ_W] = src.swz[w];
    -	return dst;
    -}
    -
    -static INLINE struct nv30_sreg
    -nv30_sr_neg(struct nv30_sreg src)
    -{
    -	src.negate = !src.negate;
    -	return src;
    -}
    -
    -static INLINE struct nv30_sreg
    -nv30_sr_abs(struct nv30_sreg src)
    -{
    -	src.abs = 1;
    -	return src;
    -}
    -
    -static INLINE struct nv30_sreg
    -nv30_sr_scale(struct nv30_sreg src, int scale)
    -{
    -	src.dst_scale = scale;
    -	return src;
    -}
    +#include "nvfx_shader.h"
     
     #endif
    diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
    index cf910e34b1..ec6d63889b 100644
    --- a/src/gallium/drivers/nv30/nv30_vertprog.c
    +++ b/src/gallium/drivers/nv30/nv30_vertprog.c
    @@ -35,9 +35,9 @@
     #define DEF_CTEST 0
     #include "nv30_shader.h"
     
    -#define swz(s,x,y,z,w) nv30_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nv30_sr_neg((s))
    -#define abs(s) nv30_sr_abs((s))
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
     
     struct nv30_vpc {
     	struct nvfx_vertex_program *vp;
    @@ -49,21 +49,21 @@ struct nv30_vpc {
     	int high_temp;
     	int temp_temp_count;
     
    -	struct nv30_sreg *imm;
    +	struct nvfx_sreg *imm;
     	unsigned nr_imm;
     };
     
    -static struct nv30_sreg
    +static struct nvfx_sreg
     temp(struct nv30_vpc *vpc)
     {
     	int idx;
     
     	idx  = vpc->temp_temp_count++;
     	idx += vpc->high_temp + 1;
    -	return nv30_sr(NV30SR_TEMP, idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
     }
     
    -static struct nv30_sreg
    +static struct nvfx_sreg
     constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
    @@ -73,7 +73,7 @@ constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
     	if (pipe >= 0) {
     		for (idx = 0; idx < vp->nr_consts; idx++) {
     			if (vp->consts[idx].index == pipe)
    -				return nv30_sr(NV30SR_CONST, idx);
    +				return nvfx_sr(NVFXSR_CONST, idx);
     		}
     	}
     
    @@ -86,37 +86,37 @@ constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
     	vpd->value[1] = y;
     	vpd->value[2] = z;
     	vpd->value[3] = w;
    -	return nv30_sr(NV30SR_CONST, idx);
    +	return nvfx_sr(NVFXSR_CONST, idx);
     }
     
     #define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv30_vp_arith((cc), (s), NV30_VP_INST_##o, (d), (m), (s0), (s1), (s2))
    +	nv30_vp_arith((cc), NVFX_VP_INST_SLOT_##s, NVFX_VP_INST_##s##_OP_##o, (d), (m), (s0), (s1), (s2))
     
     static void
    -emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nv30_sreg src)
    +emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nvfx_sreg src)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t sr = 0;
     
     	switch (src.type) {
    -	case NV30SR_TEMP:
    +	case NVFXSR_TEMP:
     		sr |= (NV30_VP_SRC_REG_TYPE_TEMP << NV30_VP_SRC_REG_TYPE_SHIFT);
     		sr |= (src.index << NV30_VP_SRC_TEMP_SRC_SHIFT);
     		break;
    -	case NV30SR_INPUT:
    +	case NVFXSR_INPUT:
     		sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
     		       NV30_VP_SRC_REG_TYPE_SHIFT);
     		vp->ir |= (1 << src.index);
     		hw[1] |= (src.index << NV30_VP_INST_INPUT_SRC_SHIFT);
     		break;
    -	case NV30SR_CONST:
    +	case NVFXSR_CONST:
     		sr |= (NV30_VP_SRC_REG_TYPE_CONST <<
     		       NV30_VP_SRC_REG_TYPE_SHIFT);
     		assert(vpc->vpi->const_index == -1 ||
     		       vpc->vpi->const_index == src.index);
     		vpc->vpi->const_index = src.index;
     		break;
    -	case NV30SR_NONE:
    +	case NVFXSR_NONE:
     		sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
     		       NV30_VP_SRC_REG_TYPE_SHIFT);
     		break;
    @@ -164,15 +164,15 @@ emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nv30_sreg src)
     }
     
     static void
    -emit_dst(struct nv30_vpc *vpc, uint32_t *hw, int slot, struct nv30_sreg dst)
    +emit_dst(struct nv30_vpc *vpc, uint32_t *hw, int slot, struct nvfx_sreg dst)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     
     	switch (dst.type) {
    -	case NV30SR_TEMP:
    +	case NVFXSR_TEMP:
     		hw[0] |= (dst.index << NV30_VP_INST_DEST_TEMP_ID_SHIFT);
     		break;
    -	case NV30SR_OUTPUT:
    +	case NVFXSR_OUTPUT:
     		switch (dst.index) {
     		case NV30_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
     		case NV30_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    @@ -207,9 +207,9 @@ emit_dst(struct nv30_vpc *vpc, uint32_t *hw, int slot, struct nv30_sreg dst)
     
     static void
     nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
    -	      struct nv30_sreg dst, int mask,
    -	      struct nv30_sreg s0, struct nv30_sreg s1,
    -	      struct nv30_sreg s2)
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1,
    +	      struct nvfx_sreg s2)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t *hw;
    @@ -221,7 +221,7 @@ nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
     
     	hw = vpc->vpi->data;
     
    -	hw[0] |= (NV30_VP_INST_COND_TR << NV30_VP_INST_COND_SHIFT);
    +	hw[0] |= (NVFX_VP_INST_COND_TR << NV30_VP_INST_COND_SHIFT);
     	hw[0] |= ((0 << NV30_VP_INST_COND_SWZ_X_SHIFT) |
     		  (1 << NV30_VP_INST_COND_SWZ_Y_SHIFT) |
     		  (2 << NV30_VP_INST_COND_SWZ_Z_SHIFT) |
    @@ -231,7 +231,7 @@ nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
     //	hw[3] |= NV30_VP_INST_SCA_DEST_TEMP_MASK;
     //	hw[3] |= (mask << NV30_VP_INST_VEC_WRITEMASK_SHIFT);
     
    -	if (dst.type == NV30SR_OUTPUT) {
    +	if (dst.type == NVFXSR_OUTPUT) {
     		if (slot)
     			hw[3] |= (mask << NV30_VP_INST_SDEST_WRITEMASK_SHIFT);
     		else
    @@ -249,13 +249,13 @@ nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
     	emit_src(vpc, hw, 2, s2);
     }
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     tgsi_src(struct nv30_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
    -	struct nv30_sreg src;
    +	struct nvfx_sreg src;
     
     	switch (fsrc->Register.File) {
     	case TGSI_FILE_INPUT:
    -		src = nv30_sr(NV30SR_INPUT, fsrc->Register.Index);
    +		src = nvfx_sr(NVFXSR_INPUT, fsrc->Register.Index);
     		break;
     	case TGSI_FILE_CONSTANT:
     		src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
    @@ -266,7 +266,7 @@ tgsi_src(struct nv30_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
     	case TGSI_FILE_TEMPORARY:
     		if (vpc->high_temp < fsrc->Register.Index)
     			vpc->high_temp = fsrc->Register.Index;
    -		src = nv30_sr(NV30SR_TEMP, fsrc->Register.Index);
    +		src = nvfx_sr(NVFXSR_TEMP, fsrc->Register.Index);
     		break;
     	default:
     		NOUVEAU_ERR("bad src file\n");
    @@ -282,18 +282,18 @@ tgsi_src(struct nv30_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
     	return src;
     }
     
    -static INLINE struct nv30_sreg
    +static INLINE struct nvfx_sreg
     tgsi_dst(struct nv30_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
    -	struct nv30_sreg dst;
    +	struct nvfx_sreg dst;
     
     	switch (fdst->Register.File) {
     	case TGSI_FILE_OUTPUT:
    -		dst = nv30_sr(NV30SR_OUTPUT,
    +		dst = nvfx_sr(NVFXSR_OUTPUT,
     			      vpc->output_map[fdst->Register.Index]);
     
     		break;
     	case TGSI_FILE_TEMPORARY:
    -		dst = nv30_sr(NV30SR_TEMP, fdst->Register.Index);
    +		dst = nvfx_sr(NVFXSR_TEMP, fdst->Register.Index);
     		if (vpc->high_temp < dst.index)
     			vpc->high_temp = dst.index;
     		break;
    @@ -321,8 +321,8 @@ static boolean
     nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
     				const struct tgsi_full_instruction *finst)
     {
    -	struct nv30_sreg src[3], dst, tmp;
    -	struct nv30_sreg none = nv30_sr(NV30SR_NONE, 0);
    +	struct nvfx_sreg src[3], dst, tmp;
    +	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
     	int mask;
     	int ai = -1, ci = -1;
     	int i;
    @@ -351,7 +351,7 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -365,7 +365,7 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -383,96 +383,96 @@ nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
     
     	switch (finst->Instruction.Opcode) {
     	case TGSI_OPCODE_ABS:
    -		arith(vpc, 0, OP_MOV, dst, mask, abs(src[0]), none, none);
    +		arith(vpc, VEC, MOV, dst, mask, abs(src[0]), none, none);
     		break;
     	case TGSI_OPCODE_ADD:
    -		arith(vpc, 0, OP_ADD, dst, mask, src[0], none, src[1]);
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, src[1]);
     		break;
     	case TGSI_OPCODE_ARL:
    -		arith(vpc, 0, OP_ARL, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, ARL, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_DP3:
    -		arith(vpc, 0, OP_DP3, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DP3, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DP4:
    -		arith(vpc, 0, OP_DP4, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DP4, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DPH:
    -		arith(vpc, 0, OP_DPH, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DPH, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DST:
    -		arith(vpc, 0, OP_DST, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DST, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_EX2:
    -		arith(vpc, 1, OP_EX2, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, EX2, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_EXP:
    -		arith(vpc, 1, OP_EXP, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, EXP, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_FLR:
    -		arith(vpc, 0, OP_FLR, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, FLR, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_FRC:
    -		arith(vpc, 0, OP_FRC, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, FRC, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_LG2:
    -		arith(vpc, 1, OP_LG2, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LG2, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_LIT:
    -		arith(vpc, 1, OP_LIT, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LIT, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_LOG:
    -		arith(vpc, 1, OP_LOG, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LOG, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_MAD:
    -		arith(vpc, 0, OP_MAD, dst, mask, src[0], src[1], src[2]);
    +		arith(vpc, VEC, MAD, dst, mask, src[0], src[1], src[2]);
     		break;
     	case TGSI_OPCODE_MAX:
    -		arith(vpc, 0, OP_MAX, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MAX, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_MIN:
    -		arith(vpc, 0, OP_MIN, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MIN, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_MOV:
    -		arith(vpc, 0, OP_MOV, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, MOV, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_MUL:
    -		arith(vpc, 0, OP_MUL, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MUL, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_POW:
     		tmp = temp(vpc);
    -		arith(vpc, 1, OP_LG2, tmp, MASK_X, none, none,
    +		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
     		      swz(src[0], X, X, X, X));
    -		arith(vpc, 0, OP_MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
     		      swz(src[1], X, X, X, X), none);
    -		arith(vpc, 1, OP_EX2, dst, mask, none, none,
    +		arith(vpc, SCA, EX2, dst, mask, none, none,
     		      swz(tmp, X, X, X, X));
     		break;
     	case TGSI_OPCODE_RCP:
    -		arith(vpc, 1, OP_RCP, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, RCP, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_RET:
     		break;
     	case TGSI_OPCODE_RSQ:
    -		arith(vpc, 1, OP_RSQ, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, RSQ, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_SGE:
    -		arith(vpc, 0, OP_SGE, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, SGE, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_SGT:
    -		arith(vpc, 0, OP_SGT, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, SGT, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_SLT:
    -		arith(vpc, 0, OP_SLT, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, SLT, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_SUB:
    -		arith(vpc, 0, OP_ADD, dst, mask, src[0], none, neg(src[1]));
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, neg(src[1]));
     		break;
     	case TGSI_OPCODE_XPD:
     		tmp = temp(vpc);
    -		arith(vpc, 0, OP_MUL, tmp, mask,
    +		arith(vpc, VEC, MUL, tmp, mask,
     		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(vpc, 0, OP_MAD, dst, (mask & ~MASK_W),
    +		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
     		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
     		      neg(tmp));
     		break;
    @@ -564,7 +564,7 @@ nv30_vertprog_prepare(struct nv30_vpc *vpc)
     	tgsi_parse_free(&p);
     
     	if (nr_imm) {
    -		vpc->imm = CALLOC(nr_imm, sizeof(struct nv30_sreg));
    +		vpc->imm = CALLOC(nr_imm, sizeof(struct nvfx_sreg));
     		assert(vpc->imm);
     	}
     
    @@ -639,7 +639,7 @@ nv30_vertprog_translate(struct nvfx_context *nvfx,
     		}
     	}
     
    -	vp->insns[vp->nr_insns - 1].data[3] |= NV30_VP_INST_LAST;
    +	vp->insns[vp->nr_insns - 1].data[3] |= NVFX_VP_INST_LAST;
     	vp->translated = TRUE;
     out_err:
     	tgsi_parse_free(&parse);
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    index 87d2689d54..4ed87779fd 100644
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ b/src/gallium/drivers/nv40/nv40_draw.c
    @@ -8,7 +8,7 @@
     #include "draw/draw_pipe.h"
     
     #include "nv40_context.h"
    -#define NV40_SHADER_NO_FUCKEDNESS
    +#define NVFX_SHADER_NO_FUCKEDNESS
     #include "nv40_shader.h"
     
     /* Simple, but crappy, swtnl path, hopefully we wont need to hit this very
    diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
    index 2a0ab0cf31..e044f367a0 100644
    --- a/src/gallium/drivers/nv40/nv40_fragprog.c
    +++ b/src/gallium/drivers/nv40/nv40_fragprog.c
    @@ -18,14 +18,14 @@
     #define MASK_Z 4
     #define MASK_W 8
     #define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE NV40_FP_OP_DST_SCALE_1X
    -#define DEF_CTEST NV40_FP_OP_COND_TR
    -#include "nv40_shader.h"
    +#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    +#define DEF_CTEST NVFX_FP_OP_COND_TR
    +#include "nvfx_shader.h"
     
    -#define swz(s,x,y,z,w) nv40_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nv40_sr_neg((s))
    -#define abs(s) nv40_sr_abs((s))
    -#define scale(s,v) nv40_sr_scale((s), NV40_FP_OP_DST_SCALE_##v)
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
    +#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
     
     #define MAX_CONSTS 128
     #define MAX_IMM 32
    @@ -36,8 +36,8 @@ struct nv40_fpc {
     
     	unsigned r_temps;
     	unsigned r_temps_discard;
    -	struct nv40_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    -	struct nv40_sreg *r_temp;
    +	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    +	struct nvfx_sreg *r_temp;
     
     	int num_regs;
     
    @@ -50,11 +50,11 @@ struct nv40_fpc {
     	} consts[MAX_CONSTS];
     	int nr_consts;
     
    -	struct nv40_sreg imm[MAX_IMM];
    +	struct nvfx_sreg imm[MAX_IMM];
     	unsigned nr_imm;
     };
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     temp(struct nv40_fpc *fpc)
     {
     	int idx = ffs(~fpc->r_temps) - 1;
    @@ -62,12 +62,12 @@ temp(struct nv40_fpc *fpc)
     	if (idx < 0) {
     		NOUVEAU_ERR("out of temps!!\n");
     		assert(0);
    -		return nv40_sr(NV40SR_TEMP, 0);
    +		return nvfx_sr(NVFXSR_TEMP, 0);
     	}
     
     	fpc->r_temps |= (1 << idx);
     	fpc->r_temps_discard |= (1 << idx);
    -	return nv40_sr(NV40SR_TEMP, idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
     }
     
     static INLINE void
    @@ -77,7 +77,7 @@ release_temps(struct nv40_fpc *fpc)
     	fpc->r_temps_discard = 0;
     }
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     constant(struct nv40_fpc *fpc, int pipe, float vals[4])
     {
     	int idx;
    @@ -89,14 +89,14 @@ constant(struct nv40_fpc *fpc, int pipe, float vals[4])
     	fpc->consts[idx].pipe = pipe;
     	if (pipe == -1)
     		memcpy(fpc->consts[idx].vals, vals, 4 * sizeof(float));
    -	return nv40_sr(NV40SR_CONST, idx);
    +	return nvfx_sr(NVFXSR_CONST, idx);
     }
     
     #define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv40_fp_arith((cc), (s), NV40_FP_OP_OPCODE_##o, \
    +	nv40_fp_arith((cc), (s), NVFX_FP_OP_OPCODE_##o, \
     			(d), (m), (s0), (s1), (s2))
     #define tex(cc,s,o,u,d,m,s0,s1,s2) \
    -	nv40_fp_tex((cc), (s), NV40_FP_OP_OPCODE_##o, (u), \
    +	nv40_fp_tex((cc), (s), NVFX_FP_OP_OPCODE_##o, (u), \
     		    (d), (m), (s0), none, none)
     
     static void
    @@ -109,25 +109,25 @@ grow_insns(struct nv40_fpc *fpc, int size)
     }
     
     static void
    -emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
    +emit_src(struct nv40_fpc *fpc, int pos, struct nvfx_sreg src)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     	uint32_t sr = 0;
     
     	switch (src.type) {
    -	case NV40SR_INPUT:
    -		sr |= (NV40_FP_REG_TYPE_INPUT << NV40_FP_REG_TYPE_SHIFT);
    -		hw[0] |= (src.index << NV40_FP_OP_INPUT_SRC_SHIFT);
    +	case NVFXSR_INPUT:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    +		hw[0] |= (src.index << NVFX_FP_OP_INPUT_SRC_SHIFT);
     		break;
    -	case NV40SR_OUTPUT:
    -		sr |= NV40_FP_REG_SRC_HALF;
    +	case NVFXSR_OUTPUT:
    +		sr |= NVFX_FP_REG_SRC_HALF;
     		/* fall-through */
    -	case NV40SR_TEMP:
    -		sr |= (NV40_FP_REG_TYPE_TEMP << NV40_FP_REG_TYPE_SHIFT);
    -		sr |= (src.index << NV40_FP_REG_SRC_SHIFT);
    +	case NVFXSR_TEMP:
    +		sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);
    +		sr |= (src.index << NVFX_FP_REG_SRC_SHIFT);
     		break;
    -	case NV40SR_CONST:
    +	case NVFXSR_CONST:
     		if (!fpc->have_const) {
     			grow_insns(fpc, 4);
     			fpc->have_const = 1;
    @@ -149,61 +149,61 @@ emit_src(struct nv40_fpc *fpc, int pos, struct nv40_sreg src)
     				sizeof(uint32_t) * 4);
     		}
     
    -		sr |= (NV40_FP_REG_TYPE_CONST << NV40_FP_REG_TYPE_SHIFT);
    +		sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);
     		break;
    -	case NV40SR_NONE:
    -		sr |= (NV40_FP_REG_TYPE_INPUT << NV40_FP_REG_TYPE_SHIFT);
    +	case NVFXSR_NONE:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
     		break;
     	default:
     		assert(0);
     	}
     
     	if (src.negate)
    -		sr |= NV40_FP_REG_NEGATE;
    +		sr |= NVFX_FP_REG_NEGATE;
     
     	if (src.abs)
     		hw[1] |= (1 << (29 + pos));
     
    -	sr |= ((src.swz[0] << NV40_FP_REG_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NV40_FP_REG_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NV40_FP_REG_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NV40_FP_REG_SWZ_W_SHIFT));
    +	sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |
    +	       (src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |
    +	       (src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |
    +	       (src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));
     
     	hw[pos + 1] |= sr;
     }
     
     static void
    -emit_dst(struct nv40_fpc *fpc, struct nv40_sreg dst)
    +emit_dst(struct nv40_fpc *fpc, struct nvfx_sreg dst)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw = &fp->insn[fpc->inst_offset];
     
     	switch (dst.type) {
    -	case NV40SR_TEMP:
    +	case NVFXSR_TEMP:
     		if (fpc->num_regs < (dst.index + 1))
     			fpc->num_regs = dst.index + 1;
     		break;
    -	case NV40SR_OUTPUT:
    +	case NVFXSR_OUTPUT:
     		if (dst.index == 1) {
     			fp->fp_control |= 0xe;
     		} else {
    -			hw[0] |= NV40_FP_OP_OUT_REG_HALF;
    +			hw[0] |= NVFX_FP_OP_OUT_REG_HALF;
     		}
     		break;
    -	case NV40SR_NONE:
    +	case NVFXSR_NONE:
     		hw[0] |= (1 << 30);
     		break;
     	default:
     		assert(0);
     	}
     
    -	hw[0] |= (dst.index << NV40_FP_OP_OUT_REG_SHIFT);
    +	hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);
     }
     
     static void
     nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
    -	      struct nv40_sreg dst, int mask,
    -	      struct nv40_sreg s0, struct nv40_sreg s1, struct nv40_sreg s2)
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     	uint32_t *hw;
    @@ -214,22 +214,22 @@ nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
     	hw = &fp->insn[fpc->inst_offset];
     	memset(hw, 0, sizeof(uint32_t) * 4);
     
    -	if (op == NV40_FP_OP_OPCODE_KIL)
    +	if (op == NVFX_FP_OP_OPCODE_KIL)
     		fp->fp_control |= NV40TCL_FP_CONTROL_KIL;
    -	hw[0] |= (op << NV40_FP_OP_OPCODE_SHIFT);
    -	hw[0] |= (mask << NV40_FP_OP_OUTMASK_SHIFT);
    -	hw[2] |= (dst.dst_scale << NV40_FP_OP_DST_SCALE_SHIFT);
    +	hw[0] |= (op << NVFX_FP_OP_OPCODE_SHIFT);
    +	hw[0] |= (mask << NVFX_FP_OP_OUTMASK_SHIFT);
    +	hw[2] |= (dst.dst_scale << NVFX_FP_OP_DST_SCALE_SHIFT);
     
     	if (sat)
    -		hw[0] |= NV40_FP_OP_OUT_SAT;
    +		hw[0] |= NVFX_FP_OP_OUT_SAT;
     
     	if (dst.cc_update)
    -		hw[0] |= NV40_FP_OP_COND_WRITE_ENABLE;
    -	hw[1] |= (dst.cc_test << NV40_FP_OP_COND_SHIFT);
    -	hw[1] |= ((dst.cc_swz[0] << NV40_FP_OP_COND_SWZ_X_SHIFT) |
    -		  (dst.cc_swz[1] << NV40_FP_OP_COND_SWZ_Y_SHIFT) |
    -		  (dst.cc_swz[2] << NV40_FP_OP_COND_SWZ_Z_SHIFT) |
    -		  (dst.cc_swz[3] << NV40_FP_OP_COND_SWZ_W_SHIFT));
    +		hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;
    +	hw[1] |= (dst.cc_test << NVFX_FP_OP_COND_SHIFT);
    +	hw[1] |= ((dst.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |
    +		  (dst.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |
    +		  (dst.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |
    +		  (dst.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));
     
     	emit_dst(fpc, dst);
     	emit_src(fpc, 0, s0);
    @@ -239,25 +239,25 @@ nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
     
     static void
     nv40_fp_tex(struct nv40_fpc *fpc, int sat, int op, int unit,
    -	    struct nv40_sreg dst, int mask,
    -	    struct nv40_sreg s0, struct nv40_sreg s1, struct nv40_sreg s2)
    +	    struct nvfx_sreg dst, int mask,
    +	    struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
     {
     	struct nvfx_fragment_program *fp = fpc->fp;
     
     	nv40_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
     
    -	fp->insn[fpc->inst_offset] |= (unit << NV40_FP_OP_TEX_UNIT_SHIFT);
    +	fp->insn[fpc->inst_offset] |= (unit << NVFX_FP_OP_TEX_UNIT_SHIFT);
     	fp->samplers |= (1 << unit);
     }
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     tgsi_src(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     {
    -	struct nv40_sreg src;
    +	struct nvfx_sreg src;
     
     	switch (fsrc->Register.File) {
     	case TGSI_FILE_INPUT:
    -		src = nv40_sr(NV40SR_INPUT,
    +		src = nvfx_sr(NVFXSR_INPUT,
     			      fpc->attrib_map[fsrc->Register.Index]);
     		break;
     	case TGSI_FILE_CONSTANT:
    @@ -288,7 +288,7 @@ tgsi_src(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc)
     	return src;
     }
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     tgsi_dst(struct nv40_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
     	switch (fdst->Register.File) {
     	case TGSI_FILE_OUTPUT:
    @@ -296,10 +296,10 @@ tgsi_dst(struct nv40_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
     	case TGSI_FILE_TEMPORARY:
     		return fpc->r_temp[fdst->Register.Index];
     	case TGSI_FILE_NULL:
    -		return nv40_sr(NV40SR_NONE, 0);
    +		return nvfx_sr(NVFXSR_NONE, 0);
     	default:
     		NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
    -		return nv40_sr(NV40SR_NONE, 0);
    +		return nvfx_sr(NVFXSR_NONE, 0);
     	}
     }
     
    @@ -317,10 +317,10 @@ tgsi_mask(uint tgsi)
     
     static boolean
     src_native_swz(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nv40_sreg *src)
    +	       struct nvfx_sreg *src)
     {
    -	const struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
    -	struct nv40_sreg tgsi = tgsi_src(fpc, fsrc);
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
     	uint mask = 0;
     	uint c;
     
    @@ -352,8 +352,8 @@ static boolean
     nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
     				const struct tgsi_full_instruction *finst)
     {
    -	const struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
    -	struct nv40_sreg src[3], dst, tmp;
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg src[3], dst, tmp;
     	int mask, sat, unit;
     	int ai = -1, ci = -1, ii = -1;
     	int i;
    @@ -445,12 +445,12 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
     		arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_CMP:
    -		tmp = nv40_sr(NV40SR_NONE, 0);
    +		tmp = nvfx_sr(NVFXSR_NONE, 0);
     		tmp.cc_update = 1;
     		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    -		dst.cc_test = NV40_VP_INST_COND_GE;
    +		dst.cc_test = NVFX_VP_INST_COND_GE;
     		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    -		dst.cc_test = NV40_VP_INST_COND_LT;
    +		dst.cc_test = NVFX_VP_INST_COND_LT;
     		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
     		break;
     	case TGSI_OPCODE_COS:
    @@ -512,10 +512,10 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
     		arith(fpc, 0, KIL, none, 0, none, none, none);
     		break;
     	case TGSI_OPCODE_KIL:
    -		dst = nv40_sr(NV40SR_NONE, 0);
    +		dst = nvfx_sr(NVFXSR_NONE, 0);
     		dst.cc_update = 1;
     		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    -		dst.cc_update = 0; dst.cc_test = NV40_FP_OP_COND_LT;
    +		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
     		arith(fpc, 0, KIL, dst, 0, none, none, none);
     		break;
     	case TGSI_OPCODE_LG2:
    @@ -662,25 +662,25 @@ nv40_fragprog_parse_decl_attrib(struct nv40_fpc *fpc,
     
     	switch (fdec->Semantic.Name) {
     	case TGSI_SEMANTIC_POSITION:
    -		hw = NV40_FP_OP_INPUT_SRC_POSITION;
    +		hw = NVFX_FP_OP_INPUT_SRC_POSITION;
     		break;
     	case TGSI_SEMANTIC_COLOR:
     		if (fdec->Semantic.Index == 0) {
    -			hw = NV40_FP_OP_INPUT_SRC_COL0;
    +			hw = NVFX_FP_OP_INPUT_SRC_COL0;
     		} else
     		if (fdec->Semantic.Index == 1) {
    -			hw = NV40_FP_OP_INPUT_SRC_COL1;
    +			hw = NVFX_FP_OP_INPUT_SRC_COL1;
     		} else {
     			NOUVEAU_ERR("bad colour semantic index\n");
     			return FALSE;
     		}
     		break;
     	case TGSI_SEMANTIC_FOG:
    -		hw = NV40_FP_OP_INPUT_SRC_FOGC;
    +		hw = NVFX_FP_OP_INPUT_SRC_FOGC;
     		break;
     	case TGSI_SEMANTIC_GENERIC:
     		if (fdec->Semantic.Index <= 7) {
    -			hw = NV40_FP_OP_INPUT_SRC_TC(fdec->Semantic.
    +			hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.
     						     Index);
     		} else {
     			NOUVEAU_ERR("bad generic semantic index\n");
    @@ -723,7 +723,7 @@ nv40_fragprog_parse_decl_output(struct nv40_fpc *fpc,
     		return FALSE;
     	}
     
    -	fpc->r_result[idx] = nv40_sr(NV40SR_OUTPUT, hw);
    +	fpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
     	fpc->r_temps |= (1 << hw);
     	return TRUE;
     }
    @@ -787,7 +787,7 @@ nv40_fragprog_prepare(struct nv40_fpc *fpc)
     	tgsi_parse_free(&p);
     
     	if (++high_temp) {
    -		fpc->r_temp = CALLOC(high_temp, sizeof(struct nv40_sreg));
    +		fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
     		for (i = 0; i < high_temp; i++)
     			fpc->r_temp[i] = temp(fpc);
     		fpc->r_temps_discard = 0;
    diff --git a/src/gallium/drivers/nv40/nv40_shader.h b/src/gallium/drivers/nv40/nv40_shader.h
    index 854dccf548..8d28137e9d 100644
    --- a/src/gallium/drivers/nv40/nv40_shader.h
    +++ b/src/gallium/drivers/nv40/nv40_shader.h
    @@ -48,14 +48,6 @@
     #define NV40_VP_INST_COND_TEST_ENABLE                                  (1 << 13)
     #define NV40_VP_INST_COND_SHIFT                                               10
     #define NV40_VP_INST_COND_MASK                                       (0x7 << 10)
    -#    define NV40_VP_INST_COND_FL                                               0
    -#    define NV40_VP_INST_COND_LT                                               1
    -#    define NV40_VP_INST_COND_EQ                                               2
    -#    define NV40_VP_INST_COND_LE                                               3
    -#    define NV40_VP_INST_COND_GT                                               4
    -#    define NV40_VP_INST_COND_NE                                               5
    -#    define NV40_VP_INST_COND_GE                                               6
    -#    define NV40_VP_INST_COND_TR                                               7
     #define NV40_VP_INST_COND_SWZ_X_SHIFT                                          8
     #define NV40_VP_INST_COND_SWZ_X_MASK                                    (3 << 8)
     #define NV40_VP_INST_COND_SWZ_Y_SHIFT                                          6
    @@ -84,63 +76,12 @@
     /* ---- OPCODE BITS 95:64 / data DWORD 1 --- */
     #define NV40_VP_INST_VEC_OPCODE_SHIFT                                         22
     #define NV40_VP_INST_VEC_OPCODE_MASK                                (0x1F << 22)
    -#    define NV40_VP_INST_OP_NOP                                             0x00
    -#    define NV40_VP_INST_OP_MOV                                             0x01
    -#    define NV40_VP_INST_OP_MUL                                             0x02
    -#    define NV40_VP_INST_OP_ADD                                             0x03
    -#    define NV40_VP_INST_OP_MAD                                             0x04
    -#    define NV40_VP_INST_OP_DP3                                             0x05
    -#    define NV40_VP_INST_OP_DPH                                             0x06
    -#    define NV40_VP_INST_OP_DP4                                             0x07
    -#    define NV40_VP_INST_OP_DST                                             0x08
    -#    define NV40_VP_INST_OP_MIN                                             0x09
    -#    define NV40_VP_INST_OP_MAX                                             0x0A
    -#    define NV40_VP_INST_OP_SLT                                             0x0B
    -#    define NV40_VP_INST_OP_SGE                                             0x0C
    -#    define NV40_VP_INST_OP_ARL                                             0x0D
    -#    define NV40_VP_INST_OP_FRC                                             0x0E
    -#    define NV40_VP_INST_OP_FLR                                             0x0F
    -#    define NV40_VP_INST_OP_SEQ                                             0x10
    -#    define NV40_VP_INST_OP_SFL                                             0x11
    -#    define NV40_VP_INST_OP_SGT                                             0x12
    -#    define NV40_VP_INST_OP_SLE                                             0x13
    -#    define NV40_VP_INST_OP_SNE                                             0x14
    -#    define NV40_VP_INST_OP_STR                                             0x15
    -#    define NV40_VP_INST_OP_SSG                                             0x16
    -#    define NV40_VP_INST_OP_ARR                                             0x17
    -#    define NV40_VP_INST_OP_ARA                                             0x18
    -#    define NV40_VP_INST_OP_TXL                                             0x19
     #define NV40_VP_INST_SCA_OPCODE_SHIFT                                         27
     #define NV40_VP_INST_SCA_OPCODE_MASK                                (0x1F << 27)
    -#    define NV40_VP_INST_OP_NOP                                             0x00
    -#    define NV40_VP_INST_OP_MOV                                             0x01
    -#    define NV40_VP_INST_OP_RCP                                             0x02
    -#    define NV40_VP_INST_OP_RCC                                             0x03
    -#    define NV40_VP_INST_OP_RSQ                                             0x04
    -#    define NV40_VP_INST_OP_EXP                                             0x05
    -#    define NV40_VP_INST_OP_LOG                                             0x06
    -#    define NV40_VP_INST_OP_LIT                                             0x07
    -#    define NV40_VP_INST_OP_BRA                                             0x09
    -#    define NV40_VP_INST_OP_CAL                                             0x0B
    -#    define NV40_VP_INST_OP_RET                                             0x0C
    -#    define NV40_VP_INST_OP_LG2                                             0x0D
    -#    define NV40_VP_INST_OP_EX2                                             0x0E
    -#    define NV40_VP_INST_OP_SIN                                             0x0F
    -#    define NV40_VP_INST_OP_COS                                             0x10
    -#    define NV40_VP_INST_OP_PUSHA                                           0x13
    -#    define NV40_VP_INST_OP_POPA                                            0x14
     #define NV40_VP_INST_CONST_SRC_SHIFT                                          12
     #define NV40_VP_INST_CONST_SRC_MASK                                 (0xFF << 12)
     #define NV40_VP_INST_INPUT_SRC_SHIFT                                           8
     #define NV40_VP_INST_INPUT_SRC_MASK                                  (0x0F << 8)
    -#    define NV40_VP_INST_IN_POS                                                0
    -#    define NV40_VP_INST_IN_WEIGHT                                             1
    -#    define NV40_VP_INST_IN_NORMAL                                             2
    -#    define NV40_VP_INST_IN_COL0                                               3
    -#    define NV40_VP_INST_IN_COL1                                               4
    -#    define NV40_VP_INST_IN_FOGC                                               5
    -#    define NV40_VP_INST_IN_TC0                                                8
    -#    define NV40_VP_INST_IN_TC(n)                                          (8+n)
     #define NV40_VP_INST_SRC0H_SHIFT                                               0
     #define NV40_VP_INST_SRC0H_MASK                                      (0xFF << 0)
     #define NV40_VP_INST1_KNOWN ( \
    @@ -194,7 +135,6 @@
     #    define NV40_VP_INST_DEST_TC(n)                                        (7+n)
     #    define NV40_VP_INST_DEST_TEMP                                          0x1F
     #define NV40_VP_INST_INDEX_CONST                                        (1 << 1)
    -#define NV40_VP_INST_LAST                                               (1 << 0)
     #define NV40_VP_INST3_KNOWN ( \
                     NV40_VP_INST_SRC2L_MASK |\
                     NV40_VP_INST_SCA_WRITEMASK_MASK |\
    @@ -232,325 +172,7 @@
     #    define NV40_VP_SRC_REG_TYPE_INPUT                                         2
     #    define NV40_VP_SRC_REG_TYPE_CONST                                         3
     
    +#include "nvfx_shader.h"
     
    -/*
    - * Each fragment program opcode appears to be comprised of 4 32-bit values.
    - *
    - *         0 - Opcode, output reg/mask, ATTRIB source
    - *         1 - Source 0
    - *         2 - Source 1
    - *         3 - Source 2
    - *
    - * There appears to be no special difference between result regs and temp regs.
    - *                 result.color == R0.xyzw
    - *                 result.depth == R1.z
    - * When the fragprog contains instructions to write depth,
    - * NV30_TCL_PRIMITIVE_3D_UNK1D78=0 otherwise it is set to 1.
    - *
    - * Constants are inserted directly after the instruction that uses them.
    - * 
    - * It appears that it's not possible to use two input registers in one
    - * instruction as the input sourcing is done in the instruction dword
    - * and not the source selection dwords.  As such instructions such as:
    - * 
    - *                 ADD result.color, fragment.color, fragment.texcoord[0];
    - *
    - * must be split into two MOV's and then an ADD (nvidia does this) but
    - * I'm not sure why it's not just one MOV and then source the second input
    - * in the ADD instruction..
    - *
    - * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
    - * negation requires multiplication with a const.
    - *
    - * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO and
    - * SWIZZLE_ONE.
    - *
    - * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as
    - * SWIZZLE_ZERO is implemented simply by not writing to the relevant components
    - * of the destination.
    - *
    - * Looping
    - *   Loops appear to be fairly expensive on NV40 at least, the proprietary
    - *   driver goes to a lot of effort to avoid using the native looping
    - *   instructions.  If the total number of *executed* instructions between
    - *   REP/ENDREP or LOOP/ENDLOOP is <=500, the driver will unroll the loop.
    - *   The maximum loop count is 255.
    - *
    - * Conditional execution
    - *   TODO
    - * 
    - * Non-native instructions:
    - *         LIT
    - *         LRP - MAD+MAD
    - *         SUB - ADD, negate second source
    - *         RSQ - LG2 + EX2
    - *         POW - LG2 + MUL + EX2
    - *         SCS - COS + SIN
    - *         XPD
    - *         DP2 - MUL + ADD
    - *         NRM
    - */
    -
    -//== Opcode / Destination selection ==
    -#define NV40_FP_OP_PROGRAM_END                                          (1 << 0)
    -#define NV40_FP_OP_OUT_REG_SHIFT                                               1
    -#define NV40_FP_OP_OUT_REG_MASK                                        (63 << 1)
    -/* Needs to be set when writing outputs to get expected result.. */
    -#define NV40_FP_OP_OUT_REG_HALF                                         (1 << 7)
    -#define NV40_FP_OP_COND_WRITE_ENABLE                                    (1 << 8)
    -#define NV40_FP_OP_OUTMASK_SHIFT                                               9
    -#define NV40_FP_OP_OUTMASK_MASK                                       (0xF << 9)
    -#    define NV40_FP_OP_OUT_X                                            (1 << 9)
    -#    define NV40_FP_OP_OUT_Y                                            (1 <<10)
    -#    define NV40_FP_OP_OUT_Z                                            (1 <<11)
    -#    define NV40_FP_OP_OUT_W                                            (1 <<12)
    -/* Uncertain about these, especially the input_src values.. it's possible that
    - * they can be dynamically changed.
    - */
    -#define NV40_FP_OP_INPUT_SRC_SHIFT                                            13
    -#define NV40_FP_OP_INPUT_SRC_MASK                                     (15 << 13)
    -#    define NV40_FP_OP_INPUT_SRC_POSITION                                    0x0
    -#    define NV40_FP_OP_INPUT_SRC_COL0                                        0x1
    -#    define NV40_FP_OP_INPUT_SRC_COL1                                        0x2
    -#    define NV40_FP_OP_INPUT_SRC_FOGC                                        0x3
    -#    define NV40_FP_OP_INPUT_SRC_TC0                                         0x4
    -#    define NV40_FP_OP_INPUT_SRC_TC(n)                                 (0x4 + n)
    -#    define NV40_FP_OP_INPUT_SRC_FACING                                      0xE
    -#define NV40_FP_OP_TEX_UNIT_SHIFT                                             17
    -#define NV40_FP_OP_TEX_UNIT_MASK                                     (0xF << 17)
    -#define NV40_FP_OP_PRECISION_SHIFT                                            22
    -#define NV40_FP_OP_PRECISION_MASK                                      (3 << 22)
    -#   define NV40_FP_PRECISION_FP32                                              0
    -#   define NV40_FP_PRECISION_FP16                                              1
    -#   define NV40_FP_PRECISION_FX12                                              2
    -#define NV40_FP_OP_OPCODE_SHIFT                                               24
    -#define NV40_FP_OP_OPCODE_MASK                                      (0x3F << 24)
    -#        define NV40_FP_OP_OPCODE_NOP                                       0x00
    -#        define NV40_FP_OP_OPCODE_MOV                                       0x01
    -#        define NV40_FP_OP_OPCODE_MUL                                       0x02
    -#        define NV40_FP_OP_OPCODE_ADD                                       0x03
    -#        define NV40_FP_OP_OPCODE_MAD                                       0x04
    -#        define NV40_FP_OP_OPCODE_DP3                                       0x05
    -#        define NV40_FP_OP_OPCODE_DP4                                       0x06
    -#        define NV40_FP_OP_OPCODE_DST                                       0x07
    -#        define NV40_FP_OP_OPCODE_MIN                                       0x08
    -#        define NV40_FP_OP_OPCODE_MAX                                       0x09
    -#        define NV40_FP_OP_OPCODE_SLT                                       0x0A
    -#        define NV40_FP_OP_OPCODE_SGE                                       0x0B
    -#        define NV40_FP_OP_OPCODE_SLE                                       0x0C
    -#        define NV40_FP_OP_OPCODE_SGT                                       0x0D
    -#        define NV40_FP_OP_OPCODE_SNE                                       0x0E
    -#        define NV40_FP_OP_OPCODE_SEQ                                       0x0F
    -#        define NV40_FP_OP_OPCODE_FRC                                       0x10
    -#        define NV40_FP_OP_OPCODE_FLR                                       0x11
    -#        define NV40_FP_OP_OPCODE_KIL                                       0x12
    -#        define NV40_FP_OP_OPCODE_PK4B                                      0x13
    -#        define NV40_FP_OP_OPCODE_UP4B                                      0x14
    -/* DDX/DDY can only write to XY */
    -#        define NV40_FP_OP_OPCODE_DDX                                       0x15
    -#        define NV40_FP_OP_OPCODE_DDY                                       0x16
    -#        define NV40_FP_OP_OPCODE_TEX                                       0x17
    -#        define NV40_FP_OP_OPCODE_TXP                                       0x18
    -#        define NV40_FP_OP_OPCODE_TXD                                       0x19
    -#        define NV40_FP_OP_OPCODE_RCP                                       0x1A
    -#        define NV40_FP_OP_OPCODE_EX2                                       0x1C
    -#        define NV40_FP_OP_OPCODE_LG2                                       0x1D
    -#        define NV40_FP_OP_OPCODE_STR                                       0x20
    -#        define NV40_FP_OP_OPCODE_SFL                                       0x21
    -#        define NV40_FP_OP_OPCODE_COS                                       0x22
    -#        define NV40_FP_OP_OPCODE_SIN                                       0x23
    -#        define NV40_FP_OP_OPCODE_PK2H                                      0x24
    -#        define NV40_FP_OP_OPCODE_UP2H                                      0x25
    -#        define NV40_FP_OP_OPCODE_PK4UB                                     0x27
    -#        define NV40_FP_OP_OPCODE_UP4UB                                     0x28
    -#        define NV40_FP_OP_OPCODE_PK2US                                     0x29
    -#        define NV40_FP_OP_OPCODE_UP2US                                     0x2A
    -#        define NV40_FP_OP_OPCODE_DP2A                                      0x2E
    -#        define NV40_FP_OP_OPCODE_TXL                                       0x2F
    -#        define NV40_FP_OP_OPCODE_TXB                                       0x31
    -#        define NV40_FP_OP_OPCODE_DIV                                       0x3A
    -#        define NV40_FP_OP_OPCODE_UNK_LIT                                   0x3C
    -/* The use of these instructions appears to be indicated by bit 31 of DWORD 2.*/
    -#        define NV40_FP_OP_BRA_OPCODE_BRK                                    0x0
    -#        define NV40_FP_OP_BRA_OPCODE_CAL                                    0x1
    -#        define NV40_FP_OP_BRA_OPCODE_IF                                     0x2
    -#        define NV40_FP_OP_BRA_OPCODE_LOOP                                   0x3
    -#        define NV40_FP_OP_BRA_OPCODE_REP                                    0x4
    -#        define NV40_FP_OP_BRA_OPCODE_RET                                    0x5
    -#define NV40_FP_OP_OUT_SAT                                             (1 << 31)
    -
    -/* high order bits of SRC0 */
    -#define NV40_FP_OP_OUT_ABS                                             (1 << 29)
    -#define NV40_FP_OP_COND_SWZ_W_SHIFT                                           27
    -#define NV40_FP_OP_COND_SWZ_W_MASK                                     (3 << 27)
    -#define NV40_FP_OP_COND_SWZ_Z_SHIFT                                           25
    -#define NV40_FP_OP_COND_SWZ_Z_MASK                                     (3 << 25)
    -#define NV40_FP_OP_COND_SWZ_Y_SHIFT                                           23
    -#define NV40_FP_OP_COND_SWZ_Y_MASK                                     (3 << 23)
    -#define NV40_FP_OP_COND_SWZ_X_SHIFT                                           21
    -#define NV40_FP_OP_COND_SWZ_X_MASK                                     (3 << 21)
    -#define NV40_FP_OP_COND_SWZ_ALL_SHIFT                                         21
    -#define NV40_FP_OP_COND_SWZ_ALL_MASK                                (0xFF << 21)
    -#define NV40_FP_OP_COND_SHIFT                                                 18
    -#define NV40_FP_OP_COND_MASK                                        (0x07 << 18)
    -#        define NV40_FP_OP_COND_FL                                             0
    -#        define NV40_FP_OP_COND_LT                                             1
    -#        define NV40_FP_OP_COND_EQ                                             2
    -#        define NV40_FP_OP_COND_LE                                             3
    -#        define NV40_FP_OP_COND_GT                                             4
    -#        define NV40_FP_OP_COND_NE                                             5
    -#        define NV40_FP_OP_COND_GE                                             6
    -#        define NV40_FP_OP_COND_TR                                             7
    -
    -/* high order bits of SRC1 */
    -#define NV40_FP_OP_OPCODE_IS_BRANCH                                      (1<<31)
    -#define NV40_FP_OP_DST_SCALE_SHIFT                                            28
    -#define NV40_FP_OP_DST_SCALE_MASK                                      (3 << 28)
    -#define NV40_FP_OP_DST_SCALE_1X                                                0
    -#define NV40_FP_OP_DST_SCALE_2X                                                1
    -#define NV40_FP_OP_DST_SCALE_4X                                                2
    -#define NV40_FP_OP_DST_SCALE_8X                                                3
    -#define NV40_FP_OP_DST_SCALE_INV_2X                                            5
    -#define NV40_FP_OP_DST_SCALE_INV_4X                                            6
    -#define NV40_FP_OP_DST_SCALE_INV_8X                                            7
    -
    -/* SRC1 LOOP */
    -#define NV40_FP_OP_LOOP_INCR_SHIFT                                            19
    -#define NV40_FP_OP_LOOP_INCR_MASK                                   (0xFF << 19)
    -#define NV40_FP_OP_LOOP_INDEX_SHIFT                                           10
    -#define NV40_FP_OP_LOOP_INDEX_MASK                                  (0xFF << 10)
    -#define NV40_FP_OP_LOOP_COUNT_SHIFT                                            2
    -#define NV40_FP_OP_LOOP_COUNT_MASK                                   (0xFF << 2)
    -
    -/* SRC1 IF */
    -#define NV40_FP_OP_ELSE_ID_SHIFT                                               2
    -#define NV40_FP_OP_ELSE_ID_MASK                                      (0xFF << 2)
    -
    -/* SRC1 CAL */
    -#define NV40_FP_OP_IADDR_SHIFT                                                 2
    -#define NV40_FP_OP_IADDR_MASK                                        (0xFF << 2)
    -
    -/* SRC1 REP
    - *   I have no idea why there are 3 count values here..  but they
    - *   have always been filled with the same value in my tests so
    - *   far..
    - */
    -#define NV40_FP_OP_REP_COUNT1_SHIFT                                            2
    -#define NV40_FP_OP_REP_COUNT1_MASK                                   (0xFF << 2)
    -#define NV40_FP_OP_REP_COUNT2_SHIFT                                           10
    -#define NV40_FP_OP_REP_COUNT2_MASK                                  (0xFF << 10)
    -#define NV40_FP_OP_REP_COUNT3_SHIFT                                           19
    -#define NV40_FP_OP_REP_COUNT3_MASK                                  (0xFF << 19)
    -
    -/* SRC2 REP/IF */
    -#define NV40_FP_OP_END_ID_SHIFT                                                2
    -#define NV40_FP_OP_END_ID_MASK                                       (0xFF << 2)
    -
    -// SRC2 high-order
    -#define NV40_FP_OP_INDEX_INPUT                                         (1 << 30)
    -#define NV40_FP_OP_ADDR_INDEX_SHIFT                                           19
    -#define NV40_FP_OP_ADDR_INDEX_MASK                                   (0xF << 19)
    -
    -//== Register selection ==
    -#define NV40_FP_REG_TYPE_SHIFT                                                 0
    -#define NV40_FP_REG_TYPE_MASK                                           (3 << 0)
    -#        define NV40_FP_REG_TYPE_TEMP                                          0
    -#        define NV40_FP_REG_TYPE_INPUT                                         1
    -#        define NV40_FP_REG_TYPE_CONST                                         2
    -#define NV40_FP_REG_SRC_SHIFT                                                  2
    -#define NV40_FP_REG_SRC_MASK                                           (63 << 2)
    -#define NV40_FP_REG_SRC_HALF                                            (1 << 8)
    -#define NV40_FP_REG_SWZ_ALL_SHIFT                                              9
    -#define NV40_FP_REG_SWZ_ALL_MASK                                      (255 << 9)
    -#define NV40_FP_REG_SWZ_X_SHIFT                                                9
    -#define NV40_FP_REG_SWZ_X_MASK                                          (3 << 9)
    -#define NV40_FP_REG_SWZ_Y_SHIFT                                               11
    -#define NV40_FP_REG_SWZ_Y_MASK                                         (3 << 11)
    -#define NV40_FP_REG_SWZ_Z_SHIFT                                               13
    -#define NV40_FP_REG_SWZ_Z_MASK                                         (3 << 13)
    -#define NV40_FP_REG_SWZ_W_SHIFT                                               15
    -#define NV40_FP_REG_SWZ_W_MASK                                         (3 << 15)
    -#        define NV40_FP_SWIZZLE_X                                              0
    -#        define NV40_FP_SWIZZLE_Y                                              1
    -#        define NV40_FP_SWIZZLE_Z                                              2
    -#        define NV40_FP_SWIZZLE_W                                              3
    -#define NV40_FP_REG_NEGATE                                             (1 << 17)
    -
    -#ifndef NV40_SHADER_NO_FUCKEDNESS
    -#define NV40SR_NONE	0
    -#define NV40SR_OUTPUT	1
    -#define NV40SR_INPUT	2
    -#define NV40SR_TEMP	3
    -#define NV40SR_CONST	4
    -
    -struct nv40_sreg {
    -	int type;
    -	int index;
    -
    -	int dst_scale;
    -
    -	int negate;
    -	int abs;
    -	int swz[4];
    -
    -	int cc_update;
    -	int cc_update_reg;
    -	int cc_test;
    -	int cc_test_reg;
    -	int cc_swz[4];
    -};
    -
    -static INLINE struct nv40_sreg
    -nv40_sr(int type, int index)
    -{
    -	struct nv40_sreg temp = {
    -		.type = type,
    -		.index = index,
    -		.dst_scale = DEF_SCALE,
    -		.abs = 0,
    -		.negate = 0,
    -		.swz = { 0, 1, 2, 3 },
    -		.cc_update = 0,
    -		.cc_update_reg = 0,
    -		.cc_test = DEF_CTEST,
    -		.cc_test_reg = 0,
    -		.cc_swz = { 0, 1, 2, 3 },
    -	};
    -	return temp;
    -}
    -
    -static INLINE struct nv40_sreg
    -nv40_sr_swz(struct nv40_sreg src, int x, int y, int z, int w)
    -{
    -	struct nv40_sreg dst = src;
    -
    -	dst.swz[SWZ_X] = src.swz[x];
    -	dst.swz[SWZ_Y] = src.swz[y];
    -	dst.swz[SWZ_Z] = src.swz[z];
    -	dst.swz[SWZ_W] = src.swz[w];
    -	return dst;
    -}
    -
    -static INLINE struct nv40_sreg
    -nv40_sr_neg(struct nv40_sreg src)
    -{
    -	src.negate = !src.negate;
    -	return src;
    -}
    -
    -static INLINE struct nv40_sreg
    -nv40_sr_abs(struct nv40_sreg src)
    -{
    -	src.abs = 1;
    -	return src;
    -}
    -
    -static INLINE struct nv40_sreg
    -nv40_sr_scale(struct nv40_sreg src, int scale)
    -{
    -	src.dst_scale = scale;
    -	return src;
    -}
     #endif
     
    -#endif
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    index a199f0766e..752cd0d1b3 100644
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ b/src/gallium/drivers/nv40/nv40_vertprog.c
    @@ -34,9 +34,9 @@
     #define DEF_CTEST 0
     #include "nv40_shader.h"
     
    -#define swz(s,x,y,z,w) nv40_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nv40_sr_neg((s))
    -#define abs(s) nv40_sr_abs((s))
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
     
     #define NV40_VP_INST_DEST_CLIP(n) ((~0 - 6) + (n))
     
    @@ -47,17 +47,17 @@ struct nv40_vpc {
     
     	unsigned r_temps;
     	unsigned r_temps_discard;
    -	struct nv40_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    -	struct nv40_sreg *r_address;
    -	struct nv40_sreg *r_temp;
    +	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    +	struct nvfx_sreg *r_address;
    +	struct nvfx_sreg *r_temp;
     
    -	struct nv40_sreg *imm;
    +	struct nvfx_sreg *imm;
     	unsigned nr_imm;
     
     	unsigned hpos_idx;
     };
     
    -static struct nv40_sreg
    +static struct nvfx_sreg
     temp(struct nv40_vpc *vpc)
     {
     	int idx = ffs(~vpc->r_temps) - 1;
    @@ -65,12 +65,12 @@ temp(struct nv40_vpc *vpc)
     	if (idx < 0) {
     		NOUVEAU_ERR("out of temps!!\n");
     		assert(0);
    -		return nv40_sr(NV40SR_TEMP, 0);
    +		return nvfx_sr(NVFXSR_TEMP, 0);
     	}
     
     	vpc->r_temps |= (1 << idx);
     	vpc->r_temps_discard |= (1 << idx);
    -	return nv40_sr(NV40SR_TEMP, idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
     }
     
     static INLINE void
    @@ -80,7 +80,7 @@ release_temps(struct nv40_vpc *vpc)
     	vpc->r_temps_discard = 0;
     }
     
    -static struct nv40_sreg
    +static struct nvfx_sreg
     constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
    @@ -90,7 +90,7 @@ constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
     	if (pipe >= 0) {
     		for (idx = 0; idx < vp->nr_consts; idx++) {
     			if (vp->consts[idx].index == pipe)
    -				return nv40_sr(NV40SR_CONST, idx);
    +				return nvfx_sr(NVFXSR_CONST, idx);
     		}
     	}
     
    @@ -103,37 +103,37 @@ constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
     	vpd->value[1] = y;
     	vpd->value[2] = z;
     	vpd->value[3] = w;
    -	return nv40_sr(NV40SR_CONST, idx);
    +	return nvfx_sr(NVFXSR_CONST, idx);
     }
     
     #define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv40_vp_arith((cc), (s), NV40_VP_INST_##o, (d), (m), (s0), (s1), (s2))
    +	nv40_vp_arith((cc), NVFX_VP_INST_SLOT_##s, NVFX_VP_INST_##s##_OP_##o, (d), (m), (s0), (s1), (s2))
     
     static void
    -emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nv40_sreg src)
    +emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nvfx_sreg src)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t sr = 0;
     
     	switch (src.type) {
    -	case NV40SR_TEMP:
    +	case NVFXSR_TEMP:
     		sr |= (NV40_VP_SRC_REG_TYPE_TEMP << NV40_VP_SRC_REG_TYPE_SHIFT);
     		sr |= (src.index << NV40_VP_SRC_TEMP_SRC_SHIFT);
     		break;
    -	case NV40SR_INPUT:
    +	case NVFXSR_INPUT:
     		sr |= (NV40_VP_SRC_REG_TYPE_INPUT <<
     		       NV40_VP_SRC_REG_TYPE_SHIFT);
     		vp->ir |= (1 << src.index);
     		hw[1] |= (src.index << NV40_VP_INST_INPUT_SRC_SHIFT);
     		break;
    -	case NV40SR_CONST:
    +	case NVFXSR_CONST:
     		sr |= (NV40_VP_SRC_REG_TYPE_CONST <<
     		       NV40_VP_SRC_REG_TYPE_SHIFT);
     		assert(vpc->vpi->const_index == -1 ||
     		       vpc->vpi->const_index == src.index);
     		vpc->vpi->const_index = src.index;
     		break;
    -	case NV40SR_NONE:
    +	case NVFXSR_NONE:
     		sr |= (NV40_VP_SRC_REG_TYPE_INPUT <<
     		       NV40_VP_SRC_REG_TYPE_SHIFT);
     		break;
    @@ -174,12 +174,12 @@ emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nv40_sreg src)
     }
     
     static void
    -emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nv40_sreg dst)
    +emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nvfx_sreg dst)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     
     	switch (dst.type) {
    -	case NV40SR_TEMP:
    +	case NVFXSR_TEMP:
     		hw[3] |= NV40_VP_INST_DEST_MASK;
     		if (slot == 0) {
     			hw[0] |= (dst.index <<
    @@ -189,7 +189,7 @@ emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nv40_sreg dst)
     				  NV40_VP_INST_SCA_DEST_TEMP_SHIFT);
     		}
     		break;
    -	case NV40SR_OUTPUT:
    +	case NVFXSR_OUTPUT:
     		switch (dst.index) {
     		case NV40_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
     		case NV40_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    @@ -255,9 +255,9 @@ emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nv40_sreg dst)
     
     static void
     nv40_vp_arith(struct nv40_vpc *vpc, int slot, int op,
    -	      struct nv40_sreg dst, int mask,
    -	      struct nv40_sreg s0, struct nv40_sreg s1,
    -	      struct nv40_sreg s2)
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1,
    +	      struct nvfx_sreg s2)
     {
     	struct nvfx_vertex_program *vp = vpc->vp;
     	uint32_t *hw;
    @@ -269,7 +269,7 @@ nv40_vp_arith(struct nv40_vpc *vpc, int slot, int op,
     
     	hw = vpc->vpi->data;
     
    -	hw[0] |= (NV40_VP_INST_COND_TR << NV40_VP_INST_COND_SHIFT);
    +	hw[0] |= (NVFX_VP_INST_COND_TR << NV40_VP_INST_COND_SHIFT);
     	hw[0] |= ((0 << NV40_VP_INST_COND_SWZ_X_SHIFT) |
     		  (1 << NV40_VP_INST_COND_SWZ_Y_SHIFT) |
     		  (2 << NV40_VP_INST_COND_SWZ_Z_SHIFT) |
    @@ -291,13 +291,13 @@ nv40_vp_arith(struct nv40_vpc *vpc, int slot, int op,
     	emit_src(vpc, hw, 2, s2);
     }
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     tgsi_src(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
    -	struct nv40_sreg src;
    +	struct nvfx_sreg src;
     
     	switch (fsrc->Register.File) {
     	case TGSI_FILE_INPUT:
    -		src = nv40_sr(NV40SR_INPUT, fsrc->Register.Index);
    +		src = nvfx_sr(NVFXSR_INPUT, fsrc->Register.Index);
     		break;
     	case TGSI_FILE_CONSTANT:
     		src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
    @@ -322,9 +322,9 @@ tgsi_src(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
     	return src;
     }
     
    -static INLINE struct nv40_sreg
    +static INLINE struct nvfx_sreg
     tgsi_dst(struct nv40_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
    -	struct nv40_sreg dst;
    +	struct nvfx_sreg dst;
     
     	switch (fdst->Register.File) {
     	case TGSI_FILE_OUTPUT:
    @@ -358,10 +358,10 @@ tgsi_mask(uint tgsi)
     
     static boolean
     src_native_swz(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nv40_sreg *src)
    +	       struct nvfx_sreg *src)
     {
    -	const struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
    -	struct nv40_sreg tgsi = tgsi_src(vpc, fsrc);
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg tgsi = tgsi_src(vpc, fsrc);
     	uint mask = 0;
     	uint c;
     
    @@ -384,7 +384,7 @@ src_native_swz(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc,
     	*src = temp(vpc);
     
     	if (mask)
    -		arith(vpc, 0, OP_MOV, *src, mask, tgsi, none, none);
    +		arith(vpc, VEC, MOV, *src, mask, tgsi, none, none);
     
     	return FALSE;
     }
    @@ -393,8 +393,8 @@ static boolean
     nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
     				const struct tgsi_full_instruction *finst)
     {
    -	struct nv40_sreg src[3], dst, tmp;
    -	struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
    +	struct nvfx_sreg src[3], dst, tmp;
    +	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
     	int mask;
     	int ai = -1, ci = -1, ii = -1;
     	int i;
    @@ -434,7 +434,7 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -445,7 +445,7 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -456,7 +456,7 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, 0, OP_MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -474,93 +474,93 @@ nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
     
     	switch (finst->Instruction.Opcode) {
     	case TGSI_OPCODE_ABS:
    -		arith(vpc, 0, OP_MOV, dst, mask, abs(src[0]), none, none);
    +		arith(vpc, VEC, MOV, dst, mask, abs(src[0]), none, none);
     		break;
     	case TGSI_OPCODE_ADD:
    -		arith(vpc, 0, OP_ADD, dst, mask, src[0], none, src[1]);
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, src[1]);
     		break;
     	case TGSI_OPCODE_ARL:
    -		arith(vpc, 0, OP_ARL, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, ARL, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_DP3:
    -		arith(vpc, 0, OP_DP3, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DP3, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DP4:
    -		arith(vpc, 0, OP_DP4, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DP4, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DPH:
    -		arith(vpc, 0, OP_DPH, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DPH, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_DST:
    -		arith(vpc, 0, OP_DST, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, DST, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_EX2:
    -		arith(vpc, 1, OP_EX2, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, EX2, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_EXP:
    -		arith(vpc, 1, OP_EXP, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, EXP, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_FLR:
    -		arith(vpc, 0, OP_FLR, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, FLR, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_FRC:
    -		arith(vpc, 0, OP_FRC, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, FRC, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_LG2:
    -		arith(vpc, 1, OP_LG2, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LG2, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_LIT:
    -		arith(vpc, 1, OP_LIT, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LIT, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_LOG:
    -		arith(vpc, 1, OP_LOG, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, LOG, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_MAD:
    -		arith(vpc, 0, OP_MAD, dst, mask, src[0], src[1], src[2]);
    +		arith(vpc, VEC, MAD, dst, mask, src[0], src[1], src[2]);
     		break;
     	case TGSI_OPCODE_MAX:
    -		arith(vpc, 0, OP_MAX, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MAX, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_MIN:
    -		arith(vpc, 0, OP_MIN, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MIN, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_MOV:
    -		arith(vpc, 0, OP_MOV, dst, mask, src[0], none, none);
    +		arith(vpc, VEC, MOV, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_MUL:
    -		arith(vpc, 0, OP_MUL, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, MUL, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_POW:
     		tmp = temp(vpc);
    -		arith(vpc, 1, OP_LG2, tmp, MASK_X, none, none,
    +		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
     		      swz(src[0], X, X, X, X));
    -		arith(vpc, 0, OP_MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
     		      swz(src[1], X, X, X, X), none);
    -		arith(vpc, 1, OP_EX2, dst, mask, none, none,
    +		arith(vpc, SCA, EX2, dst, mask, none, none,
     		      swz(tmp, X, X, X, X));
     		break;
     	case TGSI_OPCODE_RCP:
    -		arith(vpc, 1, OP_RCP, dst, mask, none, none, src[0]);
    +		arith(vpc, SCA, RCP, dst, mask, none, none, src[0]);
     		break;
     	case TGSI_OPCODE_RET:
     		break;
     	case TGSI_OPCODE_RSQ:
    -		arith(vpc, 1, OP_RSQ, dst, mask, none, none, abs(src[0]));
    +		arith(vpc, SCA, RSQ, dst, mask, none, none, abs(src[0]));
     		break;
     	case TGSI_OPCODE_SGE:
    -		arith(vpc, 0, OP_SGE, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, SGE, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_SLT:
    -		arith(vpc, 0, OP_SLT, dst, mask, src[0], src[1], none);
    +		arith(vpc, VEC, SLT, dst, mask, src[0], src[1], none);
     		break;
     	case TGSI_OPCODE_SUB:
    -		arith(vpc, 0, OP_ADD, dst, mask, src[0], none, neg(src[1]));
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, neg(src[1]));
     		break;
     	case TGSI_OPCODE_XPD:
     		tmp = temp(vpc);
    -		arith(vpc, 0, OP_MUL, tmp, mask,
    +		arith(vpc, VEC, MUL, tmp, mask,
     		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(vpc, 0, OP_MAD, dst, (mask & ~MASK_W),
    +		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
     		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
     		      neg(tmp));
     		break;
    @@ -630,7 +630,7 @@ nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
     		return FALSE;
     	}
     
    -	vpc->r_result[idx] = nv40_sr(NV40SR_OUTPUT, hw);
    +	vpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
     	return TRUE;
     }
     
    @@ -702,18 +702,18 @@ nv40_vertprog_prepare(struct nv40_vpc *vpc)
     	tgsi_parse_free(&p);
     
     	if (nr_imm) {
    -		vpc->imm = CALLOC(nr_imm, sizeof(struct nv40_sreg));
    +		vpc->imm = CALLOC(nr_imm, sizeof(struct nvfx_sreg));
     		assert(vpc->imm);
     	}
     
     	if (++high_temp) {
    -		vpc->r_temp = CALLOC(high_temp, sizeof(struct nv40_sreg));
    +		vpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
     		for (i = 0; i < high_temp; i++)
     			vpc->r_temp[i] = temp(vpc);
     	}
     
     	if (++high_addr) {
    -		vpc->r_address = CALLOC(high_addr, sizeof(struct nv40_sreg));
    +		vpc->r_address = CALLOC(high_addr, sizeof(struct nvfx_sreg));
     		for (i = 0; i < high_addr; i++)
     			vpc->r_address[i] = temp(vpc);
     	}
    @@ -728,7 +728,7 @@ nv40_vertprog_translate(struct nvfx_context *nvfx,
     {
     	struct tgsi_parse_context parse;
     	struct nv40_vpc *vpc = NULL;
    -	struct nv40_sreg none = nv40_sr(NV40SR_NONE, 0);
    +	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
     	int i;
     
     	vpc = CALLOC(1, sizeof(struct nv40_vpc));
    @@ -785,24 +785,24 @@ nv40_vertprog_translate(struct nvfx_context *nvfx,
     	}
     
     	/* Write out HPOS if it was redirected to a temp earlier */
    -	if (vpc->r_result[vpc->hpos_idx].type != NV40SR_OUTPUT) {
    -		struct nv40_sreg hpos = nv40_sr(NV40SR_OUTPUT,
    +	if (vpc->r_result[vpc->hpos_idx].type != NVFXSR_OUTPUT) {
    +		struct nvfx_sreg hpos = nvfx_sr(NVFXSR_OUTPUT,
     						NV40_VP_INST_DEST_POS);
    -		struct nv40_sreg htmp = vpc->r_result[vpc->hpos_idx];
    +		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
     
    -		arith(vpc, 0, OP_MOV, hpos, MASK_ALL, htmp, none, none);
    +		arith(vpc, VEC, MOV, hpos, MASK_ALL, htmp, none, none);
     	}
     
     	/* Insert code to handle user clip planes */
     	for (i = 0; i < vp->ucp.nr; i++) {
    -		struct nv40_sreg cdst = nv40_sr(NV40SR_OUTPUT,
    +		struct nvfx_sreg cdst = nvfx_sr(NVFXSR_OUTPUT,
     						NV40_VP_INST_DEST_CLIP(i));
    -		struct nv40_sreg ceqn = constant(vpc, -1,
    +		struct nvfx_sreg ceqn = constant(vpc, -1,
     						 nvfx->clip.ucp[i][0],
     						 nvfx->clip.ucp[i][1],
     						 nvfx->clip.ucp[i][2],
     						 nvfx->clip.ucp[i][3]);
    -		struct nv40_sreg htmp = vpc->r_result[vpc->hpos_idx];
    +		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
     		unsigned mask;
     
     		switch (i) {
    @@ -814,10 +814,10 @@ nv40_vertprog_translate(struct nvfx_context *nvfx,
     			goto out_err;
     		}
     
    -		arith(vpc, 0, OP_DP4, cdst, mask, htmp, ceqn, none);
    +		arith(vpc, VEC, DP4, cdst, mask, htmp, ceqn, none);
     	}
     
    -	vp->insns[vp->nr_insns - 1].data[3] |= NV40_VP_INST_LAST;
    +	vp->insns[vp->nr_insns - 1].data[3] |= NVFX_VP_INST_LAST;
     	vp->translated = TRUE;
     out_err:
     	tgsi_parse_free(&parse);
    diff --git a/src/gallium/drivers/nvfx/nvfx_shader.h b/src/gallium/drivers/nvfx/nvfx_shader.h
    new file mode 100644
    index 0000000000..191131a40a
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_shader.h
    @@ -0,0 +1,407 @@
    +#ifndef __NVFX_SHADER_H__
    +#define __NVFX_SHADER_H__
    +
    +/* this will resolve to either the NV30 or the NV40 version
    + * depending on the current hardware */
    +/* unusual, but very fast and compact method */
    +#define NVFX_VP(c) ((NV30_VP_##c) + (nvfx->is_nv4x & ((NV40_VP_##c) - (NV30_VP_##c))))
    +
    +#define NVFX_VP_INST_SLOT_VEC 0
    +#define NVFX_VP_INST_SLOT_SCA 1
    +
    +#define NVFX_VP_INST_COND_FL  0 /* guess */
    +#define NVFX_VP_INST_COND_LT  1
    +#define NVFX_VP_INST_COND_EQ  2
    +#define NVFX_VP_INST_COND_LE  3
    +#define NVFX_VP_INST_COND_GT  4
    +#define NVFX_VP_INST_COND_NE  5
    +#define NVFX_VP_INST_COND_GE  6
    +#define NVFX_VP_INST_COND_TR  7 /* guess */
    +
    +#define NVFX_VP_INST_IN_POS  0    /* These seem to match the bindings specified in */
    +#define NVFX_VP_INST_IN_WEIGHT  1    /* the ARB_v_p spec (2.14.3.1) */
    +#define NVFX_VP_INST_IN_NORMAL  2
    +#define NVFX_VP_INST_IN_COL0  3    /* Should probably confirm them all though */
    +#define NVFX_VP_INST_IN_COL1  4
    +#define NVFX_VP_INST_IN_FOGC  5
    +#define NVFX_VP_INST_IN_TC0  8
    +#define NVFX_VP_INST_IN_TC(n)  (8+n)
    +
    +#define NVFX_VP_INST_SCA_OP_NOP 0x00
    +#define NVFX_VP_INST_SCA_OP_MOV 0x01
    +#define NVFX_VP_INST_SCA_OP_RCP 0x02
    +#define NVFX_VP_INST_SCA_OP_RCC 0x03
    +#define NVFX_VP_INST_SCA_OP_RSQ 0x04
    +#define NVFX_VP_INST_SCA_OP_EXP 0x05
    +#define NVFX_VP_INST_SCA_OP_LOG 0x06
    +#define NVFX_VP_INST_SCA_OP_LIT 0x07
    +#define NVFX_VP_INST_SCA_OP_BRA 0x09
    +#define NVFX_VP_INST_SCA_OP_CAL 0x0B
    +#define NVFX_VP_INST_SCA_OP_RET 0x0C
    +#define NVFX_VP_INST_SCA_OP_LG2 0x0D
    +#define NVFX_VP_INST_SCA_OP_EX2 0x0E
    +#define NVFX_VP_INST_SCA_OP_SIN 0x0F
    +#define NVFX_VP_INST_SCA_OP_COS 0x10
    +
    +#define NV40_VP_INST_SCA_OP_PUSHA 0x13
    +#define NV40_VP_INST_SCA_OP_POPA 0x14
    +
    +#define NVFX_VP_INST_VEC_OP_NOP 0x00
    +#define NVFX_VP_INST_VEC_OP_MOV 0x01
    +#define NVFX_VP_INST_VEC_OP_MUL 0x02
    +#define NVFX_VP_INST_VEC_OP_ADD 0x03
    +#define NVFX_VP_INST_VEC_OP_MAD 0x04
    +#define NVFX_VP_INST_VEC_OP_DP3 0x05
    +#define NVFX_VP_INST_VEC_OP_DPH 0x06
    +#define NVFX_VP_INST_VEC_OP_DP4 0x07
    +#define NVFX_VP_INST_VEC_OP_DST 0x08
    +#define NVFX_VP_INST_VEC_OP_MIN 0x09
    +#define NVFX_VP_INST_VEC_OP_MAX 0x0A
    +#define NVFX_VP_INST_VEC_OP_SLT 0x0B
    +#define NVFX_VP_INST_VEC_OP_SGE 0x0C
    +#define NVFX_VP_INST_VEC_OP_ARL 0x0D
    +#define NVFX_VP_INST_VEC_OP_FRC 0x0E
    +#define NVFX_VP_INST_VEC_OP_FLR 0x0F
    +#define NVFX_VP_INST_VEC_OP_SEQ 0x10
    +#define NVFX_VP_INST_VEC_OP_SFL 0x11
    +#define NVFX_VP_INST_VEC_OP_SGT 0x12
    +#define NVFX_VP_INST_VEC_OP_SLE 0x13
    +#define NVFX_VP_INST_VEC_OP_SNE 0x14
    +#define NVFX_VP_INST_VEC_OP_STR 0x15
    +#define NVFX_VP_INST_VEC_OP_SSG 0x16
    +#define NVFX_VP_INST_VEC_OP_ARR 0x17
    +#define NVFX_VP_INST_VEC_OP_ARA 0x18
    +
    +#define NV40_VP_INST_VEC_OP_TXL 0x19
    +
    +/* DWORD 3 */
    +#define NVFX_VP_INST_LAST                           (1 << 0)
    +
    +/*
    + * Each fragment program opcode appears to be comprised of 4 32-bit values.
    + *
    + *   0 - Opcode, output reg/mask, ATTRIB source
    + *   1 - Source 0
    + *   2 - Source 1
    + *   3 - Source 2
    + *
    + * There appears to be no special difference between result regs and temp regs.
    + *     result.color == R0.xyzw
    + *     result.depth == R1.z
    + * When the fragprog contains instructions to write depth, NV30_TCL_PRIMITIVE_3D_UNK1D78=0
    + * otherwise it is set to 1.
    + *
    + * Constants are inserted directly after the instruction that uses them.
    + *
    + * It appears that it's not possible to use two input registers in one
    + * instruction as the input sourcing is done in the instruction dword
    + * and not the source selection dwords.  As such instructions such as:
    + *
    + *     ADD result.color, fragment.color, fragment.texcoord[0];
    + *
    + * must be split into two MOV's and then an ADD (nvidia does this) but
    + * I'm not sure why it's not just one MOV and then source the second input
    + * in the ADD instruction..
    + *
    + * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
    + * negation requires multiplication with a const.
    + *
    + * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO/SWIZZLE_ONE
    + * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as SWIZZLE_ZERO
    + * is implemented simply by not writing to the relevant components of the destination.
    + *
    + * Conditional execution
    + *   TODO
    + *
    + * Non-native instructions:
    + *   LIT
    + *   LRP - MAD+MAD
    + *   SUB - ADD, negate second source
    + *   RSQ - LG2 + EX2
    + *   POW - LG2 + MUL + EX2
    + *   SCS - COS + SIN
    + *   XPD
    + *
    + * NV40 Looping
    + *   Loops appear to be fairly expensive on NV40 at least, the proprietary
    + *   driver goes to a lot of effort to avoid using the native looping
    + *   instructions.  If the total number of *executed* instructions between
    + *   REP/ENDREP or LOOP/ENDLOOP is <=500, the driver will unroll the loop.
    + *   The maximum loop count is 255.
    + *
    + */
    +
    +//== Opcode / Destination selection ==
    +#define NVFX_FP_OP_PROGRAM_END          (1 << 0)
    +#define NVFX_FP_OP_OUT_REG_SHIFT        1
    +#define NV30_FP_OP_OUT_REG_MASK          (31 << 1)  /* uncertain */
    +#define NV40_FP_OP_OUT_REG_MASK          (63 << 1)
    +/* Needs to be set when writing outputs to get expected result.. */
    +#define NVFX_FP_OP_OUT_REG_HALF          (1 << 7)
    +#define NVFX_FP_OP_COND_WRITE_ENABLE        (1 << 8)
    +#define NVFX_FP_OP_OUTMASK_SHIFT        9
    +#define NVFX_FP_OP_OUTMASK_MASK          (0xF << 9)
    +#  define NVFX_FP_OP_OUT_X  (1<<9)
    +#  define NVFX_FP_OP_OUT_Y  (1<<10)
    +#  define NVFX_FP_OP_OUT_Z  (1<<11)
    +#  define NVFX_FP_OP_OUT_W  (1<<12)
    +/* Uncertain about these, especially the input_src values.. it's possible that
    + * they can be dynamically changed.
    + */
    +#define NVFX_FP_OP_INPUT_SRC_SHIFT        13
    +#define NVFX_FP_OP_INPUT_SRC_MASK        (15 << 13)
    +#  define NVFX_FP_OP_INPUT_SRC_POSITION  0x0
    +#  define NVFX_FP_OP_INPUT_SRC_COL0  0x1
    +#  define NVFX_FP_OP_INPUT_SRC_COL1  0x2
    +#  define NVFX_FP_OP_INPUT_SRC_FOGC  0x3
    +#  define NVFX_FP_OP_INPUT_SRC_TC0    0x4
    +#  define NVFX_FP_OP_INPUT_SRC_TC(n)  (0x4 + n)
    +#  define NV40_FP_OP_INPUT_SRC_FACING  0xE
    +#define NVFX_FP_OP_TEX_UNIT_SHIFT        17
    +#define NVFX_FP_OP_TEX_UNIT_MASK        (0xF << 17) /* guess */
    +#define NVFX_FP_OP_PRECISION_SHIFT        22
    +#define NVFX_FP_OP_PRECISION_MASK        (3 << 22)
    +#   define NVFX_FP_PRECISION_FP32  0
    +#   define NVFX_FP_PRECISION_FP16  1
    +#   define NVFX_FP_PRECISION_FX12  2
    +#define NVFX_FP_OP_OPCODE_SHIFT          24
    +#define NVFX_FP_OP_OPCODE_MASK          (0x3F << 24)
    +/* NV30/NV40 fragment program opcodes */
    +#define NVFX_FP_OP_OPCODE_NOP 0x00
    +#define NVFX_FP_OP_OPCODE_MOV 0x01
    +#define NVFX_FP_OP_OPCODE_MUL 0x02
    +#define NVFX_FP_OP_OPCODE_ADD 0x03
    +#define NVFX_FP_OP_OPCODE_MAD 0x04
    +#define NVFX_FP_OP_OPCODE_DP3 0x05
    +#define NVFX_FP_OP_OPCODE_DP4 0x06
    +#define NVFX_FP_OP_OPCODE_DST 0x07
    +#define NVFX_FP_OP_OPCODE_MIN 0x08
    +#define NVFX_FP_OP_OPCODE_MAX 0x09
    +#define NVFX_FP_OP_OPCODE_SLT 0x0A
    +#define NVFX_FP_OP_OPCODE_SGE 0x0B
    +#define NVFX_FP_OP_OPCODE_SLE 0x0C
    +#define NVFX_FP_OP_OPCODE_SGT 0x0D
    +#define NVFX_FP_OP_OPCODE_SNE 0x0E
    +#define NVFX_FP_OP_OPCODE_SEQ 0x0F
    +#define NVFX_FP_OP_OPCODE_FRC 0x10
    +#define NVFX_FP_OP_OPCODE_FLR 0x11
    +#define NVFX_FP_OP_OPCODE_KIL 0x12
    +#define NVFX_FP_OP_OPCODE_PK4B 0x13
    +#define NVFX_FP_OP_OPCODE_UP4B 0x14
    +#define NVFX_FP_OP_OPCODE_DDX 0x15 /* can only write XY */
    +#define NVFX_FP_OP_OPCODE_DDY 0x16 /* can only write XY */
    +#define NVFX_FP_OP_OPCODE_TEX 0x17
    +#define NVFX_FP_OP_OPCODE_TXP 0x18
    +#define NVFX_FP_OP_OPCODE_TXD 0x19
    +#define NVFX_FP_OP_OPCODE_RCP 0x1A
    +#define NVFX_FP_OP_OPCODE_EX2 0x1C
    +#define NVFX_FP_OP_OPCODE_LG2 0x1D
    +#define NVFX_FP_OP_OPCODE_STR 0x20
    +#define NVFX_FP_OP_OPCODE_SFL 0x21
    +#define NVFX_FP_OP_OPCODE_COS 0x22
    +#define NVFX_FP_OP_OPCODE_SIN 0x23
    +#define NVFX_FP_OP_OPCODE_PK2H 0x24
    +#define NVFX_FP_OP_OPCODE_UP2H 0x25
    +#define NVFX_FP_OP_OPCODE_PK4UB 0x27
    +#define NVFX_FP_OP_OPCODE_UP4UB 0x28
    +#define NVFX_FP_OP_OPCODE_PK2US 0x29
    +#define NVFX_FP_OP_OPCODE_UP2US 0x2A
    +#define NVFX_FP_OP_OPCODE_DP2A 0x2E
    +#define NVFX_FP_OP_OPCODE_TXB 0x31
    +#define NVFX_FP_OP_OPCODE_DIV 0x3A
    +
    +/* NV30 only fragment program opcodes */
    +#define NVFX_FP_OP_OPCODE_RSQ_NV30 0x1B
    +#define NVFX_FP_OP_OPCODE_LIT_NV30 0x1E
    +#define NVFX_FP_OP_OPCODE_LRP_NV30 0x1F
    +#define NVFX_FP_OP_OPCODE_POW_NV30 0x26
    +#define NVFX_FP_OP_OPCODE_RFL_NV30 0x36
    +
    +/* NV40 only fragment program opcodes */
    +#define NVFX_FP_OP_OPCODE_TXL_NV40 0x31
    +/* The use of these instructions appears to be indicated by bit 31 of DWORD 2.*/
    +#define NV40_FP_OP_BRA_OPCODE_BRK                                    0x0
    +#define NV40_FP_OP_BRA_OPCODE_CAL                                    0x1
    +#define NV40_FP_OP_BRA_OPCODE_IF                                     0x2
    +#define NV40_FP_OP_BRA_OPCODE_LOOP                                   0x3
    +#define NV40_FP_OP_BRA_OPCODE_REP                                    0x4
    +#define NV40_FP_OP_BRA_OPCODE_RET                                    0x5
    +
    +#define NVFX_FP_OP_OUT_SAT          (1 << 31)
    +
    +/* high order bits of SRC0 */
    +#define NVFX_FP_OP_OUT_ABS          (1 << 29)
    +#define NVFX_FP_OP_COND_SWZ_W_SHIFT        27
    +#define NVFX_FP_OP_COND_SWZ_W_MASK        (3 << 27)
    +#define NVFX_FP_OP_COND_SWZ_Z_SHIFT        25
    +#define NVFX_FP_OP_COND_SWZ_Z_MASK        (3 << 25)
    +#define NVFX_FP_OP_COND_SWZ_Y_SHIFT        23
    +#define NVFX_FP_OP_COND_SWZ_Y_MASK        (3 << 23)
    +#define NVFX_FP_OP_COND_SWZ_X_SHIFT        21
    +#define NVFX_FP_OP_COND_SWZ_X_MASK        (3 << 21)
    +#define NVFX_FP_OP_COND_SWZ_ALL_SHIFT        21
    +#define NVFX_FP_OP_COND_SWZ_ALL_MASK        (0xFF << 21)
    +#define NVFX_FP_OP_COND_SHIFT          18
    +#define NVFX_FP_OP_COND_MASK          (0x07 << 18)
    +#  define NVFX_FP_OP_COND_FL  0
    +#  define NVFX_FP_OP_COND_LT  1
    +#  define NVFX_FP_OP_COND_EQ  2
    +#  define NVFX_FP_OP_COND_LE  3
    +#  define NVFX_FP_OP_COND_GT  4
    +#  define NVFX_FP_OP_COND_NE  5
    +#  define NVFX_FP_OP_COND_GE  6
    +#  define NVFX_FP_OP_COND_TR  7
    +
    +/* high order bits of SRC1 */
    +#define NV40_FP_OP_OPCODE_IS_BRANCH                                      (1<<31)
    +#define NVFX_FP_OP_DST_SCALE_SHIFT        28
    +#define NVFX_FP_OP_DST_SCALE_MASK        (3 << 28)
    +#define NVFX_FP_OP_DST_SCALE_1X                                                0
    +#define NVFX_FP_OP_DST_SCALE_2X                                                1
    +#define NVFX_FP_OP_DST_SCALE_4X                                                2
    +#define NVFX_FP_OP_DST_SCALE_8X                                                3
    +#define NVFX_FP_OP_DST_SCALE_INV_2X                                            5
    +#define NVFX_FP_OP_DST_SCALE_INV_4X                                            6
    +#define NVFX_FP_OP_DST_SCALE_INV_8X                                            7
    +
    +/* SRC1 LOOP */
    +#define NV40_FP_OP_LOOP_INCR_SHIFT                                            19
    +#define NV40_FP_OP_LOOP_INCR_MASK                                   (0xFF << 19)
    +#define NV40_FP_OP_LOOP_INDEX_SHIFT                                           10
    +#define NV40_FP_OP_LOOP_INDEX_MASK                                  (0xFF << 10)
    +#define NV40_FP_OP_LOOP_COUNT_SHIFT                                            2
    +#define NV40_FP_OP_LOOP_COUNT_MASK                                   (0xFF << 2)
    +
    +/* SRC1 IF */
    +#define NV40_FP_OP_ELSE_ID_SHIFT                                               2
    +#define NV40_FP_OP_ELSE_ID_MASK                                      (0xFF << 2)
    +
    +/* SRC1 CAL */
    +#define NV40_FP_OP_IADDR_SHIFT                                                 2
    +#define NV40_FP_OP_IADDR_MASK                                        (0xFF << 2)
    +
    +/* SRC1 REP
    + *   I have no idea why there are 3 count values here..  but they
    + *   have always been filled with the same value in my tests so
    + *   far..
    + */
    +#define NV40_FP_OP_REP_COUNT1_SHIFT                                            2
    +#define NV40_FP_OP_REP_COUNT1_MASK                                   (0xFF << 2)
    +#define NV40_FP_OP_REP_COUNT2_SHIFT                                           10
    +#define NV40_FP_OP_REP_COUNT2_MASK                                  (0xFF << 10)
    +#define NV40_FP_OP_REP_COUNT3_SHIFT                                           19
    +#define NV40_FP_OP_REP_COUNT3_MASK                                  (0xFF << 19)
    +
    +/* SRC2 REP/IF */
    +#define NV40_FP_OP_END_ID_SHIFT                                                2
    +#define NV40_FP_OP_END_ID_MASK                                       (0xFF << 2)
    +
    +/* high order bits of SRC2 */
    +#define NVFX_FP_OP_INDEX_INPUT          (1 << 30)
    +#define NV40_FP_OP_ADDR_INDEX_SHIFT        19
    +#define NV40_FP_OP_ADDR_INDEX_MASK        (0xF << 19)
    +
    +//== Register selection ==
    +#define NVFX_FP_REG_TYPE_SHIFT           0
    +#define NVFX_FP_REG_TYPE_MASK           (3 << 0)
    +#  define NVFX_FP_REG_TYPE_TEMP   0
    +#  define NVFX_FP_REG_TYPE_INPUT  1
    +#  define NVFX_FP_REG_TYPE_CONST  2
    +#define NVFX_FP_REG_SRC_SHIFT            2
    +#define NV30_FP_REG_SRC_MASK              (31 << 2)
    +#define NV40_FP_REG_SRC_MASK              (63 << 2)
    +#define NVFX_FP_REG_SRC_HALF            (1 << 8)
    +#define NVFX_FP_REG_SWZ_ALL_SHIFT        9
    +#define NVFX_FP_REG_SWZ_ALL_MASK        (255 << 9)
    +#define NVFX_FP_REG_SWZ_X_SHIFT          9
    +#define NVFX_FP_REG_SWZ_X_MASK          (3 << 9)
    +#define NVFX_FP_REG_SWZ_Y_SHIFT          11
    +#define NVFX_FP_REG_SWZ_Y_MASK          (3 << 11)
    +#define NVFX_FP_REG_SWZ_Z_SHIFT          13
    +#define NVFX_FP_REG_SWZ_Z_MASK          (3 << 13)
    +#define NVFX_FP_REG_SWZ_W_SHIFT          15
    +#define NVFX_FP_REG_SWZ_W_MASK          (3 << 15)
    +#  define NVFX_FP_SWIZZLE_X  0
    +#  define NVFX_FP_SWIZZLE_Y  1
    +#  define NVFX_FP_SWIZZLE_Z  2
    +#  define NVFX_FP_SWIZZLE_W  3
    +#define NVFX_FP_REG_NEGATE          (1 << 17)
    +
    +#ifndef NVFX_SHADER_NO_FUCKEDNESS
    +#define NVFXSR_NONE	0
    +#define NVFXSR_OUTPUT	1
    +#define NVFXSR_INPUT	2
    +#define NVFXSR_TEMP	3
    +#define NVFXSR_CONST	4
    +
    +struct nvfx_sreg {
    +	int type;
    +	int index;
    +
    +	int dst_scale;
    +
    +	int negate;
    +	int abs;
    +	int swz[4];
    +
    +	int cc_update;
    +	int cc_update_reg;
    +	int cc_test;
    +	int cc_test_reg;
    +	int cc_swz[4];
    +};
    +
    +static INLINE struct nvfx_sreg
    +nvfx_sr(int type, int index)
    +{
    +	struct nvfx_sreg temp = {
    +		.type = type,
    +		.index = index,
    +		.dst_scale = DEF_SCALE,
    +		.abs = 0,
    +		.negate = 0,
    +		.swz = { 0, 1, 2, 3 },
    +		.cc_update = 0,
    +		.cc_update_reg = 0,
    +		.cc_test = DEF_CTEST,
    +		.cc_test_reg = 0,
    +		.cc_swz = { 0, 1, 2, 3 },
    +	};
    +	return temp;
    +}
    +
    +static INLINE struct nvfx_sreg
    +nvfx_sr_swz(struct nvfx_sreg src, int x, int y, int z, int w)
    +{
    +	struct nvfx_sreg dst = src;
    +
    +	dst.swz[SWZ_X] = src.swz[x];
    +	dst.swz[SWZ_Y] = src.swz[y];
    +	dst.swz[SWZ_Z] = src.swz[z];
    +	dst.swz[SWZ_W] = src.swz[w];
    +	return dst;
    +}
    +
    +static INLINE struct nvfx_sreg
    +nvfx_sr_neg(struct nvfx_sreg src)
    +{
    +	src.negate = !src.negate;
    +	return src;
    +}
    +
    +static INLINE struct nvfx_sreg
    +nvfx_sr_abs(struct nvfx_sreg src)
    +{
    +	src.abs = 1;
    +	return src;
    +}
    +
    +static INLINE struct nvfx_sreg
    +nvfx_sr_scale(struct nvfx_sreg src, int scale)
    +{
    +	src.dst_scale = scale;
    +	return src;
    +}
    +#endif
    +
    +#endif
    -- 
    cgit v1.2.3
    
    
    From bcb37411fc9159a5c1af50b7defbf1f526b50793 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 10:55:41 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_fragprog.c
    
    The files are mostly the same except:
    1. On NV40, some TGSI instructions are emulated with several hardware ones
    2. Some instructions such as DDX/DDY, and STR were missing from nv30
    3. NV40 has more sophisticated register management
    
    nv30 now supports all instructions and uses the nv40 register management.
    ---
     src/gallium/drivers/nv30/Makefile          |    1 -
     src/gallium/drivers/nv30/nv30_context.h    |    5 -
     src/gallium/drivers/nv30/nv30_fragprog.c   |  903 -------------------------
     src/gallium/drivers/nv30/nv30_state.c      |    2 +-
     src/gallium/drivers/nv40/Makefile          |    1 -
     src/gallium/drivers/nv40/nv40_context.h    |    5 -
     src/gallium/drivers/nv40/nv40_fragprog.c   |  984 ---------------------------
     src/gallium/drivers/nv40/nv40_state.c      |    2 +-
     src/gallium/drivers/nvfx/Makefile          |    3 +-
     src/gallium/drivers/nvfx/nvfx_context.h    |    5 +
     src/gallium/drivers/nvfx/nvfx_fragprog.c   | 1011 ++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_state_emit.c |    2 +-
     12 files changed, 1021 insertions(+), 1903 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_fragprog.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_fragprog.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_fragprog.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index b5728a34f8..196cc9a1ef 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -6,7 +6,6 @@ LIBNAME = nv30
     C_SOURCES = \
     	nv30_context.c \
     	nv30_draw.c \
    -	nv30_fragprog.c \
     	nv30_fragtex.c \
     	nv30_screen.c \
     	nv30_state.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index c203425cc9..7840318363 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -12,15 +12,10 @@ extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
     extern void nv30_vertprog_destroy(struct nvfx_context *,
     				  struct nvfx_vertex_program *);
     
    -/* nv30_fragprog.c */
    -extern void nv30_fragprog_destroy(struct nvfx_context *,
    -				  struct nvfx_fragment_program *);
    -
     /* nv30_fragtex.c */
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
     /* nv30_state.c and friends */
    -extern struct nvfx_state_entry nv30_state_fragprog;
     extern struct nvfx_state_entry nv30_state_vertprog;
     extern struct nvfx_state_entry nv30_state_fragtex;
     extern struct nvfx_state_entry nv30_state_vbo;
    diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
    deleted file mode 100644
    index 4ce16b8f0e..0000000000
    --- a/src/gallium/drivers/nv30/nv30_fragprog.c
    +++ /dev/null
    @@ -1,903 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -
    -#include "pipe/p_shader_tokens.h"
    -#include "tgsi/tgsi_dump.h"
    -#include "tgsi/tgsi_parse.h"
    -#include "tgsi/tgsi_util.h"
    -
    -#include "nv30_context.h"
    -
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 1
    -#define MASK_Y 2
    -#define MASK_Z 4
    -#define MASK_W 8
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    -#define DEF_CTEST NVFX_FP_OP_COND_TR
    -#include "nvfx_shader.h"
    -
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
    -
    -#define MAX_CONSTS 128
    -#define MAX_IMM 32
    -struct nv30_fpc {
    -	struct nvfx_fragment_program *fp;
    -
    -	uint attrib_map[PIPE_MAX_SHADER_INPUTS];
    -
    -	int high_temp;
    -	int temp_temp_count;
    -	int num_regs;
    -
    -	uint depth_id;
    -	uint colour_id;
    -
    -	unsigned inst_offset;
    -
    -	struct {
    -		int pipe;
    -		float vals[4];
    -	} consts[MAX_CONSTS];
    -	int nr_consts;
    -
    -	struct nvfx_sreg imm[MAX_IMM];
    -	unsigned nr_imm;
    -};
    -
    -static INLINE struct nvfx_sreg
    -temp(struct nv30_fpc *fpc)
    -{
    -	int idx;
    -
    -	idx  = fpc->temp_temp_count++;
    -	idx += fpc->high_temp + 1;
    -	return nvfx_sr(NVFXSR_TEMP, idx);
    -}
    -
    -static INLINE struct nvfx_sreg
    -constant(struct nv30_fpc *fpc, int pipe, float vals[4])
    -{
    -	int idx;
    -
    -	if (fpc->nr_consts == MAX_CONSTS)
    -		assert(0);
    -	idx = fpc->nr_consts++;
    -
    -	fpc->consts[idx].pipe = pipe;
    -	if (pipe == -1)
    -		memcpy(fpc->consts[idx].vals, vals, 4 * sizeof(float));
    -	return nvfx_sr(NVFXSR_CONST, idx);
    -}
    -
    -#define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv30_fp_arith((cc), (s), NVFX_FP_OP_OPCODE_##o, \
    -			(d), (m), (s0), (s1), (s2))
    -#define tex(cc,s,o,u,d,m,s0,s1,s2) \
    -	nv30_fp_tex((cc), (s), NVFX_FP_OP_OPCODE_##o, (u), \
    -		    (d), (m), (s0), none, none)
    -
    -static void
    -grow_insns(struct nv30_fpc *fpc, int size)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -
    -	fp->insn_len += size;
    -	fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);
    -}
    -
    -static void
    -emit_src(struct nv30_fpc *fpc, int pos, struct nvfx_sreg src)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw = &fp->insn[fpc->inst_offset];
    -	uint32_t sr = 0;
    -
    -	switch (src.type) {
    -	case NVFXSR_INPUT:
    -		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    -		hw[0] |= (src.index << NVFX_FP_OP_INPUT_SRC_SHIFT);
    -		break;
    -	case NVFXSR_OUTPUT:
    -		sr |= NVFX_FP_REG_SRC_HALF;
    -		/* fall-through */
    -	case NVFXSR_TEMP:
    -		sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);
    -		sr |= (src.index << NVFX_FP_REG_SRC_SHIFT);
    -		break;
    -	case NVFXSR_CONST:
    -		grow_insns(fpc, 4);
    -		hw = &fp->insn[fpc->inst_offset];
    -		if (fpc->consts[src.index].pipe >= 0) {
    -			struct nvfx_fragment_program_data *fpd;
    -
    -			fp->consts = realloc(fp->consts, ++fp->nr_consts *
    -					     sizeof(*fpd));
    -			fpd = &fp->consts[fp->nr_consts - 1];
    -			fpd->offset = fpc->inst_offset + 4;
    -			fpd->index = fpc->consts[src.index].pipe;
    -			memset(&fp->insn[fpd->offset], 0, sizeof(uint32_t) * 4);
    -		} else {
    -			memcpy(&fp->insn[fpc->inst_offset + 4],
    -				fpc->consts[src.index].vals,
    -				sizeof(uint32_t) * 4);
    -		}
    -
    -		sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);
    -		break;
    -	case NVFXSR_NONE:
    -		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (src.negate)
    -		sr |= NVFX_FP_REG_NEGATE;
    -
    -	if (src.abs)
    -		hw[1] |= (1 << (29 + pos));
    -
    -	sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));
    -
    -	hw[pos + 1] |= sr;
    -}
    -
    -static void
    -emit_dst(struct nv30_fpc *fpc, struct nvfx_sreg dst)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw = &fp->insn[fpc->inst_offset];
    -
    -	switch (dst.type) {
    -	case NVFXSR_TEMP:
    -		if (fpc->num_regs < (dst.index + 1))
    -			fpc->num_regs = dst.index + 1;
    -		break;
    -	case NVFXSR_OUTPUT:
    -		if (dst.index == 1) {
    -			fp->fp_control |= 0xe;
    -		} else {
    -			hw[0] |= NVFX_FP_OP_OUT_REG_HALF;
    -		}
    -		break;
    -	case NVFXSR_NONE:
    -		hw[0] |= (1 << 30);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);
    -}
    -
    -static void
    -nv30_fp_arith(struct nv30_fpc *fpc, int sat, int op,
    -	      struct nvfx_sreg dst, int mask,
    -	      struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw;
    -
    -	fpc->inst_offset = fp->insn_len;
    -	grow_insns(fpc, 4);
    -	hw = &fp->insn[fpc->inst_offset];
    -	memset(hw, 0, sizeof(uint32_t) * 4);
    -
    -	if (op == NVFX_FP_OP_OPCODE_KIL)
    -		fp->fp_control |= NV34TCL_FP_CONTROL_USES_KIL;
    -	hw[0] |= (op << NVFX_FP_OP_OPCODE_SHIFT);
    -	hw[0] |= (mask << NVFX_FP_OP_OUTMASK_SHIFT);
    -	hw[2] |= (dst.dst_scale << NVFX_FP_OP_DST_SCALE_SHIFT);
    -
    -	if (sat)
    -		hw[0] |= NVFX_FP_OP_OUT_SAT;
    -
    -	if (dst.cc_update)
    -		hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;
    -	hw[1] |= (dst.cc_test << NVFX_FP_OP_COND_SHIFT);
    -	hw[1] |= ((dst.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |
    -		  (dst.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |
    -		  (dst.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |
    -		  (dst.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));
    -
    -	emit_dst(fpc, dst);
    -	emit_src(fpc, 0, s0);
    -	emit_src(fpc, 1, s1);
    -	emit_src(fpc, 2, s2);
    -}
    -
    -static void
    -nv30_fp_tex(struct nv30_fpc *fpc, int sat, int op, int unit,
    -	    struct nvfx_sreg dst, int mask,
    -	    struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -
    -	nv30_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
    -
    -	fp->insn[fpc->inst_offset] |= (unit << NVFX_FP_OP_TEX_UNIT_SHIFT);
    -	fp->samplers |= (1 << unit);
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_src(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc)
    -{
    -	struct nvfx_sreg src;
    -
    -	switch (fsrc->Register.File) {
    -	case TGSI_FILE_INPUT:
    -		src = nvfx_sr(NVFXSR_INPUT,
    -			      fpc->attrib_map[fsrc->Register.Index]);
    -		break;
    -	case TGSI_FILE_CONSTANT:
    -		src = constant(fpc, fsrc->Register.Index, NULL);
    -		break;
    -	case TGSI_FILE_IMMEDIATE:
    -		assert(fsrc->Register.Index < fpc->nr_imm);
    -		src = fpc->imm[fsrc->Register.Index];
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		src = nvfx_sr(NVFXSR_TEMP, fsrc->Register.Index + 1);
    -		if (fpc->high_temp < src.index)
    -			fpc->high_temp = src.index;
    -		break;
    -	/* This is clearly insane, but gallium hands us shaders like this.
    -	 * Luckily fragprog results are just temp regs..
    -	 */
    -	case TGSI_FILE_OUTPUT:
    -		if (fsrc->Register.Index == fpc->colour_id)
    -			return nvfx_sr(NVFXSR_OUTPUT, 0);
    -		else
    -			return nvfx_sr(NVFXSR_OUTPUT, 1);
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad src file\n");
    -		break;
    -	}
    -
    -	src.abs = fsrc->Register.Absolute;
    -	src.negate = fsrc->Register.Negate;
    -	src.swz[0] = fsrc->Register.SwizzleX;
    -	src.swz[1] = fsrc->Register.SwizzleY;
    -	src.swz[2] = fsrc->Register.SwizzleZ;
    -	src.swz[3] = fsrc->Register.SwizzleW;
    -	return src;
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_dst(struct nv30_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
    -	int idx;
    -
    -	switch (fdst->Register.File) {
    -	case TGSI_FILE_OUTPUT:
    -		if (fdst->Register.Index == fpc->colour_id)
    -			return nvfx_sr(NVFXSR_OUTPUT, 0);
    -		else
    -			return nvfx_sr(NVFXSR_OUTPUT, 1);
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		idx = fdst->Register.Index + 1;
    -		if (fpc->high_temp < idx)
    -			fpc->high_temp = idx;
    -		return nvfx_sr(NVFXSR_TEMP, idx);
    -	case TGSI_FILE_NULL:
    -		return nvfx_sr(NVFXSR_NONE, 0);
    -	default:
    -		NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
    -		return nvfx_sr(NVFXSR_NONE, 0);
    -	}
    -}
    -
    -static INLINE int
    -tgsi_mask(uint tgsi)
    -{
    -	int mask = 0;
    -
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    -	return mask;
    -}
    -
    -static boolean
    -src_native_swz(struct nv30_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nvfx_sreg *src)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
    -	uint mask = 0;
    -	uint c;
    -
    -	for (c = 0; c < 4; c++) {
    -		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    -		case TGSI_SWIZZLE_X:
    -		case TGSI_SWIZZLE_Y:
    -		case TGSI_SWIZZLE_Z:
    -		case TGSI_SWIZZLE_W:
    -			mask |= (1 << c);
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	if (mask == MASK_ALL)
    -		return TRUE;
    -
    -	*src = temp(fpc);
    -
    -	if (mask)
    -		arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
    -
    -	return FALSE;
    -}
    -
    -static boolean
    -nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
    -				const struct tgsi_full_instruction *finst)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg src[3], dst, tmp;
    -	int mask, sat, unit = 0;
    -	int ai = -1, ci = -1;
    -	int i;
    -
    -	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    -		return TRUE;
    -
    -	fpc->temp_temp_count = 0;
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    -			src[i] = tgsi_src(fpc, fsrc);
    -		}
    -	}
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_TEMPORARY:
    -			if (!src_native_swz(fpc, fsrc, &src[i]))
    -				continue;
    -			break;
    -		default:
    -			break;
    -		}
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -			if (ai == -1 || ai == fsrc->Register.Index) {
    -				ai = fsrc->Register.Index;
    -				src[i] = tgsi_src(fpc, fsrc);
    -			} else {
    -				NOUVEAU_MSG("extra src attr %d\n",
    -					 fsrc->Register.Index);
    -				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    -				      tgsi_src(fpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_IMMEDIATE:
    -			if (ci == -1 || ci == fsrc->Register.Index) {
    -				ci = fsrc->Register.Index;
    -				src[i] = tgsi_src(fpc, fsrc);
    -			} else {
    -				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    -				      tgsi_src(fpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_TEMPORARY:
    -			/* handled above */
    -			break;
    -		case TGSI_FILE_SAMPLER:
    -			unit = fsrc->Register.Index;
    -			break;
    -		case TGSI_FILE_OUTPUT:
    -			break;
    -		default:
    -			NOUVEAU_ERR("bad src file\n");
    -			return FALSE;
    -		}
    -	}
    -
    -	dst  = tgsi_dst(fpc, &finst->Dst[0]);
    -	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    -	sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
    -
    -	switch (finst->Instruction.Opcode) {
    -	case TGSI_OPCODE_ABS:
    -		arith(fpc, sat, MOV, dst, mask, abs(src[0]), none, none);
    -		break;
    -	case TGSI_OPCODE_ADD:
    -		arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_CMP:
    -		tmp = nvfx_sr(NVFXSR_NONE, 0);
    -		tmp.cc_update = 1;
    -		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_GE;
    -		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_LT;
    -		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
    -		break;
    -	case TGSI_OPCODE_COS:
    -		arith(fpc, sat, COS, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_DP3:
    -		arith(fpc, sat, DP3, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DP4:
    -		arith(fpc, sat, DP4, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DPH:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[1], none);
    -		arith(fpc, sat, ADD, dst, mask, swz(tmp, X, X, X, X),
    -		      swz(src[1], W, W, W, W), none);
    -		break;
    -	case TGSI_OPCODE_DST:
    -		arith(fpc, sat, DST, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_EX2:
    -		arith(fpc, sat, EX2, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FLR:
    -		arith(fpc, sat, FLR, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FRC:
    -		arith(fpc, sat, FRC, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_KILP:
    -		arith(fpc, 0, KIL, none, 0, none, none, none);
    -		break;
    -	case TGSI_OPCODE_KIL:
    -		dst = nvfx_sr(NVFXSR_NONE, 0);
    -		dst.cc_update = 1;
    -		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    -		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
    -		arith(fpc, 0, KIL, dst, 0, none, none, none);
    -		break;
    -	case TGSI_OPCODE_LG2:
    -		arith(fpc, sat, LG2, dst, mask, src[0], none, none);
    -		break;
    -//	case TGSI_OPCODE_LIT:
    -	case TGSI_OPCODE_LRP:
    -		arith(fpc, sat, LRP_NV30, dst, mask, src[0], src[1], src[2]);
    -		break;
    -	case TGSI_OPCODE_MAD:
    -		arith(fpc, sat, MAD, dst, mask, src[0], src[1], src[2]);
    -		break;
    -	case TGSI_OPCODE_MAX:
    -		arith(fpc, sat, MAX, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MIN:
    -		arith(fpc, sat, MIN, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MOV:
    -		arith(fpc, sat, MOV, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_MUL:
    -		arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_POW:
    -		arith(fpc, sat, POW_NV30, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_RCP:
    -		arith(fpc, sat, RCP, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_RET:
    -		assert(0);
    -		break;
    -	case TGSI_OPCODE_RFL:
    -		arith(fpc, 0, RFL_NV30, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_RSQ:
    -		arith(fpc, sat, RSQ_NV30, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
    -		break;
    -	case TGSI_OPCODE_SCS:
    -		/* avoid overwriting the source */
    -		if(src[0].swz[SWZ_X] != SWZ_X)
    -		{
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -		}
    -		else
    -		{
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -		}
    -		break;
    -	case TGSI_OPCODE_SIN:
    -		arith(fpc, sat, SIN, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_SGE:
    -		arith(fpc, sat, SGE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SGT:
    -		arith(fpc, sat, SGT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SLT:
    -		arith(fpc, sat, SLT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SUB:
    -		arith(fpc, sat, ADD, dst, mask, src[0], neg(src[1]), none);
    -		break;
    -	case TGSI_OPCODE_TEX:
    -		tex(fpc, sat, TEX, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_TXB:
    -		tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_TXP:
    -		tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_XPD:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, MUL, tmp, mask,
    -		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(fpc, sat, MAD, dst, (mask & ~MASK_W),
    -		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    -		      neg(tmp));
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    -		return FALSE;
    -	}
    -
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_fragprog_parse_decl_attrib(struct nv30_fpc *fpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	int hw;
    -
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		hw = NVFX_FP_OP_INPUT_SRC_POSITION;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NVFX_FP_OP_INPUT_SRC_COL0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NVFX_FP_OP_INPUT_SRC_COL1;
    -		} else {
    -			NOUVEAU_ERR("bad colour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_FOG:
    -		hw = NVFX_FP_OP_INPUT_SRC_FOGC;
    -		break;
    -	case TGSI_SEMANTIC_GENERIC:
    -		if (fdec->Semantic.Index <= 7) {
    -			hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.
    -						     Index);
    -		} else {
    -			NOUVEAU_ERR("bad generic semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad input semantic\n");
    -		return FALSE;
    -	}
    -
    -	fpc->attrib_map[fdec->Range.First] = hw;
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_fragprog_parse_decl_output(struct nv30_fpc *fpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		fpc->depth_id = fdec->Range.First;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		fpc->colour_id = fdec->Range.First;
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad output semantic\n");
    -		return FALSE;
    -	}
    -
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_fragprog_prepare(struct nv30_fpc *fpc)
    -{
    -	struct tgsi_parse_context p;
    -	/*int high_temp = -1, i;*/
    -
    -	tgsi_parse_init(&p, fpc->fp->pipe.tokens);
    -	while (!tgsi_parse_end_of_tokens(&p)) {
    -		const union tgsi_full_token *tok = &p.FullToken;
    -
    -		tgsi_parse_token(&p);
    -		switch(tok->Token.Type) {
    -		case TGSI_TOKEN_TYPE_DECLARATION:
    -		{
    -			const struct tgsi_full_declaration *fdec;
    -			fdec = &p.FullToken.FullDeclaration;
    -			switch (fdec->Declaration.File) {
    -			case TGSI_FILE_INPUT:
    -				if (!nv30_fragprog_parse_decl_attrib(fpc, fdec))
    -					goto out_err;
    -				break;
    -			case TGSI_FILE_OUTPUT:
    -				if (!nv30_fragprog_parse_decl_output(fpc, fdec))
    -					goto out_err;
    -				break;
    -			/*case TGSI_FILE_TEMPORARY:
    -				if (fdec->Range.Last > high_temp) {
    -					high_temp =
    -						fdec->Range.Last;
    -				}
    -				break;*/
    -			default:
    -				break;
    -			}
    -		}
    -			break;
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -		{
    -			struct tgsi_full_immediate *imm;
    -			float vals[4];
    -
    -			imm = &p.FullToken.FullImmediate;
    -			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    -			assert(fpc->nr_imm < MAX_IMM);
    -
    -			vals[0] = imm->u[0].Float;
    -			vals[1] = imm->u[1].Float;
    -			vals[2] = imm->u[2].Float;
    -			vals[3] = imm->u[3].Float;
    -			fpc->imm[fpc->nr_imm++] = constant(fpc, -1, vals);
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -	tgsi_parse_free(&p);
    -
    -	/*if (++high_temp) {
    -		fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
    -		for (i = 0; i < high_temp; i++)
    -			fpc->r_temp[i] = temp(fpc);
    -		fpc->r_temps_discard = 0;
    -	}*/
    -
    -	return TRUE;
    -
    -out_err:
    -	/*if (fpc->r_temp)
    -		FREE(fpc->r_temp);*/
    -	tgsi_parse_free(&p);
    -	return FALSE;
    -}
    -
    -static void
    -nv30_fragprog_translate(struct nvfx_context *nvfx,
    -			struct nvfx_fragment_program *fp)
    -{
    -	struct tgsi_parse_context parse;
    -	struct nv30_fpc *fpc = NULL;
    -
    -	tgsi_dump(fp->pipe.tokens,0);
    -
    -	fpc = CALLOC(1, sizeof(struct nv30_fpc));
    -	if (!fpc)
    -		return;
    -	fpc->fp = fp;
    -	fpc->high_temp = -1;
    -	fpc->num_regs = 2;
    -
    -	if (!nv30_fragprog_prepare(fpc)) {
    -		FREE(fpc);
    -		return;
    -	}
    -
    -	tgsi_parse_init(&parse, fp->pipe.tokens);
    -
    -	while (!tgsi_parse_end_of_tokens(&parse)) {
    -		tgsi_parse_token(&parse);
    -
    -		switch (parse.FullToken.Token.Type) {
    -		case TGSI_TOKEN_TYPE_INSTRUCTION:
    -		{
    -			const struct tgsi_full_instruction *finst;
    -
    -			finst = &parse.FullToken.FullInstruction;
    -			if (!nv30_fragprog_parse_instruction(fpc, finst))
    -				goto out_err;
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	fp->fp_control |= (fpc->num_regs-1)/2;
    -
    -	/* Terminate final instruction */
    -	fp->insn[fpc->inst_offset] |= 0x00000001;
    -
    -	/* Append NOP + END instruction, may or may not be necessary. */
    -	fpc->inst_offset = fp->insn_len;
    -	grow_insns(fpc, 4);
    -	fp->insn[fpc->inst_offset + 0] = 0x00000001;
    -	fp->insn[fpc->inst_offset + 1] = 0x00000000;
    -	fp->insn[fpc->inst_offset + 2] = 0x00000000;
    -	fp->insn[fpc->inst_offset + 3] = 0x00000000;
    -
    -	fp->translated = TRUE;
    -out_err:
    -	tgsi_parse_free(&parse);
    -	FREE(fpc);
    -}
    -
    -static void
    -nv30_fragprog_upload(struct nvfx_context *nvfx,
    -		     struct nvfx_fragment_program *fp)
    -{
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	const uint32_t le = 1;
    -	uint32_t *map;
    -	int i;
    -
    -	map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
    -
    -#if 0
    -	for (i = 0; i < fp->insn_len; i++) {
    -		fflush(stdout); fflush(stderr);
    -		NOUVEAU_ERR("%d 0x%08x\n", i, fp->insn[i]);
    -		fflush(stdout); fflush(stderr);
    -	}
    -#endif
    -
    -	if ((*(const uint8_t *)&le)) {
    -		for (i = 0; i < fp->insn_len; i++) {
    -			map[i] = fp->insn[i];
    -		}
    -	} else {
    -		/* Weird swapping for big-endian chips */
    -		for (i = 0; i < fp->insn_len; i++) {
    -			map[i] = ((fp->insn[i] & 0xffff) << 16) |
    -				  ((fp->insn[i] >> 16) & 0xffff);
    -		}
    -	}
    -
    -	pipe_buffer_unmap(pscreen, fp->buffer);
    -}
    -
    -static boolean
    -nv30_fragprog_validate(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_fragment_program *fp = nvfx->fragprog;
    -	struct pipe_buffer *constbuf =
    -		nvfx->constbuf[PIPE_SHADER_FRAGMENT];
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nouveau_stateobj *so;
    -	boolean new_consts = FALSE;
    -	int i;
    -
    -	if (fp->translated)
    -		goto update_constants;
    -
    -	/*nvfx->fallback_swrast &= ~NVFX_NEW_FRAGPROG;*/
    -	nv30_fragprog_translate(nvfx, fp);
    -	if (!fp->translated) {
    -		/*nvfx->fallback_swrast |= NVFX_NEW_FRAGPROG;*/
    -		return FALSE;
    -	}
    -
    -	fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
    -	nv30_fragprog_upload(nvfx, fp);
    -
    -	so = so_new(4, 4, 1);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    -	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
    -		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
    -		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
    -		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_CONTROL, 1);
    -	so_data  (so, fp->fp_control);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_REG_CONTROL, 1);
    -	so_data  (so, (1<<16)|0x4);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_UNITS_ENABLE, 1);
    -	so_data  (so, fp->samplers);
    -	so_ref(so, &fp->so);
    -	so_ref(NULL, &so);
    -
    -update_constants:
    -	if (fp->nr_consts) {
    -		float *map;
    -
    -		map = pipe_buffer_map(pscreen, constbuf,
    -				      PIPE_BUFFER_USAGE_CPU_READ);
    -		for (i = 0; i < fp->nr_consts; i++) {
    -			struct nvfx_fragment_program_data *fpd = &fp->consts[i];
    -			uint32_t *p = &fp->insn[fpd->offset];
    -			uint32_t *cb = (uint32_t *)&map[fpd->index * 4];
    -
    -			if (!memcmp(p, cb, 4 * sizeof(float)))
    -				continue;
    -			memcpy(p, cb, 4 * sizeof(float));
    -			new_consts = TRUE;
    -		}
    -		pipe_buffer_unmap(pscreen, constbuf);
    -
    -		if (new_consts)
    -			nv30_fragprog_upload(nvfx, fp);
    -	}
    -
    -	if (new_consts || fp->so != nvfx->state.hw[NVFX_STATE_FRAGPROG]) {
    -		so_ref(fp->so, &nvfx->state.hw[NVFX_STATE_FRAGPROG]);
    -		return TRUE;
    -	}
    -
    -	return FALSE;
    -}
    -
    -void
    -nv30_fragprog_destroy(struct nvfx_context *nvfx,
    -		      struct nvfx_fragment_program *fp)
    -{
    -	if (fp->buffer)
    -		pipe_buffer_reference(&fp->buffer, NULL);
    -
    -	if (fp->so)
    -		so_ref(NULL, &fp->so);
    -
    -	if (fp->insn_len)
    -		FREE(fp->insn);
    -}
    -
    -struct nvfx_state_entry nv30_state_fragprog = {
    -	.validate = nv30_fragprog_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_FRAGPROG,
    -		.hw = NVFX_STATE_FRAGPROG
    -	}
    -};
    diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
    index 5263f894f2..92a4089b31 100644
    --- a/src/gallium/drivers/nv30/nv30_state.c
    +++ b/src/gallium/drivers/nv30/nv30_state.c
    @@ -567,7 +567,7 @@ nv30_fp_state_delete(struct pipe_context *pipe, void *hwcso)
     	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nvfx_fragment_program *fp = hwcso;
     
    -	nv30_fragprog_destroy(nvfx, fp);
    +	nvfx_fragprog_destroy(nvfx, fp);
     	FREE((void*)fp->pipe.tokens);
     	FREE(fp);
     }
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index f78e81ac4b..f3ff376dfd 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -6,7 +6,6 @@ LIBNAME = nv40
     C_SOURCES = \
     	nv40_context.c \
     	nv40_draw.c \
    -	nv40_fragprog.c \
     	nv40_fragtex.c \
     	nv40_screen.c \
     	nv40_state.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 3840134ce6..4cd56af8f7 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -16,15 +16,10 @@ extern void nv40_draw_elements_swtnl(struct pipe_context *pipe,
     extern void nv40_vertprog_destroy(struct nvfx_context *,
     				  struct nvfx_vertex_program *);
     
    -/* nv40_fragprog.c */
    -extern void nv40_fragprog_destroy(struct nvfx_context *,
    -				  struct nvfx_fragment_program *);
    -
     /* nv40_fragtex.c */
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
     /* nv40_state.c and friends */
    -extern struct nvfx_state_entry nv40_state_fragprog;
     extern struct nvfx_state_entry nv40_state_vertprog;
     extern struct nvfx_state_entry nv40_state_fragtex;
     extern struct nvfx_state_entry nv40_state_vbo;
    diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
    deleted file mode 100644
    index e044f367a0..0000000000
    --- a/src/gallium/drivers/nv40/nv40_fragprog.c
    +++ /dev/null
    @@ -1,984 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -
    -#include "pipe/p_shader_tokens.h"
    -#include "tgsi/tgsi_parse.h"
    -#include "tgsi/tgsi_util.h"
    -
    -#include "nv40_context.h"
    -
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 1
    -#define MASK_Y 2
    -#define MASK_Z 4
    -#define MASK_W 8
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    -#define DEF_CTEST NVFX_FP_OP_COND_TR
    -#include "nvfx_shader.h"
    -
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
    -
    -#define MAX_CONSTS 128
    -#define MAX_IMM 32
    -struct nv40_fpc {
    -	struct nvfx_fragment_program *fp;
    -
    -	uint attrib_map[PIPE_MAX_SHADER_INPUTS];
    -
    -	unsigned r_temps;
    -	unsigned r_temps_discard;
    -	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    -	struct nvfx_sreg *r_temp;
    -
    -	int num_regs;
    -
    -	unsigned inst_offset;
    -	unsigned have_const;
    -
    -	struct {
    -		int pipe;
    -		float vals[4];
    -	} consts[MAX_CONSTS];
    -	int nr_consts;
    -
    -	struct nvfx_sreg imm[MAX_IMM];
    -	unsigned nr_imm;
    -};
    -
    -static INLINE struct nvfx_sreg
    -temp(struct nv40_fpc *fpc)
    -{
    -	int idx = ffs(~fpc->r_temps) - 1;
    -
    -	if (idx < 0) {
    -		NOUVEAU_ERR("out of temps!!\n");
    -		assert(0);
    -		return nvfx_sr(NVFXSR_TEMP, 0);
    -	}
    -
    -	fpc->r_temps |= (1 << idx);
    -	fpc->r_temps_discard |= (1 << idx);
    -	return nvfx_sr(NVFXSR_TEMP, idx);
    -}
    -
    -static INLINE void
    -release_temps(struct nv40_fpc *fpc)
    -{
    -	fpc->r_temps &= ~fpc->r_temps_discard;
    -	fpc->r_temps_discard = 0;
    -}
    -
    -static INLINE struct nvfx_sreg
    -constant(struct nv40_fpc *fpc, int pipe, float vals[4])
    -{
    -	int idx;
    -
    -	if (fpc->nr_consts == MAX_CONSTS)
    -		assert(0);
    -	idx = fpc->nr_consts++;
    -
    -	fpc->consts[idx].pipe = pipe;
    -	if (pipe == -1)
    -		memcpy(fpc->consts[idx].vals, vals, 4 * sizeof(float));
    -	return nvfx_sr(NVFXSR_CONST, idx);
    -}
    -
    -#define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv40_fp_arith((cc), (s), NVFX_FP_OP_OPCODE_##o, \
    -			(d), (m), (s0), (s1), (s2))
    -#define tex(cc,s,o,u,d,m,s0,s1,s2) \
    -	nv40_fp_tex((cc), (s), NVFX_FP_OP_OPCODE_##o, (u), \
    -		    (d), (m), (s0), none, none)
    -
    -static void
    -grow_insns(struct nv40_fpc *fpc, int size)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -
    -	fp->insn_len += size;
    -	fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);
    -}
    -
    -static void
    -emit_src(struct nv40_fpc *fpc, int pos, struct nvfx_sreg src)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw = &fp->insn[fpc->inst_offset];
    -	uint32_t sr = 0;
    -
    -	switch (src.type) {
    -	case NVFXSR_INPUT:
    -		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    -		hw[0] |= (src.index << NVFX_FP_OP_INPUT_SRC_SHIFT);
    -		break;
    -	case NVFXSR_OUTPUT:
    -		sr |= NVFX_FP_REG_SRC_HALF;
    -		/* fall-through */
    -	case NVFXSR_TEMP:
    -		sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);
    -		sr |= (src.index << NVFX_FP_REG_SRC_SHIFT);
    -		break;
    -	case NVFXSR_CONST:
    -		if (!fpc->have_const) {
    -			grow_insns(fpc, 4);
    -			fpc->have_const = 1;
    -		}
    -
    -		hw = &fp->insn[fpc->inst_offset];
    -		if (fpc->consts[src.index].pipe >= 0) {
    -			struct nvfx_fragment_program_data *fpd;
    -
    -			fp->consts = realloc(fp->consts, ++fp->nr_consts *
    -					     sizeof(*fpd));
    -			fpd = &fp->consts[fp->nr_consts - 1];
    -			fpd->offset = fpc->inst_offset + 4;
    -			fpd->index = fpc->consts[src.index].pipe;
    -			memset(&fp->insn[fpd->offset], 0, sizeof(uint32_t) * 4);
    -		} else {
    -			memcpy(&fp->insn[fpc->inst_offset + 4],
    -				fpc->consts[src.index].vals,
    -				sizeof(uint32_t) * 4);
    -		}
    -
    -		sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);
    -		break;
    -	case NVFXSR_NONE:
    -		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (src.negate)
    -		sr |= NVFX_FP_REG_NEGATE;
    -
    -	if (src.abs)
    -		hw[1] |= (1 << (29 + pos));
    -
    -	sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));
    -
    -	hw[pos + 1] |= sr;
    -}
    -
    -static void
    -emit_dst(struct nv40_fpc *fpc, struct nvfx_sreg dst)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw = &fp->insn[fpc->inst_offset];
    -
    -	switch (dst.type) {
    -	case NVFXSR_TEMP:
    -		if (fpc->num_regs < (dst.index + 1))
    -			fpc->num_regs = dst.index + 1;
    -		break;
    -	case NVFXSR_OUTPUT:
    -		if (dst.index == 1) {
    -			fp->fp_control |= 0xe;
    -		} else {
    -			hw[0] |= NVFX_FP_OP_OUT_REG_HALF;
    -		}
    -		break;
    -	case NVFXSR_NONE:
    -		hw[0] |= (1 << 30);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);
    -}
    -
    -static void
    -nv40_fp_arith(struct nv40_fpc *fpc, int sat, int op,
    -	      struct nvfx_sreg dst, int mask,
    -	      struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -	uint32_t *hw;
    -
    -	fpc->inst_offset = fp->insn_len;
    -	fpc->have_const = 0;
    -	grow_insns(fpc, 4);
    -	hw = &fp->insn[fpc->inst_offset];
    -	memset(hw, 0, sizeof(uint32_t) * 4);
    -
    -	if (op == NVFX_FP_OP_OPCODE_KIL)
    -		fp->fp_control |= NV40TCL_FP_CONTROL_KIL;
    -	hw[0] |= (op << NVFX_FP_OP_OPCODE_SHIFT);
    -	hw[0] |= (mask << NVFX_FP_OP_OUTMASK_SHIFT);
    -	hw[2] |= (dst.dst_scale << NVFX_FP_OP_DST_SCALE_SHIFT);
    -
    -	if (sat)
    -		hw[0] |= NVFX_FP_OP_OUT_SAT;
    -
    -	if (dst.cc_update)
    -		hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;
    -	hw[1] |= (dst.cc_test << NVFX_FP_OP_COND_SHIFT);
    -	hw[1] |= ((dst.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |
    -		  (dst.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |
    -		  (dst.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |
    -		  (dst.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));
    -
    -	emit_dst(fpc, dst);
    -	emit_src(fpc, 0, s0);
    -	emit_src(fpc, 1, s1);
    -	emit_src(fpc, 2, s2);
    -}
    -
    -static void
    -nv40_fp_tex(struct nv40_fpc *fpc, int sat, int op, int unit,
    -	    struct nvfx_sreg dst, int mask,
    -	    struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    -{
    -	struct nvfx_fragment_program *fp = fpc->fp;
    -
    -	nv40_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
    -
    -	fp->insn[fpc->inst_offset] |= (unit << NVFX_FP_OP_TEX_UNIT_SHIFT);
    -	fp->samplers |= (1 << unit);
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_src(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc)
    -{
    -	struct nvfx_sreg src;
    -
    -	switch (fsrc->Register.File) {
    -	case TGSI_FILE_INPUT:
    -		src = nvfx_sr(NVFXSR_INPUT,
    -			      fpc->attrib_map[fsrc->Register.Index]);
    -		break;
    -	case TGSI_FILE_CONSTANT:
    -		src = constant(fpc, fsrc->Register.Index, NULL);
    -		break;
    -	case TGSI_FILE_IMMEDIATE:
    -		assert(fsrc->Register.Index < fpc->nr_imm);
    -		src = fpc->imm[fsrc->Register.Index];
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		src = fpc->r_temp[fsrc->Register.Index];
    -		break;
    -	/* NV40 fragprog result regs are just temps, so this is simple */
    -	case TGSI_FILE_OUTPUT:
    -		src = fpc->r_result[fsrc->Register.Index];
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad src file\n");
    -		break;
    -	}
    -
    -	src.abs = fsrc->Register.Absolute;
    -	src.negate = fsrc->Register.Negate;
    -	src.swz[0] = fsrc->Register.SwizzleX;
    -	src.swz[1] = fsrc->Register.SwizzleY;
    -	src.swz[2] = fsrc->Register.SwizzleZ;
    -	src.swz[3] = fsrc->Register.SwizzleW;
    -	return src;
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_dst(struct nv40_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
    -	switch (fdst->Register.File) {
    -	case TGSI_FILE_OUTPUT:
    -		return fpc->r_result[fdst->Register.Index];
    -	case TGSI_FILE_TEMPORARY:
    -		return fpc->r_temp[fdst->Register.Index];
    -	case TGSI_FILE_NULL:
    -		return nvfx_sr(NVFXSR_NONE, 0);
    -	default:
    -		NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
    -		return nvfx_sr(NVFXSR_NONE, 0);
    -	}
    -}
    -
    -static INLINE int
    -tgsi_mask(uint tgsi)
    -{
    -	int mask = 0;
    -
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    -	return mask;
    -}
    -
    -static boolean
    -src_native_swz(struct nv40_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nvfx_sreg *src)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
    -	uint mask = 0;
    -	uint c;
    -
    -	for (c = 0; c < 4; c++) {
    -		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    -		case TGSI_SWIZZLE_X:
    -		case TGSI_SWIZZLE_Y:
    -		case TGSI_SWIZZLE_Z:
    -		case TGSI_SWIZZLE_W:
    -			mask |= (1 << c);
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	if (mask == MASK_ALL)
    -		return TRUE;
    -
    -	*src = temp(fpc);
    -
    -	if (mask)
    -		arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
    -
    -	return FALSE;
    -}
    -
    -static boolean
    -nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
    -				const struct tgsi_full_instruction *finst)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg src[3], dst, tmp;
    -	int mask, sat, unit;
    -	int ai = -1, ci = -1, ii = -1;
    -	int i;
    -
    -	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    -		return TRUE;
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    -			src[i] = tgsi_src(fpc, fsrc);
    -		}
    -	}
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_TEMPORARY:
    -			if (!src_native_swz(fpc, fsrc, &src[i]))
    -				continue;
    -			break;
    -		default:
    -			break;
    -		}
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -			if (ai == -1 || ai == fsrc->Register.Index) {
    -				ai = fsrc->Register.Index;
    -				src[i] = tgsi_src(fpc, fsrc);
    -			} else {
    -				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    -				      tgsi_src(fpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_CONSTANT:
    -			if ((ci == -1 && ii == -1) ||
    -			    ci == fsrc->Register.Index) {
    -				ci = fsrc->Register.Index;
    -				src[i] = tgsi_src(fpc, fsrc);
    -			} else {
    -				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    -				      tgsi_src(fpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_IMMEDIATE:
    -			if ((ci == -1 && ii == -1) ||
    -			    ii == fsrc->Register.Index) {
    -				ii = fsrc->Register.Index;
    -				src[i] = tgsi_src(fpc, fsrc);
    -			} else {
    -				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    -				      tgsi_src(fpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_TEMPORARY:
    -			/* handled above */
    -			break;
    -		case TGSI_FILE_SAMPLER:
    -			unit = fsrc->Register.Index;
    -			break;
    -		case TGSI_FILE_OUTPUT:
    -			break;
    -		default:
    -			NOUVEAU_ERR("bad src file\n");
    -			return FALSE;
    -		}
    -	}
    -
    -	dst  = tgsi_dst(fpc, &finst->Dst[0]);
    -	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    -	sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
    -
    -	switch (finst->Instruction.Opcode) {
    -	case TGSI_OPCODE_ABS:
    -		arith(fpc, sat, MOV, dst, mask, abs(src[0]), none, none);
    -		break;
    -	case TGSI_OPCODE_ADD:
    -		arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_CMP:
    -		tmp = nvfx_sr(NVFXSR_NONE, 0);
    -		tmp.cc_update = 1;
    -		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_GE;
    -		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_LT;
    -		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
    -		break;
    -	case TGSI_OPCODE_COS:
    -		arith(fpc, sat, COS, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_DDX:
    -		if (mask & (MASK_Z | MASK_W)) {
    -			tmp = temp(fpc);
    -			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y,
    -			      swz(src[0], Z, W, Z, W), none, none);
    -			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    -			      swz(tmp, X, Y, X, Y), none, none);
    -			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y, src[0],
    -			      none, none);
    -			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
    -		} else {
    -			arith(fpc, sat, DDX, dst, mask, src[0], none, none);
    -		}
    -		break;
    -	case TGSI_OPCODE_DDY:
    -		if (mask & (MASK_Z | MASK_W)) {
    -			tmp = temp(fpc);
    -			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y,
    -			      swz(src[0], Z, W, Z, W), none, none);
    -			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    -			      swz(tmp, X, Y, X, Y), none, none);
    -			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y, src[0],
    -			      none, none);
    -			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
    -		} else {
    -			arith(fpc, sat, DDY, dst, mask, src[0], none, none);
    -		}
    -		break;
    -	case TGSI_OPCODE_DP3:
    -		arith(fpc, sat, DP3, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DP4:
    -		arith(fpc, sat, DP4, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DPH:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[1], none);
    -		arith(fpc, sat, ADD, dst, mask, swz(tmp, X, X, X, X),
    -		      swz(src[1], W, W, W, W), none);
    -		break;
    -	case TGSI_OPCODE_DST:
    -		arith(fpc, sat, DST, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_EX2:
    -		arith(fpc, sat, EX2, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FLR:
    -		arith(fpc, sat, FLR, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FRC:
    -		arith(fpc, sat, FRC, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_KILP:
    -		arith(fpc, 0, KIL, none, 0, none, none, none);
    -		break;
    -	case TGSI_OPCODE_KIL:
    -		dst = nvfx_sr(NVFXSR_NONE, 0);
    -		dst.cc_update = 1;
    -		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    -		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
    -		arith(fpc, 0, KIL, dst, 0, none, none, none);
    -		break;
    -	case TGSI_OPCODE_LG2:
    -		arith(fpc, sat, LG2, dst, mask, src[0], none, none);
    -		break;
    -//	case TGSI_OPCODE_LIT:
    -	case TGSI_OPCODE_LRP:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, MAD, tmp, mask, neg(src[0]), src[2], src[2]);
    -		arith(fpc, sat, MAD, dst, mask, src[0], src[1], tmp);
    -		break;
    -	case TGSI_OPCODE_MAD:
    -		arith(fpc, sat, MAD, dst, mask, src[0], src[1], src[2]);
    -		break;
    -	case TGSI_OPCODE_MAX:
    -		arith(fpc, sat, MAX, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MIN:
    -		arith(fpc, sat, MIN, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MOV:
    -		arith(fpc, sat, MOV, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_MUL:
    -		arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_POW:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, LG2, tmp, MASK_X,
    -		      swz(src[0], X, X, X, X), none, none);
    -		arith(fpc, 0, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    -		      swz(src[1], X, X, X, X), none);
    -		arith(fpc, sat, EX2, dst, mask,
    -		      swz(tmp, X, X, X, X), none, none);
    -		break;
    -	case TGSI_OPCODE_RCP:
    -		arith(fpc, sat, RCP, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_RET:
    -		assert(0);
    -		break;
    -	case TGSI_OPCODE_RFL:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[0], none);
    -		arith(fpc, 0, DP3, tmp, MASK_Y, src[0], src[1], none);
    -		arith(fpc, 0, DIV, scale(tmp, 2X), MASK_Z,
    -		      swz(tmp, Y, Y, Y, Y), swz(tmp, X, X, X, X), none);
    -		arith(fpc, sat, MAD, dst, mask,
    -		      swz(tmp, Z, Z, Z, Z), src[0], neg(src[1]));
    -		break;
    -	case TGSI_OPCODE_RSQ:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, LG2, scale(tmp, INV_2X), MASK_X,
    -		      abs(swz(src[0], X, X, X, X)), none, none);
    -		arith(fpc, sat, EX2, dst, mask,
    -		      neg(swz(tmp, X, X, X, X)), none, none);
    -		break;
    -	case TGSI_OPCODE_SCS:
    -		/* avoid overwriting the source */
    -		if(src[0].swz[SWZ_X] != SWZ_X)
    -		{
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -		}
    -		else
    -		{
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    -				      swz(src[0], X, X, X, X), none, none);
    -			}
    -		}
    -		break;
    -	case TGSI_OPCODE_SEQ:
    -		arith(fpc, sat, SEQ, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SFL:
    -		arith(fpc, sat, SFL, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SGE:
    -		arith(fpc, sat, SGE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SGT:
    -		arith(fpc, sat, SGT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SIN:
    -		arith(fpc, sat, SIN, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_SLE:
    -		arith(fpc, sat, SLE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SLT:
    -		arith(fpc, sat, SLT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SNE:
    -		arith(fpc, sat, SNE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_STR:
    -		arith(fpc, sat, STR, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SUB:
    -		arith(fpc, sat, ADD, dst, mask, src[0], neg(src[1]), none);
    -		break;
    -	case TGSI_OPCODE_TEX:
    -		tex(fpc, sat, TEX, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_TXB:
    -		tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_TXP:
    -		tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_XPD:
    -		tmp = temp(fpc);
    -		arith(fpc, 0, MUL, tmp, mask,
    -		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(fpc, sat, MAD, dst, (mask & ~MASK_W),
    -		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    -		      neg(tmp));
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    -		return FALSE;
    -	}
    -
    -	release_temps(fpc);
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_fragprog_parse_decl_attrib(struct nv40_fpc *fpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	int hw;
    -
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		hw = NVFX_FP_OP_INPUT_SRC_POSITION;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NVFX_FP_OP_INPUT_SRC_COL0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NVFX_FP_OP_INPUT_SRC_COL1;
    -		} else {
    -			NOUVEAU_ERR("bad colour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_FOG:
    -		hw = NVFX_FP_OP_INPUT_SRC_FOGC;
    -		break;
    -	case TGSI_SEMANTIC_GENERIC:
    -		if (fdec->Semantic.Index <= 7) {
    -			hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.
    -						     Index);
    -		} else {
    -			NOUVEAU_ERR("bad generic semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad input semantic\n");
    -		return FALSE;
    -	}
    -
    -	fpc->attrib_map[fdec->Range.First] = hw;
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_fragprog_parse_decl_output(struct nv40_fpc *fpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	unsigned idx = fdec->Range.First;
    -	unsigned hw;
    -
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		hw = 1;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		switch (fdec->Semantic.Index) {
    -		case 0: hw = 0; break;
    -		case 1: hw = 2; break;
    -		case 2: hw = 3; break;
    -		case 3: hw = 4; break;
    -		default:
    -			NOUVEAU_ERR("bad rcol index\n");
    -			return FALSE;
    -		}
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad output semantic\n");
    -		return FALSE;
    -	}
    -
    -	fpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
    -	fpc->r_temps |= (1 << hw);
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_fragprog_prepare(struct nv40_fpc *fpc)
    -{
    -	struct tgsi_parse_context p;
    -	int high_temp = -1, i;
    -
    -	tgsi_parse_init(&p, fpc->fp->pipe.tokens);
    -	while (!tgsi_parse_end_of_tokens(&p)) {
    -		const union tgsi_full_token *tok = &p.FullToken;
    -
    -		tgsi_parse_token(&p);
    -		switch(tok->Token.Type) {
    -		case TGSI_TOKEN_TYPE_DECLARATION:
    -		{
    -			const struct tgsi_full_declaration *fdec;
    -			fdec = &p.FullToken.FullDeclaration;
    -			switch (fdec->Declaration.File) {
    -			case TGSI_FILE_INPUT:
    -				if (!nv40_fragprog_parse_decl_attrib(fpc, fdec))
    -					goto out_err;
    -				break;
    -			case TGSI_FILE_OUTPUT:
    -				if (!nv40_fragprog_parse_decl_output(fpc, fdec))
    -					goto out_err;
    -				break;
    -			case TGSI_FILE_TEMPORARY:
    -				if (fdec->Range.Last > high_temp) {
    -					high_temp =
    -						fdec->Range.Last;
    -				}
    -				break;
    -			default:
    -				break;
    -			}
    -		}
    -			break;
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -		{
    -			struct tgsi_full_immediate *imm;
    -			float vals[4];
    -
    -			imm = &p.FullToken.FullImmediate;
    -			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    -			assert(fpc->nr_imm < MAX_IMM);
    -
    -			vals[0] = imm->u[0].Float;
    -			vals[1] = imm->u[1].Float;
    -			vals[2] = imm->u[2].Float;
    -			vals[3] = imm->u[3].Float;
    -			fpc->imm[fpc->nr_imm++] = constant(fpc, -1, vals);
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -	tgsi_parse_free(&p);
    -
    -	if (++high_temp) {
    -		fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
    -		for (i = 0; i < high_temp; i++)
    -			fpc->r_temp[i] = temp(fpc);
    -		fpc->r_temps_discard = 0;
    -	}
    -
    -	return TRUE;
    -
    -out_err:
    -	if (fpc->r_temp)
    -		FREE(fpc->r_temp);
    -	tgsi_parse_free(&p);
    -	return FALSE;
    -}
    -
    -static void
    -nv40_fragprog_translate(struct nvfx_context *nvfx,
    -			struct nvfx_fragment_program *fp)
    -{
    -	struct tgsi_parse_context parse;
    -	struct nv40_fpc *fpc = NULL;
    -
    -	fpc = CALLOC(1, sizeof(struct nv40_fpc));
    -	if (!fpc)
    -		return;
    -	fpc->fp = fp;
    -	fpc->num_regs = 2;
    -
    -	if (!nv40_fragprog_prepare(fpc)) {
    -		FREE(fpc);
    -		return;
    -	}
    -
    -	tgsi_parse_init(&parse, fp->pipe.tokens);
    -
    -	while (!tgsi_parse_end_of_tokens(&parse)) {
    -		tgsi_parse_token(&parse);
    -
    -		switch (parse.FullToken.Token.Type) {
    -		case TGSI_TOKEN_TYPE_INSTRUCTION:
    -		{
    -			const struct tgsi_full_instruction *finst;
    -
    -			finst = &parse.FullToken.FullInstruction;
    -			if (!nv40_fragprog_parse_instruction(fpc, finst))
    -				goto out_err;
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	fp->fp_control |= fpc->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT;
    -
    -	/* Terminate final instruction */
    -	fp->insn[fpc->inst_offset] |= 0x00000001;
    -
    -	/* Append NOP + END instruction, may or may not be necessary. */
    -	fpc->inst_offset = fp->insn_len;
    -	grow_insns(fpc, 4);
    -	fp->insn[fpc->inst_offset + 0] = 0x00000001;
    -	fp->insn[fpc->inst_offset + 1] = 0x00000000;
    -	fp->insn[fpc->inst_offset + 2] = 0x00000000;
    -	fp->insn[fpc->inst_offset + 3] = 0x00000000;
    -
    -	fp->translated = TRUE;
    -out_err:
    -	tgsi_parse_free(&parse);
    -	if (fpc->r_temp)
    -		FREE(fpc->r_temp);
    -	FREE(fpc);
    -}
    -
    -static void
    -nv40_fragprog_upload(struct nvfx_context *nvfx,
    -		     struct nvfx_fragment_program *fp)
    -{
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	const uint32_t le = 1;
    -	uint32_t *map;
    -	int i;
    -
    -	map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
    -
    -#if 0
    -	for (i = 0; i < fp->insn_len; i++) {
    -		fflush(stdout); fflush(stderr);
    -		NOUVEAU_ERR("%d 0x%08x\n", i, fp->insn[i]);
    -		fflush(stdout); fflush(stderr);
    -	}
    -#endif
    -
    -	if ((*(const uint8_t *)&le)) {
    -		for (i = 0; i < fp->insn_len; i++) {
    -			map[i] = fp->insn[i];
    -		}
    -	} else {
    -		/* Weird swapping for big-endian chips */
    -		for (i = 0; i < fp->insn_len; i++) {
    -			map[i] = ((fp->insn[i] & 0xffff) << 16) |
    -				  ((fp->insn[i] >> 16) & 0xffff);
    -		}
    -	}
    -
    -	pipe_buffer_unmap(pscreen, fp->buffer);
    -}
    -
    -static boolean
    -nv40_fragprog_validate(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_fragment_program *fp = nvfx->fragprog;
    -	struct pipe_buffer *constbuf =
    -		nvfx->constbuf[PIPE_SHADER_FRAGMENT];
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nouveau_stateobj *so;
    -	boolean new_consts = FALSE;
    -	int i;
    -
    -	if (fp->translated)
    -		goto update_constants;
    -
    -	nvfx->fallback_swrast &= ~NVFX_NEW_FRAGPROG;
    -	nv40_fragprog_translate(nvfx, fp);
    -	if (!fp->translated) {
    -		nvfx->fallback_swrast |= NVFX_NEW_FRAGPROG;
    -		return FALSE;
    -	}
    -
    -	fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
    -	nv40_fragprog_upload(nvfx, fp);
    -
    -	so = so_new(2, 2, 1);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    -	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
    -		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
    -		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
    -		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_CONTROL, 1);
    -	so_data  (so, fp->fp_control);
    -	so_ref(so, &fp->so);
    -	so_ref(NULL, &so);
    -
    -update_constants:
    -	if (fp->nr_consts) {
    -		float *map;
    -
    -		map = pipe_buffer_map(pscreen, constbuf,
    -				      PIPE_BUFFER_USAGE_CPU_READ);
    -		for (i = 0; i < fp->nr_consts; i++) {
    -			struct nvfx_fragment_program_data *fpd = &fp->consts[i];
    -			uint32_t *p = &fp->insn[fpd->offset];
    -			uint32_t *cb = (uint32_t *)&map[fpd->index * 4];
    -
    -			if (!memcmp(p, cb, 4 * sizeof(float)))
    -				continue;
    -			memcpy(p, cb, 4 * sizeof(float));
    -			new_consts = TRUE;
    -		}
    -		pipe_buffer_unmap(pscreen, constbuf);
    -
    -		if (new_consts)
    -			nv40_fragprog_upload(nvfx, fp);
    -	}
    -
    -	if (new_consts || fp->so != nvfx->state.hw[NVFX_STATE_FRAGPROG]) {
    -		so_ref(fp->so, &nvfx->state.hw[NVFX_STATE_FRAGPROG]);
    -		return TRUE;
    -	}
    -
    -	return FALSE;
    -}
    -
    -void
    -nv40_fragprog_destroy(struct nvfx_context *nvfx,
    -		      struct nvfx_fragment_program *fp)
    -{
    -	if (fp->buffer)
    -		pipe_buffer_reference(&fp->buffer, NULL);
    -
    -	if (fp->so)
    -		so_ref(NULL, &fp->so);
    -
    -	if (fp->insn_len)
    -		FREE(fp->insn);
    -}
    -
    -struct nvfx_state_entry nv40_state_fragprog = {
    -	.validate = nv40_fragprog_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_FRAGPROG,
    -		.hw = NVFX_STATE_FRAGPROG
    -	}
    -};
    -
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    index a205342ac5..1f4b9777d4 100644
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ b/src/gallium/drivers/nv40/nv40_state.c
    @@ -577,7 +577,7 @@ nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
     	struct nvfx_context *nvfx = nvfx_context(pipe);
     	struct nvfx_fragment_program *fp = hwcso;
     
    -	nv40_fragprog_destroy(nvfx, fp);
    +	nvfx_fragprog_destroy(nvfx, fp);
     	FREE((void*)fp->pipe.tokens);
     	FREE(fp);
     }
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 2f80681e5c..f8c10a249b 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -5,10 +5,11 @@ LIBNAME = nvfx
     
     C_SOURCES = \
     	nvfx_clear.c \
    -	nvfx_state_emit.c \
    +	nvfx_fragprog.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
     	nvfx_state_blend.c \
    +        nvfx_state_emit.c \
     	nvfx_state_fb.c \
     	nvfx_state_rasterizer.c \
     	nvfx_state_scissor.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 28daa1d2e7..0a7a0f1252 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -183,6 +183,7 @@ struct nvfx_state_entry {
     
     extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
    +extern struct nvfx_state_entry nvfx_state_fragprog;
     extern struct nvfx_state_entry nvfx_state_framebuffer;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
    @@ -198,6 +199,10 @@ extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    +/* nvfx_fragprog.c */
    +extern void nvfx_fragprog_destroy(struct nvfx_context *,
    +				    struct nvfx_fragment_program *);
    +
     /* nvfx_state_emit.c */
     extern void nvfx_state_flush_notify(struct nouveau_channel *chan);
     extern boolean nvfx_state_validate(struct nvfx_context *nvfx);
    diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    new file mode 100644
    index 0000000000..ecc193877b
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    @@ -0,0 +1,1011 @@
    +#include "pipe/p_context.h"
    +#include "pipe/p_defines.h"
    +#include "pipe/p_state.h"
    +#include "util/u_inlines.h"
    +
    +#include "pipe/p_shader_tokens.h"
    +#include "tgsi/tgsi_parse.h"
    +#include "tgsi/tgsi_util.h"
    +
    +#include "nvfx_context.h"
    +
    +#define SWZ_X 0
    +#define SWZ_Y 1
    +#define SWZ_Z 2
    +#define SWZ_W 3
    +#define MASK_X 1
    +#define MASK_Y 2
    +#define MASK_Z 4
    +#define MASK_W 8
    +#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    +#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    +#define DEF_CTEST NVFX_FP_OP_COND_TR
    +#include "nvfx_shader.h"
    +
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
    +#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
    +
    +#define MAX_CONSTS 128
    +#define MAX_IMM 32
    +struct nvfx_fpc {
    +	struct nvfx_fragment_program *fp;
    +
    +	uint attrib_map[PIPE_MAX_SHADER_INPUTS];
    +
    +	unsigned r_temps;
    +	unsigned r_temps_discard;
    +	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    +	struct nvfx_sreg *r_temp;
    +
    +	int num_regs;
    +
    +	unsigned inst_offset;
    +	unsigned have_const;
    +
    +	struct {
    +		int pipe;
    +		float vals[4];
    +	} consts[MAX_CONSTS];
    +	int nr_consts;
    +
    +	struct nvfx_sreg imm[MAX_IMM];
    +	unsigned nr_imm;
    +};
    +
    +static INLINE struct nvfx_sreg
    +temp(struct nvfx_fpc *fpc)
    +{
    +	int idx = ffs(~fpc->r_temps) - 1;
    +
    +	if (idx < 0) {
    +		NOUVEAU_ERR("out of temps!!\n");
    +		assert(0);
    +		return nvfx_sr(NVFXSR_TEMP, 0);
    +	}
    +
    +	fpc->r_temps |= (1 << idx);
    +	fpc->r_temps_discard |= (1 << idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
    +}
    +
    +static INLINE void
    +release_temps(struct nvfx_fpc *fpc)
    +{
    +	fpc->r_temps &= ~fpc->r_temps_discard;
    +	fpc->r_temps_discard = 0;
    +}
    +
    +static INLINE struct nvfx_sreg
    +constant(struct nvfx_fpc *fpc, int pipe, float vals[4])
    +{
    +	int idx;
    +
    +	if (fpc->nr_consts == MAX_CONSTS)
    +		assert(0);
    +	idx = fpc->nr_consts++;
    +
    +	fpc->consts[idx].pipe = pipe;
    +	if (pipe == -1)
    +		memcpy(fpc->consts[idx].vals, vals, 4 * sizeof(float));
    +	return nvfx_sr(NVFXSR_CONST, idx);
    +}
    +
    +#define arith(cc,s,o,d,m,s0,s1,s2) \
    +	nvfx_fp_arith((cc), (s), NVFX_FP_OP_OPCODE_##o, \
    +			(d), (m), (s0), (s1), (s2))
    +#define tex(cc,s,o,u,d,m,s0,s1,s2) \
    +	nvfx_fp_tex((cc), (s), NVFX_FP_OP_OPCODE_##o, (u), \
    +		    (d), (m), (s0), none, none)
    +
    +static void
    +grow_insns(struct nvfx_fpc *fpc, int size)
    +{
    +	struct nvfx_fragment_program *fp = fpc->fp;
    +
    +	fp->insn_len += size;
    +	fp->insn = realloc(fp->insn, sizeof(uint32_t) * fp->insn_len);
    +}
    +
    +static void
    +emit_src(struct nvfx_fpc *fpc, int pos, struct nvfx_sreg src)
    +{
    +	struct nvfx_fragment_program *fp = fpc->fp;
    +	uint32_t *hw = &fp->insn[fpc->inst_offset];
    +	uint32_t sr = 0;
    +
    +	switch (src.type) {
    +	case NVFXSR_INPUT:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    +		hw[0] |= (src.index << NVFX_FP_OP_INPUT_SRC_SHIFT);
    +		break;
    +	case NVFXSR_OUTPUT:
    +		sr |= NVFX_FP_REG_SRC_HALF;
    +		/* fall-through */
    +	case NVFXSR_TEMP:
    +		sr |= (NVFX_FP_REG_TYPE_TEMP << NVFX_FP_REG_TYPE_SHIFT);
    +		sr |= (src.index << NVFX_FP_REG_SRC_SHIFT);
    +		break;
    +	case NVFXSR_CONST:
    +		if (!fpc->have_const) {
    +			grow_insns(fpc, 4);
    +			fpc->have_const = 1;
    +		}
    +
    +		hw = &fp->insn[fpc->inst_offset];
    +		if (fpc->consts[src.index].pipe >= 0) {
    +			struct nvfx_fragment_program_data *fpd;
    +
    +			fp->consts = realloc(fp->consts, ++fp->nr_consts *
    +					     sizeof(*fpd));
    +			fpd = &fp->consts[fp->nr_consts - 1];
    +			fpd->offset = fpc->inst_offset + 4;
    +			fpd->index = fpc->consts[src.index].pipe;
    +			memset(&fp->insn[fpd->offset], 0, sizeof(uint32_t) * 4);
    +		} else {
    +			memcpy(&fp->insn[fpc->inst_offset + 4],
    +				fpc->consts[src.index].vals,
    +				sizeof(uint32_t) * 4);
    +		}
    +
    +		sr |= (NVFX_FP_REG_TYPE_CONST << NVFX_FP_REG_TYPE_SHIFT);
    +		break;
    +	case NVFXSR_NONE:
    +		sr |= (NVFX_FP_REG_TYPE_INPUT << NVFX_FP_REG_TYPE_SHIFT);
    +		break;
    +	default:
    +		assert(0);
    +	}
    +
    +	if (src.negate)
    +		sr |= NVFX_FP_REG_NEGATE;
    +
    +	if (src.abs)
    +		hw[1] |= (1 << (29 + pos));
    +
    +	sr |= ((src.swz[0] << NVFX_FP_REG_SWZ_X_SHIFT) |
    +	       (src.swz[1] << NVFX_FP_REG_SWZ_Y_SHIFT) |
    +	       (src.swz[2] << NVFX_FP_REG_SWZ_Z_SHIFT) |
    +	       (src.swz[3] << NVFX_FP_REG_SWZ_W_SHIFT));
    +
    +	hw[pos + 1] |= sr;
    +}
    +
    +static void
    +emit_dst(struct nvfx_fpc *fpc, struct nvfx_sreg dst)
    +{
    +	struct nvfx_fragment_program *fp = fpc->fp;
    +	uint32_t *hw = &fp->insn[fpc->inst_offset];
    +
    +	switch (dst.type) {
    +	case NVFXSR_TEMP:
    +		if (fpc->num_regs < (dst.index + 1))
    +			fpc->num_regs = dst.index + 1;
    +		break;
    +	case NVFXSR_OUTPUT:
    +		if (dst.index == 1) {
    +			fp->fp_control |= 0xe;
    +		} else {
    +			hw[0] |= NVFX_FP_OP_OUT_REG_HALF;
    +		}
    +		break;
    +	case NVFXSR_NONE:
    +		hw[0] |= (1 << 30);
    +		break;
    +	default:
    +		assert(0);
    +	}
    +
    +	hw[0] |= (dst.index << NVFX_FP_OP_OUT_REG_SHIFT);
    +}
    +
    +static void
    +nvfx_fp_arith(struct nvfx_fpc *fpc, int sat, int op,
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    +{
    +	struct nvfx_fragment_program *fp = fpc->fp;
    +	uint32_t *hw;
    +
    +	fpc->inst_offset = fp->insn_len;
    +	fpc->have_const = 0;
    +	grow_insns(fpc, 4);
    +	hw = &fp->insn[fpc->inst_offset];
    +	memset(hw, 0, sizeof(uint32_t) * 4);
    +
    +	if (op == NVFX_FP_OP_OPCODE_KIL)
    +		fp->fp_control |= NV34TCL_FP_CONTROL_USES_KIL;
    +	hw[0] |= (op << NVFX_FP_OP_OPCODE_SHIFT);
    +	hw[0] |= (mask << NVFX_FP_OP_OUTMASK_SHIFT);
    +	hw[2] |= (dst.dst_scale << NVFX_FP_OP_DST_SCALE_SHIFT);
    +
    +	if (sat)
    +		hw[0] |= NVFX_FP_OP_OUT_SAT;
    +
    +	if (dst.cc_update)
    +		hw[0] |= NVFX_FP_OP_COND_WRITE_ENABLE;
    +	hw[1] |= (dst.cc_test << NVFX_FP_OP_COND_SHIFT);
    +	hw[1] |= ((dst.cc_swz[0] << NVFX_FP_OP_COND_SWZ_X_SHIFT) |
    +		  (dst.cc_swz[1] << NVFX_FP_OP_COND_SWZ_Y_SHIFT) |
    +		  (dst.cc_swz[2] << NVFX_FP_OP_COND_SWZ_Z_SHIFT) |
    +		  (dst.cc_swz[3] << NVFX_FP_OP_COND_SWZ_W_SHIFT));
    +
    +	emit_dst(fpc, dst);
    +	emit_src(fpc, 0, s0);
    +	emit_src(fpc, 1, s1);
    +	emit_src(fpc, 2, s2);
    +}
    +
    +static void
    +nvfx_fp_tex(struct nvfx_fpc *fpc, int sat, int op, int unit,
    +	    struct nvfx_sreg dst, int mask,
    +	    struct nvfx_sreg s0, struct nvfx_sreg s1, struct nvfx_sreg s2)
    +{
    +	struct nvfx_fragment_program *fp = fpc->fp;
    +
    +	nvfx_fp_arith(fpc, sat, op, dst, mask, s0, s1, s2);
    +
    +	fp->insn[fpc->inst_offset] |= (unit << NVFX_FP_OP_TEX_UNIT_SHIFT);
    +	fp->samplers |= (1 << unit);
    +}
    +
    +static INLINE struct nvfx_sreg
    +tgsi_src(struct nvfx_fpc *fpc, const struct tgsi_full_src_register *fsrc)
    +{
    +	struct nvfx_sreg src;
    +
    +	switch (fsrc->Register.File) {
    +	case TGSI_FILE_INPUT:
    +		src = nvfx_sr(NVFXSR_INPUT,
    +			      fpc->attrib_map[fsrc->Register.Index]);
    +		break;
    +	case TGSI_FILE_CONSTANT:
    +		src = constant(fpc, fsrc->Register.Index, NULL);
    +		break;
    +	case TGSI_FILE_IMMEDIATE:
    +		assert(fsrc->Register.Index < fpc->nr_imm);
    +		src = fpc->imm[fsrc->Register.Index];
    +		break;
    +	case TGSI_FILE_TEMPORARY:
    +		src = fpc->r_temp[fsrc->Register.Index];
    +		break;
    +	/* NV40 fragprog result regs are just temps, so this is simple */
    +	case TGSI_FILE_OUTPUT:
    +		src = fpc->r_result[fsrc->Register.Index];
    +		break;
    +	default:
    +		NOUVEAU_ERR("bad src file\n");
    +		break;
    +	}
    +
    +	src.abs = fsrc->Register.Absolute;
    +	src.negate = fsrc->Register.Negate;
    +	src.swz[0] = fsrc->Register.SwizzleX;
    +	src.swz[1] = fsrc->Register.SwizzleY;
    +	src.swz[2] = fsrc->Register.SwizzleZ;
    +	src.swz[3] = fsrc->Register.SwizzleW;
    +	return src;
    +}
    +
    +static INLINE struct nvfx_sreg
    +tgsi_dst(struct nvfx_fpc *fpc, const struct tgsi_full_dst_register *fdst) {
    +	switch (fdst->Register.File) {
    +	case TGSI_FILE_OUTPUT:
    +		return fpc->r_result[fdst->Register.Index];
    +	case TGSI_FILE_TEMPORARY:
    +		return fpc->r_temp[fdst->Register.Index];
    +	case TGSI_FILE_NULL:
    +		return nvfx_sr(NVFXSR_NONE, 0);
    +	default:
    +		NOUVEAU_ERR("bad dst file %d\n", fdst->Register.File);
    +		return nvfx_sr(NVFXSR_NONE, 0);
    +	}
    +}
    +
    +static INLINE int
    +tgsi_mask(uint tgsi)
    +{
    +	int mask = 0;
    +
    +	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    +	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    +	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    +	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    +	return mask;
    +}
    +
    +static boolean
    +src_native_swz(struct nvfx_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    +	       struct nvfx_sreg *src)
    +{
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
    +	uint mask = 0;
    +	uint c;
    +
    +	for (c = 0; c < 4; c++) {
    +		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    +		case TGSI_SWIZZLE_X:
    +		case TGSI_SWIZZLE_Y:
    +		case TGSI_SWIZZLE_Z:
    +		case TGSI_SWIZZLE_W:
    +			mask |= (1 << c);
    +			break;
    +		default:
    +			assert(0);
    +		}
    +	}
    +
    +	if (mask == MASK_ALL)
    +		return TRUE;
    +
    +	*src = temp(fpc);
    +
    +	if (mask)
    +		arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
    +
    +	return FALSE;
    +}
    +
    +static boolean
    +nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
    +				const struct tgsi_full_instruction *finst)
    +{
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg src[3], dst, tmp;
    +	int mask, sat, unit;
    +	int ai = -1, ci = -1, ii = -1;
    +	int i;
    +
    +	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    +		return TRUE;
    +
    +	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    +		const struct tgsi_full_src_register *fsrc;
    +
    +		fsrc = &finst->Src[i];
    +		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    +			src[i] = tgsi_src(fpc, fsrc);
    +		}
    +	}
    +
    +	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    +		const struct tgsi_full_src_register *fsrc;
    +
    +		fsrc = &finst->Src[i];
    +
    +		switch (fsrc->Register.File) {
    +		case TGSI_FILE_INPUT:
    +		case TGSI_FILE_CONSTANT:
    +		case TGSI_FILE_TEMPORARY:
    +			if (!src_native_swz(fpc, fsrc, &src[i]))
    +				continue;
    +			break;
    +		default:
    +			break;
    +		}
    +
    +		switch (fsrc->Register.File) {
    +		case TGSI_FILE_INPUT:
    +			if (ai == -1 || ai == fsrc->Register.Index) {
    +				ai = fsrc->Register.Index;
    +				src[i] = tgsi_src(fpc, fsrc);
    +			} else {
    +				src[i] = temp(fpc);
    +				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				      tgsi_src(fpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_CONSTANT:
    +			if ((ci == -1 && ii == -1) ||
    +			    ci == fsrc->Register.Index) {
    +				ci = fsrc->Register.Index;
    +				src[i] = tgsi_src(fpc, fsrc);
    +			} else {
    +				src[i] = temp(fpc);
    +				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				      tgsi_src(fpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_IMMEDIATE:
    +			if ((ci == -1 && ii == -1) ||
    +			    ii == fsrc->Register.Index) {
    +				ii = fsrc->Register.Index;
    +				src[i] = tgsi_src(fpc, fsrc);
    +			} else {
    +				src[i] = temp(fpc);
    +				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				      tgsi_src(fpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_TEMPORARY:
    +			/* handled above */
    +			break;
    +		case TGSI_FILE_SAMPLER:
    +			unit = fsrc->Register.Index;
    +			break;
    +		case TGSI_FILE_OUTPUT:
    +			break;
    +		default:
    +			NOUVEAU_ERR("bad src file\n");
    +			return FALSE;
    +		}
    +	}
    +
    +	dst  = tgsi_dst(fpc, &finst->Dst[0]);
    +	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    +	sat  = (finst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
    +
    +	switch (finst->Instruction.Opcode) {
    +	case TGSI_OPCODE_ABS:
    +		arith(fpc, sat, MOV, dst, mask, abs(src[0]), none, none);
    +		break;
    +	case TGSI_OPCODE_ADD:
    +		arith(fpc, sat, ADD, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_CMP:
    +		tmp = nvfx_sr(NVFXSR_NONE, 0);
    +		tmp.cc_update = 1;
    +		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    +		dst.cc_test = NVFX_VP_INST_COND_GE;
    +		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    +		dst.cc_test = NVFX_VP_INST_COND_LT;
    +		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
    +		break;
    +	case TGSI_OPCODE_COS:
    +		arith(fpc, sat, COS, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_DDX:
    +		if (mask & (MASK_Z | MASK_W)) {
    +			tmp = temp(fpc);
    +			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y,
    +			      swz(src[0], Z, W, Z, W), none, none);
    +			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    +			      swz(tmp, X, Y, X, Y), none, none);
    +			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y, src[0],
    +			      none, none);
    +			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
    +		} else {
    +			arith(fpc, sat, DDX, dst, mask, src[0], none, none);
    +		}
    +		break;
    +	case TGSI_OPCODE_DDY:
    +		if (mask & (MASK_Z | MASK_W)) {
    +			tmp = temp(fpc);
    +			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y,
    +			      swz(src[0], Z, W, Z, W), none, none);
    +			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    +			      swz(tmp, X, Y, X, Y), none, none);
    +			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y, src[0],
    +			      none, none);
    +			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
    +		} else {
    +			arith(fpc, sat, DDY, dst, mask, src[0], none, none);
    +		}
    +		break;
    +	case TGSI_OPCODE_DP3:
    +		arith(fpc, sat, DP3, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_DP4:
    +		arith(fpc, sat, DP4, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_DPH:
    +		tmp = temp(fpc);
    +		arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[1], none);
    +		arith(fpc, sat, ADD, dst, mask, swz(tmp, X, X, X, X),
    +		      swz(src[1], W, W, W, W), none);
    +		break;
    +	case TGSI_OPCODE_DST:
    +		arith(fpc, sat, DST, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_EX2:
    +		arith(fpc, sat, EX2, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_FLR:
    +		arith(fpc, sat, FLR, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_FRC:
    +		arith(fpc, sat, FRC, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_KILP:
    +		arith(fpc, 0, KIL, none, 0, none, none, none);
    +		break;
    +	case TGSI_OPCODE_KIL:
    +		dst = nvfx_sr(NVFXSR_NONE, 0);
    +		dst.cc_update = 1;
    +		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    +		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
    +		arith(fpc, 0, KIL, dst, 0, none, none, none);
    +		break;
    +	case TGSI_OPCODE_LG2:
    +		arith(fpc, sat, LG2, dst, mask, src[0], none, none);
    +		break;
    +//	case TGSI_OPCODE_LIT:
    +	case TGSI_OPCODE_LRP:
    +		if(!nvfx->is_nv4x)
    +			arith(fpc, sat, LRP_NV30, dst, mask, src[0], src[1], src[2]);
    +		else {
    +			tmp = temp(fpc);
    +			arith(fpc, 0, MAD, tmp, mask, neg(src[0]), src[2], src[2]);
    +			arith(fpc, sat, MAD, dst, mask, src[0], src[1], tmp);
    +		}
    +		break;
    +	case TGSI_OPCODE_MAD:
    +		arith(fpc, sat, MAD, dst, mask, src[0], src[1], src[2]);
    +		break;
    +	case TGSI_OPCODE_MAX:
    +		arith(fpc, sat, MAX, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_MIN:
    +		arith(fpc, sat, MIN, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_MOV:
    +		arith(fpc, sat, MOV, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_MUL:
    +		arith(fpc, sat, MUL, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_POW:
    +		if(!nvfx->is_nv4x)
    +			arith(fpc, sat, POW_NV30, dst, mask, src[0], src[1], none);
    +		else {
    +			tmp = temp(fpc);
    +			arith(fpc, 0, LG2, tmp, MASK_X,
    +			      swz(src[0], X, X, X, X), none, none);
    +			arith(fpc, 0, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +			      swz(src[1], X, X, X, X), none);
    +			arith(fpc, sat, EX2, dst, mask,
    +			      swz(tmp, X, X, X, X), none, none);
    +		}
    +		break;
    +	case TGSI_OPCODE_RCP:
    +		arith(fpc, sat, RCP, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_RET:
    +		assert(0);
    +		break;
    +	case TGSI_OPCODE_RFL:
    +		if(!nvfx->is_nv4x)
    +			arith(fpc, 0, RFL_NV30, dst, mask, src[0], src[1], none);
    +		else {
    +			tmp = temp(fpc);
    +			arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[0], none);
    +			arith(fpc, 0, DP3, tmp, MASK_Y, src[0], src[1], none);
    +			arith(fpc, 0, DIV, scale(tmp, 2X), MASK_Z,
    +			      swz(tmp, Y, Y, Y, Y), swz(tmp, X, X, X, X), none);
    +			arith(fpc, sat, MAD, dst, mask,
    +			      swz(tmp, Z, Z, Z, Z), src[0], neg(src[1]));
    +		}
    +		break;
    +	case TGSI_OPCODE_RSQ:
    +		if(!nvfx->is_nv4x)
    +			arith(fpc, sat, RSQ_NV30, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
    +		else {
    +			tmp = temp(fpc);
    +			arith(fpc, 0, LG2, scale(tmp, INV_2X), MASK_X,
    +			      abs(swz(src[0], X, X, X, X)), none, none);
    +			arith(fpc, sat, EX2, dst, mask,
    +			      neg(swz(tmp, X, X, X, X)), none, none);
    +		}
    +		break;
    +	case TGSI_OPCODE_SCS:
    +		/* avoid overwriting the source */
    +		if(src[0].swz[SWZ_X] != SWZ_X)
    +		{
    +			if (mask & MASK_X) {
    +				arith(fpc, sat, COS, dst, MASK_X,
    +				      swz(src[0], X, X, X, X), none, none);
    +			}
    +			if (mask & MASK_Y) {
    +				arith(fpc, sat, SIN, dst, MASK_Y,
    +				      swz(src[0], X, X, X, X), none, none);
    +			}
    +		}
    +		else
    +		{
    +			if (mask & MASK_Y) {
    +				arith(fpc, sat, SIN, dst, MASK_Y,
    +				      swz(src[0], X, X, X, X), none, none);
    +			}
    +			if (mask & MASK_X) {
    +				arith(fpc, sat, COS, dst, MASK_X,
    +				      swz(src[0], X, X, X, X), none, none);
    +			}
    +		}
    +		break;
    +	case TGSI_OPCODE_SEQ:
    +		arith(fpc, sat, SEQ, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SFL:
    +		arith(fpc, sat, SFL, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SGE:
    +		arith(fpc, sat, SGE, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SGT:
    +		arith(fpc, sat, SGT, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SIN:
    +		arith(fpc, sat, SIN, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_SLE:
    +		arith(fpc, sat, SLE, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SLT:
    +		arith(fpc, sat, SLT, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SNE:
    +		arith(fpc, sat, SNE, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_STR:
    +		arith(fpc, sat, STR, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SUB:
    +		arith(fpc, sat, ADD, dst, mask, src[0], neg(src[1]), none);
    +		break;
    +	case TGSI_OPCODE_TEX:
    +		tex(fpc, sat, TEX, unit, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_TXB:
    +		tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_TXP:
    +		tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_XPD:
    +		tmp = temp(fpc);
    +		arith(fpc, 0, MUL, tmp, mask,
    +		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    +		arith(fpc, sat, MAD, dst, (mask & ~MASK_W),
    +		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    +		      neg(tmp));
    +		break;
    +	default:
    +		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    +		return FALSE;
    +	}
    +
    +	release_temps(fpc);
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_fragprog_parse_decl_attrib(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
    +				const struct tgsi_full_declaration *fdec)
    +{
    +	int hw;
    +
    +	switch (fdec->Semantic.Name) {
    +	case TGSI_SEMANTIC_POSITION:
    +		hw = NVFX_FP_OP_INPUT_SRC_POSITION;
    +		break;
    +	case TGSI_SEMANTIC_COLOR:
    +		if (fdec->Semantic.Index == 0) {
    +			hw = NVFX_FP_OP_INPUT_SRC_COL0;
    +		} else
    +		if (fdec->Semantic.Index == 1) {
    +			hw = NVFX_FP_OP_INPUT_SRC_COL1;
    +		} else {
    +			NOUVEAU_ERR("bad colour semantic index\n");
    +			return FALSE;
    +		}
    +		break;
    +	case TGSI_SEMANTIC_FOG:
    +		hw = NVFX_FP_OP_INPUT_SRC_FOGC;
    +		break;
    +	case TGSI_SEMANTIC_GENERIC:
    +		if (fdec->Semantic.Index <= 7) {
    +			hw = NVFX_FP_OP_INPUT_SRC_TC(fdec->Semantic.
    +						     Index);
    +		} else {
    +			NOUVEAU_ERR("bad generic semantic index\n");
    +			return FALSE;
    +		}
    +		break;
    +	default:
    +		NOUVEAU_ERR("bad input semantic\n");
    +		return FALSE;
    +	}
    +
    +	fpc->attrib_map[fdec->Range.First] = hw;
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_fragprog_parse_decl_output(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
    +				const struct tgsi_full_declaration *fdec)
    +{
    +	unsigned idx = fdec->Range.First;
    +	unsigned hw;
    +
    +	switch (fdec->Semantic.Name) {
    +	case TGSI_SEMANTIC_POSITION:
    +		hw = 1;
    +		break;
    +	case TGSI_SEMANTIC_COLOR:
    +		hw = ~0;
    +		switch (fdec->Semantic.Index) {
    +		case 0: hw = 0; break;
    +		case 1: hw = 2; break;
    +		case 2: hw = 3; break;
    +		case 3: hw = 4; break;
    +		}
    +		if(hw > ((nvfx->is_nv4x) ? 4 : 2)) {
    +			NOUVEAU_ERR("bad rcol index\n");
    +			return FALSE;
    +		}
    +		break;
    +	default:
    +		NOUVEAU_ERR("bad output semantic\n");
    +		return FALSE;
    +	}
    +
    +	fpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
    +	fpc->r_temps |= (1 << hw);
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_fragprog_prepare(struct nvfx_context* nvfx, struct nvfx_fpc *fpc)
    +{
    +	struct tgsi_parse_context p;
    +	int high_temp = -1, i;
    +
    +	tgsi_parse_init(&p, fpc->fp->pipe.tokens);
    +	while (!tgsi_parse_end_of_tokens(&p)) {
    +		const union tgsi_full_token *tok = &p.FullToken;
    +
    +		tgsi_parse_token(&p);
    +		switch(tok->Token.Type) {
    +		case TGSI_TOKEN_TYPE_DECLARATION:
    +		{
    +			const struct tgsi_full_declaration *fdec;
    +			fdec = &p.FullToken.FullDeclaration;
    +			switch (fdec->Declaration.File) {
    +			case TGSI_FILE_INPUT:
    +				if (!nvfx_fragprog_parse_decl_attrib(nvfx, fpc, fdec))
    +					goto out_err;
    +				break;
    +			case TGSI_FILE_OUTPUT:
    +				if (!nvfx_fragprog_parse_decl_output(nvfx, fpc, fdec))
    +					goto out_err;
    +				break;
    +			case TGSI_FILE_TEMPORARY:
    +				if (fdec->Range.Last > high_temp) {
    +					high_temp =
    +						fdec->Range.Last;
    +				}
    +				break;
    +			default:
    +				break;
    +			}
    +		}
    +			break;
    +		case TGSI_TOKEN_TYPE_IMMEDIATE:
    +		{
    +			struct tgsi_full_immediate *imm;
    +			float vals[4];
    +
    +			imm = &p.FullToken.FullImmediate;
    +			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    +			assert(fpc->nr_imm < MAX_IMM);
    +
    +			vals[0] = imm->u[0].Float;
    +			vals[1] = imm->u[1].Float;
    +			vals[2] = imm->u[2].Float;
    +			vals[3] = imm->u[3].Float;
    +			fpc->imm[fpc->nr_imm++] = constant(fpc, -1, vals);
    +		}
    +			break;
    +		default:
    +			break;
    +		}
    +	}
    +	tgsi_parse_free(&p);
    +
    +	if (++high_temp) {
    +		fpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
    +		for (i = 0; i < high_temp; i++)
    +			fpc->r_temp[i] = temp(fpc);
    +		fpc->r_temps_discard = 0;
    +	}
    +
    +	return TRUE;
    +
    +out_err:
    +	if (fpc->r_temp)
    +		FREE(fpc->r_temp);
    +	tgsi_parse_free(&p);
    +	return FALSE;
    +}
    +
    +static void
    +nvfx_fragprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_fragment_program *fp)
    +{
    +	struct tgsi_parse_context parse;
    +	struct nvfx_fpc *fpc = NULL;
    +
    +	fpc = CALLOC(1, sizeof(struct nvfx_fpc));
    +	if (!fpc)
    +		return;
    +	fpc->fp = fp;
    +	fpc->num_regs = 2;
    +
    +	if (!nvfx_fragprog_prepare(nvfx, fpc)) {
    +		FREE(fpc);
    +		return;
    +	}
    +
    +	tgsi_parse_init(&parse, fp->pipe.tokens);
    +
    +	while (!tgsi_parse_end_of_tokens(&parse)) {
    +		tgsi_parse_token(&parse);
    +
    +		switch (parse.FullToken.Token.Type) {
    +		case TGSI_TOKEN_TYPE_INSTRUCTION:
    +		{
    +			const struct tgsi_full_instruction *finst;
    +
    +			finst = &parse.FullToken.FullInstruction;
    +			if (!nvfx_fragprog_parse_instruction(nvfx, fpc, finst))
    +				goto out_err;
    +		}
    +			break;
    +		default:
    +			break;
    +		}
    +	}
    +
    +	if(!nvfx->is_nv4x)
    +		fp->fp_control |= (fpc->num_regs-1)/2;
    +	else
    +		fp->fp_control |= fpc->num_regs << NV40TCL_FP_CONTROL_TEMP_COUNT_SHIFT;
    +
    +	/* Terminate final instruction */
    +	fp->insn[fpc->inst_offset] |= 0x00000001;
    +
    +	/* Append NOP + END instruction, may or may not be necessary. */
    +	fpc->inst_offset = fp->insn_len;
    +	grow_insns(fpc, 4);
    +	fp->insn[fpc->inst_offset + 0] = 0x00000001;
    +	fp->insn[fpc->inst_offset + 1] = 0x00000000;
    +	fp->insn[fpc->inst_offset + 2] = 0x00000000;
    +	fp->insn[fpc->inst_offset + 3] = 0x00000000;
    +
    +	fp->translated = TRUE;
    +out_err:
    +	tgsi_parse_free(&parse);
    +	if (fpc->r_temp)
    +		FREE(fpc->r_temp);
    +	FREE(fpc);
    +}
    +
    +static void
    +nvfx_fragprog_upload(struct nvfx_context *nvfx,
    +		     struct nvfx_fragment_program *fp)
    +{
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	const uint32_t le = 1;
    +	uint32_t *map;
    +	int i;
    +
    +	map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
    +
    +#if 0
    +	for (i = 0; i < fp->insn_len; i++) {
    +		fflush(stdout); fflush(stderr);
    +		NOUVEAU_ERR("%d 0x%08x\n", i, fp->insn[i]);
    +		fflush(stdout); fflush(stderr);
    +	}
    +#endif
    +
    +	if ((*(const uint8_t *)&le)) {
    +		for (i = 0; i < fp->insn_len; i++) {
    +			map[i] = fp->insn[i];
    +		}
    +	} else {
    +		/* Weird swapping for big-endian chips */
    +		for (i = 0; i < fp->insn_len; i++) {
    +			map[i] = ((fp->insn[i] & 0xffff) << 16) |
    +				  ((fp->insn[i] >> 16) & 0xffff);
    +		}
    +	}
    +
    +	pipe_buffer_unmap(pscreen, fp->buffer);
    +}
    +
    +static boolean
    +nvfx_fragprog_validate(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
    +	struct pipe_buffer *constbuf =
    +		nvfx->constbuf[PIPE_SHADER_FRAGMENT];
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nouveau_stateobj *so;
    +	boolean new_consts = FALSE;
    +	int i;
    +
    +	if (fp->translated)
    +		goto update_constants;
    +
    +	nvfx->fallback_swrast &= ~NVFX_NEW_FRAGPROG;
    +	nvfx_fragprog_translate(nvfx, fp);
    +	if (!fp->translated) {
    +		nvfx->fallback_swrast |= NVFX_NEW_FRAGPROG;
    +		return FALSE;
    +	}
    +
    +	fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
    +	nvfx_fragprog_upload(nvfx, fp);
    +
    +	so = so_new(4, 4, 1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
    +	so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
    +		      NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
    +		      NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
    +		      NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_FP_CONTROL, 1);
    +	so_data  (so, fp->fp_control);
    +	if(!nvfx->is_nv4x) {
    +		so_method(so, nvfx->screen->eng3d, NV34TCL_FP_REG_CONTROL, 1);
    +		so_data  (so, (1<<16)|0x4);
    +		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_UNITS_ENABLE, 1);
    +		so_data  (so, fp->samplers);
    +	}
    +
    +	so_ref(so, &fp->so);
    +	so_ref(NULL, &so);
    +
    +update_constants:
    +	if (fp->nr_consts) {
    +		float *map;
    +
    +		map = pipe_buffer_map(pscreen, constbuf,
    +				      PIPE_BUFFER_USAGE_CPU_READ);
    +		for (i = 0; i < fp->nr_consts; i++) {
    +			struct nvfx_fragment_program_data *fpd = &fp->consts[i];
    +			uint32_t *p = &fp->insn[fpd->offset];
    +			uint32_t *cb = (uint32_t *)&map[fpd->index * 4];
    +
    +			if (!memcmp(p, cb, 4 * sizeof(float)))
    +				continue;
    +			memcpy(p, cb, 4 * sizeof(float));
    +			new_consts = TRUE;
    +		}
    +		pipe_buffer_unmap(pscreen, constbuf);
    +
    +		if (new_consts)
    +			nvfx_fragprog_upload(nvfx, fp);
    +	}
    +
    +	if (new_consts || fp->so != nvfx->state.hw[NVFX_STATE_FRAGPROG]) {
    +		so_ref(fp->so, &nvfx->state.hw[NVFX_STATE_FRAGPROG]);
    +		return TRUE;
    +	}
    +
    +	return FALSE;
    +}
    +
    +void
    +nvfx_fragprog_destroy(struct nvfx_context *nvfx,
    +		      struct nvfx_fragment_program *fp)
    +{
    +	if (fp->buffer)
    +		pipe_buffer_reference(&fp->buffer, NULL);
    +
    +	if (fp->so)
    +		so_ref(NULL, &fp->so);
    +
    +	if (fp->insn_len)
    +		FREE(fp->insn);
    +}
    +
    +struct nvfx_state_entry nvfx_state_fragprog = {
    +	.validate = nvfx_fragprog_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_FRAGPROG,
    +		.hw = NVFX_STATE_FRAGPROG
    +	}
    +};
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index d3088e4211..d6fbc5d8dc 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -9,7 +9,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_rasterizer, \
     	&nvfx_state_scissor, \
     	&nvfx_state_stipple, \
    -	&nvxx##_state_fragprog, \
    +	&nvfx_state_fragprog, \
     	&nvxx##_state_fragtex, \
     	&nvxx##_state_vertprog, \
     	&nvfx_state_blend, \
    -- 
    cgit v1.2.3
    
    
    From f9eafeca297497a94c438ea28ed59f3a45ed2566 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 11:17:55 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_draw.c
    
    nv30_draw.c is a stub.
    
    This patch makes both nv30 and nv40 use the nv40 swtnl path.
    
    Note that this doesn't actually work on nv30 because the vertex program is
    encoded in the nv40-only layout.
    
    However, swtnl was unimplemented before on nv30, so this is not a regression.
    Furthermore, a patch to fix this is available near the end of the patchset.
    ---
     src/gallium/drivers/nv30/Makefile          |   1 -
     src/gallium/drivers/nv30/nv30_context.c    |   2 +-
     src/gallium/drivers/nv30/nv30_context.h    |   3 -
     src/gallium/drivers/nv30/nv30_draw.c       |  61 -----
     src/gallium/drivers/nv40/Makefile          |   1 -
     src/gallium/drivers/nv40/nv40_context.c    |   2 +-
     src/gallium/drivers/nv40/nv40_context.h    |   8 -
     src/gallium/drivers/nv40/nv40_draw.c       | 360 ----------------------------
     src/gallium/drivers/nv40/nv40_vbo.c        |   4 +-
     src/gallium/drivers/nvfx/Makefile          |   1 +
     src/gallium/drivers/nvfx/nvfx_context.h    |   8 +
     src/gallium/drivers/nvfx/nvfx_draw.c       | 363 +++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_state_emit.c |   6 +-
     13 files changed, 381 insertions(+), 439 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_draw.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_draw.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_draw.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 196cc9a1ef..791b0040bb 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -5,7 +5,6 @@ LIBNAME = nv30
     
     C_SOURCES = \
     	nv30_context.c \
    -	nv30_draw.c \
     	nv30_fragtex.c \
     	nv30_screen.c \
     	nv30_state.c \
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index f13458d50a..671a1939e8 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -84,7 +84,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	draw_wide_line_threshold(nvfx->draw, 9999999.0);
     	draw_enable_line_stipple(nvfx->draw, FALSE);
     	draw_enable_point_sprites(nvfx->draw, FALSE);
    -	draw_set_rasterize_stage(nvfx->draw, nv30_draw_render_stage(nvfx));
    +	draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
     
     	return &nvfx->pipe;
     }
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 7840318363..ebdd5455ca 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -5,9 +5,6 @@
     
     extern void nv30_init_state_functions(struct nvfx_context *nvfx);
     
    -/* nv30_draw.c */
    -extern struct draw_stage *nv30_draw_render_stage(struct nvfx_context *nvfx);
    -
     /* nv30_vertprog.c */
     extern void nv30_vertprog_destroy(struct nvfx_context *,
     				  struct nvfx_vertex_program *);
    diff --git a/src/gallium/drivers/nv30/nv30_draw.c b/src/gallium/drivers/nv30/nv30_draw.c
    deleted file mode 100644
    index 5d22e78abf..0000000000
    --- a/src/gallium/drivers/nv30/nv30_draw.c
    +++ /dev/null
    @@ -1,61 +0,0 @@
    -#include "draw/draw_pipe.h"
    -
    -#include "nv30_context.h"
    -
    -struct nv30_draw_stage {
    -	struct draw_stage draw;
    -	struct nvfx_context *nvfx;
    -};
    -
    -static void
    -nv30_draw_point(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	NOUVEAU_ERR("\n");
    -}
    -
    -static void
    -nv30_draw_line(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	NOUVEAU_ERR("\n");
    -}
    -
    -static void
    -nv30_draw_tri(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	NOUVEAU_ERR("\n");
    -}
    -
    -static void
    -nv30_draw_flush(struct draw_stage *draw, unsigned flags)
    -{
    -}
    -
    -static void
    -nv30_draw_reset_stipple_counter(struct draw_stage *draw)
    -{
    -	NOUVEAU_ERR("\n");
    -}
    -
    -static void
    -nv30_draw_destroy(struct draw_stage *draw)
    -{
    -	FREE(draw);
    -}
    -
    -struct draw_stage *
    -nv30_draw_render_stage(struct nvfx_context *nvfx)
    -{
    -	struct nv30_draw_stage *nv30draw = CALLOC_STRUCT(nv30_draw_stage);
    -
    -	nv30draw->nvfx = nvfx;
    -	nv30draw->draw.draw = nvfx->draw;
    -	nv30draw->draw.point = nv30_draw_point;
    -	nv30draw->draw.line = nv30_draw_line;
    -	nv30draw->draw.tri = nv30_draw_tri;
    -	nv30draw->draw.flush = nv30_draw_flush;
    -	nv30draw->draw.reset_stipple_counter = nv30_draw_reset_stipple_counter;
    -	nv30draw->draw.destroy = nv30_draw_destroy;
    -
    -	return &nv30draw->draw;
    -}
    -
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index f3ff376dfd..7529e33a74 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -5,7 +5,6 @@ LIBNAME = nv40
     
     C_SOURCES = \
     	nv40_context.c \
    -	nv40_draw.c \
     	nv40_fragtex.c \
     	nv40_screen.c \
     	nv40_state.c \
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 441b038b05..eb83131772 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -84,7 +84,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	draw_wide_line_threshold(nvfx->draw, 9999999.0);
     	draw_enable_line_stipple(nvfx->draw, FALSE);
     	draw_enable_point_sprites(nvfx->draw, FALSE);
    -	draw_set_rasterize_stage(nvfx->draw, nv40_draw_render_stage(nvfx));
    +	draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
     
     	return &nvfx->pipe;
     }
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 4cd56af8f7..a8aba0c0ca 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -5,13 +5,6 @@
     
     extern void nv40_init_state_functions(struct nvfx_context *nvfx);
     
    -/* nv40_draw.c */
    -extern struct draw_stage *nv40_draw_render_stage(struct nvfx_context *nvfx);
    -extern void nv40_draw_elements_swtnl(struct pipe_context *pipe,
    -					struct pipe_buffer *idxbuf,
    -					unsigned ib_size, unsigned mode,
    -					unsigned start, unsigned count);
    -
     /* nv40_vertprog.c */
     extern void nv40_vertprog_destroy(struct nvfx_context *,
     				  struct nvfx_vertex_program *);
    @@ -23,7 +16,6 @@ extern void nv40_fragtex_bind(struct nvfx_context *);
     extern struct nvfx_state_entry nv40_state_vertprog;
     extern struct nvfx_state_entry nv40_state_fragtex;
     extern struct nvfx_state_entry nv40_state_vbo;
    -extern struct nvfx_state_entry nv40_state_vtxfmt;
     
     /* nv40_vbo.c */
     extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
    diff --git a/src/gallium/drivers/nv40/nv40_draw.c b/src/gallium/drivers/nv40/nv40_draw.c
    deleted file mode 100644
    index 4ed87779fd..0000000000
    --- a/src/gallium/drivers/nv40/nv40_draw.c
    +++ /dev/null
    @@ -1,360 +0,0 @@
    -#include "pipe/p_shader_tokens.h"
    -#include "util/u_inlines.h"
    -
    -#include "util/u_pack_color.h"
    -
    -#include "draw/draw_context.h"
    -#include "draw/draw_vertex.h"
    -#include "draw/draw_pipe.h"
    -
    -#include "nv40_context.h"
    -#define NVFX_SHADER_NO_FUCKEDNESS
    -#include "nv40_shader.h"
    -
    -/* Simple, but crappy, swtnl path, hopefully we wont need to hit this very
    - * often at all.  Uses "quadro style" vertex submission + a fixed vertex
    - * layout to avoid the need to generate a vertex program or vtxfmt.
    - */
    -
    -struct nv40_render_stage {
    -	struct draw_stage stage;
    -	struct nvfx_context *nvfx;
    -	unsigned prim;
    -};
    -
    -static INLINE struct nv40_render_stage *
    -nv40_render_stage(struct draw_stage *stage)
    -{
    -	return (struct nv40_render_stage *)stage;
    -}
    -
    -static INLINE void
    -nv40_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned i;
    -
    -	for (i = 0; i < nvfx->swtnl.nr_attribs; i++) {
    -		unsigned idx = nvfx->swtnl.draw[i];
    -		unsigned hw = nvfx->swtnl.hw[i];
    -
    -		switch (nvfx->swtnl.emit[i]) {
    -		case EMIT_OMIT:
    -			break;
    -		case EMIT_1F:
    -			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_1F(hw), 1);
    -			OUT_RING  (chan, fui(v->data[idx][0]));
    -			break;
    -		case EMIT_2F:
    -			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_2F_X(hw), 2);
    -			OUT_RING  (chan, fui(v->data[idx][0]));
    -			OUT_RING  (chan, fui(v->data[idx][1]));
    -			break;
    -		case EMIT_3F:
    -			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_3F_X(hw), 3);
    -			OUT_RING  (chan, fui(v->data[idx][0]));
    -			OUT_RING  (chan, fui(v->data[idx][1]));
    -			OUT_RING  (chan, fui(v->data[idx][2]));
    -			break;
    -		case EMIT_4F:
    -			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4F_X(hw), 4);
    -			OUT_RING  (chan, fui(v->data[idx][0]));
    -			OUT_RING  (chan, fui(v->data[idx][1]));
    -			OUT_RING  (chan, fui(v->data[idx][2]));
    -			OUT_RING  (chan, fui(v->data[idx][3]));
    -			break;
    -		case EMIT_4UB:
    -			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
    -			OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
    -					    float_to_ubyte(v->data[idx][1]),
    -					    float_to_ubyte(v->data[idx][2]),
    -					    float_to_ubyte(v->data[idx][3])));
    -			break;
    -		default:
    -			assert(0);
    -			break;
    -		}
    -	}
    -}
    -
    -static INLINE void
    -nv40_render_prim(struct draw_stage *stage, struct prim_header *prim,
    -	       unsigned mode, unsigned count)
    -{
    -	struct nv40_render_stage *rs = nv40_render_stage(stage);
    -	struct nvfx_context *nvfx = rs->nvfx;
    -
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned i;
    -
    -	/* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
    -	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    -		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    -			NOUVEAU_ERR("AIII, missed flush\n");
    -			assert(0);
    -		}
    -		FIRE_RING(chan);
    -		nvfx_state_emit(nvfx);
    -	}
    -
    -	/* Switch primitive modes if necessary */
    -	if (rs->prim != mode) {
    -		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -			OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, mode);
    -		rs->prim = mode;
    -	}
    -
    -	/* Emit vertex data */
    -	for (i = 0; i < count; i++)
    -		nv40_render_vertex(nvfx, prim->v[i]);
    -
    -	/* If it's likely we'll need to empty the push buffer soon, finish
    -	 * off the primitive now.
    -	 */
    -	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    -		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
    -	}
    -}
    -
    -static void
    -nv40_render_point(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_POINTS, 1);
    -}
    -
    -static void
    -nv40_render_line(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_LINES, 2);
    -}
    -
    -static void
    -nv40_render_tri(struct draw_stage *draw, struct prim_header *prim)
    -{
    -	nv40_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_TRIANGLES, 3);
    -}
    -
    -static void
    -nv40_render_flush(struct draw_stage *draw, unsigned flags)
    -{
    -	struct nv40_render_stage *rs = nv40_render_stage(draw);
    -	struct nvfx_context *nvfx = rs->nvfx;
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    -		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
    -	}
    -}
    -
    -static void
    -nv40_render_reset_stipple_counter(struct draw_stage *draw)
    -{
    -}
    -
    -static void
    -nv40_render_destroy(struct draw_stage *draw)
    -{
    -	FREE(draw);
    -}
    -
    -static INLINE void
    -emit_mov(struct nvfx_vertex_program *vp,
    -	 unsigned dst, unsigned src, unsigned vor, unsigned mask)
    -{
    -	struct nvfx_vertex_program_exec *inst;
    -
    -	vp->insns = realloc(vp->insns,
    -			    sizeof(struct nvfx_vertex_program_exec) *
    -			    ++vp->nr_insns);
    -	inst = &vp->insns[vp->nr_insns - 1];
    -
    -	inst->data[0] = 0x401f9c6c;
    -	inst->data[1] = 0x0040000d | (src << 8);
    -	inst->data[2] = 0x8106c083;
    -	inst->data[3] = 0x6041ff80 | (dst << 2) | (mask << 13);
    -	inst->const_index = -1;
    -	inst->has_branch_offset = FALSE;
    -
    -	vp->ir |= (1 << src);
    -	if (vor != ~0)
    -		vp->or |= (1 << vor);
    -}
    -
    -static struct nvfx_vertex_program *
    -create_drawvp(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_vertex_program *vp = CALLOC_STRUCT(nvfx_vertex_program);
    -	unsigned i;
    -
    -	emit_mov(vp, NV40_VP_INST_DEST_POS, 0, ~0, 0xf);
    -	emit_mov(vp, NV40_VP_INST_DEST_COL0, 3, 0, 0xf);
    -	emit_mov(vp, NV40_VP_INST_DEST_COL1, 4, 1, 0xf);
    -	emit_mov(vp, NV40_VP_INST_DEST_BFC0, 3, 2, 0xf);
    -	emit_mov(vp, NV40_VP_INST_DEST_BFC1, 4, 3, 0xf);
    -	emit_mov(vp, NV40_VP_INST_DEST_FOGC, 5, 4, 0x8);
    -	for (i = 0; i < 8; i++)
    -		emit_mov(vp, NV40_VP_INST_DEST_TC(i), 8 + i, 14 + i, 0xf);
    -
    -	vp->insns[vp->nr_insns - 1].data[3] |= 1;
    -	vp->translated = TRUE;
    -	return vp;
    -}
    -
    -struct draw_stage *
    -nv40_draw_render_stage(struct nvfx_context *nvfx)
    -{
    -	struct nv40_render_stage *render = CALLOC_STRUCT(nv40_render_stage);
    -
    -	if (!nvfx->swtnl.vertprog)
    -		nvfx->swtnl.vertprog = create_drawvp(nvfx);
    -
    -	render->nvfx = nvfx;
    -	render->stage.draw = nvfx->draw;
    -	render->stage.point = nv40_render_point;
    -	render->stage.line = nv40_render_line;
    -	render->stage.tri = nv40_render_tri;
    -	render->stage.flush = nv40_render_flush;
    -	render->stage.reset_stipple_counter = nv40_render_reset_stipple_counter;
    -	render->stage.destroy = nv40_render_destroy;
    -
    -	return &render->stage;
    -}
    -
    -void
    -nv40_draw_elements_swtnl(struct pipe_context *pipe,
    -			 struct pipe_buffer *idxbuf, unsigned idxbuf_size,
    -			 unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct pipe_screen *pscreen = pipe->screen;
    -	unsigned i;
    -	void *map;
    -
    -	if (!nvfx_state_validate_swtnl(nvfx))
    -		return;
    -	nvfx->state.dirty &= ~(1ULL << NVFX_STATE_VTXBUF);
    -	nvfx_state_emit(nvfx);
    -
    -	for (i = 0; i < nvfx->vtxbuf_nr; i++) {
    -		map = pipe_buffer_map(pscreen, nvfx->vtxbuf[i].buffer,
    -                                      PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_vertex_buffer(nvfx->draw, i, map);
    -	}
    -
    -	if (idxbuf) {
    -		map = pipe_buffer_map(pscreen, idxbuf,
    -				      PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map);
    -	} else {
    -		draw_set_mapped_element_buffer(nvfx->draw, 0, NULL);
    -	}
    -
    -	if (nvfx->constbuf[PIPE_SHADER_VERTEX]) {
    -		const unsigned nr = nvfx->constbuf_nr[PIPE_SHADER_VERTEX];
    -
    -		map = pipe_buffer_map(pscreen,
    -				      nvfx->constbuf[PIPE_SHADER_VERTEX],
    -				      PIPE_BUFFER_USAGE_CPU_READ);
    -		draw_set_mapped_constant_buffer(nvfx->draw, PIPE_SHADER_VERTEX, 0,
    -                                                map, nr);
    -	}
    -
    -	draw_arrays(nvfx->draw, mode, start, count);
    -
    -	for (i = 0; i < nvfx->vtxbuf_nr; i++)
    -		pipe_buffer_unmap(pscreen, nvfx->vtxbuf[i].buffer);
    -
    -	if (idxbuf)
    -		pipe_buffer_unmap(pscreen, idxbuf);
    -
    -	if (nvfx->constbuf[PIPE_SHADER_VERTEX])
    -		pipe_buffer_unmap(pscreen, nvfx->constbuf[PIPE_SHADER_VERTEX]);
    -
    -	draw_flush(nvfx->draw);
    -	pipe->flush(pipe, 0, NULL);
    -}
    -
    -static INLINE void
    -emit_attrib(struct nvfx_context *nvfx, unsigned hw, unsigned emit,
    -	    unsigned semantic, unsigned index)
    -{
    -	unsigned draw_out = draw_find_shader_output(nvfx->draw, semantic, index);
    -	unsigned a = nvfx->swtnl.nr_attribs++;
    -
    -	nvfx->swtnl.hw[a] = hw;
    -	nvfx->swtnl.emit[a] = emit;
    -	nvfx->swtnl.draw[a] = draw_out;
    -}
    -
    -static boolean
    -nv40_state_vtxfmt_validate(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_fragment_program *fp = nvfx->fragprog;
    -	unsigned colour = 0, texcoords = 0, fog = 0, i;
    -
    -	/* Determine needed fragprog inputs */
    -	for (i = 0; i < fp->info.num_inputs; i++) {
    -		switch (fp->info.input_semantic_name[i]) {
    -		case TGSI_SEMANTIC_POSITION:
    -			break;
    -		case TGSI_SEMANTIC_COLOR:
    -			colour |= (1 << fp->info.input_semantic_index[i]);
    -			break;
    -		case TGSI_SEMANTIC_GENERIC:
    -			texcoords |= (1 << fp->info.input_semantic_index[i]);
    -			break;
    -		case TGSI_SEMANTIC_FOG:
    -			fog = 1;
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	nvfx->swtnl.nr_attribs = 0;
    -
    -	/* Map draw vtxprog output to hw attribute IDs */
    -	for (i = 0; i < 2; i++) {
    -		if (!(colour & (1 << i)))
    -			continue;
    -		emit_attrib(nvfx, 3 + i, EMIT_4UB, TGSI_SEMANTIC_COLOR, i);
    -	}
    -
    -	for (i = 0; i < 8; i++) {
    -		if (!(texcoords & (1 << i)))
    -			continue;
    -		emit_attrib(nvfx, 8 + i, EMIT_4F, TGSI_SEMANTIC_GENERIC, i);
    -	}
    -
    -	if (fog) {
    -		emit_attrib(nvfx, 5, EMIT_1F, TGSI_SEMANTIC_FOG, 0);
    -	}
    -
    -	emit_attrib(nvfx, 0, EMIT_3F, TGSI_SEMANTIC_POSITION, 0);
    -
    -	return FALSE;
    -}
    -
    -struct nvfx_state_entry nv40_state_vtxfmt = {
    -	.validate = nv40_state_vtxfmt_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_ARRAYS | NVFX_NEW_FRAGPROG,
    -		.hw = 0
    -	}
    -};
    -
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    index 456b508d43..196a12b1f6 100644
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ b/src/gallium/drivers/nv40/nv40_vbo.c
    @@ -177,7 +177,7 @@ nv40_draw_arrays(struct pipe_context *pipe,
     
     	nv40_vbo_set_idxbuf(nvfx, NULL, 0);
     	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		nv40_draw_elements_swtnl(pipe, NULL, 0,
    +		nvfx_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
     	}
    @@ -467,7 +467,7 @@ nv40_draw_elements(struct pipe_context *pipe,
     
     	idxbuf = nv40_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
     	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		nv40_draw_elements_swtnl(pipe, NULL, 0,
    +		nvfx_draw_elements_swtnl(pipe, NULL, 0,
                                              mode, start, count);
                     return;
     	}
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index f8c10a249b..a23d024f11 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -5,6 +5,7 @@ LIBNAME = nvfx
     
     C_SOURCES = \
     	nvfx_clear.c \
    +	nvfx_draw.c \
     	nvfx_fragprog.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 0a7a0f1252..75008f8ddd 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -190,6 +190,7 @@ extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
     extern struct nvfx_state_entry nvfx_state_stipple;
     extern struct nvfx_state_entry nvfx_state_viewport;
    +extern struct nvfx_state_entry nvfx_state_vtxfmt;
     extern struct nvfx_state_entry nvfx_state_zsa;
     
     extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
    @@ -199,6 +200,13 @@ extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
     
    +/* nvfx_draw.c */
    +extern struct draw_stage *nvfx_draw_render_stage(struct nvfx_context *nvfx);
    +extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe,
    +					struct pipe_buffer *idxbuf,
    +					unsigned ib_size, unsigned mode,
    +					unsigned start, unsigned count);
    +
     /* nvfx_fragprog.c */
     extern void nvfx_fragprog_destroy(struct nvfx_context *,
     				    struct nvfx_fragment_program *);
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    new file mode 100644
    index 0000000000..8700e14329
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -0,0 +1,363 @@
    +#include "pipe/p_shader_tokens.h"
    +#include "util/u_inlines.h"
    +
    +#include "util/u_pack_color.h"
    +
    +#include "draw/draw_context.h"
    +#include "draw/draw_vertex.h"
    +#include "draw/draw_pipe.h"
    +
    +#include "nvfx_context.h"
    +#define NVFX_SHADER_NO_FUCKEDNESS
    +#include "nv30/nv30_shader.h"
    +#include "nv40/nv40_shader.h"
    +
    +/* Simple, but crappy, swtnl path, hopefully we wont need to hit this very
    + * often at all.  Uses "quadro style" vertex submission + a fixed vertex
    + * layout to avoid the need to generate a vertex program or vtxfmt.
    + */
    +
    +struct nvfx_render_stage {
    +	struct draw_stage stage;
    +	struct nvfx_context *nvfx;
    +	unsigned prim;
    +};
    +
    +static INLINE struct nvfx_render_stage *
    +nvfx_render_stage(struct draw_stage *stage)
    +{
    +	return (struct nvfx_render_stage *)stage;
    +}
    +
    +static INLINE void
    +nvfx_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
    +{
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	unsigned i;
    +
    +	for (i = 0; i < nvfx->swtnl.nr_attribs; i++) {
    +		unsigned idx = nvfx->swtnl.draw[i];
    +		unsigned hw = nvfx->swtnl.hw[i];
    +
    +		switch (nvfx->swtnl.emit[i]) {
    +		case EMIT_OMIT:
    +			break;
    +		case EMIT_1F:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_1F(hw), 1);
    +			OUT_RING  (chan, fui(v->data[idx][0]));
    +			break;
    +		case EMIT_2F:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_2F_X(hw), 2);
    +			OUT_RING  (chan, fui(v->data[idx][0]));
    +			OUT_RING  (chan, fui(v->data[idx][1]));
    +			break;
    +		case EMIT_3F:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_3F_X(hw), 3);
    +			OUT_RING  (chan, fui(v->data[idx][0]));
    +			OUT_RING  (chan, fui(v->data[idx][1]));
    +			OUT_RING  (chan, fui(v->data[idx][2]));
    +			break;
    +		case EMIT_4F:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4F_X(hw), 4);
    +			OUT_RING  (chan, fui(v->data[idx][0]));
    +			OUT_RING  (chan, fui(v->data[idx][1]));
    +			OUT_RING  (chan, fui(v->data[idx][2]));
    +			OUT_RING  (chan, fui(v->data[idx][3]));
    +			break;
    +		case EMIT_4UB:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
    +			OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
    +					    float_to_ubyte(v->data[idx][1]),
    +					    float_to_ubyte(v->data[idx][2]),
    +					    float_to_ubyte(v->data[idx][3])));
    +			break;
    +		default:
    +			assert(0);
    +			break;
    +		}
    +	}
    +}
    +
    +static INLINE void
    +nvfx_render_prim(struct draw_stage *stage, struct prim_header *prim,
    +	       unsigned mode, unsigned count)
    +{
    +	struct nvfx_render_stage *rs = nvfx_render_stage(stage);
    +	struct nvfx_context *nvfx = rs->nvfx;
    +
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	unsigned i;
    +
    +	/* Ensure there's room for 4xfloat32 + potentially 3 begin/end */
    +	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    +		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    +			NOUVEAU_ERR("AIII, missed flush\n");
    +			assert(0);
    +		}
    +		FIRE_RING(chan);
    +		nvfx_state_emit(nvfx);
    +	}
    +
    +	/* Switch primitive modes if necessary */
    +	if (rs->prim != mode) {
    +		if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +			OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, mode);
    +		rs->prim = mode;
    +	}
    +
    +	/* Emit vertex data */
    +	for (i = 0; i < count; i++)
    +		nvfx_render_vertex(nvfx, prim->v[i]);
    +
    +	/* If it's likely we'll need to empty the push buffer soon, finish
    +	 * off the primitive now.
    +	 */
    +	if (AVAIL_RING(chan) < ((count * 20) + 6)) {
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    +		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
    +	}
    +}
    +
    +static void
    +nvfx_render_point(struct draw_stage *draw, struct prim_header *prim)
    +{
    +	nvfx_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_POINTS, 1);
    +}
    +
    +static void
    +nvfx_render_line(struct draw_stage *draw, struct prim_header *prim)
    +{
    +	nvfx_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_LINES, 2);
    +}
    +
    +static void
    +nvfx_render_tri(struct draw_stage *draw, struct prim_header *prim)
    +{
    +	nvfx_render_prim(draw, prim, NV34TCL_VERTEX_BEGIN_END_TRIANGLES, 3);
    +}
    +
    +static void
    +nvfx_render_flush(struct draw_stage *draw, unsigned flags)
    +{
    +	struct nvfx_render_stage *rs = nvfx_render_stage(draw);
    +	struct nvfx_context *nvfx = rs->nvfx;
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	if (rs->prim != NV34TCL_VERTEX_BEGIN_END_STOP) {
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, NV34TCL_VERTEX_BEGIN_END_STOP);
    +		rs->prim = NV34TCL_VERTEX_BEGIN_END_STOP;
    +	}
    +}
    +
    +static void
    +nvfx_render_reset_stipple_counter(struct draw_stage *draw)
    +{
    +}
    +
    +static void
    +nvfx_render_destroy(struct draw_stage *draw)
    +{
    +	FREE(draw);
    +}
    +
    +static INLINE void
    +emit_mov(struct nvfx_vertex_program *vp,
    +	 unsigned dst, unsigned src, unsigned vor, unsigned mask)
    +{
    +	struct nvfx_vertex_program_exec *inst;
    +
    +	vp->insns = realloc(vp->insns,
    +			    sizeof(struct nvfx_vertex_program_exec) *
    +			    ++vp->nr_insns);
    +	inst = &vp->insns[vp->nr_insns - 1];
    +
    +	inst->data[0] = 0x401f9c6c;
    +	inst->data[1] = 0x0040000d | (src << 8);
    +	inst->data[2] = 0x8106c083;
    +	inst->data[3] = 0x6041ff80 | (dst << 2) | (mask << 13);
    +	inst->const_index = -1;
    +	inst->has_branch_offset = FALSE;
    +
    +	vp->ir |= (1 << src);
    +	if (vor != ~0)
    +		vp->or |= (1 << vor);
    +}
    +
    +static struct nvfx_vertex_program *
    +create_drawvp(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_vertex_program *vp = CALLOC_STRUCT(nvfx_vertex_program);
    +	unsigned i;
    +
    +	// nv30 support comes in a later patch
    +	assert(nvfx->is_nv4x);
    +
    +	emit_mov(vp, NVFX_VP(INST_DEST_POS), 0, ~0, 0xf);
    +	emit_mov(vp, NVFX_VP(INST_DEST_COL0), 3, 0, 0xf);
    +	emit_mov(vp, NVFX_VP(INST_DEST_COL1), 4, 1, 0xf);
    +	emit_mov(vp, NVFX_VP(INST_DEST_BFC0), 3, 2, 0xf);
    +	emit_mov(vp, NVFX_VP(INST_DEST_BFC1), 4, 3, 0xf);
    +	emit_mov(vp, NVFX_VP(INST_DEST_FOGC), 5, 4, 0x8);
    +	for (i = 0; i < 8; i++)
    +		emit_mov(vp, NVFX_VP(INST_DEST_TC(i)), 8 + i, 14 + i, 0xf);
    +
    +	vp->insns[vp->nr_insns - 1].data[3] |= 1;
    +	vp->translated = TRUE;
    +	return vp;
    +}
    +
    +struct draw_stage *
    +nvfx_draw_render_stage(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_render_stage *render = CALLOC_STRUCT(nvfx_render_stage);
    +
    +	if (!nvfx->swtnl.vertprog)
    +		nvfx->swtnl.vertprog = create_drawvp(nvfx);
    +
    +	render->nvfx = nvfx;
    +	render->stage.draw = nvfx->draw;
    +	render->stage.point = nvfx_render_point;
    +	render->stage.line = nvfx_render_line;
    +	render->stage.tri = nvfx_render_tri;
    +	render->stage.flush = nvfx_render_flush;
    +	render->stage.reset_stipple_counter = nvfx_render_reset_stipple_counter;
    +	render->stage.destroy = nvfx_render_destroy;
    +
    +	return &render->stage;
    +}
    +
    +void
    +nvfx_draw_elements_swtnl(struct pipe_context *pipe,
    +			 struct pipe_buffer *idxbuf, unsigned idxbuf_size,
    +			 unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct pipe_screen *pscreen = pipe->screen;
    +	unsigned i;
    +	void *map;
    +
    +	if (!nvfx_state_validate_swtnl(nvfx))
    +		return;
    +	nvfx->state.dirty &= ~(1ULL << NVFX_STATE_VTXBUF);
    +	nvfx_state_emit(nvfx);
    +
    +	for (i = 0; i < nvfx->vtxbuf_nr; i++) {
    +		map = pipe_buffer_map(pscreen, nvfx->vtxbuf[i].buffer,
    +                                      PIPE_BUFFER_USAGE_CPU_READ);
    +		draw_set_mapped_vertex_buffer(nvfx->draw, i, map);
    +	}
    +
    +	if (idxbuf) {
    +		map = pipe_buffer_map(pscreen, idxbuf,
    +				      PIPE_BUFFER_USAGE_CPU_READ);
    +		draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map);
    +	} else {
    +		draw_set_mapped_element_buffer(nvfx->draw, 0, NULL);
    +	}
    +
    +	if (nvfx->constbuf[PIPE_SHADER_VERTEX]) {
    +		const unsigned nr = nvfx->constbuf_nr[PIPE_SHADER_VERTEX];
    +
    +		map = pipe_buffer_map(pscreen,
    +				      nvfx->constbuf[PIPE_SHADER_VERTEX],
    +				      PIPE_BUFFER_USAGE_CPU_READ);
    +		draw_set_mapped_constant_buffer(nvfx->draw, PIPE_SHADER_VERTEX, 0,
    +                                                map, nr);
    +	}
    +
    +	draw_arrays(nvfx->draw, mode, start, count);
    +
    +	for (i = 0; i < nvfx->vtxbuf_nr; i++)
    +		pipe_buffer_unmap(pscreen, nvfx->vtxbuf[i].buffer);
    +
    +	if (idxbuf)
    +		pipe_buffer_unmap(pscreen, idxbuf);
    +
    +	if (nvfx->constbuf[PIPE_SHADER_VERTEX])
    +		pipe_buffer_unmap(pscreen, nvfx->constbuf[PIPE_SHADER_VERTEX]);
    +
    +	draw_flush(nvfx->draw);
    +	pipe->flush(pipe, 0, NULL);
    +}
    +
    +static INLINE void
    +emit_attrib(struct nvfx_context *nvfx, unsigned hw, unsigned emit,
    +	    unsigned semantic, unsigned index)
    +{
    +	unsigned draw_out = draw_find_shader_output(nvfx->draw, semantic, index);
    +	unsigned a = nvfx->swtnl.nr_attribs++;
    +
    +	nvfx->swtnl.hw[a] = hw;
    +	nvfx->swtnl.emit[a] = emit;
    +	nvfx->swtnl.draw[a] = draw_out;
    +}
    +
    +static boolean
    +nvfx_state_vtxfmt_validate(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
    +	unsigned colour = 0, texcoords = 0, fog = 0, i;
    +
    +	/* Determine needed fragprog inputs */
    +	for (i = 0; i < fp->info.num_inputs; i++) {
    +		switch (fp->info.input_semantic_name[i]) {
    +		case TGSI_SEMANTIC_POSITION:
    +			break;
    +		case TGSI_SEMANTIC_COLOR:
    +			colour |= (1 << fp->info.input_semantic_index[i]);
    +			break;
    +		case TGSI_SEMANTIC_GENERIC:
    +			texcoords |= (1 << fp->info.input_semantic_index[i]);
    +			break;
    +		case TGSI_SEMANTIC_FOG:
    +			fog = 1;
    +			break;
    +		default:
    +			assert(0);
    +		}
    +	}
    +
    +	nvfx->swtnl.nr_attribs = 0;
    +
    +	/* Map draw vtxprog output to hw attribute IDs */
    +	for (i = 0; i < 2; i++) {
    +		if (!(colour & (1 << i)))
    +			continue;
    +		emit_attrib(nvfx, 3 + i, EMIT_4UB, TGSI_SEMANTIC_COLOR, i);
    +	}
    +
    +	for (i = 0; i < 8; i++) {
    +		if (!(texcoords & (1 << i)))
    +			continue;
    +		emit_attrib(nvfx, 8 + i, EMIT_4F, TGSI_SEMANTIC_GENERIC, i);
    +	}
    +
    +	if (fog) {
    +		emit_attrib(nvfx, 5, EMIT_1F, TGSI_SEMANTIC_FOG, 0);
    +	}
    +
    +	emit_attrib(nvfx, 0, EMIT_3F, TGSI_SEMANTIC_POSITION, 0);
    +
    +	return FALSE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_vtxfmt = {
    +	.validate = nvfx_state_vtxfmt_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_ARRAYS | NVFX_NEW_FRAGPROG,
    +		.hw = 0
    +	}
    +};
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index d6fbc5d8dc..9961dacce4 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -3,6 +3,10 @@
     #include "nvfx_state.h"
     #include "draw/draw_context.h"
     
    +/* temporary, will be removed in next patch */
    +#define nv30_state_vtxfmt nvfx_state_vtxfmt
    +#define nv40_state_vtxfmt nvfx_state_vtxfmt
    +
     #define RENDER_STATES(name, nvxx, vbo) \
     static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_framebuffer, \
    @@ -22,7 +26,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     }
     
     RENDER_STATES(nv30, nv30, vbo);
    -RENDER_STATES(nv30_swtnl, nv30, vbo); /* TODO: replace with vtxfmt once draw is unified */
    +RENDER_STATES(nv30_swtnl, nv30, vtxfmt);
     RENDER_STATES(nv40, nv40, vbo);
     RENDER_STATES(nv40_swtnl, nv40, vtxfmt);
     
    -- 
    cgit v1.2.3
    
    
    From 6e1d0fc5eba8cda4f4c8f3188f53fec6d2d2e9c3 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 11:12:08 +0100
    Subject: nv30, nv40: unify nv[34]0_vbo.c
    
    The files are identical, except for swtnl support which is commented
    out on nv30 and restart being initialized on nv30 to avoid a compiler
    warning.
    ---
     src/gallium/drivers/nv30/Makefile          |   1 -
     src/gallium/drivers/nv30/nv30_context.c    |   4 +-
     src/gallium/drivers/nv30/nv30_context.h    |  10 -
     src/gallium/drivers/nv30/nv30_vbo.c        | 562 ----------------------------
     src/gallium/drivers/nv40/Makefile          |   1 -
     src/gallium/drivers/nv40/nv40_context.c    |   4 +-
     src/gallium/drivers/nv40/nv40_context.h    |  10 -
     src/gallium/drivers/nv40/nv40_vbo.c        | 565 -----------------------------
     src/gallium/drivers/nvfx/Makefile          |   3 +-
     src/gallium/drivers/nvfx/nvfx_context.h    |  10 +
     src/gallium/drivers/nvfx/nvfx_state_emit.c |   6 +-
     src/gallium/drivers/nvfx/nvfx_vbo.c        | 563 ++++++++++++++++++++++++++++
     12 files changed, 580 insertions(+), 1159 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_vbo.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_vbo.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_vbo.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 791b0040bb..6ec93ee346 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -8,7 +8,6 @@ C_SOURCES = \
     	nv30_fragtex.c \
     	nv30_screen.c \
     	nv30_state.c \
    -	nv30_vbo.c \
     	nv30_vertprog.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 671a1939e8..730f458878 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -60,8 +60,8 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.screen = pscreen;
     	nvfx->pipe.priv = priv;
     	nvfx->pipe.destroy = nv30_destroy;
    -	nvfx->pipe.draw_arrays = nv30_draw_arrays;
    -	nvfx->pipe.draw_elements = nv30_draw_elements;
    +	nvfx->pipe.draw_arrays = nvfx_draw_arrays;
    +	nvfx->pipe.draw_elements = nvfx_draw_elements;
     	nvfx->pipe.clear = nvfx_clear;
     	nvfx->pipe.flush = nv30_flush;
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index ebdd5455ca..de879d504f 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -15,16 +15,6 @@ extern void nv30_fragtex_bind(struct nvfx_context *);
     /* nv30_state.c and friends */
     extern struct nvfx_state_entry nv30_state_vertprog;
     extern struct nvfx_state_entry nv30_state_fragtex;
    -extern struct nvfx_state_entry nv30_state_vbo;
    -
    -/* nv30_vbo.c */
    -extern void nv30_draw_arrays(struct pipe_context *, unsigned mode,
    -				unsigned start, unsigned count);
    -extern void nv30_draw_elements(struct pipe_context *pipe,
    -				  struct pipe_buffer *indexBuffer,
    -				  unsigned indexSize,
    -				  unsigned mode, unsigned start,
    -				  unsigned count);
     
     /* nvfx_context.c */
     struct pipe_context *
    diff --git a/src/gallium/drivers/nv30/nv30_vbo.c b/src/gallium/drivers/nv30/nv30_vbo.c
    deleted file mode 100644
    index 2b4401e533..0000000000
    --- a/src/gallium/drivers/nv30/nv30_vbo.c
    +++ /dev/null
    @@ -1,562 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -
    -#include "nv30_context.h"
    -#include "nvfx_state.h"
    -
    -#include "nouveau/nouveau_channel.h"
    -#include "nouveau/nouveau_pushbuf.h"
    -#include "nouveau/nouveau_util.h"
    -
    -#define FORCE_SWTNL 0
    -
    -static INLINE int
    -nv30_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
    -{
    -	switch (pipe) {
    -	case PIPE_FORMAT_R32_FLOAT:
    -	case PIPE_FORMAT_R32G32_FLOAT:
    -	case PIPE_FORMAT_R32G32B32_FLOAT:
    -	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    -		*fmt = NV34TCL_VTXFMT_TYPE_FLOAT;
    -		break;
    -	case PIPE_FORMAT_R8_UNORM:
    -	case PIPE_FORMAT_R8G8_UNORM:
    -	case PIPE_FORMAT_R8G8B8_UNORM:
    -	case PIPE_FORMAT_R8G8B8A8_UNORM:
    -		*fmt = NV34TCL_VTXFMT_TYPE_UBYTE;
    -		break;
    -	case PIPE_FORMAT_R16_SSCALED:
    -	case PIPE_FORMAT_R16G16_SSCALED:
    -	case PIPE_FORMAT_R16G16B16_SSCALED:
    -	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    -		*fmt = NV34TCL_VTXFMT_TYPE_USHORT;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    -		return 1;
    -	}
    -
    -	switch (pipe) {
    -	case PIPE_FORMAT_R8_UNORM:
    -	case PIPE_FORMAT_R32_FLOAT:
    -	case PIPE_FORMAT_R16_SSCALED:
    -		*ncomp = 1;
    -		break;
    -	case PIPE_FORMAT_R8G8_UNORM:
    -	case PIPE_FORMAT_R32G32_FLOAT:
    -	case PIPE_FORMAT_R16G16_SSCALED:
    -		*ncomp = 2;
    -		break;
    -	case PIPE_FORMAT_R8G8B8_UNORM:
    -	case PIPE_FORMAT_R32G32B32_FLOAT:
    -	case PIPE_FORMAT_R16G16B16_SSCALED:
    -		*ncomp = 3;
    -		break;
    -	case PIPE_FORMAT_R8G8B8A8_UNORM:
    -	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    -	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    -		*ncomp = 4;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    -		return 1;
    -	}
    -
    -	return 0;
    -}
    -
    -static boolean
    -nv30_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
    -		    unsigned ib_size)
    -{
    -	struct pipe_screen *pscreen = &nvfx->screen->base.base;
    -	unsigned type;
    -
    -	if (!ib) {
    -		nvfx->idxbuf = NULL;
    -		nvfx->idxbuf_format = 0xdeadbeef;
    -		return FALSE;
    -	}
    -
    -	if (!pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF) || ib_size == 1)
    -		return FALSE;
    -
    -	switch (ib_size) {
    -	case 2:
    -		type = NV34TCL_IDXBUF_FORMAT_TYPE_U16;
    -		break;
    -	case 4:
    -		type = NV34TCL_IDXBUF_FORMAT_TYPE_U32;
    -		break;
    -	default:
    -		return FALSE;
    -	}
    -
    -	if (ib != nvfx->idxbuf ||
    -	    type != nvfx->idxbuf_format) {
    -		nvfx->dirty |= NVFX_NEW_ARRAYS;
    -		nvfx->idxbuf = ib;
    -		nvfx->idxbuf_format = type;
    -	}
    -
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
    -		       int attrib, struct pipe_vertex_element *ve,
    -		       struct pipe_vertex_buffer *vb)
    -{
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	unsigned type, ncomp;
    -	void *map;
    -
    -	if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp))
    -		return FALSE;
    -
    -	map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
    -	map += vb->buffer_offset + ve->src_offset;
    -
    -	switch (type) {
    -	case NV34TCL_VTXFMT_TYPE_FLOAT:
    -	{
    -		float *v = map;
    -
    -		switch (ncomp) {
    -		case 4:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			so_data  (so, fui(v[2]));
    -			so_data  (so, fui(v[3]));
    -			break;
    -		case 3:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			so_data  (so, fui(v[2]));
    -			break;
    -		case 2:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			break;
    -		case 1:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_1F(attrib), 1);
    -			so_data  (so, fui(v[0]));
    -			break;
    -		default:
    -			pipe_buffer_unmap(pscreen, vb->buffer);
    -			return FALSE;
    -		}
    -	}
    -		break;
    -	default:
    -		pipe_buffer_unmap(pscreen, vb->buffer);
    -		return FALSE;
    -	}
    -
    -	pipe_buffer_unmap(pscreen, vb->buffer);
    -	return TRUE;
    -}
    -
    -void
    -nv30_draw_arrays(struct pipe_context *pipe,
    -		 unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned restart = 0;
    -
    -	nv30_vbo_set_idxbuf(nvfx, NULL, 0);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
    -						mode, start, count);*/
    -		return;
    -	}
    -
    -	while (count) {
    -		unsigned vc, nr;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    -					mode, start, count, &restart);
    -		if (!vc) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		nr = (vc & 0xff);
    -		if (nr) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, 1);
    -			OUT_RING  (chan, ((nr - 1) << 24) | start);
    -			start += nr;
    -		}
    -
    -		nr = vc >> 8;
    -		while (nr) {
    -			unsigned push = nr > 2047 ? 2047 : nr;
    -
    -			nr -= push;
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, push);
    -			while (push--) {
    -				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    -				start += 0x100;
    -			}
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		count -= vc;
    -		start = restart;
    -	}
    -
    -	pipe->flush(pipe, 0, NULL);
    -}
    -
    -static INLINE void
    -nv30_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint8_t *elts = (uint8_t *)ib + start;
    -		unsigned vc, push, restart = 0;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		if (vc & 1) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    -			OUT_RING  (chan, elts[0]);
    -			elts++; vc--;
    -		}
    -
    -		while (vc) {
    -			unsigned i;
    -
    -			push = MIN2(vc, 2047 * 2);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    -			for (i = 0; i < push; i+=2)
    -				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static INLINE void
    -nv30_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint16_t *elts = (uint16_t *)ib + start;
    -		unsigned vc, push, restart = 0;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		if (vc & 1) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    -			OUT_RING  (chan, elts[0]);
    -			elts++; vc--;
    -		}
    -
    -		while (vc) {
    -			unsigned i;
    -
    -			push = MIN2(vc, 2047 * 2);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    -			for (i = 0; i < push; i+=2)
    -				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static INLINE void
    -nv30_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint32_t *elts = (uint32_t *)ib + start;
    -		unsigned vc, push, restart = 0;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		while (vc) {
    -			push = MIN2(vc, 2047);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U32, push);
    -			OUT_RINGp    (chan, elts, push);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static void
    -nv30_draw_elements_inline(struct pipe_context *pipe,
    -			  struct pipe_buffer *ib, unsigned ib_size,
    -			  unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct pipe_screen *pscreen = pipe->screen;
    -	void *map;
    -
    -	map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
    -	if (!ib) {
    -		NOUVEAU_ERR("failed mapping ib\n");
    -		return;
    -	}
    -
    -	switch (ib_size) {
    -	case 1:
    -		nv30_draw_elements_u08(nvfx, map, mode, start, count);
    -		break;
    -	case 2:
    -		nv30_draw_elements_u16(nvfx, map, mode, start, count);
    -		break;
    -	case 4:
    -		nv30_draw_elements_u32(nvfx, map, mode, start, count);
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
    -		break;
    -	}
    -
    -	pipe_buffer_unmap(pscreen, ib);
    -}
    -
    -static void
    -nv30_draw_elements_vbo(struct pipe_context *pipe,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned restart = 0;
    -
    -	while (count) {
    -		unsigned nr, vc;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    -					mode, start, count, &restart);
    -		if (!vc) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		nr = (vc & 0xff);
    -		if (nr) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_INDEX_BATCH, 1);
    -			OUT_RING  (chan, ((nr - 1) << 24) | start);
    -			start += nr;
    -		}
    -
    -		nr = vc >> 8;
    -		while (nr) {
    -			unsigned push = nr > 2047 ? 2047 : nr;
    -
    -			nr -= push;
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_INDEX_BATCH, push);
    -			while (push--) {
    -				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    -				start += 0x100;
    -			}
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		count -= vc;
    -		start = restart;
    -	}
    -}
    -
    -void
    -nv30_draw_elements(struct pipe_context *pipe,
    -		   struct pipe_buffer *indexBuffer, unsigned indexSize,
    -		   unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	boolean idxbuf;
    -
    -	idxbuf = nv30_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		/*return nv30_draw_elements_swtnl(pipe, NULL, 0,
    -						mode, start, count);*/
    -		return;
    -	}
    -
    -	if (idxbuf) {
    -		nv30_draw_elements_vbo(pipe, mode, start, count);
    -	} else {
    -		nv30_draw_elements_inline(pipe, indexBuffer, indexSize,
    -					  mode, start, count);
    -	}
    -
    -	pipe->flush(pipe, 0, NULL);
    -}
    -
    -static boolean
    -nv30_vbo_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct pipe_buffer *ib = nvfx->idxbuf;
    -	unsigned ib_format = nvfx->idxbuf_format;
    -	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    -	int hw;
    -
    -	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nvfx->vtxelt->num_elements);
    -	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nvfx->vtxelt->num_elements);
    -
    -	for (hw = 0; hw < nvfx->vtxelt->num_elements; hw++) {
    -		struct pipe_vertex_element *ve;
    -		struct pipe_vertex_buffer *vb;
    -		unsigned type, ncomp;
    -
    -		ve = &nvfx->vtxelt->pipe[hw];
    -		vb = &nvfx->vtxbuf[ve->vertex_buffer_index];
    -
    -		if (!vb->stride) {
    -			if (!sattr)
    -				sattr = so_new(16, 16 * 4, 0);
    -
    -			if (nv30_vbo_static_attrib(nvfx, sattr, hw, ve, vb)) {
    -				so_data(vtxbuf, 0);
    -				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
    -				continue;
    -			}
    -		}
    -
    -		if (nv30_vbo_format_to_hw(ve->src_format, &type, &ncomp)) {
    -			/*nvfx->fallback_swtnl |= NVFX_NEW_ARRAYS;*/
    -			so_ref(NULL, &vtxbuf);
    -			so_ref(NULL, &vtxfmt);
    -			return FALSE;
    -		}
    -
    -		so_reloc(vtxbuf, nouveau_bo(vb->buffer), vb->buffer_offset +
    -				 ve->src_offset, vb_flags | NOUVEAU_BO_LOW |
    -				 NOUVEAU_BO_OR, 0, NV34TCL_VTXBUF_ADDRESS_DMA1);
    -		so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) |
    -				  (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type));
    -	}
    -
    -	if (ib) {
    -		struct nouveau_bo *bo = nouveau_bo(ib);
    -
    -		so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
    -		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
    -		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
    -				  0, NV34TCL_IDXBUF_FORMAT_DMA1);
    -	}
    -
    -	so_method(vtxbuf, eng3d, 0x1710, 1);
    -	so_data  (vtxbuf, 0);
    -
    -	so_ref(vtxbuf, &nvfx->state.hw[NVFX_STATE_VTXBUF]);
    -	so_ref(NULL, &vtxbuf);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXBUF);
    -	so_ref(vtxfmt, &nvfx->state.hw[NVFX_STATE_VTXFMT]);
    -	so_ref(NULL, &vtxfmt);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXFMT);
    -	so_ref(sattr, &nvfx->state.hw[NVFX_STATE_VTXATTR]);
    -	so_ref(NULL, &sattr);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXATTR);
    -	return FALSE;
    -}
    -
    -struct nvfx_state_entry nv30_state_vbo = {
    -	.validate = nv30_vbo_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_ARRAYS,
    -		.hw = 0,
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 7529e33a74..6908506906 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -8,7 +8,6 @@ C_SOURCES = \
     	nv40_fragtex.c \
     	nv40_screen.c \
     	nv40_state.c \
    -	nv40_vbo.c \
     	nv40_vertprog.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index eb83131772..85c1355b4f 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -60,8 +60,8 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     	nvfx->pipe.priv = priv;
     	nvfx->pipe.screen = pscreen;
     	nvfx->pipe.destroy = nv40_destroy;
    -	nvfx->pipe.draw_arrays = nv40_draw_arrays;
    -	nvfx->pipe.draw_elements = nv40_draw_elements;
    +	nvfx->pipe.draw_arrays = nvfx_draw_arrays;
    +	nvfx->pipe.draw_elements = nvfx_draw_elements;
     	nvfx->pipe.clear = nvfx_clear;
     	nvfx->pipe.flush = nv40_flush;
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index a8aba0c0ca..cebf21d00c 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -15,16 +15,6 @@ extern void nv40_fragtex_bind(struct nvfx_context *);
     /* nv40_state.c and friends */
     extern struct nvfx_state_entry nv40_state_vertprog;
     extern struct nvfx_state_entry nv40_state_fragtex;
    -extern struct nvfx_state_entry nv40_state_vbo;
    -
    -/* nv40_vbo.c */
    -extern void nv40_draw_arrays(struct pipe_context *, unsigned mode,
    -				unsigned start, unsigned count);
    -extern void nv40_draw_elements(struct pipe_context *pipe,
    -				  struct pipe_buffer *indexBuffer,
    -				  unsigned indexSize,
    -				  unsigned mode, unsigned start,
    -				  unsigned count);
     
     /* nvfx_context.c */
     struct pipe_context *
    diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
    deleted file mode 100644
    index 196a12b1f6..0000000000
    --- a/src/gallium/drivers/nv40/nv40_vbo.c
    +++ /dev/null
    @@ -1,565 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -
    -#include "nv40_context.h"
    -#include "nvfx_state.h"
    -
    -#include "nouveau/nouveau_channel.h"
    -#include "nouveau/nouveau_pushbuf.h"
    -#include "nouveau/nouveau_util.h"
    -
    -#define FORCE_SWTNL 0
    -
    -static INLINE int
    -nv40_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
    -{
    -	switch (pipe) {
    -	case PIPE_FORMAT_R32_FLOAT:
    -	case PIPE_FORMAT_R32G32_FLOAT:
    -	case PIPE_FORMAT_R32G32B32_FLOAT:
    -	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    -		*fmt = NV34TCL_VTXFMT_TYPE_FLOAT;
    -		break;
    -	case PIPE_FORMAT_R8_UNORM:
    -	case PIPE_FORMAT_R8G8_UNORM:
    -	case PIPE_FORMAT_R8G8B8_UNORM:
    -	case PIPE_FORMAT_R8G8B8A8_UNORM:
    -		*fmt = NV34TCL_VTXFMT_TYPE_UBYTE;
    -		break;
    -	case PIPE_FORMAT_R16_SSCALED:
    -	case PIPE_FORMAT_R16G16_SSCALED:
    -	case PIPE_FORMAT_R16G16B16_SSCALED:
    -	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    -		*fmt = NV34TCL_VTXFMT_TYPE_USHORT;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    -		return 1;
    -	}
    -
    -	switch (pipe) {
    -	case PIPE_FORMAT_R8_UNORM:
    -	case PIPE_FORMAT_R32_FLOAT:
    -	case PIPE_FORMAT_R16_SSCALED:
    -		*ncomp = 1;
    -		break;
    -	case PIPE_FORMAT_R8G8_UNORM:
    -	case PIPE_FORMAT_R32G32_FLOAT:
    -	case PIPE_FORMAT_R16G16_SSCALED:
    -		*ncomp = 2;
    -		break;
    -	case PIPE_FORMAT_R8G8B8_UNORM:
    -	case PIPE_FORMAT_R32G32B32_FLOAT:
    -	case PIPE_FORMAT_R16G16B16_SSCALED:
    -		*ncomp = 3;
    -		break;
    -	case PIPE_FORMAT_R8G8B8A8_UNORM:
    -	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    -	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    -		*ncomp = 4;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    -		return 1;
    -	}
    -
    -	return 0;
    -}
    -
    -static boolean
    -nv40_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
    -		    unsigned ib_size)
    -{
    -	struct pipe_screen *pscreen = &nvfx->screen->base.base;
    -	unsigned type;
    -
    -	if (!ib) {
    -		nvfx->idxbuf = NULL;
    -		nvfx->idxbuf_format = 0xdeadbeef;
    -		return FALSE;
    -	}
    -
    -	if (!pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF) || ib_size == 1)
    -		return FALSE;
    -
    -	switch (ib_size) {
    -	case 2:
    -		type = NV34TCL_IDXBUF_FORMAT_TYPE_U16;
    -		break;
    -	case 4:
    -		type = NV34TCL_IDXBUF_FORMAT_TYPE_U32;
    -		break;
    -	default:
    -		return FALSE;
    -	}
    -
    -	if (ib != nvfx->idxbuf ||
    -	    type != nvfx->idxbuf_format) {
    -		nvfx->dirty |= NVFX_NEW_ARRAYS;
    -		nvfx->idxbuf = ib;
    -		nvfx->idxbuf_format = type;
    -	}
    -
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
    -		       int attrib, struct pipe_vertex_element *ve,
    -		       struct pipe_vertex_buffer *vb)
    -{
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	unsigned type, ncomp;
    -	void *map;
    -
    -	if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp))
    -		return FALSE;
    -
    -	map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
    -	map += vb->buffer_offset + ve->src_offset;
    -
    -	switch (type) {
    -	case NV34TCL_VTXFMT_TYPE_FLOAT:
    -	{
    -		float *v = map;
    -
    -		switch (ncomp) {
    -		case 4:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			so_data  (so, fui(v[2]));
    -			so_data  (so, fui(v[3]));
    -			break;
    -		case 3:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			so_data  (so, fui(v[2]));
    -			break;
    -		case 2:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
    -			so_data  (so, fui(v[0]));
    -			so_data  (so, fui(v[1]));
    -			break;
    -		case 1:
    -			so_method(so, eng3d, NV34TCL_VTX_ATTR_1F(attrib), 1);
    -			so_data  (so, fui(v[0]));
    -			break;
    -		default:
    -			pipe_buffer_unmap(pscreen, vb->buffer);
    -			return FALSE;
    -		}
    -	}
    -		break;
    -	default:
    -		pipe_buffer_unmap(pscreen, vb->buffer);
    -		return FALSE;
    -	}
    -
    -	pipe_buffer_unmap(pscreen, vb->buffer);
    -
    -	return TRUE;
    -}
    -
    -void
    -nv40_draw_arrays(struct pipe_context *pipe,
    -		 unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned restart;
    -
    -	nv40_vbo_set_idxbuf(nvfx, NULL, 0);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		nvfx_draw_elements_swtnl(pipe, NULL, 0,
    -                                         mode, start, count);
    -                return;
    -	}
    -
    -	while (count) {
    -		unsigned vc, nr;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    -					mode, start, count, &restart);
    -		if (!vc) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		nr = (vc & 0xff);
    -		if (nr) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, 1);
    -			OUT_RING  (chan, ((nr - 1) << 24) | start);
    -			start += nr;
    -		}
    -
    -		nr = vc >> 8;
    -		while (nr) {
    -			unsigned push = nr > 2047 ? 2047 : nr;
    -
    -			nr -= push;
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, push);
    -			while (push--) {
    -				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    -				start += 0x100;
    -			}
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		count -= vc;
    -		start = restart;
    -	}
    -
    -	pipe->flush(pipe, 0, NULL);
    -}
    -
    -static INLINE void
    -nv40_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint8_t *elts = (uint8_t *)ib + start;
    -		unsigned vc, push, restart;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		if (vc & 1) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    -			OUT_RING  (chan, elts[0]);
    -			elts++; vc--;
    -		}
    -
    -		while (vc) {
    -			unsigned i;
    -
    -			push = MIN2(vc, 2047 * 2);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    -			for (i = 0; i < push; i+=2)
    -				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static INLINE void
    -nv40_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint16_t *elts = (uint16_t *)ib + start;
    -		unsigned vc, push, restart;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		if (vc & 1) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    -			OUT_RING  (chan, elts[0]);
    -			elts++; vc--;
    -		}
    -
    -		while (vc) {
    -			unsigned i;
    -
    -			push = MIN2(vc, 2047 * 2);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    -			for (i = 0; i < push; i+=2)
    -				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static INLINE void
    -nv40_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	while (count) {
    -		uint32_t *elts = (uint32_t *)ib + start;
    -		unsigned vc, push, restart;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
    -					mode, start, count, &restart);
    -		if (vc == 0) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -		count -= vc;
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		while (vc) {
    -			push = MIN2(vc, 2047);
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U32, push);
    -			OUT_RINGp    (chan, elts, push);
    -
    -			vc -= push;
    -			elts += push;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		start = restart;
    -	}
    -}
    -
    -static void
    -nv40_draw_elements_inline(struct pipe_context *pipe,
    -			  struct pipe_buffer *ib, unsigned ib_size,
    -			  unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct pipe_screen *pscreen = pipe->screen;
    -	void *map;
    -
    -	map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
    -	if (!ib) {
    -		NOUVEAU_ERR("failed mapping ib\n");
    -		return;
    -	}
    -
    -	switch (ib_size) {
    -	case 1:
    -		nv40_draw_elements_u08(nvfx, map, mode, start, count);
    -		break;
    -	case 2:
    -		nv40_draw_elements_u16(nvfx, map, mode, start, count);
    -		break;
    -	case 4:
    -		nv40_draw_elements_u32(nvfx, map, mode, start, count);
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
    -		break;
    -	}
    -
    -	pipe_buffer_unmap(pscreen, ib);
    -}
    -
    -static void
    -nv40_draw_elements_vbo(struct pipe_context *pipe,
    -		       unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	unsigned restart;
    -
    -	while (count) {
    -		unsigned nr, vc;
    -
    -		nvfx_state_emit(nvfx);
    -
    -		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    -					mode, start, count, &restart);
    -		if (!vc) {
    -			FIRE_RING(chan);
    -			continue;
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, nvgl_primitive(mode));
    -
    -		nr = (vc & 0xff);
    -		if (nr) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VB_INDEX_BATCH, 1);
    -			OUT_RING  (chan, ((nr - 1) << 24) | start);
    -			start += nr;
    -		}
    -
    -		nr = vc >> 8;
    -		while (nr) {
    -			unsigned push = nr > 2047 ? 2047 : nr;
    -
    -			nr -= push;
    -
    -			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_INDEX_BATCH, push);
    -			while (push--) {
    -				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    -				start += 0x100;
    -			}
    -		}
    -
    -		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    -		OUT_RING  (chan, 0);
    -
    -		count -= vc;
    -		start = restart;
    -	}
    -}
    -
    -void
    -nv40_draw_elements(struct pipe_context *pipe,
    -		   struct pipe_buffer *indexBuffer, unsigned indexSize,
    -		   unsigned mode, unsigned start, unsigned count)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	boolean idxbuf;
    -
    -	idxbuf = nv40_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    -		nvfx_draw_elements_swtnl(pipe, NULL, 0,
    -                                         mode, start, count);
    -                return;
    -	}
    -
    -	if (idxbuf) {
    -		nv40_draw_elements_vbo(pipe, mode, start, count);
    -	} else {
    -		nv40_draw_elements_inline(pipe, indexBuffer, indexSize,
    -					  mode, start, count);
    -	}
    -
    -	pipe->flush(pipe, 0, NULL);
    -}
    -
    -static boolean
    -nv40_vbo_validate(struct nvfx_context *nvfx)
    -{
    -	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct pipe_buffer *ib = nvfx->idxbuf;
    -	unsigned ib_format = nvfx->idxbuf_format;
    -	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    -	int hw;
    -
    -	vtxbuf = so_new(3, 17, 18);
    -	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nvfx->vtxelt->num_elements);
    -	vtxfmt = so_new(1, 16, 0);
    -	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nvfx->vtxelt->num_elements);
    -
    -	for (hw = 0; hw < nvfx->vtxelt->num_elements; hw++) {
    -		struct pipe_vertex_element *ve;
    -		struct pipe_vertex_buffer *vb;
    -		unsigned type, ncomp;
    -
    -		ve = &nvfx->vtxelt->pipe[hw];
    -		vb = &nvfx->vtxbuf[ve->vertex_buffer_index];
    -
    -		if (!vb->stride) {
    -			if (!sattr)
    -				sattr = so_new(16, 16 * 4, 0);
    -
    -			if (nv40_vbo_static_attrib(nvfx, sattr, hw, ve, vb)) {
    -				so_data(vtxbuf, 0);
    -				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
    -				continue;
    -			}
    -		}
    -
    -		if (nv40_vbo_format_to_hw(ve->src_format, &type, &ncomp)) {
    -			nvfx->fallback_swtnl |= NVFX_NEW_ARRAYS;
    -			so_ref(NULL, &vtxbuf);
    -			so_ref(NULL, &vtxfmt);
    -			return FALSE;
    -		}
    -
    -		so_reloc(vtxbuf, nouveau_bo(vb->buffer),
    -				 vb->buffer_offset + ve->src_offset,
    -				 vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
    -				 0, NV34TCL_VTXBUF_ADDRESS_DMA1);
    -		so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) |
    -				  (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type));
    -	}
    -
    -	if (ib) {
    -		struct nouveau_bo *bo = nouveau_bo(ib);
    -
    -		so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
    -		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
    -		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
    -			  0, NV34TCL_IDXBUF_FORMAT_DMA1);
    -	}
    -
    -	so_method(vtxbuf, eng3d, 0x1710, 1);
    -	so_data  (vtxbuf, 0);
    -
    -	so_ref(vtxbuf, &nvfx->state.hw[NVFX_STATE_VTXBUF]);
    -	so_ref(NULL, &vtxbuf);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXBUF);
    -	so_ref(vtxfmt, &nvfx->state.hw[NVFX_STATE_VTXFMT]);
    -	so_ref(NULL, &vtxfmt);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXFMT);
    -	so_ref(sattr, &nvfx->state.hw[NVFX_STATE_VTXATTR]);
    -	so_ref(NULL, &sattr);
    -	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXATTR);
    -	return FALSE;
    -}
    -
    -struct nvfx_state_entry nv40_state_vbo = {
    -	.validate = nv40_vbo_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_ARRAYS,
    -		.hw = 0,
    -	}
    -};
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index a23d024f11..d1304ccea0 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -18,6 +18,7 @@ C_SOURCES = \
     	nvfx_state_viewport.c \
     	nvfx_state_zsa.c \
     	nvfx_surface.c \
    -	nvfx_transfer.c
    +	nvfx_transfer.c \
    +	nvfx_vbo.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 75008f8ddd..8f121fe3af 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -189,6 +189,7 @@ extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
     extern struct nvfx_state_entry nvfx_state_stipple;
    +extern struct nvfx_state_entry nvfx_state_vbo;
     extern struct nvfx_state_entry nvfx_state_viewport;
     extern struct nvfx_state_entry nvfx_state_vtxfmt;
     extern struct nvfx_state_entry nvfx_state_zsa;
    @@ -220,4 +221,13 @@ extern void nvfx_state_emit(struct nvfx_context *nvfx);
     /* nvfx_transfer.c */
     extern void nvfx_init_transfer_functions(struct nvfx_context *nvfx);
     
    +/* nvfx_vbo.c */
    +extern void nvfx_draw_arrays(struct pipe_context *, unsigned mode,
    +				unsigned start, unsigned count);
    +extern void nvfx_draw_elements(struct pipe_context *pipe,
    +				  struct pipe_buffer *indexBuffer,
    +				  unsigned indexSize,
    +				  unsigned mode, unsigned start,
    +				  unsigned count);
    +
     #endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 9961dacce4..88b86f9fb5 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -3,10 +3,6 @@
     #include "nvfx_state.h"
     #include "draw/draw_context.h"
     
    -/* temporary, will be removed in next patch */
    -#define nv30_state_vtxfmt nvfx_state_vtxfmt
    -#define nv40_state_vtxfmt nvfx_state_vtxfmt
    -
     #define RENDER_STATES(name, nvxx, vbo) \
     static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_framebuffer, \
    @@ -21,7 +17,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_zsa, \
     	&nvfx_state_sr, \
     	&nvfx_state_viewport, \
    -	&nvxx##_state_##vbo, \
    +	&nvfx_state_##vbo, \
     	NULL \
     }
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c
    new file mode 100644
    index 0000000000..9d501ef1da
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c
    @@ -0,0 +1,563 @@
    +#include "pipe/p_context.h"
    +#include "pipe/p_state.h"
    +#include "util/u_inlines.h"
    +#include "util/u_format.h"
    +
    +#include "nvfx_context.h"
    +#include "nvfx_state.h"
    +
    +#include "nouveau/nouveau_channel.h"
    +#include "nouveau/nouveau_pushbuf.h"
    +#include "nouveau/nouveau_util.h"
    +
    +#define FORCE_SWTNL 0
    +
    +static INLINE int
    +nvfx_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
    +{
    +	switch (pipe) {
    +	case PIPE_FORMAT_R32_FLOAT:
    +	case PIPE_FORMAT_R32G32_FLOAT:
    +	case PIPE_FORMAT_R32G32B32_FLOAT:
    +	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    +		*fmt = NV34TCL_VTXFMT_TYPE_FLOAT;
    +		break;
    +	case PIPE_FORMAT_R8_UNORM:
    +	case PIPE_FORMAT_R8G8_UNORM:
    +	case PIPE_FORMAT_R8G8B8_UNORM:
    +	case PIPE_FORMAT_R8G8B8A8_UNORM:
    +		*fmt = NV34TCL_VTXFMT_TYPE_UBYTE;
    +		break;
    +	case PIPE_FORMAT_R16_SSCALED:
    +	case PIPE_FORMAT_R16G16_SSCALED:
    +	case PIPE_FORMAT_R16G16B16_SSCALED:
    +	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    +		*fmt = NV34TCL_VTXFMT_TYPE_USHORT;
    +		break;
    +	default:
    +		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    +		return 1;
    +	}
    +
    +	switch (pipe) {
    +	case PIPE_FORMAT_R8_UNORM:
    +	case PIPE_FORMAT_R32_FLOAT:
    +	case PIPE_FORMAT_R16_SSCALED:
    +		*ncomp = 1;
    +		break;
    +	case PIPE_FORMAT_R8G8_UNORM:
    +	case PIPE_FORMAT_R32G32_FLOAT:
    +	case PIPE_FORMAT_R16G16_SSCALED:
    +		*ncomp = 2;
    +		break;
    +	case PIPE_FORMAT_R8G8B8_UNORM:
    +	case PIPE_FORMAT_R32G32B32_FLOAT:
    +	case PIPE_FORMAT_R16G16B16_SSCALED:
    +		*ncomp = 3;
    +		break;
    +	case PIPE_FORMAT_R8G8B8A8_UNORM:
    +	case PIPE_FORMAT_R32G32B32A32_FLOAT:
    +	case PIPE_FORMAT_R16G16B16A16_SSCALED:
    +		*ncomp = 4;
    +		break;
    +	default:
    +		NOUVEAU_ERR("Unknown format %s\n", util_format_name(pipe));
    +		return 1;
    +	}
    +
    +	return 0;
    +}
    +
    +static boolean
    +nvfx_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
    +		    unsigned ib_size)
    +{
    +	struct pipe_screen *pscreen = &nvfx->screen->base.base;
    +	unsigned type;
    +
    +	if (!ib) {
    +		nvfx->idxbuf = NULL;
    +		nvfx->idxbuf_format = 0xdeadbeef;
    +		return FALSE;
    +	}
    +
    +	if (!pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF) || ib_size == 1)
    +		return FALSE;
    +
    +	switch (ib_size) {
    +	case 2:
    +		type = NV34TCL_IDXBUF_FORMAT_TYPE_U16;
    +		break;
    +	case 4:
    +		type = NV34TCL_IDXBUF_FORMAT_TYPE_U32;
    +		break;
    +	default:
    +		return FALSE;
    +	}
    +
    +	if (ib != nvfx->idxbuf ||
    +	    type != nvfx->idxbuf_format) {
    +		nvfx->dirty |= NVFX_NEW_ARRAYS;
    +		nvfx->idxbuf = ib;
    +		nvfx->idxbuf_format = type;
    +	}
    +
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
    +		       int attrib, struct pipe_vertex_element *ve,
    +		       struct pipe_vertex_buffer *vb)
    +{
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	unsigned type, ncomp;
    +	void *map;
    +
    +	if (nvfx_vbo_format_to_hw(ve->src_format, &type, &ncomp))
    +		return FALSE;
    +
    +	map  = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
    +	map += vb->buffer_offset + ve->src_offset;
    +
    +	switch (type) {
    +	case NV34TCL_VTXFMT_TYPE_FLOAT:
    +	{
    +		float *v = map;
    +
    +		switch (ncomp) {
    +		case 4:
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_4F_X(attrib), 4);
    +			so_data  (so, fui(v[0]));
    +			so_data  (so, fui(v[1]));
    +			so_data  (so, fui(v[2]));
    +			so_data  (so, fui(v[3]));
    +			break;
    +		case 3:
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_3F_X(attrib), 3);
    +			so_data  (so, fui(v[0]));
    +			so_data  (so, fui(v[1]));
    +			so_data  (so, fui(v[2]));
    +			break;
    +		case 2:
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_2F_X(attrib), 2);
    +			so_data  (so, fui(v[0]));
    +			so_data  (so, fui(v[1]));
    +			break;
    +		case 1:
    +			so_method(so, eng3d, NV34TCL_VTX_ATTR_1F(attrib), 1);
    +			so_data  (so, fui(v[0]));
    +			break;
    +		default:
    +			pipe_buffer_unmap(pscreen, vb->buffer);
    +			return FALSE;
    +		}
    +	}
    +		break;
    +	default:
    +		pipe_buffer_unmap(pscreen, vb->buffer);
    +		return FALSE;
    +	}
    +
    +	pipe_buffer_unmap(pscreen, vb->buffer);
    +	return TRUE;
    +}
    +
    +void
    +nvfx_draw_arrays(struct pipe_context *pipe,
    +		 unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	unsigned restart = 0;
    +
    +	nvfx_vbo_set_idxbuf(nvfx, NULL, 0);
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    +		nvfx_draw_elements_swtnl(pipe, NULL, 0,
    +                                           mode, start, count);
    +                return;
    +	}
    +
    +	while (count) {
    +		unsigned vc, nr;
    +
    +		nvfx_state_emit(nvfx);
    +
    +		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    +					mode, start, count, &restart);
    +		if (!vc) {
    +			FIRE_RING(chan);
    +			continue;
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, nvgl_primitive(mode));
    +
    +		nr = (vc & 0xff);
    +		if (nr) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, 1);
    +			OUT_RING  (chan, ((nr - 1) << 24) | start);
    +			start += nr;
    +		}
    +
    +		nr = vc >> 8;
    +		while (nr) {
    +			unsigned push = nr > 2047 ? 2047 : nr;
    +
    +			nr -= push;
    +
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_VERTEX_BATCH, push);
    +			while (push--) {
    +				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    +				start += 0x100;
    +			}
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, 0);
    +
    +		count -= vc;
    +		start = restart;
    +	}
    +
    +	pipe->flush(pipe, 0, NULL);
    +}
    +
    +static INLINE void
    +nvfx_draw_elements_u08(struct nvfx_context *nvfx, void *ib,
    +		       unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	while (count) {
    +		uint8_t *elts = (uint8_t *)ib + start;
    +		unsigned vc, push, restart = 0;
    +
    +		nvfx_state_emit(nvfx);
    +
    +		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    +					mode, start, count, &restart);
    +		if (vc == 0) {
    +			FIRE_RING(chan);
    +			continue;
    +		}
    +		count -= vc;
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, nvgl_primitive(mode));
    +
    +		if (vc & 1) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    +			OUT_RING  (chan, elts[0]);
    +			elts++; vc--;
    +		}
    +
    +		while (vc) {
    +			unsigned i;
    +
    +			push = MIN2(vc, 2047 * 2);
    +
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			for (i = 0; i < push; i+=2)
    +				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    +
    +			vc -= push;
    +			elts += push;
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, 0);
    +
    +		start = restart;
    +	}
    +}
    +
    +static INLINE void
    +nvfx_draw_elements_u16(struct nvfx_context *nvfx, void *ib,
    +		       unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	while (count) {
    +		uint16_t *elts = (uint16_t *)ib + start;
    +		unsigned vc, push, restart = 0;
    +
    +		nvfx_state_emit(nvfx);
    +
    +		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 2,
    +					mode, start, count, &restart);
    +		if (vc == 0) {
    +			FIRE_RING(chan);
    +			continue;
    +		}
    +		count -= vc;
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, nvgl_primitive(mode));
    +
    +		if (vc & 1) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_ELEMENT_U32, 1);
    +			OUT_RING  (chan, elts[0]);
    +			elts++; vc--;
    +		}
    +
    +		while (vc) {
    +			unsigned i;
    +
    +			push = MIN2(vc, 2047 * 2);
    +
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U16, push >> 1);
    +			for (i = 0; i < push; i+=2)
    +				OUT_RING(chan, (elts[i+1] << 16) | elts[i]);
    +
    +			vc -= push;
    +			elts += push;
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, 0);
    +
    +		start = restart;
    +	}
    +}
    +
    +static INLINE void
    +nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
    +		       unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	while (count) {
    +		uint32_t *elts = (uint32_t *)ib + start;
    +		unsigned vc, push, restart = 0;
    +
    +		nvfx_state_emit(nvfx);
    +
    +		vc = nouveau_vbuf_split(AVAIL_RING(chan), 5, 1,
    +					mode, start, count, &restart);
    +		if (vc == 0) {
    +			FIRE_RING(chan);
    +			continue;
    +		}
    +		count -= vc;
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, nvgl_primitive(mode));
    +
    +		while (vc) {
    +			push = MIN2(vc, 2047);
    +
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_ELEMENT_U32, push);
    +			OUT_RINGp    (chan, elts, push);
    +
    +			vc -= push;
    +			elts += push;
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, 0);
    +
    +		start = restart;
    +	}
    +}
    +
    +static void
    +nvfx_draw_elements_inline(struct pipe_context *pipe,
    +			  struct pipe_buffer *ib, unsigned ib_size,
    +			  unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct pipe_screen *pscreen = pipe->screen;
    +	void *map;
    +
    +	map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
    +	if (!ib) {
    +		NOUVEAU_ERR("failed mapping ib\n");
    +		return;
    +	}
    +
    +	switch (ib_size) {
    +	case 1:
    +		nvfx_draw_elements_u08(nvfx, map, mode, start, count);
    +		break;
    +	case 2:
    +		nvfx_draw_elements_u16(nvfx, map, mode, start, count);
    +		break;
    +	case 4:
    +		nvfx_draw_elements_u32(nvfx, map, mode, start, count);
    +		break;
    +	default:
    +		NOUVEAU_ERR("invalid idxbuf fmt %d\n", ib_size);
    +		break;
    +	}
    +
    +	pipe_buffer_unmap(pscreen, ib);
    +}
    +
    +static void
    +nvfx_draw_elements_vbo(struct pipe_context *pipe,
    +		       unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	unsigned restart = 0;
    +
    +	while (count) {
    +		unsigned nr, vc;
    +
    +		nvfx_state_emit(nvfx);
    +
    +		vc = nouveau_vbuf_split(AVAIL_RING(chan), 6, 256,
    +					mode, start, count, &restart);
    +		if (!vc) {
    +			FIRE_RING(chan);
    +			continue;
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, nvgl_primitive(mode));
    +
    +		nr = (vc & 0xff);
    +		if (nr) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VB_INDEX_BATCH, 1);
    +			OUT_RING  (chan, ((nr - 1) << 24) | start);
    +			start += nr;
    +		}
    +
    +		nr = vc >> 8;
    +		while (nr) {
    +			unsigned push = nr > 2047 ? 2047 : nr;
    +
    +			nr -= push;
    +
    +			BEGIN_RING_NI(chan, eng3d, NV34TCL_VB_INDEX_BATCH, push);
    +			while (push--) {
    +				OUT_RING(chan, ((0x100 - 1) << 24) | start);
    +				start += 0x100;
    +			}
    +		}
    +
    +		BEGIN_RING(chan, eng3d, NV34TCL_VERTEX_BEGIN_END, 1);
    +		OUT_RING  (chan, 0);
    +
    +		count -= vc;
    +		start = restart;
    +	}
    +}
    +
    +void
    +nvfx_draw_elements(struct pipe_context *pipe,
    +		   struct pipe_buffer *indexBuffer, unsigned indexSize,
    +		   unsigned mode, unsigned start, unsigned count)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	boolean idxbuf;
    +
    +	idxbuf = nvfx_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    +	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    +		nvfx_draw_elements_swtnl(pipe, NULL, 0,
    +                                           mode, start, count);
    +		return;
    +	}
    +
    +	if (idxbuf) {
    +		nvfx_draw_elements_vbo(pipe, mode, start, count);
    +	} else {
    +		nvfx_draw_elements_inline(pipe, indexBuffer, indexSize,
    +					  mode, start, count);
    +	}
    +
    +	pipe->flush(pipe, 0, NULL);
    +}
    +
    +static boolean
    +nvfx_vbo_validate(struct nvfx_context *nvfx)
    +{
    +	struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct pipe_buffer *ib = nvfx->idxbuf;
    +	unsigned ib_format = nvfx->idxbuf_format;
    +	unsigned vb_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    +	int hw;
    +
    +	vtxbuf = so_new(3, 17, 18);
    +	so_method(vtxbuf, eng3d, NV34TCL_VTXBUF_ADDRESS(0), nvfx->vtxelt->num_elements);
    +	vtxfmt = so_new(1, 16, 0);
    +	so_method(vtxfmt, eng3d, NV34TCL_VTXFMT(0), nvfx->vtxelt->num_elements);
    +
    +	for (hw = 0; hw < nvfx->vtxelt->num_elements; hw++) {
    +		struct pipe_vertex_element *ve;
    +		struct pipe_vertex_buffer *vb;
    +		unsigned type, ncomp;
    +
    +		ve = &nvfx->vtxelt->pipe[hw];
    +		vb = &nvfx->vtxbuf[ve->vertex_buffer_index];
    +
    +		if (!vb->stride) {
    +			if (!sattr)
    +				sattr = so_new(16, 16 * 4, 0);
    +
    +			if (nvfx_vbo_static_attrib(nvfx, sattr, hw, ve, vb)) {
    +				so_data(vtxbuf, 0);
    +				so_data(vtxfmt, NV34TCL_VTXFMT_TYPE_FLOAT);
    +				continue;
    +			}
    +		}
    +
    +		if (nvfx_vbo_format_to_hw(ve->src_format, &type, &ncomp)) {
    +			nvfx->fallback_swtnl |= NVFX_NEW_ARRAYS;
    +			so_ref(NULL, &vtxbuf);
    +			so_ref(NULL, &vtxfmt);
    +			return FALSE;
    +		}
    +
    +		so_reloc(vtxbuf, nouveau_bo(vb->buffer),
    +				 vb->buffer_offset + ve->src_offset,
    +				 vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
    +				 0, NV34TCL_VTXBUF_ADDRESS_DMA1);
    +		so_data (vtxfmt, ((vb->stride << NV34TCL_VTXFMT_STRIDE_SHIFT) |
    +				  (ncomp << NV34TCL_VTXFMT_SIZE_SHIFT) | type));
    +	}
    +
    +	if (ib) {
    +		struct nouveau_bo *bo = nouveau_bo(ib);
    +
    +		so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
    +		so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
    +		so_reloc (vtxbuf, bo, ib_format, vb_flags | NOUVEAU_BO_OR,
    +				  0, NV34TCL_IDXBUF_FORMAT_DMA1);
    +	}
    +
    +	so_method(vtxbuf, eng3d, 0x1710, 1);
    +	so_data  (vtxbuf, 0);
    +
    +	so_ref(vtxbuf, &nvfx->state.hw[NVFX_STATE_VTXBUF]);
    +	so_ref(NULL, &vtxbuf);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXBUF);
    +	so_ref(vtxfmt, &nvfx->state.hw[NVFX_STATE_VTXFMT]);
    +	so_ref(NULL, &vtxfmt);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXFMT);
    +	so_ref(sattr, &nvfx->state.hw[NVFX_STATE_VTXATTR]);
    +	so_ref(NULL, &sattr);
    +	nvfx->state.dirty |= (1ULL << NVFX_STATE_VTXATTR);
    +	return FALSE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_vbo = {
    +	.validate = nvfx_vbo_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_ARRAYS,
    +		.hw = 0,
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From c65a8f3ed2ab1650df38a3ed32d1e91e84b50520 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 12:39:21 +0100
    Subject: nv30, nv40: partially unify nv[34]0_state.c
    
    state.c is identical except for:
    1. Sampler state creation is different
    2. nv40 swtnl support
    3. Separate blend equations on nv40
    
    This patch unifies nv[34]0_state.c, except the sampler state creation code.
    ---
     src/gallium/drivers/nv30/nv30_context.c |   2 +-
     src/gallium/drivers/nv30/nv30_context.h |   6 -
     src/gallium/drivers/nv30/nv30_state.c   | 573 +-----------------------------
     src/gallium/drivers/nv40/nv40_context.c |   2 +-
     src/gallium/drivers/nv40/nv40_context.h |   6 -
     src/gallium/drivers/nv40/nv40_state.c   | 577 +-----------------------------
     src/gallium/drivers/nvfx/Makefile       |   1 +
     src/gallium/drivers/nvfx/nvfx_context.h |   8 +
     src/gallium/drivers/nvfx/nvfx_state.c   | 605 ++++++++++++++++++++++++++++++++
     9 files changed, 618 insertions(+), 1162 deletions(-)
     create mode 100644 src/gallium/drivers/nvfx/nvfx_state.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 730f458878..9ddb331e74 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -75,7 +75,7 @@ nv30_create(struct pipe_screen *pscreen, void *priv)
     
     	nvfx_init_query_functions(nvfx);
     	nvfx_init_surface_functions(nvfx);
    -	nv30_init_state_functions(nvfx);
    +	nvfx_init_state_functions(nvfx);
     	nvfx_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index de879d504f..16cf3cbaa4 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -3,12 +3,6 @@
     
     #include "nvfx_context.h"
     
    -extern void nv30_init_state_functions(struct nvfx_context *nvfx);
    -
    -/* nv30_vertprog.c */
    -extern void nv30_vertprog_destroy(struct nvfx_context *,
    -				  struct nvfx_vertex_program *);
    -
     /* nv30_fragtex.c */
     extern void nv30_fragtex_bind(struct nvfx_context *);
     
    diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
    index 92a4089b31..bf96f7cf35 100644
    --- a/src/gallium/drivers/nv30/nv30_state.c
    +++ b/src/gallium/drivers/nv30/nv30_state.c
    @@ -7,74 +7,6 @@
     #include "nv30_context.h"
     #include "nvfx_state.h"
     
    -static void *
    -nv30_blend_state_create(struct pipe_context *pipe,
    -			const struct pipe_blend_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
    -	struct nouveau_stateobj *so = so_new(5, 8, 0);
    -
    -	if (cso->rt[0].blend_enable) {
    -		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
    -		so_data  (so, 1);
    -		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
    -			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
    -		so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
    -			      nvgl_blend_func(cso->rt[0].rgb_dst_factor));
    -		/* FIXME: Gallium assumes GL_EXT_blend_func_separate.
    -		   It is not the case for NV30 */
    -		so_method(so, eng3d, NV34TCL_BLEND_EQUATION, 1);
    -		so_data  (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
    -	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
    -
    -	if (cso->logicop_enable) {
    -		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
    -		so_data  (so, 1);
    -		so_data  (so, nvgl_logicop_func(cso->logicop_func));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
    -	so_data  (so, cso->dither ? 1 : 0);
    -
    -	so_ref(so, &bso->so);
    -	so_ref(NULL, &so);
    -	bso->pipe = *cso;
    -	return (void *)bso;
    -}
    -
    -static void
    -nv30_blend_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->blend = hwcso;
    -	nvfx->dirty |= NVFX_NEW_BLEND;
    -}
    -
    -static void
    -nv30_blend_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_blend_state *bso = hwcso;
    -
    -	so_ref(NULL, &bso->so);
    -	FREE(bso);
    -}
    -
    -
     static INLINE unsigned
     wrap_mode(unsigned wrap) {
     	unsigned ret;
    @@ -113,7 +45,7 @@ wrap_mode(unsigned wrap) {
     	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
     }
     
    -static void *
    +void *
     nv30_sampler_state_create(struct pipe_context *pipe,
     			  const struct pipe_sampler_state *cso)
     {
    @@ -245,506 +177,3 @@ nv30_sampler_state_create(struct pipe_context *pipe,
     	return (void *)ps;
     }
     
    -static void
    -nv30_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned unit;
    -
    -	for (unit = 0; unit < nr; unit++) {
    -		nvfx->tex_sampler[unit] = sampler[unit];
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	for (unit = nr; unit < nvfx->nr_samplers; unit++) {
    -		nvfx->tex_sampler[unit] = NULL;
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	nvfx->nr_samplers = nr;
    -	nvfx->dirty |= NVFX_NEW_SAMPLER;
    -}
    -
    -static void
    -nv30_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	FREE(hwcso);
    -}
    -
    -static void
    -nv30_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
    -			 struct pipe_texture **miptree)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned unit;
    -
    -	for (unit = 0; unit < nr; unit++) {
    -		pipe_texture_reference((struct pipe_texture **)
    -				       &nvfx->tex_miptree[unit], miptree[unit]);
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	for (unit = nr; unit < nvfx->nr_textures; unit++) {
    -		pipe_texture_reference((struct pipe_texture **)
    -				       &nvfx->tex_miptree[unit], NULL);
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	nvfx->nr_textures = nr;
    -	nvfx->dirty |= NVFX_NEW_SAMPLER;
    -}
    -
    -static void *
    -nv30_rasterizer_state_create(struct pipe_context *pipe,
    -			     const struct pipe_rasterizer_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
    -	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -
    -	/*XXX: ignored:
    -	 * 	light_twoside
    -	 * 	point_smooth -nohw
    -	 * 	multisample
    -	 */
    -
    -	so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
    -	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
    -				       NV34TCL_SHADE_MODEL_SMOOTH);
    -
    -	so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
    -	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
    -	so_data  (so, cso->line_smooth ? 1 : 0);
    -	so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
    -	so_data  (so, cso->line_stipple_enable ? 1 : 0);
    -	so_data  (so, (cso->line_stipple_pattern << 16) |
    -		       cso->line_stipple_factor);
    -
    -	so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
    -	so_data  (so, fui(cso->point_size));
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
    -	if (cso->front_winding == PIPE_WINDING_CCW) {
    -		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    -		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    -		switch (cso->cull_mode) {
    -		case PIPE_WINDING_CCW:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT);
    -			break;
    -		case PIPE_WINDING_CW:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		case PIPE_WINDING_BOTH:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    -			break;
    -		default:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		}
    -		so_data(so, NV34TCL_FRONT_FACE_CCW);
    -	} else {
    -		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    -		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    -		switch (cso->cull_mode) {
    -		case PIPE_WINDING_CCW:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		case PIPE_WINDING_CW:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT);
    -			break;
    -		case PIPE_WINDING_BOTH:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    -			break;
    -		default:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		}
    -		so_data(so, NV34TCL_FRONT_FACE_CW);
    -	}
    -	so_data(so, cso->poly_smooth ? 1 : 0);
    -	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if (cso->offset_cw || cso->offset_ccw) {
    -		so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
    -		so_data  (so, fui(cso->offset_scale));
    -		so_data  (so, fui(cso->offset_units * 2));
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
    -	if (cso->point_quad_rasterization) {
    -		unsigned psctl = (1 << 0), i;
    -
    -		for (i = 0; i < 8; i++) {
    -			if ((cso->sprite_coord_enable >> i) & 1)
    -				psctl |= (1 << (8 + i));
    -		}
    -
    -		so_data(so, psctl);
    -	} else {
    -		so_data(so, 0);
    -	}
    -
    -	so_ref(so, &rsso->so);
    -	so_ref(NULL, &so);
    -	rsso->pipe = *cso;
    -	return (void *)rsso;
    -}
    -
    -static void
    -nv30_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->rasterizer = hwcso;
    -	nvfx->dirty |= NVFX_NEW_RAST;
    -	/*nvfx->draw_dirty |= NVFX_NEW_RAST;*/
    -}
    -
    -static void
    -nv30_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_rasterizer_state *rsso = hwcso;
    -
    -	so_ref(NULL, &rsso->so);
    -	FREE(rsso);
    -}
    -
    -static void *
    -nv30_depth_stencil_alpha_state_create(struct pipe_context *pipe,
    -			const struct pipe_depth_stencil_alpha_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
    -	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -
    -	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
    -	so_data  (so, nvgl_comparison_op(cso->depth.func));
    -	so_data  (so, cso->depth.writemask ? 1 : 0);
    -	so_data  (so, cso->depth.enabled ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
    -	so_data  (so, cso->alpha.enabled ? 1 : 0);
    -	so_data  (so, nvgl_comparison_op(cso->alpha.func));
    -	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
    -
    -	if (cso->stencil[0].enabled) {
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
    -		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
    -		so_data  (so, cso->stencil[0].writemask);
    -		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
    -		so_data  (so, cso->stencil[0].valuemask);
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	if (cso->stencil[1].enabled) {
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
    -		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
    -		so_data  (so, cso->stencil[1].writemask);
    -		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
    -		so_data  (so, cso->stencil[1].valuemask);
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_ref(so, &zsaso->so);
    -	so_ref(NULL, &so);
    -	zsaso->pipe = *cso;
    -	return (void *)zsaso;
    -}
    -
    -static void
    -nv30_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->zsa = hwcso;
    -	nvfx->dirty |= NVFX_NEW_ZSA;
    -}
    -
    -static void
    -nv30_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_zsa_state *zsaso = hwcso;
    -
    -	so_ref(NULL, &zsaso->so);
    -	FREE(zsaso);
    -}
    -
    -static void *
    -nv30_vp_state_create(struct pipe_context *pipe,
    -		     const struct pipe_shader_state *cso)
    -{
    -	/*struct nvfx_context *nvfx = nvfx_context(pipe);*/
    -	struct nvfx_vertex_program *vp;
    -
    -	vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
    -	vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -	/*vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);*/
    -
    -	return (void *)vp;
    -}
    -
    -static void
    -nv30_vp_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->vertprog = hwcso;
    -	nvfx->dirty |= NVFX_NEW_VERTPROG;
    -	/*nvfx->draw_dirty |= NVFX_NEW_VERTPROG;*/
    -}
    -
    -static void
    -nv30_vp_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_vertex_program *vp = hwcso;
    -
    -	/*draw_delete_vertex_shader(nvfx->draw, vp->draw);*/
    -	nv30_vertprog_destroy(nvfx, vp);
    -	FREE((void*)vp->pipe.tokens);
    -	FREE(vp);
    -}
    -
    -static void *
    -nv30_fp_state_create(struct pipe_context *pipe,
    -		     const struct pipe_shader_state *cso)
    -{
    -	struct nvfx_fragment_program *fp;
    -
    -	fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
    -	fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -
    -	tgsi_scan_shader(fp->pipe.tokens, &fp->info);
    -
    -	return (void *)fp;
    -}
    -
    -static void
    -nv30_fp_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->fragprog = hwcso;
    -	nvfx->dirty |= NVFX_NEW_FRAGPROG;
    -}
    -
    -static void
    -nv30_fp_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_fragment_program *fp = hwcso;
    -
    -	nvfx_fragprog_destroy(nvfx, fp);
    -	FREE((void*)fp->pipe.tokens);
    -	FREE(fp);
    -}
    -
    -static void
    -nv30_set_blend_color(struct pipe_context *pipe,
    -		     const struct pipe_blend_color *bcol)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->blend_colour = *bcol;
    -	nvfx->dirty |= NVFX_NEW_BCOL;
    -}
    -
    -static void
    -nv30_set_stencil_ref(struct pipe_context *pipe,
    -		     const struct pipe_stencil_ref *sr)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->stencil_ref = *sr;
    -	nvfx->dirty |= NVFX_NEW_SR;
    -}
    -
    -static void
    -nv30_set_clip_state(struct pipe_context *pipe,
    -		    const struct pipe_clip_state *clip)
    -{
    -}
    -
    -static void
    -nv30_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
    -			 struct pipe_buffer *buf )
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->constbuf[shader] = buf;
    -	nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
    -
    -	if (shader == PIPE_SHADER_VERTEX) {
    -		nvfx->dirty |= NVFX_NEW_VERTPROG;
    -	} else
    -	if (shader == PIPE_SHADER_FRAGMENT) {
    -		nvfx->dirty |= NVFX_NEW_FRAGPROG;
    -	}
    -}
    -
    -static void
    -nv30_set_framebuffer_state(struct pipe_context *pipe,
    -			   const struct pipe_framebuffer_state *fb)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->framebuffer = *fb;
    -	nvfx->dirty |= NVFX_NEW_FB;
    -}
    -
    -static void
    -nv30_set_polygon_stipple(struct pipe_context *pipe,
    -			 const struct pipe_poly_stipple *stipple)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
    -	nvfx->dirty |= NVFX_NEW_STIPPLE;
    -}
    -
    -static void
    -nv30_set_scissor_state(struct pipe_context *pipe,
    -		       const struct pipe_scissor_state *s)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->scissor = *s;
    -	nvfx->dirty |= NVFX_NEW_SCISSOR;
    -}
    -
    -static void
    -nv30_set_viewport_state(struct pipe_context *pipe,
    -			const struct pipe_viewport_state *vpt)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->viewport = *vpt;
    -	nvfx->dirty |= NVFX_NEW_VIEWPORT;
    -	/*nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;*/
    -}
    -
    -static void
    -nv30_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
    -			const struct pipe_vertex_buffer *vb)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
    -	nvfx->vtxbuf_nr = count;
    -
    -	nvfx->dirty |= NVFX_NEW_ARRAYS;
    -	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
    -}
    -
    -static void *
    -nv30_vtxelts_state_create(struct pipe_context *pipe,
    -			  unsigned num_elements,
    -			  const struct pipe_vertex_element *elements)
    -{
    -	struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
    -
    -	assert(num_elements < 16); /* not doing fallbacks yet */
    -	cso->num_elements = num_elements;
    -	memcpy(cso->pipe, elements, num_elements * sizeof(*elements));
    -
    -/*	nv30_vtxelt_construct(cso);*/
    -
    -	return (void *)cso;
    -}
    -
    -static void
    -nv30_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	FREE(hwcso);
    -}
    -
    -static void
    -nv30_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->vtxelt = hwcso;
    -	nvfx->dirty |= NVFX_NEW_ARRAYS;
    -	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
    -}
    -
    -void
    -nv30_init_state_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.create_blend_state = nv30_blend_state_create;
    -	nvfx->pipe.bind_blend_state = nv30_blend_state_bind;
    -	nvfx->pipe.delete_blend_state = nv30_blend_state_delete;
    -
    -	nvfx->pipe.create_sampler_state = nv30_sampler_state_create;
    -	nvfx->pipe.bind_fragment_sampler_states = nv30_sampler_state_bind;
    -	nvfx->pipe.delete_sampler_state = nv30_sampler_state_delete;
    -	nvfx->pipe.set_fragment_sampler_textures = nv30_set_sampler_texture;
    -
    -	nvfx->pipe.create_rasterizer_state = nv30_rasterizer_state_create;
    -	nvfx->pipe.bind_rasterizer_state = nv30_rasterizer_state_bind;
    -	nvfx->pipe.delete_rasterizer_state = nv30_rasterizer_state_delete;
    -
    -	nvfx->pipe.create_depth_stencil_alpha_state =
    -		nv30_depth_stencil_alpha_state_create;
    -	nvfx->pipe.bind_depth_stencil_alpha_state =
    -		nv30_depth_stencil_alpha_state_bind;
    -	nvfx->pipe.delete_depth_stencil_alpha_state =
    -		nv30_depth_stencil_alpha_state_delete;
    -
    -	nvfx->pipe.create_vs_state = nv30_vp_state_create;
    -	nvfx->pipe.bind_vs_state = nv30_vp_state_bind;
    -	nvfx->pipe.delete_vs_state = nv30_vp_state_delete;
    -
    -	nvfx->pipe.create_fs_state = nv30_fp_state_create;
    -	nvfx->pipe.bind_fs_state = nv30_fp_state_bind;
    -	nvfx->pipe.delete_fs_state = nv30_fp_state_delete;
    -
    -	nvfx->pipe.set_blend_color = nv30_set_blend_color;
    -	nvfx->pipe.set_stencil_ref = nv30_set_stencil_ref;
    -	nvfx->pipe.set_clip_state = nv30_set_clip_state;
    -	nvfx->pipe.set_constant_buffer = nv30_set_constant_buffer;
    -	nvfx->pipe.set_framebuffer_state = nv30_set_framebuffer_state;
    -	nvfx->pipe.set_polygon_stipple = nv30_set_polygon_stipple;
    -	nvfx->pipe.set_scissor_state = nv30_set_scissor_state;
    -	nvfx->pipe.set_viewport_state = nv30_set_viewport_state;
    -
    -	nvfx->pipe.create_vertex_elements_state = nv30_vtxelts_state_create;
    -	nvfx->pipe.delete_vertex_elements_state = nv30_vtxelts_state_delete;
    -	nvfx->pipe.bind_vertex_elements_state = nv30_vtxelts_state_bind;
    -
    -	nvfx->pipe.set_vertex_buffers = nv30_set_vertex_buffers;
    -}
    -
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 85c1355b4f..13bd50dd1d 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -75,7 +75,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
     
     	nvfx_init_query_functions(nvfx);
     	nvfx_init_surface_functions(nvfx);
    -	nv40_init_state_functions(nvfx);
    +	nvfx_init_state_functions(nvfx);
     	nvfx_init_transfer_functions(nvfx);
     
     	/* Create, configure, and install fallback swtnl path */
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index cebf21d00c..5ea2229fac 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -3,12 +3,6 @@
     
     #include "nvfx_context.h"
     
    -extern void nv40_init_state_functions(struct nvfx_context *nvfx);
    -
    -/* nv40_vertprog.c */
    -extern void nv40_vertprog_destroy(struct nvfx_context *,
    -				  struct nvfx_vertex_program *);
    -
     /* nv40_fragtex.c */
     extern void nv40_fragtex_bind(struct nvfx_context *);
     
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    index 1f4b9777d4..4d4098bc42 100644
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ b/src/gallium/drivers/nv40/nv40_state.c
    @@ -9,73 +9,6 @@
     #include "nv40_context.h"
     #include "nvfx_state.h"
     
    -static void *
    -nv40_blend_state_create(struct pipe_context *pipe,
    -			const struct pipe_blend_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -	struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
    -	struct nouveau_stateobj *so = so_new(5, 8, 0);
    -
    -	if (cso->rt[0].blend_enable) {
    -		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
    -		so_data  (so, 1);
    -		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
    -			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
    -		so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
    -			      nvgl_blend_func(cso->rt[0].rgb_dst_factor));
    -		so_method(so, eng3d, NV40TCL_BLEND_EQUATION, 1);
    -		so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
    -			      nvgl_blend_eqn(cso->rt[0].rgb_func));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
    -	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
    -		       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
    -
    -	if (cso->logicop_enable) {
    -		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
    -		so_data  (so, 1);
    -		so_data  (so, nvgl_logicop_func(cso->logicop_func));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
    -	so_data  (so, cso->dither ? 1 : 0);
    -
    -	so_ref(so, &bso->so);
    -	so_ref(NULL, &so);
    -	bso->pipe = *cso;
    -	return (void *)bso;
    -}
    -
    -static void
    -nv40_blend_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->blend = hwcso;
    -	nvfx->dirty |= NVFX_NEW_BLEND;
    -}
    -
    -static void
    -nv40_blend_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_blend_state *bso = hwcso;
    -
    -	so_ref(NULL, &bso->so);
    -	FREE(bso);
    -}
    -
    -
     static INLINE unsigned
     wrap_mode(unsigned wrap) {
     	unsigned ret;
    @@ -114,7 +47,7 @@ wrap_mode(unsigned wrap) {
     	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
     }
     
    -static void *
    +void *
     nv40_sampler_state_create(struct pipe_context *pipe,
     			  const struct pipe_sampler_state *cso)
     {
    @@ -255,511 +188,3 @@ nv40_sampler_state_create(struct pipe_context *pipe,
     	return (void *)ps;
     }
     
    -static void
    -nv40_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned unit;
    -
    -	for (unit = 0; unit < nr; unit++) {
    -		nvfx->tex_sampler[unit] = sampler[unit];
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	for (unit = nr; unit < nvfx->nr_samplers; unit++) {
    -		nvfx->tex_sampler[unit] = NULL;
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	nvfx->nr_samplers = nr;
    -	nvfx->dirty |= NVFX_NEW_SAMPLER;
    -}
    -
    -static void
    -nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	FREE(hwcso);
    -}
    -
    -static void
    -nv40_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
    -			 struct pipe_texture **miptree)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned unit;
    -
    -	for (unit = 0; unit < nr; unit++) {
    -		pipe_texture_reference((struct pipe_texture **)
    -				       &nvfx->tex_miptree[unit], miptree[unit]);
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	for (unit = nr; unit < nvfx->nr_textures; unit++) {
    -		pipe_texture_reference((struct pipe_texture **)
    -				       &nvfx->tex_miptree[unit], NULL);
    -		nvfx->dirty_samplers |= (1 << unit);
    -	}
    -
    -	nvfx->nr_textures = nr;
    -	nvfx->dirty |= NVFX_NEW_SAMPLER;
    -}
    -
    -static void *
    -nv40_rasterizer_state_create(struct pipe_context *pipe,
    -			     const struct pipe_rasterizer_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
    -	struct nouveau_stateobj *so = so_new(9, 19, 0);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -
    -	/*XXX: ignored:
    -	 * 	light_twoside
    -	 * 	point_smooth -nohw
    -	 * 	multisample
    -	 */
    -
    -	so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
    -	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
    -				       NV34TCL_SHADE_MODEL_SMOOTH);
    -
    -	so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
    -	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
    -	so_data  (so, cso->line_smooth ? 1 : 0);
    -	so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
    -	so_data  (so, cso->line_stipple_enable ? 1 : 0);
    -	so_data  (so, (cso->line_stipple_pattern << 16) |
    -		       cso->line_stipple_factor);
    -
    -	so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
    -	so_data  (so, fui(cso->point_size));
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
    -	if (cso->front_winding == PIPE_WINDING_CCW) {
    -		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    -		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    -		switch (cso->cull_mode) {
    -		case PIPE_WINDING_CCW:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT);
    -			break;
    -		case PIPE_WINDING_CW:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		case PIPE_WINDING_BOTH:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    -			break;
    -		default:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		}
    -		so_data(so, NV34TCL_FRONT_FACE_CCW);
    -	} else {
    -		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    -		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    -		switch (cso->cull_mode) {
    -		case PIPE_WINDING_CCW:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		case PIPE_WINDING_CW:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT);
    -			break;
    -		case PIPE_WINDING_BOTH:
    -			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    -			break;
    -		default:
    -			so_data(so, NV34TCL_CULL_FACE_BACK);
    -			break;
    -		}
    -		so_data(so, NV34TCL_FRONT_FACE_CW);
    -	}
    -	so_data(so, cso->poly_smooth ? 1 : 0);
    -	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    -	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
    -	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
    -		so_data(so, 1);
    -	else
    -		so_data(so, 0);
    -	if (cso->offset_cw || cso->offset_ccw) {
    -		so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
    -		so_data  (so, fui(cso->offset_scale));
    -		so_data  (so, fui(cso->offset_units * 2));
    -	}
    -
    -	so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
    -	if (cso->point_quad_rasterization) {
    -		unsigned psctl = (1 << 0), i;
    -
    -		for (i = 0; i < 8; i++) {
    -			if ((cso->sprite_coord_enable >> i) & 1)
    -				psctl |= (1 << (8 + i));
    -		}
    -
    -		so_data(so, psctl);
    -	} else {
    -		so_data(so, 0);
    -	}
    -
    -	so_ref(so, &rsso->so);
    -	so_ref(NULL, &so);
    -	rsso->pipe = *cso;
    -	return (void *)rsso;
    -}
    -
    -static void
    -nv40_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->rasterizer = hwcso;
    -	nvfx->dirty |= NVFX_NEW_RAST;
    -	nvfx->draw_dirty |= NVFX_NEW_RAST;
    -}
    -
    -static void
    -nv40_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_rasterizer_state *rsso = hwcso;
    -
    -	so_ref(NULL, &rsso->so);
    -	FREE(rsso);
    -}
    -
    -static void *
    -nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
    -			const struct pipe_depth_stencil_alpha_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
    -	struct nouveau_stateobj *so = so_new(6, 20, 0);
    -	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    -
    -	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
    -	so_data  (so, nvgl_comparison_op(cso->depth.func));
    -	so_data  (so, cso->depth.writemask ? 1 : 0);
    -	so_data  (so, cso->depth.enabled ? 1 : 0);
    -
    -	so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
    -	so_data  (so, cso->alpha.enabled ? 1 : 0);
    -	so_data  (so, nvgl_comparison_op(cso->alpha.func));
    -	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
    -
    -	if (cso->stencil[0].enabled) {
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
    -		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
    -		so_data  (so, cso->stencil[0].writemask);
    -		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
    -		so_data  (so, cso->stencil[0].valuemask);
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	if (cso->stencil[1].enabled) {
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
    -		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
    -		so_data  (so, cso->stencil[1].writemask);
    -		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
    -		so_data  (so, cso->stencil[1].valuemask);
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
    -		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
    -	} else {
    -		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_ref(so, &zsaso->so);
    -	so_ref(NULL, &so);
    -	zsaso->pipe = *cso;
    -	return (void *)zsaso;
    -}
    -
    -static void
    -nv40_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->zsa = hwcso;
    -	nvfx->dirty |= NVFX_NEW_ZSA;
    -}
    -
    -static void
    -nv40_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_zsa_state *zsaso = hwcso;
    -
    -	so_ref(NULL, &zsaso->so);
    -	FREE(zsaso);
    -}
    -
    -static void *
    -nv40_vp_state_create(struct pipe_context *pipe,
    -		     const struct pipe_shader_state *cso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_vertex_program *vp;
    -
    -	vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
    -	vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -	vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);
    -
    -	return (void *)vp;
    -}
    -
    -static void
    -nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->vertprog = hwcso;
    -	nvfx->dirty |= NVFX_NEW_VERTPROG;
    -	nvfx->draw_dirty |= NVFX_NEW_VERTPROG;
    -}
    -
    -static void
    -nv40_vp_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_vertex_program *vp = hwcso;
    -
    -	draw_delete_vertex_shader(nvfx->draw, vp->draw);
    -	nv40_vertprog_destroy(nvfx, vp);
    -	FREE((void*)vp->pipe.tokens);
    -	FREE(vp);
    -}
    -
    -static void *
    -nv40_fp_state_create(struct pipe_context *pipe,
    -		     const struct pipe_shader_state *cso)
    -{
    -	struct nvfx_fragment_program *fp;
    -
    -	fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
    -	fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    -
    -	tgsi_scan_shader(fp->pipe.tokens, &fp->info);
    -
    -	return (void *)fp;
    -}
    -
    -static void
    -nv40_fp_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->fragprog = hwcso;
    -	nvfx->dirty |= NVFX_NEW_FRAGPROG;
    -}
    -
    -static void
    -nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_fragment_program *fp = hwcso;
    -
    -	nvfx_fragprog_destroy(nvfx, fp);
    -	FREE((void*)fp->pipe.tokens);
    -	FREE(fp);
    -}
    -
    -static void
    -nv40_set_blend_color(struct pipe_context *pipe,
    -		     const struct pipe_blend_color *bcol)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->blend_colour = *bcol;
    -	nvfx->dirty |= NVFX_NEW_BCOL;
    -}
    -
    - static void
    -nv40_set_stencil_ref(struct pipe_context *pipe,
    -		     const struct pipe_stencil_ref *sr)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->stencil_ref = *sr;
    -	nvfx->dirty |= NVFX_NEW_SR;
    -}
    -
    -static void
    -nv40_set_clip_state(struct pipe_context *pipe,
    -		    const struct pipe_clip_state *clip)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->clip = *clip;
    -	nvfx->dirty |= NVFX_NEW_UCP;
    -	nvfx->draw_dirty |= NVFX_NEW_UCP;
    -}
    -
    -static void
    -nv40_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
    -			 struct pipe_buffer *buf )
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->constbuf[shader] = buf;
    -	nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
    -
    -	if (shader == PIPE_SHADER_VERTEX) {
    -		nvfx->dirty |= NVFX_NEW_VERTPROG;
    -	} else
    -	if (shader == PIPE_SHADER_FRAGMENT) {
    -		nvfx->dirty |= NVFX_NEW_FRAGPROG;
    -	}
    -}
    -
    -static void
    -nv40_set_framebuffer_state(struct pipe_context *pipe,
    -			   const struct pipe_framebuffer_state *fb)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->framebuffer = *fb;
    -	nvfx->dirty |= NVFX_NEW_FB;
    -}
    -
    -static void
    -nv40_set_polygon_stipple(struct pipe_context *pipe,
    -			 const struct pipe_poly_stipple *stipple)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
    -	nvfx->dirty |= NVFX_NEW_STIPPLE;
    -}
    -
    -static void
    -nv40_set_scissor_state(struct pipe_context *pipe,
    -		       const struct pipe_scissor_state *s)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->scissor = *s;
    -	nvfx->dirty |= NVFX_NEW_SCISSOR;
    -}
    -
    -static void
    -nv40_set_viewport_state(struct pipe_context *pipe,
    -			const struct pipe_viewport_state *vpt)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->viewport = *vpt;
    -	nvfx->dirty |= NVFX_NEW_VIEWPORT;
    -	nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;
    -}
    -
    -static void
    -nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
    -			const struct pipe_vertex_buffer *vb)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
    -	nvfx->vtxbuf_nr = count;
    -
    -	nvfx->dirty |= NVFX_NEW_ARRAYS;
    -	nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
    -}
    -
    -static void *
    -nv40_vtxelts_state_create(struct pipe_context *pipe,
    -			  unsigned num_elements,
    -			  const struct pipe_vertex_element *elements)
    -{
    -	struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
    -
    -	assert(num_elements < 16); /* not doing fallbacks yet */
    -	cso->num_elements = num_elements;
    -	memcpy(cso->pipe, elements, num_elements * sizeof(*elements));
    -
    -/*	nv40_vtxelt_construct(cso);*/
    -
    -	return (void *)cso;
    -}
    -
    -static void
    -nv40_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
    -{
    -	FREE(hwcso);
    -}
    -
    -static void
    -nv40_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -
    -	nvfx->vtxelt = hwcso;
    -	nvfx->dirty |= NVFX_NEW_ARRAYS;
    -	nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
    -}
    -
    -void
    -nv40_init_state_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.create_blend_state = nv40_blend_state_create;
    -	nvfx->pipe.bind_blend_state = nv40_blend_state_bind;
    -	nvfx->pipe.delete_blend_state = nv40_blend_state_delete;
    -
    -	nvfx->pipe.create_sampler_state = nv40_sampler_state_create;
    -	nvfx->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
    -	nvfx->pipe.delete_sampler_state = nv40_sampler_state_delete;
    -	nvfx->pipe.set_fragment_sampler_textures = nv40_set_sampler_texture;
    -
    -	nvfx->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
    -	nvfx->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
    -	nvfx->pipe.delete_rasterizer_state = nv40_rasterizer_state_delete;
    -
    -	nvfx->pipe.create_depth_stencil_alpha_state =
    -		nv40_depth_stencil_alpha_state_create;
    -	nvfx->pipe.bind_depth_stencil_alpha_state =
    -		nv40_depth_stencil_alpha_state_bind;
    -	nvfx->pipe.delete_depth_stencil_alpha_state =
    -		nv40_depth_stencil_alpha_state_delete;
    -
    -	nvfx->pipe.create_vs_state = nv40_vp_state_create;
    -	nvfx->pipe.bind_vs_state = nv40_vp_state_bind;
    -	nvfx->pipe.delete_vs_state = nv40_vp_state_delete;
    -
    -	nvfx->pipe.create_fs_state = nv40_fp_state_create;
    -	nvfx->pipe.bind_fs_state = nv40_fp_state_bind;
    -	nvfx->pipe.delete_fs_state = nv40_fp_state_delete;
    -
    -	nvfx->pipe.set_blend_color = nv40_set_blend_color;
    -	nvfx->pipe.set_stencil_ref = nv40_set_stencil_ref;
    -	nvfx->pipe.set_clip_state = nv40_set_clip_state;
    -	nvfx->pipe.set_constant_buffer = nv40_set_constant_buffer;
    -	nvfx->pipe.set_framebuffer_state = nv40_set_framebuffer_state;
    -	nvfx->pipe.set_polygon_stipple = nv40_set_polygon_stipple;
    -	nvfx->pipe.set_scissor_state = nv40_set_scissor_state;
    -	nvfx->pipe.set_viewport_state = nv40_set_viewport_state;
    -
    -	nvfx->pipe.create_vertex_elements_state = nv40_vtxelts_state_create;
    -	nvfx->pipe.delete_vertex_elements_state = nv40_vtxelts_state_delete;
    -	nvfx->pipe.bind_vertex_elements_state = nv40_vtxelts_state_bind;
    -
    -	nvfx->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
    -}
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index d1304ccea0..6c4ee17493 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,7 @@ C_SOURCES = \
     	nvfx_fragprog.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
    +	nvfx_state.c \
     	nvfx_state_blend.c \
             nvfx_state_emit.c \
     	nvfx_state_fb.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 8f121fe3af..ab1a1fbbe9 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -212,6 +212,9 @@ extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe,
     extern void nvfx_fragprog_destroy(struct nvfx_context *,
     				    struct nvfx_fragment_program *);
     
    +/* nvfx_state.c */
    +extern void nvfx_init_state_functions(struct nvfx_context *nvfx);
    +
     /* nvfx_state_emit.c */
     extern void nvfx_state_flush_notify(struct nouveau_channel *chan);
     extern boolean nvfx_state_validate(struct nvfx_context *nvfx);
    @@ -230,4 +233,9 @@ extern void nvfx_draw_elements(struct pipe_context *pipe,
     				  unsigned mode, unsigned start,
     				  unsigned count);
     
    +/* nvfx_vertprog.c */
    +extern void nv30_vertprog_destroy(struct nvfx_context *,
    +				  struct nvfx_vertex_program *);
    +extern void nv40_vertprog_destroy(struct nvfx_context *,
    +				  struct nvfx_vertex_program *);
     #endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c
    new file mode 100644
    index 0000000000..76780dc4f5
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_state.c
    @@ -0,0 +1,605 @@
    +#include "pipe/p_state.h"
    +#include "pipe/p_defines.h"
    +#include "util/u_inlines.h"
    +
    +#include "draw/draw_context.h"
    +
    +#include "tgsi/tgsi_parse.h"
    +
    +#include "nvfx_context.h"
    +#include "nvfx_state.h"
    +
    +static void *
    +nvfx_blend_state_create(struct pipe_context *pipe,
    +			const struct pipe_blend_state *cso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +	struct nvfx_blend_state *bso = CALLOC(1, sizeof(*bso));
    +	struct nouveau_stateobj *so = so_new(5, 8, 0);
    +
    +	if (cso->rt[0].blend_enable) {
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 3);
    +		so_data  (so, 1);
    +		so_data  (so, (nvgl_blend_func(cso->rt[0].alpha_src_factor) << 16) |
    +			       nvgl_blend_func(cso->rt[0].rgb_src_factor));
    +		so_data  (so, nvgl_blend_func(cso->rt[0].alpha_dst_factor) << 16 |
    +			      nvgl_blend_func(cso->rt[0].rgb_dst_factor));
    +		if(nvfx->screen->base.device->chipset < 0x40) {
    +			so_method(so, eng3d, NV34TCL_BLEND_EQUATION, 1);
    +			so_data  (so, nvgl_blend_eqn(cso->rt[0].rgb_func));
    +		} else {
    +			so_method(so, eng3d, NV40TCL_BLEND_EQUATION, 1);
    +			so_data  (so, nvgl_blend_eqn(cso->rt[0].alpha_func) << 16 |
    +			      nvgl_blend_eqn(cso->rt[0].rgb_func));
    +		}
    +	} else {
    +		so_method(so, eng3d, NV34TCL_BLEND_FUNC_ENABLE, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_method(so, eng3d, NV34TCL_COLOR_MASK, 1);
    +	so_data  (so, (((cso->rt[0].colormask & PIPE_MASK_A) ? (0x01 << 24) : 0) |
    +	       ((cso->rt[0].colormask & PIPE_MASK_R) ? (0x01 << 16) : 0) |
    +	       ((cso->rt[0].colormask & PIPE_MASK_G) ? (0x01 <<  8) : 0) |
    +	       ((cso->rt[0].colormask & PIPE_MASK_B) ? (0x01 <<  0) : 0)));
    +
    +	/* TODO: add NV40 MRT color mask */
    +
    +	if (cso->logicop_enable) {
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 2);
    +		so_data  (so, 1);
    +		so_data  (so, nvgl_logicop_func(cso->logicop_func));
    +	} else {
    +		so_method(so, eng3d, NV34TCL_COLOR_LOGIC_OP_ENABLE, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_method(so, eng3d, NV34TCL_DITHER_ENABLE, 1);
    +	so_data  (so, cso->dither ? 1 : 0);
    +
    +	so_ref(so, &bso->so);
    +	so_ref(NULL, &so);
    +	bso->pipe = *cso;
    +	return (void *)bso;
    +}
    +
    +static void
    +nvfx_blend_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->blend = hwcso;
    +	nvfx->dirty |= NVFX_NEW_BLEND;
    +}
    +
    +static void
    +nvfx_blend_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_blend_state *bso = hwcso;
    +
    +	so_ref(NULL, &bso->so);
    +	FREE(bso);
    +}
    +
    +static void
    +nv40_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	unsigned unit;
    +
    +	for (unit = 0; unit < nr; unit++) {
    +		nvfx->tex_sampler[unit] = sampler[unit];
    +		nvfx->dirty_samplers |= (1 << unit);
    +	}
    +
    +	for (unit = nr; unit < nvfx->nr_samplers; unit++) {
    +		nvfx->tex_sampler[unit] = NULL;
    +		nvfx->dirty_samplers |= (1 << unit);
    +	}
    +
    +	nvfx->nr_samplers = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
    +}
    +
    +static void
    +nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	FREE(hwcso);
    +}
    +
    +static void
    +nvfx_set_sampler_texture(struct pipe_context *pipe, unsigned nr,
    +			 struct pipe_texture **miptree)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	unsigned unit;
    +
    +	for (unit = 0; unit < nr; unit++) {
    +		pipe_texture_reference((struct pipe_texture **)
    +				       &nvfx->tex_miptree[unit], miptree[unit]);
    +		nvfx->dirty_samplers |= (1 << unit);
    +	}
    +
    +	for (unit = nr; unit < nvfx->nr_textures; unit++) {
    +		pipe_texture_reference((struct pipe_texture **)
    +				       &nvfx->tex_miptree[unit], NULL);
    +		nvfx->dirty_samplers |= (1 << unit);
    +	}
    +
    +	nvfx->nr_textures = nr;
    +	nvfx->dirty |= NVFX_NEW_SAMPLER;
    +}
    +
    +static void *
    +nvfx_rasterizer_state_create(struct pipe_context *pipe,
    +			     const struct pipe_rasterizer_state *cso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_rasterizer_state *rsso = CALLOC(1, sizeof(*rsso));
    +	struct nouveau_stateobj *so = so_new(9, 19, 0);
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +
    +	/*XXX: ignored:
    +	 * 	light_twoside
    +	 * 	point_smooth -nohw
    +	 * 	multisample
    +	 */
    +
    +	so_method(so, eng3d, NV34TCL_SHADE_MODEL, 1);
    +	so_data  (so, cso->flatshade ? NV34TCL_SHADE_MODEL_FLAT :
    +				       NV34TCL_SHADE_MODEL_SMOOTH);
    +
    +	so_method(so, eng3d, NV34TCL_LINE_WIDTH, 2);
    +	so_data  (so, (unsigned char)(cso->line_width * 8.0) & 0xff);
    +	so_data  (so, cso->line_smooth ? 1 : 0);
    +	so_method(so, eng3d, NV34TCL_LINE_STIPPLE_ENABLE, 2);
    +	so_data  (so, cso->line_stipple_enable ? 1 : 0);
    +	so_data  (so, (cso->line_stipple_pattern << 16) |
    +		       cso->line_stipple_factor);
    +
    +	so_method(so, eng3d, NV34TCL_POINT_SIZE, 1);
    +	so_data  (so, fui(cso->point_size));
    +
    +	so_method(so, eng3d, NV34TCL_POLYGON_MODE_FRONT, 6);
    +	if (cso->front_winding == PIPE_WINDING_CCW) {
    +		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    +		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    +		switch (cso->cull_mode) {
    +		case PIPE_WINDING_CCW:
    +			so_data(so, NV34TCL_CULL_FACE_FRONT);
    +			break;
    +		case PIPE_WINDING_CW:
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
    +			break;
    +		case PIPE_WINDING_BOTH:
    +			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    +			break;
    +		default:
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
    +			break;
    +		}
    +		so_data(so, NV34TCL_FRONT_FACE_CCW);
    +	} else {
    +		so_data(so, nvgl_polygon_mode(cso->fill_cw));
    +		so_data(so, nvgl_polygon_mode(cso->fill_ccw));
    +		switch (cso->cull_mode) {
    +		case PIPE_WINDING_CCW:
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
    +			break;
    +		case PIPE_WINDING_CW:
    +			so_data(so, NV34TCL_CULL_FACE_FRONT);
    +			break;
    +		case PIPE_WINDING_BOTH:
    +			so_data(so, NV34TCL_CULL_FACE_FRONT_AND_BACK);
    +			break;
    +		default:
    +			so_data(so, NV34TCL_CULL_FACE_BACK);
    +			break;
    +		}
    +		so_data(so, NV34TCL_FRONT_FACE_CW);
    +	}
    +	so_data(so, cso->poly_smooth ? 1 : 0);
    +	so_data(so, (cso->cull_mode != PIPE_WINDING_NONE) ? 1 : 0);
    +
    +	so_method(so, eng3d, NV34TCL_POLYGON_STIPPLE_ENABLE, 1);
    +	so_data  (so, cso->poly_stipple_enable ? 1 : 0);
    +
    +	so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_POINT_ENABLE, 3);
    +	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_POINT) ||
    +	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_POINT))
    +		so_data(so, 1);
    +	else
    +		so_data(so, 0);
    +	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_LINE) ||
    +	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_LINE))
    +		so_data(so, 1);
    +	else
    +		so_data(so, 0);
    +	if ((cso->offset_cw && cso->fill_cw == PIPE_POLYGON_MODE_FILL) ||
    +	    (cso->offset_ccw && cso->fill_ccw == PIPE_POLYGON_MODE_FILL))
    +		so_data(so, 1);
    +	else
    +		so_data(so, 0);
    +	if (cso->offset_cw || cso->offset_ccw) {
    +		so_method(so, eng3d, NV34TCL_POLYGON_OFFSET_FACTOR, 2);
    +		so_data  (so, fui(cso->offset_scale));
    +		so_data  (so, fui(cso->offset_units * 2));
    +	}
    +
    +	so_method(so, eng3d, NV34TCL_POINT_SPRITE, 1);
    +	if (cso->point_quad_rasterization) {
    +		unsigned psctl = (1 << 0), i;
    +
    +		for (i = 0; i < 8; i++) {
    +			if ((cso->sprite_coord_enable >> i) & 1)
    +				psctl |= (1 << (8 + i));
    +		}
    +
    +		so_data(so, psctl);
    +	} else {
    +		so_data(so, 0);
    +	}
    +
    +	so_ref(so, &rsso->so);
    +	so_ref(NULL, &so);
    +	rsso->pipe = *cso;
    +	return (void *)rsso;
    +}
    +
    +static void
    +nvfx_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->rasterizer = hwcso;
    +	nvfx->dirty |= NVFX_NEW_RAST;
    +	nvfx->draw_dirty |= NVFX_NEW_RAST;
    +}
    +
    +static void
    +nvfx_rasterizer_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_rasterizer_state *rsso = hwcso;
    +
    +	so_ref(NULL, &rsso->so);
    +	FREE(rsso);
    +}
    +
    +static void *
    +nvfx_depth_stencil_alpha_state_create(struct pipe_context *pipe,
    +			const struct pipe_depth_stencil_alpha_state *cso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_zsa_state *zsaso = CALLOC(1, sizeof(*zsaso));
    +	struct nouveau_stateobj *so = so_new(6, 20, 0);
    +	struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
    +
    +	so_method(so, eng3d, NV34TCL_DEPTH_FUNC, 3);
    +	so_data  (so, nvgl_comparison_op(cso->depth.func));
    +	so_data  (so, cso->depth.writemask ? 1 : 0);
    +	so_data  (so, cso->depth.enabled ? 1 : 0);
    +
    +	so_method(so, eng3d, NV34TCL_ALPHA_FUNC_ENABLE, 3);
    +	so_data  (so, cso->alpha.enabled ? 1 : 0);
    +	so_data  (so, nvgl_comparison_op(cso->alpha.func));
    +	so_data  (so, float_to_ubyte(cso->alpha.ref_value));
    +
    +	if (cso->stencil[0].enabled) {
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 3);
    +		so_data  (so, cso->stencil[0].enabled ? 1 : 0);
    +		so_data  (so, cso->stencil[0].writemask);
    +		so_data  (so, nvgl_comparison_op(cso->stencil[0].func));
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_FUNC_MASK, 4);
    +		so_data  (so, cso->stencil[0].valuemask);
    +		so_data  (so, nvgl_stencil_op(cso->stencil[0].fail_op));
    +		so_data  (so, nvgl_stencil_op(cso->stencil[0].zfail_op));
    +		so_data  (so, nvgl_stencil_op(cso->stencil[0].zpass_op));
    +	} else {
    +		so_method(so, eng3d, NV34TCL_STENCIL_FRONT_ENABLE, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	if (cso->stencil[1].enabled) {
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 3);
    +		so_data  (so, cso->stencil[1].enabled ? 1 : 0);
    +		so_data  (so, cso->stencil[1].writemask);
    +		so_data  (so, nvgl_comparison_op(cso->stencil[1].func));
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_FUNC_MASK, 4);
    +		so_data  (so, cso->stencil[1].valuemask);
    +		so_data  (so, nvgl_stencil_op(cso->stencil[1].fail_op));
    +		so_data  (so, nvgl_stencil_op(cso->stencil[1].zfail_op));
    +		so_data  (so, nvgl_stencil_op(cso->stencil[1].zpass_op));
    +	} else {
    +		so_method(so, eng3d, NV34TCL_STENCIL_BACK_ENABLE, 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_ref(so, &zsaso->so);
    +	so_ref(NULL, &so);
    +	zsaso->pipe = *cso;
    +	return (void *)zsaso;
    +}
    +
    +static void
    +nvfx_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->zsa = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ZSA;
    +}
    +
    +static void
    +nvfx_depth_stencil_alpha_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_zsa_state *zsaso = hwcso;
    +
    +	so_ref(NULL, &zsaso->so);
    +	FREE(zsaso);
    +}
    +
    +static void *
    +nvfx_vp_state_create(struct pipe_context *pipe,
    +		     const struct pipe_shader_state *cso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_vertex_program *vp;
    +
    +	vp = CALLOC(1, sizeof(struct nvfx_vertex_program));
    +	vp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    +	vp->draw = draw_create_vertex_shader(nvfx->draw, &vp->pipe);
    +
    +	return (void *)vp;
    +}
    +
    +static void
    +nvfx_vp_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->vertprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_VERTPROG;
    +	nvfx->draw_dirty |= NVFX_NEW_VERTPROG;
    +}
    +
    +static void
    +nvfx_vp_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_vertex_program *vp = hwcso;
    +
    +	draw_delete_vertex_shader(nvfx->draw, vp->draw);
    +	if(!nvfx->is_nv4x)
    +		nv30_vertprog_destroy(nvfx, vp);
    +	else
    +		nv40_vertprog_destroy(nvfx, vp);
    +	FREE((void*)vp->pipe.tokens);
    +	FREE(vp);
    +}
    +
    +static void *
    +nvfx_fp_state_create(struct pipe_context *pipe,
    +		     const struct pipe_shader_state *cso)
    +{
    +	struct nvfx_fragment_program *fp;
    +
    +	fp = CALLOC(1, sizeof(struct nvfx_fragment_program));
    +	fp->pipe.tokens = tgsi_dup_tokens(cso->tokens);
    +
    +	tgsi_scan_shader(fp->pipe.tokens, &fp->info);
    +
    +	return (void *)fp;
    +}
    +
    +static void
    +nvfx_fp_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->fragprog = hwcso;
    +	nvfx->dirty |= NVFX_NEW_FRAGPROG;
    +}
    +
    +static void
    +nvfx_fp_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_fragment_program *fp = hwcso;
    +
    +	nvfx_fragprog_destroy(nvfx, fp);
    +	FREE((void*)fp->pipe.tokens);
    +	FREE(fp);
    +}
    +
    +static void
    +nvfx_set_blend_color(struct pipe_context *pipe,
    +		     const struct pipe_blend_color *bcol)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->blend_colour = *bcol;
    +	nvfx->dirty |= NVFX_NEW_BCOL;
    +}
    +
    +static void
    +nvfx_set_stencil_ref(struct pipe_context *pipe,
    +		     const struct pipe_stencil_ref *sr)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->stencil_ref = *sr;
    +	nvfx->dirty |= NVFX_NEW_SR;
    +}
    +
    +static void
    +nvfx_set_clip_state(struct pipe_context *pipe,
    +		    const struct pipe_clip_state *clip)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->clip = *clip;
    +	nvfx->dirty |= NVFX_NEW_UCP;
    +	nvfx->draw_dirty |= NVFX_NEW_UCP;
    +}
    +
    +static void
    +nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
    +			 struct pipe_buffer *buf )
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->constbuf[shader] = buf;
    +	nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
    +
    +	if (shader == PIPE_SHADER_VERTEX) {
    +		nvfx->dirty |= NVFX_NEW_VERTPROG;
    +	} else
    +	if (shader == PIPE_SHADER_FRAGMENT) {
    +		nvfx->dirty |= NVFX_NEW_FRAGPROG;
    +	}
    +}
    +
    +static void
    +nvfx_set_framebuffer_state(struct pipe_context *pipe,
    +			   const struct pipe_framebuffer_state *fb)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->framebuffer = *fb;
    +	nvfx->dirty |= NVFX_NEW_FB;
    +}
    +
    +static void
    +nvfx_set_polygon_stipple(struct pipe_context *pipe,
    +			 const struct pipe_poly_stipple *stipple)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	memcpy(nvfx->stipple, stipple->stipple, 4 * 32);
    +	nvfx->dirty |= NVFX_NEW_STIPPLE;
    +}
    +
    +static void
    +nvfx_set_scissor_state(struct pipe_context *pipe,
    +		       const struct pipe_scissor_state *s)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->scissor = *s;
    +	nvfx->dirty |= NVFX_NEW_SCISSOR;
    +}
    +
    +static void
    +nvfx_set_viewport_state(struct pipe_context *pipe,
    +			const struct pipe_viewport_state *vpt)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->viewport = *vpt;
    +	nvfx->dirty |= NVFX_NEW_VIEWPORT;
    +	nvfx->draw_dirty |= NVFX_NEW_VIEWPORT;
    +}
    +
    +static void
    +nvfx_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
    +			const struct pipe_vertex_buffer *vb)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	memcpy(nvfx->vtxbuf, vb, sizeof(*vb) * count);
    +	nvfx->vtxbuf_nr = count;
    +
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	nvfx->draw_dirty |= NVFX_NEW_ARRAYS;
    +}
    +
    +static void *
    +nvfx_vtxelts_state_create(struct pipe_context *pipe,
    +			  unsigned num_elements,
    +			  const struct pipe_vertex_element *elements)
    +{
    +	struct nvfx_vtxelt_state *cso = CALLOC_STRUCT(nvfx_vtxelt_state);
    +
    +	assert(num_elements < 16); /* not doing fallbacks yet */
    +	cso->num_elements = num_elements;
    +	memcpy(cso->pipe, elements, num_elements * sizeof(*elements));
    +
    +/*	nvfx_vtxelt_construct(cso);*/
    +
    +	return (void *)cso;
    +}
    +
    +static void
    +nvfx_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
    +{
    +	FREE(hwcso);
    +}
    +
    +static void
    +nvfx_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +
    +	nvfx->vtxelt = hwcso;
    +	nvfx->dirty |= NVFX_NEW_ARRAYS;
    +	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
    +}
    +
    +void *
    +nv30_sampler_state_create(struct pipe_context *pipe,
    +			  const struct pipe_sampler_state *cso);
    +
    +void *
    +nv40_sampler_state_create(struct pipe_context *pipe,
    +			  const struct pipe_sampler_state *cso);
    +
    +void
    +nvfx_init_state_functions(struct nvfx_context *nvfx)
    +{
    +	nvfx->pipe.create_blend_state = nvfx_blend_state_create;
    +	nvfx->pipe.bind_blend_state = nvfx_blend_state_bind;
    +	nvfx->pipe.delete_blend_state = nvfx_blend_state_delete;
    +
    +	if(nvfx->is_nv4x)
    +		nvfx->pipe.create_sampler_state = nv40_sampler_state_create;
    +	else
    +		nvfx->pipe.create_sampler_state = nv30_sampler_state_create;
    +	nvfx->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
    +	nvfx->pipe.delete_sampler_state = nv40_sampler_state_delete;
    +	nvfx->pipe.set_fragment_sampler_textures = nvfx_set_sampler_texture;
    +
    +	nvfx->pipe.create_rasterizer_state = nvfx_rasterizer_state_create;
    +	nvfx->pipe.bind_rasterizer_state = nvfx_rasterizer_state_bind;
    +	nvfx->pipe.delete_rasterizer_state = nvfx_rasterizer_state_delete;
    +
    +	nvfx->pipe.create_depth_stencil_alpha_state =
    +		nvfx_depth_stencil_alpha_state_create;
    +	nvfx->pipe.bind_depth_stencil_alpha_state =
    +		nvfx_depth_stencil_alpha_state_bind;
    +	nvfx->pipe.delete_depth_stencil_alpha_state =
    +		nvfx_depth_stencil_alpha_state_delete;
    +
    +	nvfx->pipe.create_vs_state = nvfx_vp_state_create;
    +	nvfx->pipe.bind_vs_state = nvfx_vp_state_bind;
    +	nvfx->pipe.delete_vs_state = nvfx_vp_state_delete;
    +
    +	nvfx->pipe.create_fs_state = nvfx_fp_state_create;
    +	nvfx->pipe.bind_fs_state = nvfx_fp_state_bind;
    +	nvfx->pipe.delete_fs_state = nvfx_fp_state_delete;
    +
    +	nvfx->pipe.set_blend_color = nvfx_set_blend_color;
    +        nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref;
    +	nvfx->pipe.set_clip_state = nvfx_set_clip_state;
    +	nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer;
    +	nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state;
    +	nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple;
    +	nvfx->pipe.set_scissor_state = nvfx_set_scissor_state;
    +	nvfx->pipe.set_viewport_state = nvfx_set_viewport_state;
    +
    +	nvfx->pipe.create_vertex_elements_state = nvfx_vtxelts_state_create;
    +	nvfx->pipe.delete_vertex_elements_state = nvfx_vtxelts_state_delete;
    +	nvfx->pipe.bind_vertex_elements_state = nvfx_vtxelts_state_bind;
    +
    +	nvfx->pipe.set_vertex_buffers = nvfx_set_vertex_buffers;
    +}
    -- 
    cgit v1.2.3
    
    
    From 840c36f5e6d940343a3154af7e76fec341ca46e6 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 13:33:48 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_vertprog.c
    
    vertprog.c is similar but has substantial differences:
    1. nv40 supports clip planes
    2. nv40 uses a more advanced register allocator
    3. Some register setup is different
    4. Constants with the same name have different values
    
    This patch unifies the two files.
    nv30 gains clip plane support and the nv40 register allocator.
    
    A new NVFX_VP(x) macro is introduced that at runtime resolved to
    either the nv30 or the nv40 constant value.
    
    nv30 clip planes are not tested and might not work
    ---
     src/gallium/drivers/nv30/Makefile          |    3 +-
     src/gallium/drivers/nv30/nv30_context.h    |    3 -
     src/gallium/drivers/nv30/nv30_vertprog.c   |  842 ---------------------
     src/gallium/drivers/nv40/Makefile          |    3 +-
     src/gallium/drivers/nv40/nv40_context.h    |    3 -
     src/gallium/drivers/nv40/nv40_vertprog.c   | 1048 --------------------------
     src/gallium/drivers/nvfx/Makefile          |    3 +-
     src/gallium/drivers/nvfx/nvfx_context.h    |    6 +-
     src/gallium/drivers/nvfx/nvfx_state.c      |    5 +-
     src/gallium/drivers/nvfx/nvfx_state_emit.c |    2 +-
     src/gallium/drivers/nvfx/nvfx_vertprog.c   | 1108 ++++++++++++++++++++++++++++
     11 files changed, 1117 insertions(+), 1909 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_vertprog.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_vertprog.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_vertprog.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 6ec93ee346..b71afbbb9a 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -7,8 +7,7 @@ C_SOURCES = \
     	nv30_context.c \
     	nv30_fragtex.c \
     	nv30_screen.c \
    -	nv30_state.c \
    -	nv30_vertprog.c
    +	nv30_state.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    index 16cf3cbaa4..eacbb1753d 100644
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ b/src/gallium/drivers/nv30/nv30_context.h
    @@ -5,9 +5,6 @@
     
     /* nv30_fragtex.c */
     extern void nv30_fragtex_bind(struct nvfx_context *);
    -
    -/* nv30_state.c and friends */
    -extern struct nvfx_state_entry nv30_state_vertprog;
     extern struct nvfx_state_entry nv30_state_fragtex;
     
     /* nvfx_context.c */
    diff --git a/src/gallium/drivers/nv30/nv30_vertprog.c b/src/gallium/drivers/nv30/nv30_vertprog.c
    deleted file mode 100644
    index ec6d63889b..0000000000
    --- a/src/gallium/drivers/nv30/nv30_vertprog.c
    +++ /dev/null
    @@ -1,842 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -
    -#include "pipe/p_shader_tokens.h"
    -#include "tgsi/tgsi_parse.h"
    -#include "tgsi/tgsi_dump.h"
    -
    -#include "nv30_context.h"
    -#include "nvfx_state.h"
    -
    -/* TODO (at least...):
    - *  1. Indexed consts  + ARL
    - *  2. Arb. swz/negation
    - *  3. NV_vp11, NV_vp2, NV_vp3 features
    - *       - extra arith opcodes
    - *       - branching
    - *       - texture sampling
    - *       - indexed attribs
    - *       - indexed results
    - *  4. bugs
    - */
    -
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 8
    -#define MASK_Y 4
    -#define MASK_Z 2
    -#define MASK_W 1
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE 0
    -#define DEF_CTEST 0
    -#include "nv30_shader.h"
    -
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -
    -struct nv30_vpc {
    -	struct nvfx_vertex_program *vp;
    -
    -	struct nvfx_vertex_program_exec *vpi;
    -
    -	unsigned output_map[PIPE_MAX_SHADER_OUTPUTS];
    -
    -	int high_temp;
    -	int temp_temp_count;
    -
    -	struct nvfx_sreg *imm;
    -	unsigned nr_imm;
    -};
    -
    -static struct nvfx_sreg
    -temp(struct nv30_vpc *vpc)
    -{
    -	int idx;
    -
    -	idx  = vpc->temp_temp_count++;
    -	idx += vpc->high_temp + 1;
    -	return nvfx_sr(NVFXSR_TEMP, idx);
    -}
    -
    -static struct nvfx_sreg
    -constant(struct nv30_vpc *vpc, int pipe, float x, float y, float z, float w)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	struct nvfx_vertex_program_data *vpd;
    -	int idx;
    -
    -	if (pipe >= 0) {
    -		for (idx = 0; idx < vp->nr_consts; idx++) {
    -			if (vp->consts[idx].index == pipe)
    -				return nvfx_sr(NVFXSR_CONST, idx);
    -		}
    -	}
    -
    -	idx = vp->nr_consts++;
    -	vp->consts = realloc(vp->consts, sizeof(*vpd) * vp->nr_consts);
    -	vpd = &vp->consts[idx];
    -
    -	vpd->index = pipe;
    -	vpd->value[0] = x;
    -	vpd->value[1] = y;
    -	vpd->value[2] = z;
    -	vpd->value[3] = w;
    -	return nvfx_sr(NVFXSR_CONST, idx);
    -}
    -
    -#define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv30_vp_arith((cc), NVFX_VP_INST_SLOT_##s, NVFX_VP_INST_##s##_OP_##o, (d), (m), (s0), (s1), (s2))
    -
    -static void
    -emit_src(struct nv30_vpc *vpc, uint32_t *hw, int pos, struct nvfx_sreg src)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	uint32_t sr = 0;
    -
    -	switch (src.type) {
    -	case NVFXSR_TEMP:
    -		sr |= (NV30_VP_SRC_REG_TYPE_TEMP << NV30_VP_SRC_REG_TYPE_SHIFT);
    -		sr |= (src.index << NV30_VP_SRC_TEMP_SRC_SHIFT);
    -		break;
    -	case NVFXSR_INPUT:
    -		sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
    -		       NV30_VP_SRC_REG_TYPE_SHIFT);
    -		vp->ir |= (1 << src.index);
    -		hw[1] |= (src.index << NV30_VP_INST_INPUT_SRC_SHIFT);
    -		break;
    -	case NVFXSR_CONST:
    -		sr |= (NV30_VP_SRC_REG_TYPE_CONST <<
    -		       NV30_VP_SRC_REG_TYPE_SHIFT);
    -		assert(vpc->vpi->const_index == -1 ||
    -		       vpc->vpi->const_index == src.index);
    -		vpc->vpi->const_index = src.index;
    -		break;
    -	case NVFXSR_NONE:
    -		sr |= (NV30_VP_SRC_REG_TYPE_INPUT <<
    -		       NV30_VP_SRC_REG_TYPE_SHIFT);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (src.negate)
    -		sr |= NV30_VP_SRC_NEGATE;
    -
    -	if (src.abs)
    -		hw[0] |= (1 << (21 + pos));
    -
    -	sr |= ((src.swz[0] << NV30_VP_SRC_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NV30_VP_SRC_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NV30_VP_SRC_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NV30_VP_SRC_SWZ_W_SHIFT));
    -
    -/*
    - * |VVV|
    - * d�.�b
    - *  \u/
    - *
    - */
    -
    -	switch (pos) {
    -	case 0:
    -		hw[1] |= ((sr & NV30_VP_SRC0_HIGH_MASK) >>
    -			  NV30_VP_SRC0_HIGH_SHIFT) << NV30_VP_INST_SRC0H_SHIFT;
    -		hw[2] |= (sr & NV30_VP_SRC0_LOW_MASK) <<
    -			  NV30_VP_INST_SRC0L_SHIFT;
    -		break;
    -	case 1:
    -		hw[2] |= sr << NV30_VP_INST_SRC1_SHIFT;
    -		break;
    -	case 2:
    -		hw[2] |= ((sr & NV30_VP_SRC2_HIGH_MASK) >>
    -			  NV30_VP_SRC2_HIGH_SHIFT) << NV30_VP_INST_SRC2H_SHIFT;
    -		hw[3] |= (sr & NV30_VP_SRC2_LOW_MASK) <<
    -			  NV30_VP_INST_SRC2L_SHIFT;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -}
    -
    -static void
    -emit_dst(struct nv30_vpc *vpc, uint32_t *hw, int slot, struct nvfx_sreg dst)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -
    -	switch (dst.type) {
    -	case NVFXSR_TEMP:
    -		hw[0] |= (dst.index << NV30_VP_INST_DEST_TEMP_ID_SHIFT);
    -		break;
    -	case NVFXSR_OUTPUT:
    -		switch (dst.index) {
    -		case NV30_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
    -		case NV30_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    -		case NV30_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break;
    -		case NV30_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break;
    -		case NV30_VP_INST_DEST_FOGC : vp->or |= (1 << 4); break;
    -		case NV30_VP_INST_DEST_PSZ  : vp->or |= (1 << 5); break;
    -		case NV30_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break;
    -		case NV30_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break;
    -		case NV30_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break;
    -		case NV30_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break;
    -		case NV30_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break;
    -		case NV30_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break;
    -		case NV30_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break;
    -		case NV30_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
    -		default:
    -			break;
    -		}
    -
    -		hw[3] |= (dst.index << NV30_VP_INST_DEST_SHIFT);
    -		hw[0] |= NV30_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
    -
    -		/*XXX: no way this is entirely correct, someone needs to
    -		 *     figure out what exactly it is.
    -		 */
    -		hw[3] |= 0x800;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -}
    -
    -static void
    -nv30_vp_arith(struct nv30_vpc *vpc, int slot, int op,
    -	      struct nvfx_sreg dst, int mask,
    -	      struct nvfx_sreg s0, struct nvfx_sreg s1,
    -	      struct nvfx_sreg s2)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	uint32_t *hw;
    -
    -	vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
    -	vpc->vpi = &vp->insns[vp->nr_insns - 1];
    -	memset(vpc->vpi, 0, sizeof(*vpc->vpi));
    -	vpc->vpi->const_index = -1;
    -
    -	hw = vpc->vpi->data;
    -
    -	hw[0] |= (NVFX_VP_INST_COND_TR << NV30_VP_INST_COND_SHIFT);
    -	hw[0] |= ((0 << NV30_VP_INST_COND_SWZ_X_SHIFT) |
    -		  (1 << NV30_VP_INST_COND_SWZ_Y_SHIFT) |
    -		  (2 << NV30_VP_INST_COND_SWZ_Z_SHIFT) |
    -		  (3 << NV30_VP_INST_COND_SWZ_W_SHIFT));
    -
    -	hw[1] |= (op << NV30_VP_INST_VEC_OPCODE_SHIFT);
    -//	hw[3] |= NV30_VP_INST_SCA_DEST_TEMP_MASK;
    -//	hw[3] |= (mask << NV30_VP_INST_VEC_WRITEMASK_SHIFT);
    -
    -	if (dst.type == NVFXSR_OUTPUT) {
    -		if (slot)
    -			hw[3] |= (mask << NV30_VP_INST_SDEST_WRITEMASK_SHIFT);
    -		else
    -			hw[3] |= (mask << NV30_VP_INST_VDEST_WRITEMASK_SHIFT);
    -	} else {
    -		if (slot)
    -			hw[3] |= (mask << NV30_VP_INST_STEMP_WRITEMASK_SHIFT);
    -		else
    -			hw[3] |= (mask << NV30_VP_INST_VTEMP_WRITEMASK_SHIFT);
    -	}
    -
    -	emit_dst(vpc, hw, slot, dst);
    -	emit_src(vpc, hw, 0, s0);
    -	emit_src(vpc, hw, 1, s1);
    -	emit_src(vpc, hw, 2, s2);
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_src(struct nv30_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
    -	struct nvfx_sreg src;
    -
    -	switch (fsrc->Register.File) {
    -	case TGSI_FILE_INPUT:
    -		src = nvfx_sr(NVFXSR_INPUT, fsrc->Register.Index);
    -		break;
    -	case TGSI_FILE_CONSTANT:
    -		src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
    -		break;
    -	case TGSI_FILE_IMMEDIATE:
    -		src = vpc->imm[fsrc->Register.Index];
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		if (vpc->high_temp < fsrc->Register.Index)
    -			vpc->high_temp = fsrc->Register.Index;
    -		src = nvfx_sr(NVFXSR_TEMP, fsrc->Register.Index);
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad src file\n");
    -		break;
    -	}
    -
    -	src.abs = fsrc->Register.Absolute;
    -	src.negate = fsrc->Register.Negate;
    -	src.swz[0] = fsrc->Register.SwizzleX;
    -	src.swz[1] = fsrc->Register.SwizzleY;
    -	src.swz[2] = fsrc->Register.SwizzleZ;
    -	src.swz[3] = fsrc->Register.SwizzleW;
    -	return src;
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_dst(struct nv30_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
    -	struct nvfx_sreg dst;
    -
    -	switch (fdst->Register.File) {
    -	case TGSI_FILE_OUTPUT:
    -		dst = nvfx_sr(NVFXSR_OUTPUT,
    -			      vpc->output_map[fdst->Register.Index]);
    -
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		dst = nvfx_sr(NVFXSR_TEMP, fdst->Register.Index);
    -		if (vpc->high_temp < dst.index)
    -			vpc->high_temp = dst.index;
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad dst file\n");
    -		break;
    -	}
    -
    -	return dst;
    -}
    -
    -static INLINE int
    -tgsi_mask(uint tgsi)
    -{
    -	int mask = 0;
    -
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    -	return mask;
    -}
    -
    -static boolean
    -nv30_vertprog_parse_instruction(struct nv30_vpc *vpc,
    -				const struct tgsi_full_instruction *finst)
    -{
    -	struct nvfx_sreg src[3], dst, tmp;
    -	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	int mask;
    -	int ai = -1, ci = -1;
    -	int i;
    -
    -	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    -		return TRUE;
    -
    -	vpc->temp_temp_count = 0;
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    -			src[i] = tgsi_src(vpc, fsrc);
    -		}
    -	}
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -			if (ai == -1 || ai == fsrc->Register.Index) {
    -				ai = fsrc->Register.Index;
    -				src[i] = tgsi_src(vpc, fsrc);
    -			} else {
    -				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    -				      tgsi_src(vpc, fsrc), none, none);
    -			}
    -			break;
    -		/*XXX: index comparison is broken now that consts come from
    -		 *     two different register files.
    -		 */
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_IMMEDIATE:
    -			if (ci == -1 || ci == fsrc->Register.Index) {
    -				ci = fsrc->Register.Index;
    -				src[i] = tgsi_src(vpc, fsrc);
    -			} else {
    -				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    -				      tgsi_src(vpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_TEMPORARY:
    -			/* handled above */
    -			break;
    -		default:
    -			NOUVEAU_ERR("bad src file\n");
    -			return FALSE;
    -		}
    -	}
    -
    -	dst  = tgsi_dst(vpc, &finst->Dst[0]);
    -	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    -
    -	switch (finst->Instruction.Opcode) {
    -	case TGSI_OPCODE_ABS:
    -		arith(vpc, VEC, MOV, dst, mask, abs(src[0]), none, none);
    -		break;
    -	case TGSI_OPCODE_ADD:
    -		arith(vpc, VEC, ADD, dst, mask, src[0], none, src[1]);
    -		break;
    -	case TGSI_OPCODE_ARL:
    -		arith(vpc, VEC, ARL, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_DP3:
    -		arith(vpc, VEC, DP3, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DP4:
    -		arith(vpc, VEC, DP4, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DPH:
    -		arith(vpc, VEC, DPH, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DST:
    -		arith(vpc, VEC, DST, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_EX2:
    -		arith(vpc, SCA, EX2, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_EXP:
    -		arith(vpc, SCA, EXP, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_FLR:
    -		arith(vpc, VEC, FLR, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FRC:
    -		arith(vpc, VEC, FRC, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_LG2:
    -		arith(vpc, SCA, LG2, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_LIT:
    -		arith(vpc, SCA, LIT, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_LOG:
    -		arith(vpc, SCA, LOG, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_MAD:
    -		arith(vpc, VEC, MAD, dst, mask, src[0], src[1], src[2]);
    -		break;
    -	case TGSI_OPCODE_MAX:
    -		arith(vpc, VEC, MAX, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MIN:
    -		arith(vpc, VEC, MIN, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MOV:
    -		arith(vpc, VEC, MOV, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_MUL:
    -		arith(vpc, VEC, MUL, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_POW:
    -		tmp = temp(vpc);
    -		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
    -		      swz(src[0], X, X, X, X));
    -		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    -		      swz(src[1], X, X, X, X), none);
    -		arith(vpc, SCA, EX2, dst, mask, none, none,
    -		      swz(tmp, X, X, X, X));
    -		break;
    -	case TGSI_OPCODE_RCP:
    -		arith(vpc, SCA, RCP, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_RET:
    -		break;
    -	case TGSI_OPCODE_RSQ:
    -		arith(vpc, SCA, RSQ, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_SGE:
    -		arith(vpc, VEC, SGE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SGT:
    -		arith(vpc, VEC, SGT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SLT:
    -		arith(vpc, VEC, SLT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SUB:
    -		arith(vpc, VEC, ADD, dst, mask, src[0], none, neg(src[1]));
    -		break;
    -	case TGSI_OPCODE_XPD:
    -		tmp = temp(vpc);
    -		arith(vpc, VEC, MUL, tmp, mask,
    -		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
    -		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    -		      neg(tmp));
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    -		return FALSE;
    -	}
    -
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_vertprog_parse_decl_output(struct nv30_vpc *vpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	int hw;
    -
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		hw = NV30_VP_INST_DEST_POS;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NV30_VP_INST_DEST_COL0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NV30_VP_INST_DEST_COL1;
    -		} else {
    -			NOUVEAU_ERR("bad colour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_BCOLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NV30_VP_INST_DEST_BFC0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NV30_VP_INST_DEST_BFC1;
    -		} else {
    -			NOUVEAU_ERR("bad bcolour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_FOG:
    -		hw = NV30_VP_INST_DEST_FOGC;
    -		break;
    -	case TGSI_SEMANTIC_PSIZE:
    -		hw = NV30_VP_INST_DEST_PSZ;
    -		break;
    -	case TGSI_SEMANTIC_GENERIC:
    -		if (fdec->Semantic.Index <= 7) {
    -			hw = NV30_VP_INST_DEST_TC(fdec->Semantic.Index);
    -		} else {
    -			NOUVEAU_ERR("bad generic semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_EDGEFLAG:
    -		NOUVEAU_ERR("cannot handle edgeflag output\n");
    -		return FALSE;
    -	default:
    -		NOUVEAU_ERR("bad output semantic\n");
    -		return FALSE;
    -	}
    -
    -	vpc->output_map[fdec->Range.First] = hw;
    -	return TRUE;
    -}
    -
    -static boolean
    -nv30_vertprog_prepare(struct nv30_vpc *vpc)
    -{
    -	struct tgsi_parse_context p;
    -	int nr_imm = 0;
    -
    -	tgsi_parse_init(&p, vpc->vp->pipe.tokens);
    -	while (!tgsi_parse_end_of_tokens(&p)) {
    -		const union tgsi_full_token *tok = &p.FullToken;
    -
    -		tgsi_parse_token(&p);
    -		switch(tok->Token.Type) {
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -			nr_imm++;
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -	tgsi_parse_free(&p);
    -
    -	if (nr_imm) {
    -		vpc->imm = CALLOC(nr_imm, sizeof(struct nvfx_sreg));
    -		assert(vpc->imm);
    -	}
    -
    -	return TRUE;
    -}
    -
    -static void
    -nv30_vertprog_translate(struct nvfx_context *nvfx,
    -			struct nvfx_vertex_program *vp)
    -{
    -	struct tgsi_parse_context parse;
    -	struct nv30_vpc *vpc = NULL;
    -
    -	tgsi_dump(vp->pipe.tokens,0);
    -
    -	vpc = CALLOC(1, sizeof(struct nv30_vpc));
    -	if (!vpc)
    -		return;
    -	vpc->vp = vp;
    -	vpc->high_temp = -1;
    -
    -	if (!nv30_vertprog_prepare(vpc)) {
    -		FREE(vpc);
    -		return;
    -	}
    -
    -	tgsi_parse_init(&parse, vp->pipe.tokens);
    -
    -	while (!tgsi_parse_end_of_tokens(&parse)) {
    -		tgsi_parse_token(&parse);
    -
    -		switch (parse.FullToken.Token.Type) {
    -		case TGSI_TOKEN_TYPE_DECLARATION:
    -		{
    -			const struct tgsi_full_declaration *fdec;
    -			fdec = &parse.FullToken.FullDeclaration;
    -			switch (fdec->Declaration.File) {
    -			case TGSI_FILE_OUTPUT:
    -				if (!nv30_vertprog_parse_decl_output(vpc, fdec))
    -					goto out_err;
    -				break;
    -			default:
    -				break;
    -			}
    -		}
    -			break;
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -		{
    -			const struct tgsi_full_immediate *imm;
    -
    -			imm = &parse.FullToken.FullImmediate;
    -			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    -			assert(imm->Immediate.NrTokens == 4 + 1);
    -			vpc->imm[vpc->nr_imm++] =
    -				constant(vpc, -1,
    -					 imm->u[0].Float,
    -					 imm->u[1].Float,
    -					 imm->u[2].Float,
    -					 imm->u[3].Float);
    -		}
    -			break;
    -		case TGSI_TOKEN_TYPE_INSTRUCTION:
    -		{
    -			const struct tgsi_full_instruction *finst;
    -			finst = &parse.FullToken.FullInstruction;
    -			if (!nv30_vertprog_parse_instruction(vpc, finst))
    -				goto out_err;
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	vp->insns[vp->nr_insns - 1].data[3] |= NVFX_VP_INST_LAST;
    -	vp->translated = TRUE;
    -out_err:
    -	tgsi_parse_free(&parse);
    -	FREE(vpc);
    -}
    -
    -static boolean
    -nv30_vertprog_validate(struct nvfx_context *nvfx)
    -{ 
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	struct nvfx_vertex_program *vp;
    -	struct pipe_buffer *constbuf;
    -	boolean upload_code = FALSE, upload_data = FALSE;
    -	int i;
    -
    -	vp = nvfx->vertprog;
    -	constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
    -
    -	/* Translate TGSI shader into hw bytecode */
    -	if (!vp->translated) {
    -		nv30_vertprog_translate(nvfx, vp);
    -		if (!vp->translated)
    -			return FALSE;
    -	}
    -
    -	/* Allocate hw vtxprog exec slots */
    -	if (!vp->exec) {
    -		struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
    -		struct nouveau_stateobj *so;
    -		uint vplen = vp->nr_insns;
    -
    -		if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
    -			while (heap->next && heap->size < vplen) {
    -				struct nvfx_vertex_program *evict;
    -				
    -				evict = heap->next->priv;
    -				nouveau_resource_free(&evict->exec);
    -			}
    -
    -			if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec))
    -				assert(0);
    -		}
    -
    -		so = so_new(1, 1, 0);
    -		so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
    -		so_data  (so, vp->exec->start);
    -		so_ref(so, &vp->so);
    -		so_ref(NULL, &so);
    -
    -		upload_code = TRUE;
    -	}
    -
    -	/* Allocate hw vtxprog const slots */
    -	if (vp->nr_consts && !vp->data) {
    -		struct nouveau_resource *heap = nvfx->screen->vp_data_heap;
    -
    -		if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
    -			while (heap->next && heap->size < vp->nr_consts) {
    -				struct nvfx_vertex_program *evict;
    -				
    -				evict = heap->next->priv;
    -				nouveau_resource_free(&evict->data);
    -			}
    -
    -			if (nouveau_resource_alloc(heap, vp->nr_consts, vp,
    -						   &vp->data))
    -				assert(0);
    -		}
    -
    -		/*XXX: handle this some day */
    -		assert(vp->data->start >= vp->data_start_min);
    -
    -		upload_data = TRUE;
    -		if (vp->data_start != vp->data->start)
    -			upload_code = TRUE;
    -	}
    -
    -	/* If exec or data segments moved we need to patch the program to
    -	 * fixup offsets and register IDs.
    -	 */
    -	if (vp->exec_start != vp->exec->start) {
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    -
    -			if (vpi->has_branch_offset) {
    -				assert(0);
    -			}
    -		}
    -
    -		vp->exec_start = vp->exec->start;
    -	}
    -
    -	if (vp->nr_consts && vp->data_start != vp->data->start) {
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    -
    -			if (vpi->const_index >= 0) {
    -				vpi->data[1] &= ~NV30_VP_INST_CONST_SRC_MASK;
    -				vpi->data[1] |=
    -					(vpi->const_index + vp->data->start) <<
    -					NV30_VP_INST_CONST_SRC_SHIFT;
    -
    -			}
    -		}
    -
    -		vp->data_start = vp->data->start;
    -	}
    -
    -	/* Update + Upload constant values */
    -	if (vp->nr_consts) {
    -		float *map = NULL;
    -
    -		if (constbuf) {
    -			map = pipe_buffer_map(pscreen, constbuf,
    -					      PIPE_BUFFER_USAGE_CPU_READ);
    -		}
    -
    -		for (i = 0; i < vp->nr_consts; i++) {
    -			struct nvfx_vertex_program_data *vpd = &vp->consts[i];
    -
    -			if (vpd->index >= 0) {
    -				if (!upload_data &&
    -				    !memcmp(vpd->value, &map[vpd->index * 4],
    -					    4 * sizeof(float)))
    -					continue;
    -				memcpy(vpd->value, &map[vpd->index * 4],
    -				       4 * sizeof(float));
    -			}
    -
    -			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_CONST_ID, 5);
    -			OUT_RING  (chan, i + vp->data->start);
    -			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
    -		}
    -
    -		if (constbuf)
    -			pipe_buffer_unmap(pscreen, constbuf);
    -	}
    -
    -	/* Upload vtxprog */
    -	if (upload_code) {
    -#if 0
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			NOUVEAU_MSG("VP inst %d: 0x%08x 0x%08x 0x%08x 0x%08x\n",
    -				i, vp->insns[i].data[0], vp->insns[i].data[1],
    -				vp->insns[i].data[2], vp->insns[i].data[3]);
    -		}
    -#endif
    -		BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_FROM_ID, 1);
    -		OUT_RING  (chan, vp->exec->start);
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_INST(0), 4);
    -			OUT_RINGp (chan, vp->insns[i].data, 4);
    -		}
    -	}
    -
    -	if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
    -		so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
    -		return TRUE;
    -	}
    -
    -	return FALSE;
    -}
    -
    -void
    -nv30_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
    -{
    -	vp->translated = FALSE;
    -
    -	if (vp->nr_insns) {
    -		FREE(vp->insns);
    -		vp->insns = NULL;
    -		vp->nr_insns = 0;
    -	}
    -
    -	if (vp->nr_consts) {
    -		FREE(vp->consts);
    -		vp->consts = NULL;
    -		vp->nr_consts = 0;
    -	}
    -
    -	nouveau_resource_free(&vp->exec);
    -	vp->exec_start = 0;
    -	nouveau_resource_free(&vp->data);
    -	vp->data_start = 0;
    -	vp->data_start_min = 0;
    -
    -	vp->ir = vp->or = 0;
    -	so_ref(NULL, &vp->so);
    -}
    -
    -struct nvfx_state_entry nv30_state_vertprog = {
    -	.validate = nv30_vertprog_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_VERTPROG /*| NVFX_NEW_UCP*/,
    -		.hw = NVFX_STATE_VERTPROG,
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 6908506906..c8f3858c36 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -7,8 +7,7 @@ C_SOURCES = \
     	nv40_context.c \
     	nv40_fragtex.c \
     	nv40_screen.c \
    -	nv40_state.c \
    -	nv40_vertprog.c
    +	nv40_state.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    index 5ea2229fac..8dc87e426f 100644
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ b/src/gallium/drivers/nv40/nv40_context.h
    @@ -5,9 +5,6 @@
     
     /* nv40_fragtex.c */
     extern void nv40_fragtex_bind(struct nvfx_context *);
    -
    -/* nv40_state.c and friends */
    -extern struct nvfx_state_entry nv40_state_vertprog;
     extern struct nvfx_state_entry nv40_state_fragtex;
     
     /* nvfx_context.c */
    diff --git a/src/gallium/drivers/nv40/nv40_vertprog.c b/src/gallium/drivers/nv40/nv40_vertprog.c
    deleted file mode 100644
    index 752cd0d1b3..0000000000
    --- a/src/gallium/drivers/nv40/nv40_vertprog.c
    +++ /dev/null
    @@ -1,1048 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_defines.h"
    -#include "pipe/p_state.h"
    -#include "util/u_inlines.h"
    -
    -#include "pipe/p_shader_tokens.h"
    -#include "tgsi/tgsi_parse.h"
    -#include "tgsi/tgsi_util.h"
    -
    -#include "nv40_context.h"
    -#include "nvfx_state.h"
    -
    -/* TODO (at least...):
    - *  1. Indexed consts  + ARL
    - *  3. NV_vp11, NV_vp2, NV_vp3 features
    - *       - extra arith opcodes
    - *       - branching
    - *       - texture sampling
    - *       - indexed attribs
    - *       - indexed results
    - *  4. bugs
    - */
    -
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 8
    -#define MASK_Y 4
    -#define MASK_Z 2
    -#define MASK_W 1
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE 0
    -#define DEF_CTEST 0
    -#include "nv40_shader.h"
    -
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -
    -#define NV40_VP_INST_DEST_CLIP(n) ((~0 - 6) + (n))
    -
    -struct nv40_vpc {
    -	struct nvfx_vertex_program *vp;
    -
    -	struct nvfx_vertex_program_exec *vpi;
    -
    -	unsigned r_temps;
    -	unsigned r_temps_discard;
    -	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    -	struct nvfx_sreg *r_address;
    -	struct nvfx_sreg *r_temp;
    -
    -	struct nvfx_sreg *imm;
    -	unsigned nr_imm;
    -
    -	unsigned hpos_idx;
    -};
    -
    -static struct nvfx_sreg
    -temp(struct nv40_vpc *vpc)
    -{
    -	int idx = ffs(~vpc->r_temps) - 1;
    -
    -	if (idx < 0) {
    -		NOUVEAU_ERR("out of temps!!\n");
    -		assert(0);
    -		return nvfx_sr(NVFXSR_TEMP, 0);
    -	}
    -
    -	vpc->r_temps |= (1 << idx);
    -	vpc->r_temps_discard |= (1 << idx);
    -	return nvfx_sr(NVFXSR_TEMP, idx);
    -}
    -
    -static INLINE void
    -release_temps(struct nv40_vpc *vpc)
    -{
    -	vpc->r_temps &= ~vpc->r_temps_discard;
    -	vpc->r_temps_discard = 0;
    -}
    -
    -static struct nvfx_sreg
    -constant(struct nv40_vpc *vpc, int pipe, float x, float y, float z, float w)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	struct nvfx_vertex_program_data *vpd;
    -	int idx;
    -
    -	if (pipe >= 0) {
    -		for (idx = 0; idx < vp->nr_consts; idx++) {
    -			if (vp->consts[idx].index == pipe)
    -				return nvfx_sr(NVFXSR_CONST, idx);
    -		}
    -	}
    -
    -	idx = vp->nr_consts++;
    -	vp->consts = realloc(vp->consts, sizeof(*vpd) * vp->nr_consts);
    -	vpd = &vp->consts[idx];
    -
    -	vpd->index = pipe;
    -	vpd->value[0] = x;
    -	vpd->value[1] = y;
    -	vpd->value[2] = z;
    -	vpd->value[3] = w;
    -	return nvfx_sr(NVFXSR_CONST, idx);
    -}
    -
    -#define arith(cc,s,o,d,m,s0,s1,s2) \
    -	nv40_vp_arith((cc), NVFX_VP_INST_SLOT_##s, NVFX_VP_INST_##s##_OP_##o, (d), (m), (s0), (s1), (s2))
    -
    -static void
    -emit_src(struct nv40_vpc *vpc, uint32_t *hw, int pos, struct nvfx_sreg src)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	uint32_t sr = 0;
    -
    -	switch (src.type) {
    -	case NVFXSR_TEMP:
    -		sr |= (NV40_VP_SRC_REG_TYPE_TEMP << NV40_VP_SRC_REG_TYPE_SHIFT);
    -		sr |= (src.index << NV40_VP_SRC_TEMP_SRC_SHIFT);
    -		break;
    -	case NVFXSR_INPUT:
    -		sr |= (NV40_VP_SRC_REG_TYPE_INPUT <<
    -		       NV40_VP_SRC_REG_TYPE_SHIFT);
    -		vp->ir |= (1 << src.index);
    -		hw[1] |= (src.index << NV40_VP_INST_INPUT_SRC_SHIFT);
    -		break;
    -	case NVFXSR_CONST:
    -		sr |= (NV40_VP_SRC_REG_TYPE_CONST <<
    -		       NV40_VP_SRC_REG_TYPE_SHIFT);
    -		assert(vpc->vpi->const_index == -1 ||
    -		       vpc->vpi->const_index == src.index);
    -		vpc->vpi->const_index = src.index;
    -		break;
    -	case NVFXSR_NONE:
    -		sr |= (NV40_VP_SRC_REG_TYPE_INPUT <<
    -		       NV40_VP_SRC_REG_TYPE_SHIFT);
    -		break;
    -	default:
    -		assert(0);
    -	}
    -
    -	if (src.negate)
    -		sr |= NV40_VP_SRC_NEGATE;
    -
    -	if (src.abs)
    -		hw[0] |= (1 << (21 + pos));
    -
    -	sr |= ((src.swz[0] << NV40_VP_SRC_SWZ_X_SHIFT) |
    -	       (src.swz[1] << NV40_VP_SRC_SWZ_Y_SHIFT) |
    -	       (src.swz[2] << NV40_VP_SRC_SWZ_Z_SHIFT) |
    -	       (src.swz[3] << NV40_VP_SRC_SWZ_W_SHIFT));
    -
    -	switch (pos) {
    -	case 0:
    -		hw[1] |= ((sr & NV40_VP_SRC0_HIGH_MASK) >>
    -			  NV40_VP_SRC0_HIGH_SHIFT) << NV40_VP_INST_SRC0H_SHIFT;
    -		hw[2] |= (sr & NV40_VP_SRC0_LOW_MASK) <<
    -			  NV40_VP_INST_SRC0L_SHIFT;
    -		break;
    -	case 1:
    -		hw[2] |= sr << NV40_VP_INST_SRC1_SHIFT;
    -		break;
    -	case 2:
    -		hw[2] |= ((sr & NV40_VP_SRC2_HIGH_MASK) >>
    -			  NV40_VP_SRC2_HIGH_SHIFT) << NV40_VP_INST_SRC2H_SHIFT;
    -		hw[3] |= (sr & NV40_VP_SRC2_LOW_MASK) <<
    -			  NV40_VP_INST_SRC2L_SHIFT;
    -		break;
    -	default:
    -		assert(0);
    -	}
    -}
    -
    -static void
    -emit_dst(struct nv40_vpc *vpc, uint32_t *hw, int slot, struct nvfx_sreg dst)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -
    -	switch (dst.type) {
    -	case NVFXSR_TEMP:
    -		hw[3] |= NV40_VP_INST_DEST_MASK;
    -		if (slot == 0) {
    -			hw[0] |= (dst.index <<
    -				  NV40_VP_INST_VEC_DEST_TEMP_SHIFT);
    -		} else {
    -			hw[3] |= (dst.index << 
    -				  NV40_VP_INST_SCA_DEST_TEMP_SHIFT);
    -		}
    -		break;
    -	case NVFXSR_OUTPUT:
    -		switch (dst.index) {
    -		case NV40_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
    -		case NV40_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    -		case NV40_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break;
    -		case NV40_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break;
    -		case NV40_VP_INST_DEST_FOGC : vp->or |= (1 << 4); break;
    -		case NV40_VP_INST_DEST_PSZ  : vp->or |= (1 << 5); break;
    -		case NV40_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break;
    -		case NV40_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break;
    -		case NV40_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break;
    -		case NV40_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break;
    -		case NV40_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break;
    -		case NV40_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break;
    -		case NV40_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break;
    -		case NV40_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
    -		case NV40_VP_INST_DEST_CLIP(0):
    -			vp->or |= (1 << 6);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE0;
    -			dst.index = NV40_VP_INST_DEST_FOGC;
    -			break;
    -		case NV40_VP_INST_DEST_CLIP(1):
    -			vp->or |= (1 << 7);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE1;
    -			dst.index = NV40_VP_INST_DEST_FOGC;
    -			break;
    -		case NV40_VP_INST_DEST_CLIP(2):
    -			vp->or |= (1 << 8);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE2;
    -			dst.index = NV40_VP_INST_DEST_FOGC;
    -			break;
    -		case NV40_VP_INST_DEST_CLIP(3):
    -			vp->or |= (1 << 9);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE3;
    -			dst.index = NV40_VP_INST_DEST_PSZ;
    -			break;
    -		case NV40_VP_INST_DEST_CLIP(4):
    -			vp->or |= (1 << 10);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE4;
    -			dst.index = NV40_VP_INST_DEST_PSZ;
    -			break;
    -		case NV40_VP_INST_DEST_CLIP(5):
    -			vp->or |= (1 << 11);
    -			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE5;
    -			dst.index = NV40_VP_INST_DEST_PSZ;
    -			break;
    -		default:
    -			break;
    -		}
    -
    -		hw[3] |= (dst.index << NV40_VP_INST_DEST_SHIFT);
    -		if (slot == 0) {
    -			hw[0] |= NV40_VP_INST_VEC_RESULT;
    -			hw[0] |= NV40_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
    -		} else {
    -			hw[3] |= NV40_VP_INST_SCA_RESULT;
    -			hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK;
    -		}
    -		break;
    -	default:
    -		assert(0);
    -	}
    -}
    -
    -static void
    -nv40_vp_arith(struct nv40_vpc *vpc, int slot, int op,
    -	      struct nvfx_sreg dst, int mask,
    -	      struct nvfx_sreg s0, struct nvfx_sreg s1,
    -	      struct nvfx_sreg s2)
    -{
    -	struct nvfx_vertex_program *vp = vpc->vp;
    -	uint32_t *hw;
    -
    -	vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
    -	vpc->vpi = &vp->insns[vp->nr_insns - 1];
    -	memset(vpc->vpi, 0, sizeof(*vpc->vpi));
    -	vpc->vpi->const_index = -1;
    -
    -	hw = vpc->vpi->data;
    -
    -	hw[0] |= (NVFX_VP_INST_COND_TR << NV40_VP_INST_COND_SHIFT);
    -	hw[0] |= ((0 << NV40_VP_INST_COND_SWZ_X_SHIFT) |
    -		  (1 << NV40_VP_INST_COND_SWZ_Y_SHIFT) |
    -		  (2 << NV40_VP_INST_COND_SWZ_Z_SHIFT) |
    -		  (3 << NV40_VP_INST_COND_SWZ_W_SHIFT));
    -
    -	if (slot == 0) {
    -		hw[1] |= (op << NV40_VP_INST_VEC_OPCODE_SHIFT);
    -		hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK;
    -		hw[3] |= (mask << NV40_VP_INST_VEC_WRITEMASK_SHIFT);
    -	} else {
    -		hw[1] |= (op << NV40_VP_INST_SCA_OPCODE_SHIFT);
    -		hw[0] |= (NV40_VP_INST_VEC_DEST_TEMP_MASK | (1 << 20));
    -		hw[3] |= (mask << NV40_VP_INST_SCA_WRITEMASK_SHIFT);
    -	}
    -
    -	emit_dst(vpc, hw, slot, dst);
    -	emit_src(vpc, hw, 0, s0);
    -	emit_src(vpc, hw, 1, s1);
    -	emit_src(vpc, hw, 2, s2);
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_src(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
    -	struct nvfx_sreg src;
    -
    -	switch (fsrc->Register.File) {
    -	case TGSI_FILE_INPUT:
    -		src = nvfx_sr(NVFXSR_INPUT, fsrc->Register.Index);
    -		break;
    -	case TGSI_FILE_CONSTANT:
    -		src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
    -		break;
    -	case TGSI_FILE_IMMEDIATE:
    -		src = vpc->imm[fsrc->Register.Index];
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		src = vpc->r_temp[fsrc->Register.Index];
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad src file\n");
    -		break;
    -	}
    -
    -	src.abs = fsrc->Register.Absolute;
    -	src.negate = fsrc->Register.Negate;
    -	src.swz[0] = fsrc->Register.SwizzleX;
    -	src.swz[1] = fsrc->Register.SwizzleY;
    -	src.swz[2] = fsrc->Register.SwizzleZ;
    -	src.swz[3] = fsrc->Register.SwizzleW;
    -	return src;
    -}
    -
    -static INLINE struct nvfx_sreg
    -tgsi_dst(struct nv40_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
    -	struct nvfx_sreg dst;
    -
    -	switch (fdst->Register.File) {
    -	case TGSI_FILE_OUTPUT:
    -		dst = vpc->r_result[fdst->Register.Index];
    -		break;
    -	case TGSI_FILE_TEMPORARY:
    -		dst = vpc->r_temp[fdst->Register.Index];
    -		break;
    -	case TGSI_FILE_ADDRESS:
    -		dst = vpc->r_address[fdst->Register.Index];
    -		break;
    -	default:
    -		NOUVEAU_ERR("bad dst file\n");
    -		break;
    -	}
    -
    -	return dst;
    -}
    -
    -static INLINE int
    -tgsi_mask(uint tgsi)
    -{
    -	int mask = 0;
    -
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    -	return mask;
    -}
    -
    -static boolean
    -src_native_swz(struct nv40_vpc *vpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nvfx_sreg *src)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg tgsi = tgsi_src(vpc, fsrc);
    -	uint mask = 0;
    -	uint c;
    -
    -	for (c = 0; c < 4; c++) {
    -		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    -		case TGSI_SWIZZLE_X:
    -		case TGSI_SWIZZLE_Y:
    -		case TGSI_SWIZZLE_Z:
    -		case TGSI_SWIZZLE_W:
    -			mask |= tgsi_mask(1 << c);
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	if (mask == MASK_ALL)
    -		return TRUE;
    -
    -	*src = temp(vpc);
    -
    -	if (mask)
    -		arith(vpc, VEC, MOV, *src, mask, tgsi, none, none);
    -
    -	return FALSE;
    -}
    -
    -static boolean
    -nv40_vertprog_parse_instruction(struct nv40_vpc *vpc,
    -				const struct tgsi_full_instruction *finst)
    -{
    -	struct nvfx_sreg src[3], dst, tmp;
    -	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	int mask;
    -	int ai = -1, ci = -1, ii = -1;
    -	int i;
    -
    -	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    -		return TRUE;
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    -			src[i] = tgsi_src(vpc, fsrc);
    -		}
    -	}
    -
    -	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    -		const struct tgsi_full_src_register *fsrc;
    -
    -		fsrc = &finst->Src[i];
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_TEMPORARY:
    -			if (!src_native_swz(vpc, fsrc, &src[i]))
    -				continue;
    -			break;
    -		default:
    -			break;
    -		}
    -
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -			if (ai == -1 || ai == fsrc->Register.Index) {
    -				ai = fsrc->Register.Index;
    -				src[i] = tgsi_src(vpc, fsrc);
    -			} else {
    -				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    -				      tgsi_src(vpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_CONSTANT:
    -			if ((ci == -1 && ii == -1) ||
    -			    ci == fsrc->Register.Index) {
    -				ci = fsrc->Register.Index;
    -				src[i] = tgsi_src(vpc, fsrc);
    -			} else {
    -				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    -				      tgsi_src(vpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_IMMEDIATE:
    -			if ((ci == -1 && ii == -1) ||
    -			    ii == fsrc->Register.Index) {
    -				ii = fsrc->Register.Index;
    -				src[i] = tgsi_src(vpc, fsrc);
    -			} else {
    -				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    -				      tgsi_src(vpc, fsrc), none, none);
    -			}
    -			break;
    -		case TGSI_FILE_TEMPORARY:
    -			/* handled above */
    -			break;
    -		default:
    -			NOUVEAU_ERR("bad src file\n");
    -			return FALSE;
    -		}
    -	}
    -
    -	dst  = tgsi_dst(vpc, &finst->Dst[0]);
    -	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    -
    -	switch (finst->Instruction.Opcode) {
    -	case TGSI_OPCODE_ABS:
    -		arith(vpc, VEC, MOV, dst, mask, abs(src[0]), none, none);
    -		break;
    -	case TGSI_OPCODE_ADD:
    -		arith(vpc, VEC, ADD, dst, mask, src[0], none, src[1]);
    -		break;
    -	case TGSI_OPCODE_ARL:
    -		arith(vpc, VEC, ARL, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_DP3:
    -		arith(vpc, VEC, DP3, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DP4:
    -		arith(vpc, VEC, DP4, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DPH:
    -		arith(vpc, VEC, DPH, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_DST:
    -		arith(vpc, VEC, DST, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_EX2:
    -		arith(vpc, SCA, EX2, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_EXP:
    -		arith(vpc, SCA, EXP, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_FLR:
    -		arith(vpc, VEC, FLR, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_FRC:
    -		arith(vpc, VEC, FRC, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_LG2:
    -		arith(vpc, SCA, LG2, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_LIT:
    -		arith(vpc, SCA, LIT, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_LOG:
    -		arith(vpc, SCA, LOG, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_MAD:
    -		arith(vpc, VEC, MAD, dst, mask, src[0], src[1], src[2]);
    -		break;
    -	case TGSI_OPCODE_MAX:
    -		arith(vpc, VEC, MAX, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MIN:
    -		arith(vpc, VEC, MIN, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_MOV:
    -		arith(vpc, VEC, MOV, dst, mask, src[0], none, none);
    -		break;
    -	case TGSI_OPCODE_MUL:
    -		arith(vpc, VEC, MUL, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_POW:
    -		tmp = temp(vpc);
    -		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
    -		      swz(src[0], X, X, X, X));
    -		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    -		      swz(src[1], X, X, X, X), none);
    -		arith(vpc, SCA, EX2, dst, mask, none, none,
    -		      swz(tmp, X, X, X, X));
    -		break;
    -	case TGSI_OPCODE_RCP:
    -		arith(vpc, SCA, RCP, dst, mask, none, none, src[0]);
    -		break;
    -	case TGSI_OPCODE_RET:
    -		break;
    -	case TGSI_OPCODE_RSQ:
    -		arith(vpc, SCA, RSQ, dst, mask, none, none, abs(src[0]));
    -		break;
    -	case TGSI_OPCODE_SGE:
    -		arith(vpc, VEC, SGE, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SLT:
    -		arith(vpc, VEC, SLT, dst, mask, src[0], src[1], none);
    -		break;
    -	case TGSI_OPCODE_SUB:
    -		arith(vpc, VEC, ADD, dst, mask, src[0], none, neg(src[1]));
    -		break;
    -	case TGSI_OPCODE_XPD:
    -		tmp = temp(vpc);
    -		arith(vpc, VEC, MUL, tmp, mask,
    -		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
    -		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    -		      neg(tmp));
    -		break;
    -	default:
    -		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    -		return FALSE;
    -	}
    -
    -	release_temps(vpc);
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_vertprog_parse_decl_output(struct nv40_vpc *vpc,
    -				const struct tgsi_full_declaration *fdec)
    -{
    -	unsigned idx = fdec->Range.First;
    -	int hw;
    -
    -	switch (fdec->Semantic.Name) {
    -	case TGSI_SEMANTIC_POSITION:
    -		hw = NV40_VP_INST_DEST_POS;
    -		vpc->hpos_idx = idx;
    -		break;
    -	case TGSI_SEMANTIC_COLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NV40_VP_INST_DEST_COL0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NV40_VP_INST_DEST_COL1;
    -		} else {
    -			NOUVEAU_ERR("bad colour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_BCOLOR:
    -		if (fdec->Semantic.Index == 0) {
    -			hw = NV40_VP_INST_DEST_BFC0;
    -		} else
    -		if (fdec->Semantic.Index == 1) {
    -			hw = NV40_VP_INST_DEST_BFC1;
    -		} else {
    -			NOUVEAU_ERR("bad bcolour semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_FOG:
    -		hw = NV40_VP_INST_DEST_FOGC;
    -		break;
    -	case TGSI_SEMANTIC_PSIZE:
    -		hw = NV40_VP_INST_DEST_PSZ;
    -		break;
    -	case TGSI_SEMANTIC_GENERIC:
    -		if (fdec->Semantic.Index <= 7) {
    -			hw = NV40_VP_INST_DEST_TC(fdec->Semantic.Index);
    -		} else {
    -			NOUVEAU_ERR("bad generic semantic index\n");
    -			return FALSE;
    -		}
    -		break;
    -	case TGSI_SEMANTIC_EDGEFLAG:
    -		/* not really an error just a fallback */
    -		NOUVEAU_ERR("cannot handle edgeflag output\n");
    -		return FALSE;
    -	default:
    -		NOUVEAU_ERR("bad output semantic\n");
    -		return FALSE;
    -	}
    -
    -	vpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
    -	return TRUE;
    -}
    -
    -static boolean
    -nv40_vertprog_prepare(struct nv40_vpc *vpc)
    -{
    -	struct tgsi_parse_context p;
    -	int high_temp = -1, high_addr = -1, nr_imm = 0, i;
    -
    -	tgsi_parse_init(&p, vpc->vp->pipe.tokens);
    -	while (!tgsi_parse_end_of_tokens(&p)) {
    -		const union tgsi_full_token *tok = &p.FullToken;
    -
    -		tgsi_parse_token(&p);
    -		switch(tok->Token.Type) {
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -			nr_imm++;
    -			break;
    -		case TGSI_TOKEN_TYPE_DECLARATION:
    -		{
    -			const struct tgsi_full_declaration *fdec;
    -
    -			fdec = &p.FullToken.FullDeclaration;
    -			switch (fdec->Declaration.File) {
    -			case TGSI_FILE_TEMPORARY:
    -				if (fdec->Range.Last > high_temp) {
    -					high_temp =
    -						fdec->Range.Last;
    -				}
    -				break;
    -#if 0 /* this would be nice.. except gallium doesn't track it */
    -			case TGSI_FILE_ADDRESS:
    -				if (fdec->Range.Last > high_addr) {
    -					high_addr =
    -						fdec->Range.Last;
    -				}
    -				break;
    -#endif
    -			case TGSI_FILE_OUTPUT:
    -				if (!nv40_vertprog_parse_decl_output(vpc, fdec))
    -					return FALSE;
    -				break;
    -			default:
    -				break;
    -			}
    -		}
    -			break;
    -#if 1 /* yay, parse instructions looking for address regs instead */
    -		case TGSI_TOKEN_TYPE_INSTRUCTION:
    -		{
    -			const struct tgsi_full_instruction *finst;
    -			const struct tgsi_full_dst_register *fdst;
    -
    -			finst = &p.FullToken.FullInstruction;
    -			fdst = &finst->Dst[0];
    -
    -			if (fdst->Register.File == TGSI_FILE_ADDRESS) {
    -				if (fdst->Register.Index > high_addr)
    -					high_addr = fdst->Register.Index;
    -			}
    -		
    -		}
    -			break;
    -#endif
    -		default:
    -			break;
    -		}
    -	}
    -	tgsi_parse_free(&p);
    -
    -	if (nr_imm) {
    -		vpc->imm = CALLOC(nr_imm, sizeof(struct nvfx_sreg));
    -		assert(vpc->imm);
    -	}
    -
    -	if (++high_temp) {
    -		vpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
    -		for (i = 0; i < high_temp; i++)
    -			vpc->r_temp[i] = temp(vpc);
    -	}
    -
    -	if (++high_addr) {
    -		vpc->r_address = CALLOC(high_addr, sizeof(struct nvfx_sreg));
    -		for (i = 0; i < high_addr; i++)
    -			vpc->r_address[i] = temp(vpc);
    -	}
    -
    -	vpc->r_temps_discard = 0;
    -	return TRUE;
    -}
    -
    -static void
    -nv40_vertprog_translate(struct nvfx_context *nvfx,
    -			struct nvfx_vertex_program *vp)
    -{
    -	struct tgsi_parse_context parse;
    -	struct nv40_vpc *vpc = NULL;
    -	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	int i;
    -
    -	vpc = CALLOC(1, sizeof(struct nv40_vpc));
    -	if (!vpc)
    -		return;
    -	vpc->vp = vp;
    -
    -	if (!nv40_vertprog_prepare(vpc)) {
    -		FREE(vpc);
    -		return;
    -	}
    -
    -	/* Redirect post-transform vertex position to a temp if user clip
    -	 * planes are enabled.  We need to append code to the vtxprog
    -	 * to handle clip planes later.
    -	 */
    -	if (vp->ucp.nr)  {
    -		vpc->r_result[vpc->hpos_idx] = temp(vpc);
    -		vpc->r_temps_discard = 0;
    -	}
    -
    -	tgsi_parse_init(&parse, vp->pipe.tokens);
    -
    -	while (!tgsi_parse_end_of_tokens(&parse)) {
    -		tgsi_parse_token(&parse);
    -
    -		switch (parse.FullToken.Token.Type) {
    -		case TGSI_TOKEN_TYPE_IMMEDIATE:
    -		{
    -			const struct tgsi_full_immediate *imm;
    -
    -			imm = &parse.FullToken.FullImmediate;
    -			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    -			assert(imm->Immediate.NrTokens == 4 + 1);
    -			vpc->imm[vpc->nr_imm++] =
    -				constant(vpc, -1,
    -					 imm->u[0].Float,
    -					 imm->u[1].Float,
    -					 imm->u[2].Float,
    -					 imm->u[3].Float);
    -		}
    -			break;
    -		case TGSI_TOKEN_TYPE_INSTRUCTION:
    -		{
    -			const struct tgsi_full_instruction *finst;
    -			finst = &parse.FullToken.FullInstruction;
    -			if (!nv40_vertprog_parse_instruction(vpc, finst))
    -				goto out_err;
    -		}
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	/* Write out HPOS if it was redirected to a temp earlier */
    -	if (vpc->r_result[vpc->hpos_idx].type != NVFXSR_OUTPUT) {
    -		struct nvfx_sreg hpos = nvfx_sr(NVFXSR_OUTPUT,
    -						NV40_VP_INST_DEST_POS);
    -		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
    -
    -		arith(vpc, VEC, MOV, hpos, MASK_ALL, htmp, none, none);
    -	}
    -
    -	/* Insert code to handle user clip planes */
    -	for (i = 0; i < vp->ucp.nr; i++) {
    -		struct nvfx_sreg cdst = nvfx_sr(NVFXSR_OUTPUT,
    -						NV40_VP_INST_DEST_CLIP(i));
    -		struct nvfx_sreg ceqn = constant(vpc, -1,
    -						 nvfx->clip.ucp[i][0],
    -						 nvfx->clip.ucp[i][1],
    -						 nvfx->clip.ucp[i][2],
    -						 nvfx->clip.ucp[i][3]);
    -		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
    -		unsigned mask;
    -
    -		switch (i) {
    -		case 0: case 3: mask = MASK_Y; break;
    -		case 1: case 4: mask = MASK_Z; break;
    -		case 2: case 5: mask = MASK_W; break;
    -		default:
    -			NOUVEAU_ERR("invalid clip dist #%d\n", i);
    -			goto out_err;
    -		}
    -
    -		arith(vpc, VEC, DP4, cdst, mask, htmp, ceqn, none);
    -	}
    -
    -	vp->insns[vp->nr_insns - 1].data[3] |= NVFX_VP_INST_LAST;
    -	vp->translated = TRUE;
    -out_err:
    -	tgsi_parse_free(&parse);
    -	if (vpc->r_temp)
    -		FREE(vpc->r_temp); 
    -	if (vpc->r_address)
    -		FREE(vpc->r_address); 
    -	if (vpc->imm)	
    -		FREE(vpc->imm); 
    -	FREE(vpc);
    -}
    -
    -static boolean
    -nv40_vertprog_validate(struct nvfx_context *nvfx)
    -{ 
    -	struct pipe_screen *pscreen = nvfx->pipe.screen;
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -	struct nvfx_vertex_program *vp;
    -	struct pipe_buffer *constbuf;
    -	boolean upload_code = FALSE, upload_data = FALSE;
    -	int i;
    -
    -	if (nvfx->render_mode == HW) {
    -		vp = nvfx->vertprog;
    -		constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
    -
    -		if ((nvfx->dirty & NVFX_NEW_UCP) ||
    -		    memcmp(&nvfx->clip, &vp->ucp, sizeof(vp->ucp))) {
    -			nv40_vertprog_destroy(nvfx, vp);
    -			memcpy(&vp->ucp, &nvfx->clip, sizeof(vp->ucp));
    -		}
    -	} else {
    -		vp = nvfx->swtnl.vertprog;
    -		constbuf = NULL;
    -	}
    -
    -	/* Translate TGSI shader into hw bytecode */
    -	if (vp->translated)
    -		goto check_gpu_resources;
    -
    -	nvfx->fallback_swtnl &= ~NVFX_NEW_VERTPROG;
    -	nv40_vertprog_translate(nvfx, vp);
    -	if (!vp->translated) {
    -		nvfx->fallback_swtnl |= NVFX_NEW_VERTPROG;
    -		return FALSE;
    -	}
    -
    -check_gpu_resources:
    -	/* Allocate hw vtxprog exec slots */
    -	if (!vp->exec) {
    -		struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
    -		struct nouveau_stateobj *so;
    -		uint vplen = vp->nr_insns;
    -
    -		if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
    -			while (heap->next && heap->size < vplen) {
    -				struct nvfx_vertex_program *evict;
    -				
    -				evict = heap->next->priv;
    -				nouveau_resource_free(&evict->exec);
    -			}
    -
    -			if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec))
    -				assert(0);
    -		}
    -
    -		so = so_new(3, 4, 0);
    -		so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
    -		so_data  (so, vp->exec->start);
    -		so_method(so, eng3d, NV40TCL_VP_ATTRIB_EN, 2);
    -		so_data  (so, vp->ir);
    -		so_data  (so, vp->or);
    -		so_method(so, eng3d,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
    -		so_data  (so, vp->clip_ctrl);
    -		so_ref(so, &vp->so);
    -		so_ref(NULL, &so);
    -
    -		upload_code = TRUE;
    -	}
    -
    -	/* Allocate hw vtxprog const slots */
    -	if (vp->nr_consts && !vp->data) {
    -		struct nouveau_resource *heap = nvfx->screen->vp_data_heap;
    -
    -		if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
    -			while (heap->next && heap->size < vp->nr_consts) {
    -				struct nvfx_vertex_program *evict;
    -				
    -				evict = heap->next->priv;
    -				nouveau_resource_free(&evict->data);
    -			}
    -
    -			if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data))
    -				assert(0);
    -		}
    -
    -		/*XXX: handle this some day */
    -		assert(vp->data->start >= vp->data_start_min);
    -
    -		upload_data = TRUE;
    -		if (vp->data_start != vp->data->start)
    -			upload_code = TRUE;
    -	}
    -
    -	/* If exec or data segments moved we need to patch the program to
    -	 * fixup offsets and register IDs.
    -	 */
    -	if (vp->exec_start != vp->exec->start) {
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    -
    -			if (vpi->has_branch_offset) {
    -				assert(0);
    -			}
    -		}
    -
    -		vp->exec_start = vp->exec->start;
    -	}
    -
    -	if (vp->nr_consts && vp->data_start != vp->data->start) {
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    -
    -			if (vpi->const_index >= 0) {
    -				vpi->data[1] &= ~NV40_VP_INST_CONST_SRC_MASK;
    -				vpi->data[1] |=
    -					(vpi->const_index + vp->data->start) <<
    -					NV40_VP_INST_CONST_SRC_SHIFT;
    -
    -			}
    -		}
    -
    -		vp->data_start = vp->data->start;
    -	}
    -
    -	/* Update + Upload constant values */
    -	if (vp->nr_consts) {
    -		float *map = NULL;
    -
    -		if (constbuf) {
    -			map = pipe_buffer_map(pscreen, constbuf,
    -					      PIPE_BUFFER_USAGE_CPU_READ);
    -		}
    -
    -		for (i = 0; i < vp->nr_consts; i++) {
    -			struct nvfx_vertex_program_data *vpd = &vp->consts[i];
    -
    -			if (vpd->index >= 0) {
    -				if (!upload_data &&
    -				    !memcmp(vpd->value, &map[vpd->index * 4],
    -					    4 * sizeof(float)))
    -					continue;
    -				memcpy(vpd->value, &map[vpd->index * 4],
    -				       4 * sizeof(float));
    -			}
    -
    -			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_CONST_ID, 5);
    -			OUT_RING  (chan, i + vp->data->start);
    -			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
    -		}
    -
    -		if (constbuf)
    -			pscreen->buffer_unmap(pscreen, constbuf);
    -	}
    -
    -	/* Upload vtxprog */
    -	if (upload_code) {
    -#if 0
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[0]);
    -			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[1]);
    -			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[2]);
    -			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[3]);
    -		}
    -#endif
    -		BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_FROM_ID, 1);
    -		OUT_RING  (chan, vp->exec->start);
    -		for (i = 0; i < vp->nr_insns; i++) {
    -			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_INST(0), 4);
    -			OUT_RINGp (chan, vp->insns[i].data, 4);
    -		}
    -	}
    -
    -	if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
    -		so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
    -		return TRUE;
    -	}
    -
    -	return FALSE;
    -}
    -
    -void
    -nv40_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
    -{
    -	vp->translated = FALSE;
    -
    -	if (vp->nr_insns) {
    -		FREE(vp->insns);
    -		vp->insns = NULL;
    -		vp->nr_insns = 0;
    -	}
    -
    -	if (vp->nr_consts) {
    -		FREE(vp->consts);
    -		vp->consts = NULL;
    -		vp->nr_consts = 0;
    -	}
    -
    -	nouveau_resource_free(&vp->exec);
    -	vp->exec_start = 0;
    -	nouveau_resource_free(&vp->data);
    -	vp->data_start = 0;
    -	vp->data_start_min = 0;
    -
    -	vp->ir = vp->or = vp->clip_ctrl = 0;
    -	so_ref(NULL, &vp->so);
    -}
    -
    -struct nvfx_state_entry nv40_state_vertprog = {
    -	.validate = nv40_vertprog_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_VERTPROG | NVFX_NEW_UCP,
    -		.hw = NVFX_STATE_VERTPROG,
    -	}
    -};
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 6c4ee17493..a665c7e263 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -20,6 +20,7 @@ C_SOURCES = \
     	nvfx_state_zsa.c \
     	nvfx_surface.c \
     	nvfx_transfer.c \
    -	nvfx_vbo.c
    +	nvfx_vbo.c \
    +	nvfx_vertprog.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index ab1a1fbbe9..9a4b4631b5 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -190,6 +190,7 @@ extern struct nvfx_state_entry nvfx_state_scissor;
     extern struct nvfx_state_entry nvfx_state_sr;
     extern struct nvfx_state_entry nvfx_state_stipple;
     extern struct nvfx_state_entry nvfx_state_vbo;
    +extern struct nvfx_state_entry nvfx_state_vertprog;
     extern struct nvfx_state_entry nvfx_state_viewport;
     extern struct nvfx_state_entry nvfx_state_vtxfmt;
     extern struct nvfx_state_entry nvfx_state_zsa;
    @@ -234,8 +235,7 @@ extern void nvfx_draw_elements(struct pipe_context *pipe,
     				  unsigned count);
     
     /* nvfx_vertprog.c */
    -extern void nv30_vertprog_destroy(struct nvfx_context *,
    -				  struct nvfx_vertex_program *);
    -extern void nv40_vertprog_destroy(struct nvfx_context *,
    +extern void nvfx_vertprog_destroy(struct nvfx_context *,
     				  struct nvfx_vertex_program *);
    +
     #endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c
    index 76780dc4f5..7e138afc71 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state.c
    @@ -370,10 +370,7 @@ nvfx_vp_state_delete(struct pipe_context *pipe, void *hwcso)
     	struct nvfx_vertex_program *vp = hwcso;
     
     	draw_delete_vertex_shader(nvfx->draw, vp->draw);
    -	if(!nvfx->is_nv4x)
    -		nv30_vertprog_destroy(nvfx, vp);
    -	else
    -		nv40_vertprog_destroy(nvfx, vp);
    +	nvfx_vertprog_destroy(nvfx, vp);
     	FREE((void*)vp->pipe.tokens);
     	FREE(vp);
     }
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 88b86f9fb5..fcbf831050 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -11,7 +11,7 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	&nvfx_state_stipple, \
     	&nvfx_state_fragprog, \
     	&nvxx##_state_fragtex, \
    -	&nvxx##_state_vertprog, \
    +	&nvfx_state_vertprog, \
     	&nvfx_state_blend, \
     	&nvfx_state_blend_colour, \
     	&nvfx_state_zsa, \
    diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    new file mode 100644
    index 0000000000..730361a982
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    @@ -0,0 +1,1108 @@
    +#include "pipe/p_context.h"
    +#include "pipe/p_defines.h"
    +#include "pipe/p_state.h"
    +#include "util/u_inlines.h"
    +
    +#include "pipe/p_shader_tokens.h"
    +#include "tgsi/tgsi_parse.h"
    +#include "tgsi/tgsi_dump.h"
    +#include "tgsi/tgsi_util.h"
    +
    +#include "nvfx_context.h"
    +#include "nvfx_state.h"
    +
    +/* TODO (at least...):
    + *  1. Indexed consts  + ARL
    + *  3. NV_vp11, NV_vp2, NV_vp3 features
    + *       - extra arith opcodes
    + *       - branching
    + *       - texture sampling
    + *       - indexed attribs
    + *       - indexed results
    + *  4. bugs
    + */
    +
    +#define SWZ_X 0
    +#define SWZ_Y 1
    +#define SWZ_Z 2
    +#define SWZ_W 3
    +#define MASK_X 8
    +#define MASK_Y 4
    +#define MASK_Z 2
    +#define MASK_W 1
    +#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    +#define DEF_SCALE 0
    +#define DEF_CTEST 0
    +#include "nv30/nv30_shader.h"
    +#include "nv40/nv40_shader.h"
    +
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
    +
    +#define NVFX_VP_INST_DEST_CLIP(n) ((~0 - 6) + (n))
    +
    +struct nvfx_vpc {
    +	struct nvfx_vertex_program *vp;
    +
    +	struct nvfx_vertex_program_exec *vpi;
    +
    +	unsigned r_temps;
    +	unsigned r_temps_discard;
    +	struct nvfx_sreg r_result[PIPE_MAX_SHADER_OUTPUTS];
    +	struct nvfx_sreg *r_address;
    +	struct nvfx_sreg *r_temp;
    +
    +	struct nvfx_sreg *imm;
    +	unsigned nr_imm;
    +
    +	unsigned hpos_idx;
    +};
    +
    +static struct nvfx_sreg
    +temp(struct nvfx_vpc *vpc)
    +{
    +	int idx = ffs(~vpc->r_temps) - 1;
    +
    +	if (idx < 0) {
    +		NOUVEAU_ERR("out of temps!!\n");
    +		assert(0);
    +		return nvfx_sr(NVFXSR_TEMP, 0);
    +	}
    +
    +	vpc->r_temps |= (1 << idx);
    +	vpc->r_temps_discard |= (1 << idx);
    +	return nvfx_sr(NVFXSR_TEMP, idx);
    +}
    +
    +static INLINE void
    +release_temps(struct nvfx_vpc *vpc)
    +{
    +	vpc->r_temps &= ~vpc->r_temps_discard;
    +	vpc->r_temps_discard = 0;
    +}
    +
    +static struct nvfx_sreg
    +constant(struct nvfx_vpc *vpc, int pipe, float x, float y, float z, float w)
    +{
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +	struct nvfx_vertex_program_data *vpd;
    +	int idx;
    +
    +	if (pipe >= 0) {
    +		for (idx = 0; idx < vp->nr_consts; idx++) {
    +			if (vp->consts[idx].index == pipe)
    +				return nvfx_sr(NVFXSR_CONST, idx);
    +		}
    +	}
    +
    +	idx = vp->nr_consts++;
    +	vp->consts = realloc(vp->consts, sizeof(*vpd) * vp->nr_consts);
    +	vpd = &vp->consts[idx];
    +
    +	vpd->index = pipe;
    +	vpd->value[0] = x;
    +	vpd->value[1] = y;
    +	vpd->value[2] = z;
    +	vpd->value[3] = w;
    +	return nvfx_sr(NVFXSR_CONST, idx);
    +}
    +
    +#define arith(cc,s,o,d,m,s0,s1,s2) \
    +	nvfx_vp_arith(nvfx, (cc), NVFX_VP_INST_SLOT_##s, NVFX_VP_INST_##s##_OP_##o, (d), (m), (s0), (s1), (s2))
    +
    +static void
    +emit_src(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, uint32_t *hw, int pos, struct nvfx_sreg src)
    +{
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +	uint32_t sr = 0;
    +
    +	switch (src.type) {
    +	case NVFXSR_TEMP:
    +		sr |= (NVFX_VP(SRC_REG_TYPE_TEMP) << NVFX_VP(SRC_REG_TYPE_SHIFT));
    +		sr |= (src.index << NVFX_VP(SRC_TEMP_SRC_SHIFT));
    +		break;
    +	case NVFXSR_INPUT:
    +		sr |= (NVFX_VP(SRC_REG_TYPE_INPUT) <<
    +		       NVFX_VP(SRC_REG_TYPE_SHIFT));
    +		vp->ir |= (1 << src.index);
    +		hw[1] |= (src.index << NVFX_VP(INST_INPUT_SRC_SHIFT));
    +		break;
    +	case NVFXSR_CONST:
    +		sr |= (NVFX_VP(SRC_REG_TYPE_CONST) <<
    +		       NVFX_VP(SRC_REG_TYPE_SHIFT));
    +		assert(vpc->vpi->const_index == -1 ||
    +		       vpc->vpi->const_index == src.index);
    +		vpc->vpi->const_index = src.index;
    +		break;
    +	case NVFXSR_NONE:
    +		sr |= (NVFX_VP(SRC_REG_TYPE_INPUT) <<
    +		       NVFX_VP(SRC_REG_TYPE_SHIFT));
    +		break;
    +	default:
    +		assert(0);
    +	}
    +
    +	if (src.negate)
    +		sr |= NVFX_VP(SRC_NEGATE);
    +
    +	if (src.abs)
    +		hw[0] |= (1 << (21 + pos));
    +
    +	sr |= ((src.swz[0] << NVFX_VP(SRC_SWZ_X_SHIFT)) |
    +	       (src.swz[1] << NVFX_VP(SRC_SWZ_Y_SHIFT)) |
    +	       (src.swz[2] << NVFX_VP(SRC_SWZ_Z_SHIFT)) |
    +	       (src.swz[3] << NVFX_VP(SRC_SWZ_W_SHIFT)));
    +
    +	switch (pos) {
    +	case 0:
    +		hw[1] |= ((sr & NVFX_VP(SRC0_HIGH_MASK)) >>
    +			  NVFX_VP(SRC0_HIGH_SHIFT)) << NVFX_VP(INST_SRC0H_SHIFT);
    +		hw[2] |= (sr & NVFX_VP(SRC0_LOW_MASK)) <<
    +			  NVFX_VP(INST_SRC0L_SHIFT);
    +		break;
    +	case 1:
    +		hw[2] |= sr << NVFX_VP(INST_SRC1_SHIFT);
    +		break;
    +	case 2:
    +		hw[2] |= ((sr & NVFX_VP(SRC2_HIGH_MASK)) >>
    +			  NVFX_VP(SRC2_HIGH_SHIFT)) << NVFX_VP(INST_SRC2H_SHIFT);
    +		hw[3] |= (sr & NVFX_VP(SRC2_LOW_MASK)) <<
    +			  NVFX_VP(INST_SRC2L_SHIFT);
    +		break;
    +	default:
    +		assert(0);
    +	}
    +}
    +
    +static void
    +emit_dst(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, uint32_t *hw, int slot, struct nvfx_sreg dst)
    +{
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +
    +	switch (dst.type) {
    +	case NVFXSR_TEMP:
    +		if(!nvfx->is_nv4x)
    +			hw[0] |= (dst.index << NV30_VP_INST_DEST_TEMP_ID_SHIFT);
    +		else {
    +			hw[3] |= NV40_VP_INST_DEST_MASK;
    +			if (slot == 0) {
    +				hw[0] |= (dst.index <<
    +					  NV40_VP_INST_VEC_DEST_TEMP_SHIFT);
    +			} else {
    +				hw[3] |= (dst.index <<
    +					  NV40_VP_INST_SCA_DEST_TEMP_SHIFT);
    +			}
    +		}
    +		break;
    +	case NVFXSR_OUTPUT:
    +		/* TODO: this may be wrong because on nv30 COL0 and BFC0 are swapped */
    +		switch (dst.index) {
    +		case NVFX_VP_INST_DEST_CLIP(0):
    +			vp->or |= (1 << 6);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE0;
    +			dst.index = NVFX_VP(INST_DEST_FOGC);
    +			break;
    +		case NVFX_VP_INST_DEST_CLIP(1):
    +			vp->or |= (1 << 7);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE1;
    +			dst.index = NVFX_VP(INST_DEST_FOGC);
    +			break;
    +		case NVFX_VP_INST_DEST_CLIP(2):
    +			vp->or |= (1 << 8);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE2;
    +			dst.index = NVFX_VP(INST_DEST_FOGC);
    +			break;
    +		case NVFX_VP_INST_DEST_CLIP(3):
    +			vp->or |= (1 << 9);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE3;
    +			dst.index = NVFX_VP(INST_DEST_PSZ);
    +			break;
    +		case NVFX_VP_INST_DEST_CLIP(4):
    +			vp->or |= (1 << 10);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE4;
    +			dst.index = NVFX_VP(INST_DEST_PSZ);
    +			break;
    +		case NVFX_VP_INST_DEST_CLIP(5):
    +			vp->or |= (1 << 11);
    +			vp->clip_ctrl |= NV34TCL_VP_CLIP_PLANES_ENABLE_PLANE5;
    +			dst.index = NVFX_VP(INST_DEST_PSZ);
    +			break;
    +		default:
    +			if(!nvfx->is_nv4x) {
    +				switch (dst.index) {
    +				case NV30_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
    +				case NV30_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    +				case NV30_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break;
    +				case NV30_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break;
    +				case NV30_VP_INST_DEST_FOGC: vp->or |= (1 << 4); break;
    +				case NV30_VP_INST_DEST_PSZ  : vp->or |= (1 << 5); break;
    +				case NV30_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break;
    +				case NV30_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break;
    +				case NV30_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break;
    +				case NV30_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break;
    +				case NV30_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break;
    +				case NV30_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break;
    +				case NV30_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break;
    +				case NV30_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
    +				}
    +			} else {
    +				switch (dst.index) {
    +				case NV40_VP_INST_DEST_COL0 : vp->or |= (1 << 0); break;
    +				case NV40_VP_INST_DEST_COL1 : vp->or |= (1 << 1); break;
    +				case NV40_VP_INST_DEST_BFC0 : vp->or |= (1 << 2); break;
    +				case NV40_VP_INST_DEST_BFC1 : vp->or |= (1 << 3); break;
    +				case NV40_VP_INST_DEST_FOGC: vp->or |= (1 << 4); break;
    +				case NV40_VP_INST_DEST_PSZ  : vp->or |= (1 << 5); break;
    +				case NV40_VP_INST_DEST_TC(0): vp->or |= (1 << 14); break;
    +				case NV40_VP_INST_DEST_TC(1): vp->or |= (1 << 15); break;
    +				case NV40_VP_INST_DEST_TC(2): vp->or |= (1 << 16); break;
    +				case NV40_VP_INST_DEST_TC(3): vp->or |= (1 << 17); break;
    +				case NV40_VP_INST_DEST_TC(4): vp->or |= (1 << 18); break;
    +				case NV40_VP_INST_DEST_TC(5): vp->or |= (1 << 19); break;
    +				case NV40_VP_INST_DEST_TC(6): vp->or |= (1 << 20); break;
    +				case NV40_VP_INST_DEST_TC(7): vp->or |= (1 << 21); break;
    +				}
    +			}
    +			break;
    +		}
    +
    +		if(!nvfx->is_nv4x) {
    +			hw[3] |= (dst.index << NV30_VP_INST_DEST_SHIFT);
    +			hw[0] |= NV30_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
    +
    +			/*XXX: no way this is entirely correct, someone needs to
    +			 *     figure out what exactly it is.
    +			 */
    +			hw[3] |= 0x800;
    +		} else {
    +			hw[3] |= (dst.index << NV40_VP_INST_DEST_SHIFT);
    +			if (slot == 0) {
    +				hw[0] |= NV40_VP_INST_VEC_RESULT;
    +				hw[0] |= NV40_VP_INST_VEC_DEST_TEMP_MASK | (1<<20);
    +			} else {
    +				hw[3] |= NV40_VP_INST_SCA_RESULT;
    +				hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK;
    +			}
    +		}
    +		break;
    +	default:
    +		assert(0);
    +	}
    +}
    +
    +static void
    +nvfx_vp_arith(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, int slot, int op,
    +	      struct nvfx_sreg dst, int mask,
    +	      struct nvfx_sreg s0, struct nvfx_sreg s1,
    +	      struct nvfx_sreg s2)
    +{
    +	struct nvfx_vertex_program *vp = vpc->vp;
    +	uint32_t *hw;
    +
    +	vp->insns = realloc(vp->insns, ++vp->nr_insns * sizeof(*vpc->vpi));
    +	vpc->vpi = &vp->insns[vp->nr_insns - 1];
    +	memset(vpc->vpi, 0, sizeof(*vpc->vpi));
    +	vpc->vpi->const_index = -1;
    +
    +	hw = vpc->vpi->data;
    +
    +	hw[0] |= (NVFX_VP_INST_COND_TR << NVFX_VP(INST_COND_SHIFT));
    +	hw[0] |= ((0 << NVFX_VP(INST_COND_SWZ_X_SHIFT)) |
    +		  (1 << NVFX_VP(INST_COND_SWZ_Y_SHIFT)) |
    +		  (2 << NVFX_VP(INST_COND_SWZ_Z_SHIFT)) |
    +		  (3 << NVFX_VP(INST_COND_SWZ_W_SHIFT)));
    +
    +	if(!nvfx->is_nv4x) {
    +		hw[1] |= (op << NV30_VP_INST_VEC_OPCODE_SHIFT);
    +//		hw[3] |= NVFX_VP(INST_SCA_DEST_TEMP_MASK);
    +//		hw[3] |= (mask << NVFX_VP(INST_VEC_WRITEMASK_SHIFT));
    +
    +		if (dst.type == NVFXSR_OUTPUT) {
    +			if (slot)
    +				hw[3] |= (mask << NV30_VP_INST_SDEST_WRITEMASK_SHIFT);
    +			else
    +				hw[3] |= (mask << NV30_VP_INST_VDEST_WRITEMASK_SHIFT);
    +		} else {
    +			if (slot)
    +				hw[3] |= (mask << NV30_VP_INST_STEMP_WRITEMASK_SHIFT);
    +			else
    +				hw[3] |= (mask << NV30_VP_INST_VTEMP_WRITEMASK_SHIFT);
    +		}
    +	 } else {
    +		if (slot == 0) {
    +			hw[1] |= (op << NV40_VP_INST_VEC_OPCODE_SHIFT);
    +			hw[3] |= NV40_VP_INST_SCA_DEST_TEMP_MASK;
    +			hw[3] |= (mask << NV40_VP_INST_VEC_WRITEMASK_SHIFT);
    +	    } else {
    +			hw[1] |= (op << NV40_VP_INST_SCA_OPCODE_SHIFT);
    +			hw[0] |= (NV40_VP_INST_VEC_DEST_TEMP_MASK | (1 << 20));
    +			hw[3] |= (mask << NV40_VP_INST_SCA_WRITEMASK_SHIFT);
    +		}
    +	}
    +
    +	emit_dst(nvfx, vpc, hw, slot, dst);
    +	emit_src(nvfx, vpc, hw, 0, s0);
    +	emit_src(nvfx, vpc, hw, 1, s1);
    +	emit_src(nvfx, vpc, hw, 2, s2);
    +}
    +
    +static INLINE struct nvfx_sreg
    +tgsi_src(struct nvfx_vpc *vpc, const struct tgsi_full_src_register *fsrc) {
    +	struct nvfx_sreg src;
    +
    +	switch (fsrc->Register.File) {
    +	case TGSI_FILE_INPUT:
    +		src = nvfx_sr(NVFXSR_INPUT, fsrc->Register.Index);
    +		break;
    +	case TGSI_FILE_CONSTANT:
    +		src = constant(vpc, fsrc->Register.Index, 0, 0, 0, 0);
    +		break;
    +	case TGSI_FILE_IMMEDIATE:
    +		src = vpc->imm[fsrc->Register.Index];
    +		break;
    +	case TGSI_FILE_TEMPORARY:
    +		src = vpc->r_temp[fsrc->Register.Index];
    +		break;
    +	default:
    +		NOUVEAU_ERR("bad src file\n");
    +		break;
    +	}
    +
    +	src.abs = fsrc->Register.Absolute;
    +	src.negate = fsrc->Register.Negate;
    +	src.swz[0] = fsrc->Register.SwizzleX;
    +	src.swz[1] = fsrc->Register.SwizzleY;
    +	src.swz[2] = fsrc->Register.SwizzleZ;
    +	src.swz[3] = fsrc->Register.SwizzleW;
    +	return src;
    +}
    +
    +static INLINE struct nvfx_sreg
    +tgsi_dst(struct nvfx_vpc *vpc, const struct tgsi_full_dst_register *fdst) {
    +	struct nvfx_sreg dst;
    +
    +	switch (fdst->Register.File) {
    +	case TGSI_FILE_OUTPUT:
    +		dst = vpc->r_result[fdst->Register.Index];
    +		break;
    +	case TGSI_FILE_TEMPORARY:
    +		dst = vpc->r_temp[fdst->Register.Index];
    +		break;
    +	case TGSI_FILE_ADDRESS:
    +		dst = vpc->r_address[fdst->Register.Index];
    +		break;
    +	default:
    +		NOUVEAU_ERR("bad dst file\n");
    +		break;
    +	}
    +
    +	return dst;
    +}
    +
    +static INLINE int
    +tgsi_mask(uint tgsi)
    +{
    +	int mask = 0;
    +
    +	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    +	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    +	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    +	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    +	return mask;
    +}
    +
    +static boolean
    +src_native_swz(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, const struct tgsi_full_src_register *fsrc,
    +	       struct nvfx_sreg *src)
    +{
    +	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	struct nvfx_sreg tgsi = tgsi_src(vpc, fsrc);
    +	uint mask = 0;
    +	uint c;
    +
    +	for (c = 0; c < 4; c++) {
    +		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    +		case TGSI_SWIZZLE_X:
    +		case TGSI_SWIZZLE_Y:
    +		case TGSI_SWIZZLE_Z:
    +		case TGSI_SWIZZLE_W:
    +			mask |= tgsi_mask(1 << c);
    +			break;
    +		default:
    +			assert(0);
    +		}
    +	}
    +
    +	if (mask == MASK_ALL)
    +		return TRUE;
    +
    +	*src = temp(vpc);
    +
    +	if (mask)
    +		arith(vpc, VEC, MOV, *src, mask, tgsi, none, none);
    +
    +	return FALSE;
    +}
    +
    +static boolean
    +nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
    +				const struct tgsi_full_instruction *finst)
    +{
    +	struct nvfx_sreg src[3], dst, tmp;
    +	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	int mask;
    +	int ai = -1, ci = -1, ii = -1;
    +	int i;
    +
    +	if (finst->Instruction.Opcode == TGSI_OPCODE_END)
    +		return TRUE;
    +
    +	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    +		const struct tgsi_full_src_register *fsrc;
    +
    +		fsrc = &finst->Src[i];
    +		if (fsrc->Register.File == TGSI_FILE_TEMPORARY) {
    +			src[i] = tgsi_src(vpc, fsrc);
    +		}
    +	}
    +
    +	for (i = 0; i < finst->Instruction.NumSrcRegs; i++) {
    +		const struct tgsi_full_src_register *fsrc;
    +
    +		fsrc = &finst->Src[i];
    +
    +		switch (fsrc->Register.File) {
    +		case TGSI_FILE_INPUT:
    +		case TGSI_FILE_CONSTANT:
    +		case TGSI_FILE_TEMPORARY:
    +			if (!src_native_swz(nvfx, vpc, fsrc, &src[i]))
    +				continue;
    +			break;
    +		default:
    +			break;
    +		}
    +
    +		switch (fsrc->Register.File) {
    +		case TGSI_FILE_INPUT:
    +			if (ai == -1 || ai == fsrc->Register.Index) {
    +				ai = fsrc->Register.Index;
    +				src[i] = tgsi_src(vpc, fsrc);
    +			} else {
    +				src[i] = temp(vpc);
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				      tgsi_src(vpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_CONSTANT:
    +			if ((ci == -1 && ii == -1) ||
    +			    ci == fsrc->Register.Index) {
    +				ci = fsrc->Register.Index;
    +				src[i] = tgsi_src(vpc, fsrc);
    +			} else {
    +				src[i] = temp(vpc);
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				      tgsi_src(vpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_IMMEDIATE:
    +			if ((ci == -1 && ii == -1) ||
    +			    ii == fsrc->Register.Index) {
    +				ii = fsrc->Register.Index;
    +				src[i] = tgsi_src(vpc, fsrc);
    +			} else {
    +				src[i] = temp(vpc);
    +				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				      tgsi_src(vpc, fsrc), none, none);
    +			}
    +			break;
    +		case TGSI_FILE_TEMPORARY:
    +			/* handled above */
    +			break;
    +		default:
    +			NOUVEAU_ERR("bad src file\n");
    +			return FALSE;
    +		}
    +	}
    +
    +	dst  = tgsi_dst(vpc, &finst->Dst[0]);
    +	mask = tgsi_mask(finst->Dst[0].Register.WriteMask);
    +
    +	switch (finst->Instruction.Opcode) {
    +	case TGSI_OPCODE_ABS:
    +		arith(vpc, VEC, MOV, dst, mask, abs(src[0]), none, none);
    +		break;
    +	case TGSI_OPCODE_ADD:
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, src[1]);
    +		break;
    +	case TGSI_OPCODE_ARL:
    +		arith(vpc, VEC, ARL, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_DP3:
    +		arith(vpc, VEC, DP3, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_DP4:
    +		arith(vpc, VEC, DP4, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_DPH:
    +		arith(vpc, VEC, DPH, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_DST:
    +		arith(vpc, VEC, DST, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_EX2:
    +		arith(vpc, SCA, EX2, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_EXP:
    +		arith(vpc, SCA, EXP, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_FLR:
    +		arith(vpc, VEC, FLR, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_FRC:
    +		arith(vpc, VEC, FRC, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_LG2:
    +		arith(vpc, SCA, LG2, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_LIT:
    +		arith(vpc, SCA, LIT, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_LOG:
    +		arith(vpc, SCA, LOG, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_MAD:
    +		arith(vpc, VEC, MAD, dst, mask, src[0], src[1], src[2]);
    +		break;
    +	case TGSI_OPCODE_MAX:
    +		arith(vpc, VEC, MAX, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_MIN:
    +		arith(vpc, VEC, MIN, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_MOV:
    +		arith(vpc, VEC, MOV, dst, mask, src[0], none, none);
    +		break;
    +	case TGSI_OPCODE_MUL:
    +		arith(vpc, VEC, MUL, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_POW:
    +		tmp = temp(vpc);
    +		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
    +		      swz(src[0], X, X, X, X));
    +		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +		      swz(src[1], X, X, X, X), none);
    +		arith(vpc, SCA, EX2, dst, mask, none, none,
    +		      swz(tmp, X, X, X, X));
    +		break;
    +	case TGSI_OPCODE_RCP:
    +		arith(vpc, SCA, RCP, dst, mask, none, none, src[0]);
    +		break;
    +	case TGSI_OPCODE_RET:
    +		break;
    +	case TGSI_OPCODE_RSQ:
    +		arith(vpc, SCA, RSQ, dst, mask, none, none, abs(src[0]));
    +		break;
    +	case TGSI_OPCODE_SGE:
    +		arith(vpc, VEC, SGE, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SGT:
    +		arith(vpc, VEC, SGT, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SLT:
    +		arith(vpc, VEC, SLT, dst, mask, src[0], src[1], none);
    +		break;
    +	case TGSI_OPCODE_SUB:
    +		arith(vpc, VEC, ADD, dst, mask, src[0], none, neg(src[1]));
    +		break;
    +	case TGSI_OPCODE_XPD:
    +		tmp = temp(vpc);
    +		arith(vpc, VEC, MUL, tmp, mask,
    +		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    +		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
    +		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
    +		      neg(tmp));
    +		break;
    +	default:
    +		NOUVEAU_ERR("invalid opcode %d\n", finst->Instruction.Opcode);
    +		return FALSE;
    +	}
    +
    +	release_temps(vpc);
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_vertprog_parse_decl_output(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
    +				const struct tgsi_full_declaration *fdec)
    +{
    +	unsigned idx = fdec->Range.First;
    +	int hw;
    +
    +	switch (fdec->Semantic.Name) {
    +	case TGSI_SEMANTIC_POSITION:
    +		hw = NVFX_VP(INST_DEST_POS);
    +		vpc->hpos_idx = idx;
    +		break;
    +	case TGSI_SEMANTIC_COLOR:
    +		if (fdec->Semantic.Index == 0) {
    +			hw = NVFX_VP(INST_DEST_COL0);
    +		} else
    +		if (fdec->Semantic.Index == 1) {
    +			hw = NVFX_VP(INST_DEST_COL1);
    +		} else {
    +			NOUVEAU_ERR("bad colour semantic index\n");
    +			return FALSE;
    +		}
    +		break;
    +	case TGSI_SEMANTIC_BCOLOR:
    +		if (fdec->Semantic.Index == 0) {
    +			hw = NVFX_VP(INST_DEST_BFC0);
    +		} else
    +		if (fdec->Semantic.Index == 1) {
    +			hw = NVFX_VP(INST_DEST_BFC1);
    +		} else {
    +			NOUVEAU_ERR("bad bcolour semantic index\n");
    +			return FALSE;
    +		}
    +		break;
    +	case TGSI_SEMANTIC_FOG:
    +		hw = NVFX_VP(INST_DEST_FOGC);
    +		break;
    +	case TGSI_SEMANTIC_PSIZE:
    +		hw = NVFX_VP(INST_DEST_PSZ);
    +		break;
    +	case TGSI_SEMANTIC_GENERIC:
    +		if (fdec->Semantic.Index <= 7) {
    +			hw = NVFX_VP(INST_DEST_TC(fdec->Semantic.Index));
    +		} else {
    +			NOUVEAU_ERR("bad generic semantic index\n");
    +			return FALSE;
    +		}
    +		break;
    +	case TGSI_SEMANTIC_EDGEFLAG:
    +		/* not really an error just a fallback */
    +		NOUVEAU_ERR("cannot handle edgeflag output\n");
    +		return FALSE;
    +	default:
    +		NOUVEAU_ERR("bad output semantic\n");
    +		return FALSE;
    +	}
    +
    +	vpc->r_result[idx] = nvfx_sr(NVFXSR_OUTPUT, hw);
    +	return TRUE;
    +}
    +
    +static boolean
    +nvfx_vertprog_prepare(struct nvfx_context* nvfx, struct nvfx_vpc *vpc)
    +{
    +	struct tgsi_parse_context p;
    +	int high_temp = -1, high_addr = -1, nr_imm = 0, i;
    +
    +	tgsi_parse_init(&p, vpc->vp->pipe.tokens);
    +	while (!tgsi_parse_end_of_tokens(&p)) {
    +		const union tgsi_full_token *tok = &p.FullToken;
    +
    +		tgsi_parse_token(&p);
    +		switch(tok->Token.Type) {
    +		case TGSI_TOKEN_TYPE_IMMEDIATE:
    +			nr_imm++;
    +			break;
    +		case TGSI_TOKEN_TYPE_DECLARATION:
    +		{
    +			const struct tgsi_full_declaration *fdec;
    +
    +			fdec = &p.FullToken.FullDeclaration;
    +			switch (fdec->Declaration.File) {
    +			case TGSI_FILE_TEMPORARY:
    +				if (fdec->Range.Last > high_temp) {
    +					high_temp =
    +						fdec->Range.Last;
    +				}
    +				break;
    +#if 0 /* this would be nice.. except gallium doesn't track it */
    +			case TGSI_FILE_ADDRESS:
    +				if (fdec->Range.Last > high_addr) {
    +					high_addr =
    +						fdec->Range.Last;
    +				}
    +				break;
    +#endif
    +			case TGSI_FILE_OUTPUT:
    +				if (!nvfx_vertprog_parse_decl_output(nvfx, vpc, fdec))
    +					return FALSE;
    +				break;
    +			default:
    +				break;
    +			}
    +		}
    +			break;
    +#if 1 /* yay, parse instructions looking for address regs instead */
    +		case TGSI_TOKEN_TYPE_INSTRUCTION:
    +		{
    +			const struct tgsi_full_instruction *finst;
    +			const struct tgsi_full_dst_register *fdst;
    +
    +			finst = &p.FullToken.FullInstruction;
    +			fdst = &finst->Dst[0];
    +
    +			if (fdst->Register.File == TGSI_FILE_ADDRESS) {
    +				if (fdst->Register.Index > high_addr)
    +					high_addr = fdst->Register.Index;
    +			}
    +
    +		}
    +			break;
    +#endif
    +		default:
    +			break;
    +		}
    +	}
    +	tgsi_parse_free(&p);
    +
    +	if (nr_imm) {
    +		vpc->imm = CALLOC(nr_imm, sizeof(struct nvfx_sreg));
    +		assert(vpc->imm);
    +	}
    +
    +	if (++high_temp) {
    +		vpc->r_temp = CALLOC(high_temp, sizeof(struct nvfx_sreg));
    +		for (i = 0; i < high_temp; i++)
    +			vpc->r_temp[i] = temp(vpc);
    +	}
    +
    +	if (++high_addr) {
    +		vpc->r_address = CALLOC(high_addr, sizeof(struct nvfx_sreg));
    +		for (i = 0; i < high_addr; i++)
    +			vpc->r_address[i] = temp(vpc);
    +	}
    +
    +	vpc->r_temps_discard = 0;
    +	return TRUE;
    +}
    +
    +static void
    +nvfx_vertprog_translate(struct nvfx_context *nvfx,
    +			struct nvfx_vertex_program *vp)
    +{
    +	struct tgsi_parse_context parse;
    +	struct nvfx_vpc *vpc = NULL;
    +	struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    +	int i;
    +
    +	vpc = CALLOC(1, sizeof(struct nvfx_vpc));
    +	if (!vpc)
    +		return;
    +	vpc->vp = vp;
    +
    +	if (!nvfx_vertprog_prepare(nvfx, vpc)) {
    +		FREE(vpc);
    +		return;
    +	}
    +
    +	/* Redirect post-transform vertex position to a temp if user clip
    +	 * planes are enabled.  We need to append code to the vtxprog
    +	 * to handle clip planes later.
    +	 */
    +	if (vp->ucp.nr)  {
    +		vpc->r_result[vpc->hpos_idx] = temp(vpc);
    +		vpc->r_temps_discard = 0;
    +	}
    +
    +	tgsi_parse_init(&parse, vp->pipe.tokens);
    +
    +	while (!tgsi_parse_end_of_tokens(&parse)) {
    +		tgsi_parse_token(&parse);
    +
    +		switch (parse.FullToken.Token.Type) {
    +		case TGSI_TOKEN_TYPE_IMMEDIATE:
    +		{
    +			const struct tgsi_full_immediate *imm;
    +
    +			imm = &parse.FullToken.FullImmediate;
    +			assert(imm->Immediate.DataType == TGSI_IMM_FLOAT32);
    +			assert(imm->Immediate.NrTokens == 4 + 1);
    +			vpc->imm[vpc->nr_imm++] =
    +				constant(vpc, -1,
    +					 imm->u[0].Float,
    +					 imm->u[1].Float,
    +					 imm->u[2].Float,
    +					 imm->u[3].Float);
    +		}
    +			break;
    +		case TGSI_TOKEN_TYPE_INSTRUCTION:
    +		{
    +			const struct tgsi_full_instruction *finst;
    +			finst = &parse.FullToken.FullInstruction;
    +			if (!nvfx_vertprog_parse_instruction(nvfx, vpc, finst))
    +				goto out_err;
    +		}
    +			break;
    +		default:
    +			break;
    +		}
    +	}
    +
    +	/* Write out HPOS if it was redirected to a temp earlier */
    +	if (vpc->r_result[vpc->hpos_idx].type != NVFXSR_OUTPUT) {
    +		struct nvfx_sreg hpos = nvfx_sr(NVFXSR_OUTPUT,
    +						NVFX_VP(INST_DEST_POS));
    +		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
    +
    +		arith(vpc, VEC, MOV, hpos, MASK_ALL, htmp, none, none);
    +	}
    +
    +	/* Insert code to handle user clip planes */
    +	for (i = 0; i < vp->ucp.nr; i++) {
    +		struct nvfx_sreg cdst = nvfx_sr(NVFXSR_OUTPUT,
    +						NVFX_VP_INST_DEST_CLIP(i));
    +		struct nvfx_sreg ceqn = constant(vpc, -1,
    +						 nvfx->clip.ucp[i][0],
    +						 nvfx->clip.ucp[i][1],
    +						 nvfx->clip.ucp[i][2],
    +						 nvfx->clip.ucp[i][3]);
    +		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
    +		unsigned mask;
    +
    +		switch (i) {
    +		case 0: case 3: mask = MASK_Y; break;
    +		case 1: case 4: mask = MASK_Z; break;
    +		case 2: case 5: mask = MASK_W; break;
    +		default:
    +			NOUVEAU_ERR("invalid clip dist #%d\n", i);
    +			goto out_err;
    +		}
    +
    +		arith(vpc, VEC, DP4, cdst, mask, htmp, ceqn, none);
    +	}
    +
    +	vp->insns[vp->nr_insns - 1].data[3] |= NVFX_VP_INST_LAST;
    +	vp->translated = TRUE;
    +out_err:
    +	tgsi_parse_free(&parse);
    +	if (vpc->r_temp)
    +		FREE(vpc->r_temp);
    +	if (vpc->r_address)
    +		FREE(vpc->r_address);
    +	if (vpc->imm)
    +		FREE(vpc->imm);
    +	FREE(vpc);
    +}
    +
    +static boolean
    +nvfx_vertprog_validate(struct nvfx_context *nvfx)
    +{
    +	struct pipe_screen *pscreen = nvfx->pipe.screen;
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +	struct nvfx_vertex_program *vp;
    +	struct pipe_buffer *constbuf;
    +	boolean upload_code = FALSE, upload_data = FALSE;
    +	int i;
    +
    +	if (nvfx->render_mode == HW) {
    +		vp = nvfx->vertprog;
    +		constbuf = nvfx->constbuf[PIPE_SHADER_VERTEX];
    +
    +		if ((nvfx->dirty & NVFX_NEW_UCP) ||
    +		    memcmp(&nvfx->clip, &vp->ucp, sizeof(vp->ucp))) {
    +			nvfx_vertprog_destroy(nvfx, vp);
    +			memcpy(&vp->ucp, &nvfx->clip, sizeof(vp->ucp));
    +		}
    +	} else {
    +		vp = nvfx->swtnl.vertprog;
    +		constbuf = NULL;
    +	}
    +
    +	/* Translate TGSI shader into hw bytecode */
    +	if (vp->translated)
    +		goto check_gpu_resources;
    +
    +	nvfx->fallback_swtnl &= ~NVFX_NEW_VERTPROG;
    +		nvfx_vertprog_translate(nvfx, vp);
    +	if (!vp->translated) {
    +		nvfx->fallback_swtnl |= NVFX_NEW_VERTPROG;
    +			return FALSE;
    +	}
    +
    +check_gpu_resources:
    +	/* Allocate hw vtxprog exec slots */
    +	if (!vp->exec) {
    +		struct nouveau_resource *heap = nvfx->screen->vp_exec_heap;
    +		struct nouveau_stateobj *so;
    +		uint vplen = vp->nr_insns;
    +
    +		if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec)) {
    +			while (heap->next && heap->size < vplen) {
    +				struct nvfx_vertex_program *evict;
    +
    +				evict = heap->next->priv;
    +				nouveau_resource_free(&evict->exec);
    +			}
    +
    +			if (nouveau_resource_alloc(heap, vplen, vp, &vp->exec))
    +				assert(0);
    +		}
    +
    +		so = so_new(3, 4, 0);
    +		so_method(so, eng3d, NV34TCL_VP_START_FROM_ID, 1);
    +		so_data  (so, vp->exec->start);
    +		if(nvfx->is_nv4x) {
    +			so_method(so, eng3d, NV40TCL_VP_ATTRIB_EN, 2);
    +			so_data  (so, vp->ir);
    +			so_data  (so, vp->or);
    +		}
    +		so_method(so, eng3d,  NV34TCL_VP_CLIP_PLANES_ENABLE, 1);
    +		so_data  (so, vp->clip_ctrl);
    +		so_ref(so, &vp->so);
    +		so_ref(NULL, &so);
    +
    +		upload_code = TRUE;
    +	}
    +
    +	/* Allocate hw vtxprog const slots */
    +	if (vp->nr_consts && !vp->data) {
    +		struct nouveau_resource *heap = nvfx->screen->vp_data_heap;
    +
    +		if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data)) {
    +			while (heap->next && heap->size < vp->nr_consts) {
    +				struct nvfx_vertex_program *evict;
    +
    +				evict = heap->next->priv;
    +				nouveau_resource_free(&evict->data);
    +			}
    +
    +			if (nouveau_resource_alloc(heap, vp->nr_consts, vp, &vp->data))
    +				assert(0);
    +		}
    +
    +		/*XXX: handle this some day */
    +		assert(vp->data->start >= vp->data_start_min);
    +
    +		upload_data = TRUE;
    +		if (vp->data_start != vp->data->start)
    +			upload_code = TRUE;
    +	}
    +
    +	/* If exec or data segments moved we need to patch the program to
    +	 * fixup offsets and register IDs.
    +	 */
    +	if (vp->exec_start != vp->exec->start) {
    +		for (i = 0; i < vp->nr_insns; i++) {
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    +
    +			if (vpi->has_branch_offset) {
    +				assert(0);
    +			}
    +		}
    +
    +		vp->exec_start = vp->exec->start;
    +	}
    +
    +	if (vp->nr_consts && vp->data_start != vp->data->start) {
    +		for (i = 0; i < vp->nr_insns; i++) {
    +			struct nvfx_vertex_program_exec *vpi = &vp->insns[i];
    +
    +			if (vpi->const_index >= 0) {
    +				vpi->data[1] &= ~NVFX_VP(INST_CONST_SRC_MASK);
    +				vpi->data[1] |=
    +					(vpi->const_index + vp->data->start) <<
    +					NVFX_VP(INST_CONST_SRC_SHIFT);
    +
    +			}
    +		}
    +
    +		vp->data_start = vp->data->start;
    +	}
    +
    +	/* Update + Upload constant values */
    +	if (vp->nr_consts) {
    +		float *map = NULL;
    +
    +		if (constbuf) {
    +			map = pipe_buffer_map(pscreen, constbuf,
    +					      PIPE_BUFFER_USAGE_CPU_READ);
    +		}
    +
    +		for (i = 0; i < vp->nr_consts; i++) {
    +			struct nvfx_vertex_program_data *vpd = &vp->consts[i];
    +
    +			if (vpd->index >= 0) {
    +				if (!upload_data &&
    +				    !memcmp(vpd->value, &map[vpd->index * 4],
    +					    4 * sizeof(float)))
    +					continue;
    +				memcpy(vpd->value, &map[vpd->index * 4],
    +				       4 * sizeof(float));
    +			}
    +
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_CONST_ID, 5);
    +			OUT_RING  (chan, i + vp->data->start);
    +			OUT_RINGp (chan, (uint32_t *)vpd->value, 4);
    +		}
    +
    +		if (constbuf)
    +			pipe_buffer_unmap(pscreen, constbuf);
    +	}
    +
    +	/* Upload vtxprog */
    +	if (upload_code) {
    +#if 0
    +		for (i = 0; i < vp->nr_insns; i++) {
    +			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[0]);
    +			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[1]);
    +			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[2]);
    +			NOUVEAU_MSG("VP %d: 0x%08x\n", i, vp->insns[i].data[3]);
    +		}
    +#endif
    +		BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_FROM_ID, 1);
    +		OUT_RING  (chan, vp->exec->start);
    +		for (i = 0; i < vp->nr_insns; i++) {
    +			BEGIN_RING(chan, eng3d, NV34TCL_VP_UPLOAD_INST(0), 4);
    +			OUT_RINGp (chan, vp->insns[i].data, 4);
    +		}
    +	}
    +
    +	if (vp->so != nvfx->state.hw[NVFX_STATE_VERTPROG]) {
    +		so_ref(vp->so, &nvfx->state.hw[NVFX_STATE_VERTPROG]);
    +		return TRUE;
    +	}
    +
    +	return FALSE;
    +}
    +
    +void
    +nvfx_vertprog_destroy(struct nvfx_context *nvfx, struct nvfx_vertex_program *vp)
    +{
    +	vp->translated = FALSE;
    +
    +	if (vp->nr_insns) {
    +		FREE(vp->insns);
    +		vp->insns = NULL;
    +		vp->nr_insns = 0;
    +	}
    +
    +	if (vp->nr_consts) {
    +		FREE(vp->consts);
    +		vp->consts = NULL;
    +		vp->nr_consts = 0;
    +	}
    +
    +	nouveau_resource_free(&vp->exec);
    +	vp->exec_start = 0;
    +	nouveau_resource_free(&vp->data);
    +	vp->data_start = 0;
    +	vp->data_start_min = 0;
    +
    +	vp->ir = vp->or = vp->clip_ctrl = 0;
    +	so_ref(NULL, &vp->so);
    +}
    +
    +struct nvfx_state_entry nvfx_state_vertprog = {
    +	.validate = nvfx_vertprog_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_VERTPROG | NVFX_NEW_UCP,
    +		.hw = NVFX_STATE_VERTPROG,
    +	}
    +};
    -- 
    cgit v1.2.3
    
    
    From 10f464fc1073e8f3b53dbcf2209a2204f4924094 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 14:31:27 +0100
    Subject: nv30, nv40: non-trivially unify nv[34]0_screen.c
    
    The files have the same structure but are substantially different.
    
    They are unified with appropriate conditionals.
    ---
     src/gallium/drivers/nouveau/nouveau_winsys.h       |   5 +-
     src/gallium/drivers/nv30/Makefile                  |   1 -
     src/gallium/drivers/nv30/nv30_screen.c             | 361 -----------------
     src/gallium/drivers/nv40/Makefile                  |   1 -
     src/gallium/drivers/nv40/nv40_screen.c             | 322 ---------------
     src/gallium/drivers/nvfx/Makefile                  |   1 +
     src/gallium/drivers/nvfx/nvfx_screen.c             | 436 +++++++++++++++++++++
     .../winsys/drm/nouveau/drm/nouveau_drm_api.c       |   4 +-
     8 files changed, 439 insertions(+), 692 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_screen.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_screen.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_screen.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
    index af9ddd558c..bed014b9ce 100644
    --- a/src/gallium/drivers/nouveau/nouveau_winsys.h
    +++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
    @@ -27,10 +27,7 @@
     #define NOUVEAU_BUFFER_USAGE_NO_RENDER (1 << 19)
     
     extern struct pipe_screen *
    -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
    -
    -extern struct pipe_screen *
    -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
    +nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
     
     extern struct pipe_screen *
     nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index b71afbbb9a..ef3ce7eafa 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -6,7 +6,6 @@ LIBNAME = nv30
     C_SOURCES = \
     	nv30_context.c \
     	nv30_fragtex.c \
    -	nv30_screen.c \
     	nv30_state.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
    deleted file mode 100644
    index 3a48255c18..0000000000
    --- a/src/gallium/drivers/nv30/nv30_screen.c
    +++ /dev/null
    @@ -1,361 +0,0 @@
    -#include "pipe/p_screen.h"
    -#include "pipe/p_state.h"
    -
    -#include "nouveau/nouveau_screen.h"
    -
    -#include "nv30_context.h"
    -#include "nvfx_screen.h"
    -
    -#define NV30TCL_CHIPSET_3X_MASK 0x00000003
    -#define NV34TCL_CHIPSET_3X_MASK 0x00000010
    -#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
    -
    -/* FIXME: It seems I should not include directly ../../winsys/drm/nouveau/drm/nouveau_drm_api.h
    - * to get the pointer to the context front buffer, so I copied nouveau_winsys here.
    - * nv30_screen_surface_format_supported() can then use it to enforce creating fbo
    - * with same number of bits everywhere.
    - */
    -struct nouveau_winsys {
    -	struct pipe_winsys base;
    -
    -	struct pipe_screen *pscreen;
    -
    -	struct pipe_surface *front;
    -};
    -
    -static int
    -nv30_screen_get_param(struct pipe_screen *pscreen, int param)
    -{
    -	switch (param) {
    -	case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
    -		return 8;
    -	case PIPE_CAP_NPOT_TEXTURES:
    -		return 0;
    -	case PIPE_CAP_TWO_SIDED_STENCIL:
    -		return 1;
    -	case PIPE_CAP_GLSL:
    -		return 0;
    -	case PIPE_CAP_ANISOTROPIC_FILTER:
    -		return 1;
    -	case PIPE_CAP_POINT_SPRITE:
    -		return 1;
    -	case PIPE_CAP_MAX_RENDER_TARGETS:
    -		return 2;
    -	case PIPE_CAP_OCCLUSION_QUERY:
    -		return 1;
    -	case PIPE_CAP_TEXTURE_SHADOW_MAP:
    -		return 1;
    -	case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
    -		return 13;
    -	case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
    -		return 10;
    -	case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
    -		return 13;
    -	case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
    -		return 0;
    -	case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
    -		return 1;
    -	case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
    -		return 0;
    -	case PIPE_CAP_TGSI_CONT_SUPPORTED:
    -		return 0;
    -	case PIPE_CAP_BLEND_EQUATION_SEPARATE:
    -		return 0;
    -	case NOUVEAU_CAP_HW_VTXBUF:
    -	case NOUVEAU_CAP_HW_IDXBUF:
    -		return 1;
    -	case PIPE_CAP_MAX_COMBINED_SAMPLERS:
    -		return 16;
    -	case PIPE_CAP_INDEP_BLEND_ENABLE:
    -		return 0;
    -	case PIPE_CAP_INDEP_BLEND_FUNC:
    -		return 0;
    -	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
    -	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
    -		return 1;
    -	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
    -	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
    -		return 0;
    -	default:
    -		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    -		return 0;
    -	}
    -}
    -
    -static float
    -nv30_screen_get_paramf(struct pipe_screen *pscreen, int param)
    -{
    -	switch (param) {
    -	case PIPE_CAP_MAX_LINE_WIDTH:
    -	case PIPE_CAP_MAX_LINE_WIDTH_AA:
    -		return 10.0;
    -	case PIPE_CAP_MAX_POINT_WIDTH:
    -	case PIPE_CAP_MAX_POINT_WIDTH_AA:
    -		return 64.0;
    -	case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
    -		return 8.0;
    -	case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
    -		return 4.0;
    -	default:
    -		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    -		return 0.0;
    -	}
    -}
    -
    -static boolean
    -nv30_screen_surface_format_supported(struct pipe_screen *pscreen,
    -				     enum pipe_format format,
    -				     enum pipe_texture_target target,
    -				     unsigned tex_usage, unsigned geom_flags)
    -{
    -	struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
    -
    -	if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
    -		switch (format) {
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B5G6R5_UNORM:
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	} else
    -	if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
    -		switch (format) {
    -		case PIPE_FORMAT_S8Z24_UNORM:
    -		case PIPE_FORMAT_X8Z24_UNORM:
    -			return TRUE;
    -		case PIPE_FORMAT_Z16_UNORM:
    -			if (front) {
    -				return (front->format == PIPE_FORMAT_B5G6R5_UNORM);
    -			}
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	} else {
    -		switch (format) {
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B5G5R5A1_UNORM:
    -		case PIPE_FORMAT_B4G4R4A4_UNORM:
    -		case PIPE_FORMAT_B5G6R5_UNORM:
    -		case PIPE_FORMAT_L8_UNORM:
    -		case PIPE_FORMAT_A8_UNORM:
    -		case PIPE_FORMAT_I8_UNORM:
    -		case PIPE_FORMAT_L8A8_UNORM:
    -		case PIPE_FORMAT_Z16_UNORM:
    -		case PIPE_FORMAT_S8Z24_UNORM:
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	return FALSE;
    -}
    -
    -static struct pipe_buffer *
    -nv30_surface_buffer(struct pipe_surface *surf)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
    -
    -	return mt->buffer;
    -}
    -
    -static void
    -nv30_screen_destroy(struct pipe_screen *pscreen)
    -{
    -	struct nvfx_screen *screen = nvfx_screen(pscreen);
    -	unsigned i;
    -
    -	for (i = 0; i < NVFX_STATE_MAX; i++) {
    -		if (screen->state[i])
    -			so_ref(NULL, &screen->state[i]);
    -	}
    -
    -	nouveau_resource_destroy(&screen->vp_exec_heap);
    -	nouveau_resource_destroy(&screen->vp_data_heap);
    -	nouveau_resource_destroy(&screen->query_heap);
    -	nouveau_notifier_free(&screen->query);
    -	nouveau_notifier_free(&screen->sync);
    -	nouveau_grobj_free(&screen->eng3d);
    -	nv04_surface_2d_takedown(&screen->eng2d);
    -
    -	nouveau_screen_fini(&screen->base);
    -
    -	FREE(pscreen);
    -}
    -
    -struct pipe_screen *
    -nv30_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
    -{
    -	struct nvfx_screen *screen = CALLOC_STRUCT(nvfx_screen);
    -	struct nouveau_channel *chan;
    -	struct pipe_screen *pscreen;
    -	struct nouveau_stateobj *so;
    -	unsigned eng3d_class = 0;
    -	int ret, i;
    -
    -	if (!screen)
    -		return NULL;
    -	pscreen = &screen->base.base;
    -
    -	ret = nouveau_screen_init(&screen->base, dev);
    -	if (ret) {
    -		nv30_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -	chan = screen->base.channel;
    -
    -	pscreen->winsys = ws;
    -	pscreen->destroy = nv30_screen_destroy;
    -	pscreen->get_param = nv30_screen_get_param;
    -	pscreen->get_paramf = nv30_screen_get_paramf;
    -	pscreen->is_format_supported = nv30_screen_surface_format_supported;
    -	pscreen->context_create = nv30_create;
    -
    -	nvfx_screen_init_miptree_functions(pscreen);
    -
    -	/* 3D object */
    -	switch (dev->chipset & 0xf0) {
    -	case 0x30:
    -		if (NV30TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = 0x0397;
    -		else
    -		if (NV34TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = 0x0697;
    -		else
    -		if (NV35TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = 0x0497;
    -		break;
    -	default:
    -		break;
    -	}
    -
    -	if (!eng3d_class) {
    -		NOUVEAU_ERR("Unknown nv3x chipset: nv%02x\n", dev->chipset);
    -		return NULL;
    -	}
    -
    -	ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class,
    -				  &screen->eng3d);
    -	if (ret) {
    -		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
    -		return FALSE;
    -	}
    -
    -	/* 2D engine setup */
    -	screen->eng2d = nv04_surface_2d_init(&screen->base);
    -	screen->eng2d->buf = nv30_surface_buffer;
    -
    -	/* Notifier for sync purposes */
    -	ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
    -	if (ret) {
    -		NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
    -		nv30_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Query objects */
    -	ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query);
    -	if (ret) {
    -		NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
    -		nv30_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	ret = nouveau_resource_init(&screen->query_heap, 0, 32);
    -	if (ret) {
    -		NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
    -		nv30_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Vtxprog resources */
    -	if (nouveau_resource_init(&screen->vp_exec_heap, 0, 256) ||
    -	    nouveau_resource_init(&screen->vp_data_heap, 0, 256)) {
    -		nv30_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Static eng3d initialisation */
    -	so = so_new(36, 60, 0);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_NOTIFY, 1);
    -	so_data  (so, screen->sync->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_TEXTURE0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR1, 1);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_VTXBUF0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->gart->handle);
    -/*	so_method(so, screen->eng3d, NV34TCL_DMA_FENCE, 2);
    -	so_data  (so, 0);
    -	so_data  (so, screen->query->handle);*/
    -	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY7, 1);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY8, 1);
    -	so_data  (so, chan->vram->handle);
    -
    -	for (i=1; i<8; i++) {
    -		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
    -		so_data  (so, 0);
    -		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
    -		so_data  (so, 0);
    -	}
    -
    -	so_method(so, screen->eng3d, 0x220, 1);
    -	so_data  (so, 1);
    -
    -	so_method(so, screen->eng3d, 0x03b0, 1);
    -	so_data  (so, 0x00100000);
    -	so_method(so, screen->eng3d, 0x1454, 1);
    -	so_data  (so, 0);
    -	so_method(so, screen->eng3d, 0x1d80, 1);
    -	so_data  (so, 3);
    -	so_method(so, screen->eng3d, 0x1450, 1);
    -	so_data  (so, 0x00030004);
    -
    -	/* NEW */
    -	so_method(so, screen->eng3d, 0x1e98, 1);
    -	so_data  (so, 0);
    -	so_method(so, screen->eng3d, 0x17e0, 3);
    -	so_data  (so, fui(0.0));
    -	so_data  (so, fui(0.0));
    -	so_data  (so, fui(1.0));
    -	so_method(so, screen->eng3d, 0x1f80, 16);
    -	for (i=0; i<16; i++) {
    -		so_data  (so, (i==8) ? 0x0000ffff : 0);
    -	}
    -
    -	so_method(so, screen->eng3d, 0x120, 3);
    -	so_data  (so, 0);
    -	so_data  (so, 1);
    -	so_data  (so, 2);
    -
    -	so_method(so, screen->eng3d, 0x1d88, 1);
    -	so_data  (so, 0x00001200);
    -
    -	so_method(so, screen->eng3d, NV34TCL_RC_ENABLE, 1);
    -	so_data  (so, 0);
    -
    -	so_method(so, screen->eng3d, NV34TCL_DEPTH_RANGE_NEAR, 2);
    -	so_data  (so, fui(0.0));
    -	so_data  (so, fui(1.0));
    -
    -	so_method(so, screen->eng3d, NV34TCL_MULTISAMPLE_CONTROL, 1);
    -	so_data  (so, 0xffff0000);
    -
    -	/* enables use of vp rather than fixed-function somehow */
    -	so_method(so, screen->eng3d, 0x1e94, 1);
    -	so_data  (so, 0x13);
    -
    -	so_emit(chan, so);
    -	so_ref(NULL, &so);
    -	nouveau_pushbuf_flush(chan, 0);
    -
    -	return pscreen;
    -}
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index c8f3858c36..a37446d50c 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -6,7 +6,6 @@ LIBNAME = nv40
     C_SOURCES = \
     	nv40_context.c \
     	nv40_fragtex.c \
    -	nv40_screen.c \
     	nv40_state.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
    deleted file mode 100644
    index 0603b7d1c1..0000000000
    --- a/src/gallium/drivers/nv40/nv40_screen.c
    +++ /dev/null
    @@ -1,322 +0,0 @@
    -#include "pipe/p_screen.h"
    -
    -#include "nv40_context.h"
    -#include "nvfx_screen.h"
    -
    -#define NV4X_GRCLASS4097_CHIPSETS 0x00000baf
    -#define NV4X_GRCLASS4497_CHIPSETS 0x00005450
    -#define NV6X_GRCLASS4497_CHIPSETS 0x00000088
    -
    -static int
    -nv40_screen_get_param(struct pipe_screen *pscreen, int param)
    -{
    -	struct nvfx_screen *screen = nvfx_screen(pscreen);
    -
    -	switch (param) {
    -	case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
    -		return 16;
    -	case PIPE_CAP_NPOT_TEXTURES:
    -		return 1;
    -	case PIPE_CAP_TWO_SIDED_STENCIL:
    -		return 1;
    -	case PIPE_CAP_GLSL:
    -		return 0;
    -	case PIPE_CAP_ANISOTROPIC_FILTER:
    -		return 1;
    -	case PIPE_CAP_POINT_SPRITE:
    -		return 1;
    -	case PIPE_CAP_MAX_RENDER_TARGETS:
    -		return 4;
    -	case PIPE_CAP_OCCLUSION_QUERY:
    -		return 1;
    -	case PIPE_CAP_TEXTURE_SHADOW_MAP:
    -		return 1;
    -	case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
    -		return 13;
    -	case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
    -		return 10;
    -	case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
    -		return 13;
    -	case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
    -	case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
    -		return 1;
    -	case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
    -		return 0; /* We have 4 - but unsupported currently */
    -	case PIPE_CAP_TGSI_CONT_SUPPORTED:
    -		return 0;
    -	case PIPE_CAP_BLEND_EQUATION_SEPARATE:
    -		return 1;
    -	case NOUVEAU_CAP_HW_VTXBUF:
    -		return 1;
    -	case NOUVEAU_CAP_HW_IDXBUF:
    -		if (screen->eng3d->grclass == NV40TCL)
    -			return 1;
    -		return 0;
    -	case PIPE_CAP_INDEP_BLEND_ENABLE:
    -		return 0;
    -	case PIPE_CAP_INDEP_BLEND_FUNC:
    -		return 0;
    -	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
    -	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
    -		return 1;
    -	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
    -	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
    -		return 0;
    -	case PIPE_CAP_MAX_COMBINED_SAMPLERS:
    -		return 16;
    -	default:
    -		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    -		return 0;
    -	}
    -}
    -
    -static float
    -nv40_screen_get_paramf(struct pipe_screen *pscreen, int param)
    -{
    -	switch (param) {
    -	case PIPE_CAP_MAX_LINE_WIDTH:
    -	case PIPE_CAP_MAX_LINE_WIDTH_AA:
    -		return 10.0;
    -	case PIPE_CAP_MAX_POINT_WIDTH:
    -	case PIPE_CAP_MAX_POINT_WIDTH_AA:
    -		return 64.0;
    -	case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
    -		return 16.0;
    -	case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
    -		return 16.0;
    -	default:
    -		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    -		return 0.0;
    -	}
    -}
    -
    -static boolean
    -nv40_screen_surface_format_supported(struct pipe_screen *pscreen,
    -				     enum pipe_format format,
    -				     enum pipe_texture_target target,
    -				     unsigned tex_usage, unsigned geom_flags)
    -{
    -	if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
    -		switch (format) {
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B5G6R5_UNORM: 
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	} else
    -	if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
    -		switch (format) {
    -		case PIPE_FORMAT_S8Z24_UNORM:
    -		case PIPE_FORMAT_X8Z24_UNORM:
    -		case PIPE_FORMAT_Z16_UNORM:
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	} else {
    -		switch (format) {
    -		case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		case PIPE_FORMAT_B5G5R5A1_UNORM:
    -		case PIPE_FORMAT_B4G4R4A4_UNORM:
    -		case PIPE_FORMAT_B5G6R5_UNORM:
    -		case PIPE_FORMAT_R16_SNORM:
    -		case PIPE_FORMAT_L8_UNORM:
    -		case PIPE_FORMAT_A8_UNORM:
    -		case PIPE_FORMAT_I8_UNORM:
    -		case PIPE_FORMAT_L8A8_UNORM:
    -		case PIPE_FORMAT_Z16_UNORM:
    -		case PIPE_FORMAT_S8Z24_UNORM:
    -		case PIPE_FORMAT_DXT1_RGB:
    -		case PIPE_FORMAT_DXT1_RGBA:
    -		case PIPE_FORMAT_DXT3_RGBA:
    -		case PIPE_FORMAT_DXT5_RGBA:
    -			return TRUE;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	return FALSE;
    -}
    -
    -static struct pipe_buffer *
    -nv40_surface_buffer(struct pipe_surface *surf)
    -{
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
    -
    -	return mt->buffer;
    -}
    -
    -static void
    -nv40_screen_destroy(struct pipe_screen *pscreen)
    -{
    -	struct nvfx_screen *screen = nvfx_screen(pscreen);
    -	unsigned i;
    -
    -	for (i = 0; i < NVFX_STATE_MAX; i++) {
    -		if (screen->state[i])
    -			so_ref(NULL, &screen->state[i]);
    -	}
    -
    -	nouveau_resource_destroy(&screen->vp_exec_heap);
    -	nouveau_resource_destroy(&screen->vp_data_heap);
    -	nouveau_resource_destroy(&screen->query_heap);
    -	nouveau_notifier_free(&screen->query);
    -	nouveau_notifier_free(&screen->sync);
    -	nouveau_grobj_free(&screen->eng3d);
    -	nv04_surface_2d_takedown(&screen->eng2d);
    -
    -	nouveau_screen_fini(&screen->base);
    -
    -	FREE(pscreen);
    -}
    -
    -struct pipe_screen *
    -nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
    -{
    -	struct nvfx_screen *screen = CALLOC_STRUCT(nvfx_screen);
    -	struct nouveau_channel *chan;
    -	struct pipe_screen *pscreen;
    -	struct nouveau_stateobj *so;
    -	unsigned eng3d_class = 0;
    -	int ret;
    -
    -	if (!screen)
    -		return NULL;
    -
    -	screen->is_nv4x = ~0;
    -
    -	pscreen = &screen->base.base;
    -
    -	ret = nouveau_screen_init(&screen->base, dev);
    -	if (ret) {
    -		nv40_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -	chan = screen->base.channel;
    -
    -	pscreen->winsys = ws;
    -	pscreen->destroy = nv40_screen_destroy;
    -	pscreen->get_param = nv40_screen_get_param;
    -	pscreen->get_paramf = nv40_screen_get_paramf;
    -	pscreen->is_format_supported = nv40_screen_surface_format_supported;
    -	pscreen->context_create = nv40_create;
    -
    -	nvfx_screen_init_miptree_functions(pscreen);
    -
    -	/* 3D object */
    -	switch (dev->chipset & 0xf0) {
    -	case 0x40:
    -		if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = NV40TCL;
    -		else
    -		if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = NV44TCL;
    -		break;
    -	case 0x60:
    -		if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    -			eng3d_class = NV44TCL;
    -		break;
    -	}
    -
    -	if (!eng3d_class) {
    -		NOUVEAU_ERR("Unknown nv4x chipset: nv%02x\n", dev->chipset);
    -		return NULL;
    -	}
    -
    -	ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d);
    -	if (ret) {
    -		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
    -		return FALSE;
    -	}
    -
    -	/* 2D engine setup */
    -	screen->eng2d = nv04_surface_2d_init(&screen->base);
    -	screen->eng2d->buf = nv40_surface_buffer;
    -
    -	/* Notifier for sync purposes */
    -	ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
    -	if (ret) {
    -		NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
    -		nv40_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Query objects */
    -	ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query);
    -	if (ret) {
    -		NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
    -		nv40_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	nouveau_resource_init(&screen->query_heap, 0, 32);
    -	if (ret) {
    -		NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
    -		nv40_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Vtxprog resources */
    -	if (nouveau_resource_init(&screen->vp_exec_heap, 0, 512) ||
    -	    nouveau_resource_init(&screen->vp_data_heap, 0, 256)) {
    -		nv40_screen_destroy(pscreen);
    -		return NULL;
    -	}
    -
    -	/* Static eng3d initialisation */
    -	so = so_new(16, 25, 0);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_NOTIFY, 1);
    -	so_data  (so, screen->sync->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_TEXTURE0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR1, 1);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_VTXBUF0, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->gart->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_FENCE, 2);
    -	so_data  (so, 0);
    -	so_data  (so, screen->query->handle);
    -	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY7, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->vram->handle);
    -	so_method(so, screen->eng3d, NV40TCL_DMA_COLOR2, 2);
    -	so_data  (so, chan->vram->handle);
    -	so_data  (so, chan->vram->handle);
    -
    -	so_method(so, screen->eng3d, 0x1ea4, 3);
    -	so_data  (so, 0x00000010);
    -	so_data  (so, 0x01000100);
    -	so_data  (so, 0xff800006);
    -
    -	/* vtxprog output routing */
    -	so_method(so, screen->eng3d, 0x1fc4, 1);
    -	so_data  (so, 0x06144321);
    -	so_method(so, screen->eng3d, 0x1fc8, 2);
    -	so_data  (so, 0xedcba987);
    -	so_data  (so, 0x00000021);
    -	so_method(so, screen->eng3d, 0x1fd0, 1);
    -	so_data  (so, 0x00171615);
    -	so_method(so, screen->eng3d, 0x1fd4, 1);
    -	so_data  (so, 0x001b1a19);
    -
    -	so_method(so, screen->eng3d, 0x1ef8, 1);
    -	so_data  (so, 0x0020ffff);
    -	so_method(so, screen->eng3d, 0x1d64, 1);
    -	so_data  (so, 0x00d30000);
    -	so_method(so, screen->eng3d, 0x1e94, 1);
    -	so_data  (so, 0x00000001);
    -
    -	so_emit(chan, so);
    -	so_ref(NULL, &so);
    -	nouveau_pushbuf_flush(chan, 0);
    -
    -	return pscreen;
    -}
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index a665c7e263..e2c24ebc3c 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,7 @@ C_SOURCES = \
     	nvfx_fragprog.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
    +	nvfx_screen.c \
     	nvfx_state.c \
     	nvfx_state_blend.c \
             nvfx_state_emit.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
    new file mode 100644
    index 0000000000..6132cf94e2
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.c
    @@ -0,0 +1,436 @@
    +#include "pipe/p_screen.h"
    +#include "pipe/p_state.h"
    +
    +#include "nouveau/nouveau_screen.h"
    +
    +#include "nv30/nv30_context.h"
    +#include "nv40/nv40_context.h"
    +#include "nvfx_screen.h"
    +
    +#define NV30TCL_CHIPSET_3X_MASK 0x00000003
    +#define NV34TCL_CHIPSET_3X_MASK 0x00000010
    +#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
    +
    +/* FIXME: It seems I should not include directly ../../winsys/drm/nouveau/drm/nouveau_drm_api.h
    +* to get the pointer to the context front buffer, so I copied nouveau_winsys here.
    +* nv30_screen_surface_format_supported() can then use it to enforce creating fbo
    +* with same number of bits everywhere.
    +*/
    +struct nouveau_winsys {
    +	struct pipe_winsys base;
    +
    +	struct pipe_screen *pscreen;
    +
    +	struct pipe_surface *front;
    +};
    +#define NV4X_GRCLASS4097_CHIPSETS 0x00000baf
    +#define NV4X_GRCLASS4497_CHIPSETS 0x00005450
    +#define NV6X_GRCLASS4497_CHIPSETS 0x00000088
    +
    +static int
    +nvfx_screen_get_param(struct pipe_screen *pscreen, int param)
    +{
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
    +
    +	switch (param) {
    +	case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS:
    +		/* TODO: check this */
    +		return screen->is_nv4x ? 16 : 8;
    +	case PIPE_CAP_NPOT_TEXTURES:
    +		return !!screen->is_nv4x;
    +	case PIPE_CAP_TWO_SIDED_STENCIL:
    +		return 1;
    +	case PIPE_CAP_GLSL:
    +		return 0;
    +	case PIPE_CAP_ANISOTROPIC_FILTER:
    +		return 1;
    +	case PIPE_CAP_POINT_SPRITE:
    +		return 1;
    +	case PIPE_CAP_MAX_RENDER_TARGETS:
    +		return screen->is_nv4x ? 4 : 2;
    +	case PIPE_CAP_OCCLUSION_QUERY:
    +		return 1;
    +	case PIPE_CAP_TEXTURE_SHADOW_MAP:
    +		return 1;
    +	case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
    +		return 13;
    +	case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
    +		return 10;
    +	case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
    +		return 13;
    +	case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
    +		return !!screen->is_nv4x;
    +	case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
    +		return 1;
    +	case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS:
    +		return 0; /* We have 4 on nv40 - but unsupported currently */
    +	case PIPE_CAP_TGSI_CONT_SUPPORTED:
    +		return 0;
    +	case PIPE_CAP_BLEND_EQUATION_SEPARATE:
    +		return !!screen->is_nv4x;
    +	case NOUVEAU_CAP_HW_VTXBUF:
    +		/* TODO: this is almost surely wrong */
    +		return !!screen->is_nv4x;
    +	case NOUVEAU_CAP_HW_IDXBUF:
    +		/* TODO: this is also almost surely wrong */
    +		return screen->is_nv4x && screen->eng3d->grclass == NV40TCL;
    +	case PIPE_CAP_MAX_COMBINED_SAMPLERS:
    +		return 16;
    +	case PIPE_CAP_INDEP_BLEND_ENABLE:
    +		/* TODO: on nv40 we have separate color masks */
    +		/* TODO: nv40 mrt blending is probably broken */
    +		return 0;
    +	case PIPE_CAP_INDEP_BLEND_FUNC:
    +		return 0;
    +	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT:
    +	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER:
    +		return 1;
    +	case PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT:
    +	case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
    +		return 0;
    +	default:
    +		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    +		return 0;
    +	}
    +}
    +
    +static float
    +nvfx_screen_get_paramf(struct pipe_screen *pscreen, int param)
    +{
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
    +
    +	switch (param) {
    +	case PIPE_CAP_MAX_LINE_WIDTH:
    +	case PIPE_CAP_MAX_LINE_WIDTH_AA:
    +		return 10.0;
    +	case PIPE_CAP_MAX_POINT_WIDTH:
    +	case PIPE_CAP_MAX_POINT_WIDTH_AA:
    +		return 64.0;
    +	case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
    +		return screen->is_nv4x ? 16.0 : 8.0;
    +	case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
    +		return screen->is_nv4x ? 16.0 : 4.0;
    +	default:
    +		NOUVEAU_ERR("Unknown PIPE_CAP %d\n", param);
    +		return 0.0;
    +	}
    +}
    +
    +static boolean
    +nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
    +				     enum pipe_format format,
    +				     enum pipe_texture_target target,
    +				     unsigned tex_usage, unsigned geom_flags)
    +{
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
    +	struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
    +
    +	if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
    +		switch (format) {
    +		case PIPE_FORMAT_B8G8R8A8_UNORM:
    +		case PIPE_FORMAT_B5G6R5_UNORM:
    +			return TRUE;
    +		default:
    +			break;
    +		}
    +	} else
    +	if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
    +		switch (format) {
    +		case PIPE_FORMAT_S8Z24_UNORM:
    +		case PIPE_FORMAT_X8Z24_UNORM:
    +			return TRUE;
    +		case PIPE_FORMAT_Z16_UNORM:
    +			/* TODO: this nv30 limitation probably does not exist */
    +			if (!screen->is_nv4x && front)
    +				return (front->format == PIPE_FORMAT_B5G6R5_UNORM);
    +			return TRUE;
    +		default:
    +			break;
    +		}
    +	} else {
    +		switch (format) {
    +		case PIPE_FORMAT_B8G8R8A8_UNORM:
    +		case PIPE_FORMAT_B5G5R5A1_UNORM:
    +		case PIPE_FORMAT_B4G4R4A4_UNORM:
    +		case PIPE_FORMAT_B5G6R5_UNORM:
    +		case PIPE_FORMAT_L8_UNORM:
    +		case PIPE_FORMAT_A8_UNORM:
    +		case PIPE_FORMAT_I8_UNORM:
    +		case PIPE_FORMAT_L8A8_UNORM:
    +		case PIPE_FORMAT_Z16_UNORM:
    +		case PIPE_FORMAT_S8Z24_UNORM:
    +		case PIPE_FORMAT_DXT1_RGB:
    +		case PIPE_FORMAT_DXT1_RGBA:
    +		case PIPE_FORMAT_DXT3_RGBA:
    +		case PIPE_FORMAT_DXT5_RGBA:
    +			return TRUE;
    +		/* TODO: does nv30 support this? */
    +		case PIPE_FORMAT_R16_SNORM:
    +			return !!screen->is_nv4x;
    +		default:
    +			break;
    +		}
    +	}
    +
    +	return FALSE;
    +}
    +
    +static struct pipe_buffer *
    +nvfx_surface_buffer(struct pipe_surface *surf)
    +{
    +	struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
    +
    +	return mt->buffer;
    +}
    +
    +static void
    +nvfx_screen_destroy(struct pipe_screen *pscreen)
    +{
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
    +	unsigned i;
    +
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
    +		if (screen->state[i])
    +			so_ref(NULL, &screen->state[i]);
    +	}
    +
    +	nouveau_resource_destroy(&screen->vp_exec_heap);
    +	nouveau_resource_destroy(&screen->vp_data_heap);
    +	nouveau_resource_destroy(&screen->query_heap);
    +	nouveau_notifier_free(&screen->query);
    +	nouveau_notifier_free(&screen->sync);
    +	nouveau_grobj_free(&screen->eng3d);
    +	nv04_surface_2d_takedown(&screen->eng2d);
    +
    +	nouveau_screen_fini(&screen->base);
    +
    +	FREE(pscreen);
    +}
    +
    +static void nv30_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj* so)
    +{
    +	screen->base.base.context_create = nv30_create;
    +	int i;
    +
    +	/* TODO: perhaps we should do some of this on nv40 too? */
    +	for (i=1; i<8; i++) {
    +		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_HORIZ(i), 1);
    +		so_data  (so, 0);
    +		so_method(so, screen->eng3d, NV34TCL_VIEWPORT_CLIP_VERT(i), 1);
    +		so_data  (so, 0);
    +	}
    +
    +	so_method(so, screen->eng3d, 0x220, 1);
    +	so_data  (so, 1);
    +
    +	so_method(so, screen->eng3d, 0x03b0, 1);
    +	so_data  (so, 0x00100000);
    +	so_method(so, screen->eng3d, 0x1454, 1);
    +	so_data  (so, 0);
    +	so_method(so, screen->eng3d, 0x1d80, 1);
    +	so_data  (so, 3);
    +	so_method(so, screen->eng3d, 0x1450, 1);
    +	so_data  (so, 0x00030004);
    +
    +	/* NEW */
    +	so_method(so, screen->eng3d, 0x1e98, 1);
    +	so_data  (so, 0);
    +	so_method(so, screen->eng3d, 0x17e0, 3);
    +	so_data  (so, fui(0.0));
    +	so_data  (so, fui(0.0));
    +	so_data  (so, fui(1.0));
    +	so_method(so, screen->eng3d, 0x1f80, 16);
    +	for (i=0; i<16; i++) {
    +		so_data  (so, (i==8) ? 0x0000ffff : 0);
    +	}
    +
    +	so_method(so, screen->eng3d, 0x120, 3);
    +	so_data  (so, 0);
    +	so_data  (so, 1);
    +	so_data  (so, 2);
    +
    +	so_method(so, screen->eng3d, 0x1d88, 1);
    +	so_data  (so, 0x00001200);
    +
    +	so_method(so, screen->eng3d, NV34TCL_RC_ENABLE, 1);
    +	so_data  (so, 0);
    +
    +	so_method(so, screen->eng3d, NV34TCL_DEPTH_RANGE_NEAR, 2);
    +	so_data  (so, fui(0.0));
    +	so_data  (so, fui(1.0));
    +
    +	so_method(so, screen->eng3d, NV34TCL_MULTISAMPLE_CONTROL, 1);
    +	so_data  (so, 0xffff0000);
    +
    +	/* enables use of vp rather than fixed-function somehow */
    +	so_method(so, screen->eng3d, 0x1e94, 1);
    +	so_data  (so, 0x13);
    +}
    +
    +static void nv40_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj* so)
    +{
    +	screen->base.base.context_create = nv40_create;
    +
    +	so_method(so, screen->eng3d, NV40TCL_DMA_COLOR2, 2);
    +	so_data  (so, screen->base.channel->vram->handle);
    +	so_data  (so, screen->base.channel->vram->handle);
    +
    +	so_method(so, screen->eng3d, 0x1ea4, 3);
    +	so_data  (so, 0x00000010);
    +	so_data  (so, 0x01000100);
    +	so_data  (so, 0xff800006);
    +
    +	/* vtxprog output routing */
    +	so_method(so, screen->eng3d, 0x1fc4, 1);
    +	so_data  (so, 0x06144321);
    +	so_method(so, screen->eng3d, 0x1fc8, 2);
    +	so_data  (so, 0xedcba987);
    +	so_data  (so, 0x00000021);
    +	so_method(so, screen->eng3d, 0x1fd0, 1);
    +	so_data  (so, 0x00171615);
    +	so_method(so, screen->eng3d, 0x1fd4, 1);
    +	so_data  (so, 0x001b1a19);
    +
    +	so_method(so, screen->eng3d, 0x1ef8, 1);
    +	so_data  (so, 0x0020ffff);
    +	so_method(so, screen->eng3d, 0x1d64, 1);
    +	so_data  (so, 0x00d30000);
    +	so_method(so, screen->eng3d, 0x1e94, 1);
    +	so_data  (so, 0x00000001);
    +}
    +
    +struct pipe_screen *
    +nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
    +{
    +	struct nvfx_screen *screen = CALLOC_STRUCT(nvfx_screen);
    +	struct nouveau_channel *chan;
    +	struct pipe_screen *pscreen;
    +	struct nouveau_stateobj *so;
    +	unsigned eng3d_class = 0;
    +	int ret;
    +
    +	if (!screen)
    +		return NULL;
    +
    +	pscreen = &screen->base.base;
    +
    +	ret = nouveau_screen_init(&screen->base, dev);
    +	if (ret) {
    +		nvfx_screen_destroy(pscreen);
    +		return NULL;
    +	}
    +	chan = screen->base.channel;
    +
    +	pscreen->winsys = ws;
    +	pscreen->destroy = nvfx_screen_destroy;
    +	pscreen->get_param = nvfx_screen_get_param;
    +	pscreen->get_paramf = nvfx_screen_get_paramf;
    +	pscreen->is_format_supported = nvfx_screen_surface_format_supported;
    +
    +	switch (dev->chipset & 0xf0) {
    +	case 0x30:
    +		if (NV30TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = 0x0397;
    +		else if (NV34TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = 0x0697;
    +		else if (NV35TCL_CHIPSET_3X_MASK & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = 0x0497;
    +		break;
    +	case 0x40:
    +		if (NV4X_GRCLASS4097_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = NV40TCL;
    +		else if (NV4X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = NV44TCL;
    +		screen->is_nv4x = ~0;
    +		break;
    +	case 0x60:
    +		if (NV6X_GRCLASS4497_CHIPSETS & (1 << (dev->chipset & 0x0f)))
    +			eng3d_class = NV44TCL;
    +		screen->is_nv4x = ~0;
    +		break;
    +	}
    +
    +	if (!eng3d_class) {
    +		NOUVEAU_ERR("Unknown nv3x/nv4x chipset: nv%02x\n", dev->chipset);
    +		return NULL;
    +	}
    +
    +	nvfx_screen_init_miptree_functions(pscreen);
    +
    +	ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d);
    +	if (ret) {
    +		NOUVEAU_ERR("Error creating 3D object: %d\n", ret);
    +		return FALSE;
    +	}
    +
    +	/* 2D engine setup */
    +	screen->eng2d = nv04_surface_2d_init(&screen->base);
    +	screen->eng2d->buf = nvfx_surface_buffer;
    +
    +	/* Notifier for sync purposes */
    +	ret = nouveau_notifier_alloc(chan, 0xbeef0301, 1, &screen->sync);
    +	if (ret) {
    +		NOUVEAU_ERR("Error creating notifier object: %d\n", ret);
    +		nvfx_screen_destroy(pscreen);
    +		return NULL;
    +	}
    +
    +	/* Query objects */
    +	ret = nouveau_notifier_alloc(chan, 0xbeef0302, 32, &screen->query);
    +	if (ret) {
    +		NOUVEAU_ERR("Error initialising query objects: %d\n", ret);
    +		nvfx_screen_destroy(pscreen);
    +		return NULL;
    +	}
    +
    +	ret = nouveau_resource_init(&screen->query_heap, 0, 32);
    +	if (ret) {
    +		NOUVEAU_ERR("Error initialising query object heap: %d\n", ret);
    +		nvfx_screen_destroy(pscreen);
    +		return NULL;
    +	}
    +
    +	/* Vtxprog resources */
    +	if (nouveau_resource_init(&screen->vp_exec_heap, 0, screen->is_nv4x ? 512 : 256) ||
    +	    nouveau_resource_init(&screen->vp_data_heap, 0, 256)) {
    +		nvfx_screen_destroy(pscreen);
    +		return NULL;
    +	}
    +
    +	/* Static eng3d initialisation */
    +	/* make the so big and don't worry about exact values
    +	   since we it will be thrown away immediately after use */
    +	so = so_new(256, 256, 0);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_NOTIFY, 1);
    +	so_data  (so, screen->sync->handle);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_TEXTURE0, 2);
    +	so_data  (so, chan->vram->handle);
    +	so_data  (so, chan->gart->handle);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR1, 1);
    +	so_data  (so, chan->vram->handle);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_COLOR0, 2);
    +	so_data  (so, chan->vram->handle);
    +	so_data  (so, chan->vram->handle);
    +	so_method(so, screen->eng3d, NV34TCL_DMA_VTXBUF0, 2);
    +	so_data  (so, chan->vram->handle);
    +	so_data  (so, chan->gart->handle);
    +
    +	so_method(so, screen->eng3d, NV34TCL_DMA_FENCE, 2);
    +	so_data  (so, 0);
    +	so_data  (so, screen->query->handle);
    +
    +	so_method(so, screen->eng3d, NV34TCL_DMA_IN_MEMORY7, 2);
    +	so_data  (so, chan->vram->handle);
    +	so_data  (so, chan->vram->handle);
    +
    +	if(!screen->is_nv4x)
    +		nv30_screen_init(screen, so);
    +	else
    +		nv40_screen_init(screen, so);
    +
    +	so_emit(chan, so);
    +	so_ref(NULL, &so);
    +	nouveau_pushbuf_flush(chan, 0);
    +
    +	return pscreen;
    +}
    diff --git a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
    index 21517b4bb5..716d4bacd3 100644
    --- a/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
    +++ b/src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c
    @@ -86,11 +86,9 @@ nouveau_drm_create_screen(struct drm_api *api, int fd,
     
     	switch (dev->chipset & 0xf0) {
     	case 0x30:
    -		init = nv30_screen_create;
    -		break;
     	case 0x40:
     	case 0x60:
    -		init = nv40_screen_create;
    +		init = nvfx_screen_create;
     		break;
     	case 0x50:
     	case 0x80:
    -- 
    cgit v1.2.3
    
    
    From 6992be543383ba0850bd813153def24ab4e28911 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 14:38:04 +0100
    Subject: nv30, nv40: fully unify nv[34]0_context.h
    
    Move the remaining content to the common header.
    ---
     src/gallium/drivers/nv30/nv30_context.c    |  2 +-
     src/gallium/drivers/nv30/nv30_context.h    | 14 --------------
     src/gallium/drivers/nv30/nv30_fragtex.c    |  2 +-
     src/gallium/drivers/nv40/nv40_context.c    |  2 +-
     src/gallium/drivers/nv40/nv40_context.h    | 14 --------------
     src/gallium/drivers/nv40/nv40_fragtex.c    |  3 +--
     src/gallium/drivers/nvfx/nvfx_context.h    | 18 ++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_screen.c     |  3 +--
     src/gallium/drivers/nvfx/nvfx_state_emit.c |  3 +--
     9 files changed, 24 insertions(+), 37 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_context.h
     delete mode 100644 src/gallium/drivers/nv40/nv40_context.h
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    index 9ddb331e74..7e3fd83ee0 100644
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ b/src/gallium/drivers/nv30/nv30_context.c
    @@ -1,7 +1,7 @@
     #include "draw/draw_context.h"
     #include "pipe/p_defines.h"
     
    -#include "nv30_context.h"
    +#include "nvfx_context.h"
     #include "nvfx_screen.h"
     
     static void
    diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h
    deleted file mode 100644
    index eacbb1753d..0000000000
    --- a/src/gallium/drivers/nv30/nv30_context.h
    +++ /dev/null
    @@ -1,14 +0,0 @@
    -#ifndef __NV30_CONTEXT_H__
    -#define __NV30_CONTEXT_H__
    -
    -#include "nvfx_context.h"
    -
    -/* nv30_fragtex.c */
    -extern void nv30_fragtex_bind(struct nvfx_context *);
    -extern struct nvfx_state_entry nv30_state_fragtex;
    -
    -/* nvfx_context.c */
    -struct pipe_context *
    -nv30_create(struct pipe_screen *pscreen, void *priv);
    -
    -#endif
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    index 34e7dd5444..ab39dedae6 100644
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ b/src/gallium/drivers/nv30/nv30_fragtex.c
    @@ -1,6 +1,6 @@
     #include "util/u_format.h"
     
    -#include "nv30_context.h"
    +#include "nvfx_context.h"
     #include "nouveau/nouveau_util.h"
     
     #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    index 13bd50dd1d..5a526423ac 100644
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ b/src/gallium/drivers/nv40/nv40_context.c
    @@ -1,7 +1,7 @@
     #include "draw/draw_context.h"
     #include "pipe/p_defines.h"
     
    -#include "nv40_context.h"
    +#include "nvfx_context.h"
     #include "nvfx_screen.h"
     
     static void
    diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
    deleted file mode 100644
    index 8dc87e426f..0000000000
    --- a/src/gallium/drivers/nv40/nv40_context.h
    +++ /dev/null
    @@ -1,14 +0,0 @@
    -#ifndef __NV40_CONTEXT_H__
    -#define __NV40_CONTEXT_H__
    -
    -#include "nvfx_context.h"
    -
    -/* nv40_fragtex.c */
    -extern void nv40_fragtex_bind(struct nvfx_context *);
    -extern struct nvfx_state_entry nv40_state_fragtex;
    -
    -/* nvfx_context.c */
    -struct pipe_context *
    -nv40_create(struct pipe_screen *pscreen, void *priv);
    -
    -#endif
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index 0b46a5313b..29257173b8 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -1,6 +1,5 @@
     #include "util/u_format.h"
    -
    -#include "nv40_context.h"
    +#include "nvfx_context.h"
     
     #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw)            \
     {                                                                              \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 9a4b4631b5..46cc7362ea 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -198,6 +198,14 @@ extern struct nvfx_state_entry nvfx_state_zsa;
     extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
     extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
     
    +/* nv30_context.c */
    +struct pipe_context *
    +nv30_create(struct pipe_screen *pscreen, void *priv);
    +
    +/* nv40_context.c */
    +struct pipe_context *
    +nv40_create(struct pipe_screen *pscreen, void *priv);
    +
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
     		       const float *rgba, double depth, unsigned stencil);
    @@ -213,6 +221,16 @@ extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe,
     extern void nvfx_fragprog_destroy(struct nvfx_context *,
     				    struct nvfx_fragment_program *);
     
    +/* nv30_fragtex.c */
    +extern void nv30_init_sampler_functions(struct nvfx_context *nvfx);
    +extern void nv30_fragtex_bind(struct nvfx_context *);
    +extern struct nvfx_state_entry nv30_state_fragtex;
    +
    +/* nv40_fragtex.c */
    +extern void nv40_init_sampler_functions(struct nvfx_context *nvfx);
    +extern void nv40_fragtex_bind(struct nvfx_context *);
    +extern struct nvfx_state_entry nv40_state_fragtex;
    +
     /* nvfx_state.c */
     extern void nvfx_init_state_functions(struct nvfx_context *nvfx);
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
    index 6132cf94e2..0c906ecb1d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_screen.c
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.c
    @@ -3,8 +3,7 @@
     
     #include "nouveau/nouveau_screen.h"
     
    -#include "nv30/nv30_context.h"
    -#include "nv40/nv40_context.h"
    +#include "nvfx_context.h"
     #include "nvfx_screen.h"
     
     #define NV30TCL_CHIPSET_3X_MASK 0x00000003
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index fcbf831050..9d28b59074 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -1,5 +1,4 @@
    -#include "nv30/nv30_context.h"
    -#include "nv40/nv40_context.h"
    +#include "nvfx_context.h"
     #include "nvfx_state.h"
     #include "draw/draw_context.h"
     
    -- 
    cgit v1.2.3
    
    
    From da5103c3b382ca08368a19a195a24278596db4cb Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 14:40:32 +0100
    Subject: nv30, nv40: unify nv[34]0_context.c
    
    They are now almost identical, except for nv30 vs nv40 fragtex
    initialization.
    ---
     src/gallium/drivers/nv30/Makefile       |  1 -
     src/gallium/drivers/nv30/nv30_context.c | 90 ---------------------------------
     src/gallium/drivers/nv40/Makefile       |  1 -
     src/gallium/drivers/nv40/nv40_context.c | 90 ---------------------------------
     src/gallium/drivers/nvfx/Makefile       |  1 +
     src/gallium/drivers/nvfx/nvfx_context.c | 90 +++++++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_context.h |  8 +--
     src/gallium/drivers/nvfx/nvfx_screen.c  |  4 +-
     8 files changed, 94 insertions(+), 191 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_context.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_context.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_context.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index ef3ce7eafa..0a20de9e7a 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -4,7 +4,6 @@ include $(TOP)/configs/current
     LIBNAME = nv30
     
     C_SOURCES = \
    -	nv30_context.c \
     	nv30_fragtex.c \
     	nv30_state.c
     
    diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c
    deleted file mode 100644
    index 7e3fd83ee0..0000000000
    --- a/src/gallium/drivers/nv30/nv30_context.c
    +++ /dev/null
    @@ -1,90 +0,0 @@
    -#include "draw/draw_context.h"
    -#include "pipe/p_defines.h"
    -
    -#include "nvfx_context.h"
    -#include "nvfx_screen.h"
    -
    -static void
    -nv30_flush(struct pipe_context *pipe, unsigned flags,
    -	   struct pipe_fence_handle **fence)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
    -		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    -		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    -		OUT_RING  (chan, 1);
    -	}
    -
    -	FIRE_RING(chan);
    -	if (fence)
    -		*fence = NULL;
    -}
    -
    -static void
    -nv30_destroy(struct pipe_context *pipe)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned i;
    -
    -	for (i = 0; i < NVFX_STATE_MAX; i++) {
    -		if (nvfx->state.hw[i])
    -			so_ref(NULL, &nvfx->state.hw[i]);
    -	}
    -
    -	if (nvfx->draw)
    -		draw_destroy(nvfx->draw);
    -	FREE(nvfx);
    -}
    -
    -struct pipe_context *
    -nv30_create(struct pipe_screen *pscreen, void *priv)
    -{
    -	struct nvfx_screen *screen = nvfx_screen(pscreen);
    -	struct pipe_winsys *ws = pscreen->winsys;
    -	struct nvfx_context *nvfx;
    -	struct nouveau_winsys *nvws = screen->nvws;
    -
    -	nvfx = CALLOC(1, sizeof(struct nvfx_context));
    -	if (!nvfx)
    -		return NULL;
    -	nvfx->screen = screen;
    -
    -	nvfx->nvws = nvws;
    -
    -	nvfx->pipe.winsys = ws;
    -	nvfx->pipe.screen = pscreen;
    -	nvfx->pipe.priv = priv;
    -	nvfx->pipe.destroy = nv30_destroy;
    -	nvfx->pipe.draw_arrays = nvfx_draw_arrays;
    -	nvfx->pipe.draw_elements = nvfx_draw_elements;
    -	nvfx->pipe.clear = nvfx_clear;
    -	nvfx->pipe.flush = nv30_flush;
    -
    -	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    -	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
    -
    -	screen->base.channel->user_private = nvfx;
    -	screen->base.channel->flush_notify = nvfx_state_flush_notify;
    -
    -	nvfx->is_nv4x = screen->is_nv4x;
    -
    -	nvfx_init_query_functions(nvfx);
    -	nvfx_init_surface_functions(nvfx);
    -	nvfx_init_state_functions(nvfx);
    -	nvfx_init_transfer_functions(nvfx);
    -
    -	/* Create, configure, and install fallback swtnl path */
    -	nvfx->draw = draw_create();
    -	draw_wide_point_threshold(nvfx->draw, 9999999.0);
    -	draw_wide_line_threshold(nvfx->draw, 9999999.0);
    -	draw_enable_line_stipple(nvfx->draw, FALSE);
    -	draw_enable_point_sprites(nvfx->draw, FALSE);
    -	draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
    -
    -	return &nvfx->pipe;
    -}
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index a37446d50c..6e764512cf 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -4,7 +4,6 @@ include $(TOP)/configs/current
     LIBNAME = nv40
     
     C_SOURCES = \
    -	nv40_context.c \
     	nv40_fragtex.c \
     	nv40_state.c
     
    diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
    deleted file mode 100644
    index 5a526423ac..0000000000
    --- a/src/gallium/drivers/nv40/nv40_context.c
    +++ /dev/null
    @@ -1,90 +0,0 @@
    -#include "draw/draw_context.h"
    -#include "pipe/p_defines.h"
    -
    -#include "nvfx_context.h"
    -#include "nvfx_screen.h"
    -
    -static void
    -nv40_flush(struct pipe_context *pipe, unsigned flags,
    -	   struct pipe_fence_handle **fence)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	struct nvfx_screen *screen = nvfx->screen;
    -	struct nouveau_channel *chan = screen->base.channel;
    -	struct nouveau_grobj *eng3d = screen->eng3d;
    -
    -	if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
    -		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    -		OUT_RING  (chan, 2);
    -		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    -		OUT_RING  (chan, 1);
    -	}
    -
    -	FIRE_RING(chan);
    -	if (fence)
    -		*fence = NULL;
    -}
    -
    -static void
    -nv40_destroy(struct pipe_context *pipe)
    -{
    -	struct nvfx_context *nvfx = nvfx_context(pipe);
    -	unsigned i;
    -
    -	for (i = 0; i < NVFX_STATE_MAX; i++) {
    -		if (nvfx->state.hw[i])
    -			so_ref(NULL, &nvfx->state.hw[i]);
    -	}
    -
    -	if (nvfx->draw)
    -		draw_destroy(nvfx->draw);
    -	FREE(nvfx);
    -}
    -
    -struct pipe_context *
    -nv40_create(struct pipe_screen *pscreen, void *priv)
    -{
    -	struct nvfx_screen *screen = nvfx_screen(pscreen);
    -	struct pipe_winsys *ws = pscreen->winsys;
    -	struct nvfx_context *nvfx;
    -	struct nouveau_winsys *nvws = screen->nvws;
    -
    -	nvfx = CALLOC(1, sizeof(struct nvfx_context));
    -	if (!nvfx)
    -		return NULL;
    -	nvfx->screen = screen;
    -
    -	nvfx->nvws = nvws;
    -
    -	nvfx->pipe.winsys = ws;
    -	nvfx->pipe.priv = priv;
    -	nvfx->pipe.screen = pscreen;
    -	nvfx->pipe.destroy = nv40_destroy;
    -	nvfx->pipe.draw_arrays = nvfx_draw_arrays;
    -	nvfx->pipe.draw_elements = nvfx_draw_elements;
    -	nvfx->pipe.clear = nvfx_clear;
    -	nvfx->pipe.flush = nv40_flush;
    -
    -	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    -	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
    -
    -	screen->base.channel->user_private = nvfx;
    -	screen->base.channel->flush_notify = nvfx_state_flush_notify;
    -
    -	nvfx->is_nv4x = screen->is_nv4x;
    -
    -	nvfx_init_query_functions(nvfx);
    -	nvfx_init_surface_functions(nvfx);
    -	nvfx_init_state_functions(nvfx);
    -	nvfx_init_transfer_functions(nvfx);
    -
    -	/* Create, configure, and install fallback swtnl path */
    -	nvfx->draw = draw_create();
    -	draw_wide_point_threshold(nvfx->draw, 9999999.0);
    -	draw_wide_line_threshold(nvfx->draw, 9999999.0);
    -	draw_enable_line_stipple(nvfx->draw, FALSE);
    -	draw_enable_point_sprites(nvfx->draw, FALSE);
    -	draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
    -
    -	return &nvfx->pipe;
    -}
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index e2c24ebc3c..aa03a155e3 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -4,6 +4,7 @@ include $(TOP)/configs/current
     LIBNAME = nvfx
     
     C_SOURCES = \
    +	nvfx_context.c \
     	nvfx_clear.c \
     	nvfx_draw.c \
     	nvfx_fragprog.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.c b/src/gallium/drivers/nvfx/nvfx_context.c
    new file mode 100644
    index 0000000000..fc3cbdb558
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_context.c
    @@ -0,0 +1,90 @@
    +#include "draw/draw_context.h"
    +#include "pipe/p_defines.h"
    +
    +#include "nvfx_context.h"
    +#include "nvfx_screen.h"
    +
    +static void
    +nvfx_flush(struct pipe_context *pipe, unsigned flags,
    +	   struct pipe_fence_handle **fence)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_screen *screen = nvfx->screen;
    +	struct nouveau_channel *chan = screen->base.channel;
    +	struct nouveau_grobj *eng3d = screen->eng3d;
    +
    +	if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    +		OUT_RING  (chan, 2);
    +		BEGIN_RING(chan, eng3d, 0x1fd8, 1);
    +		OUT_RING  (chan, 1);
    +	}
    +
    +	FIRE_RING(chan);
    +	if (fence)
    +		*fence = NULL;
    +}
    +
    +static void
    +nvfx_destroy(struct pipe_context *pipe)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	unsigned i;
    +
    +	for (i = 0; i < NVFX_STATE_MAX; i++) {
    +		if (nvfx->state.hw[i])
    +			so_ref(NULL, &nvfx->state.hw[i]);
    +	}
    +
    +	if (nvfx->draw)
    +		draw_destroy(nvfx->draw);
    +	FREE(nvfx);
    +}
    +
    +struct pipe_context *
    +nvfx_create(struct pipe_screen *pscreen, void *priv)
    +{
    +	struct nvfx_screen *screen = nvfx_screen(pscreen);
    +	struct pipe_winsys *ws = pscreen->winsys;
    +	struct nvfx_context *nvfx;
    +	struct nouveau_winsys *nvws = screen->nvws;
    +
    +	nvfx = CALLOC(1, sizeof(struct nvfx_context));
    +	if (!nvfx)
    +		return NULL;
    +	nvfx->screen = screen;
    +
    +	nvfx->nvws = nvws;
    +
    +	nvfx->pipe.winsys = ws;
    +	nvfx->pipe.screen = pscreen;
    +	nvfx->pipe.priv = priv;
    +	nvfx->pipe.destroy = nvfx_destroy;
    +	nvfx->pipe.draw_arrays = nvfx_draw_arrays;
    +	nvfx->pipe.draw_elements = nvfx_draw_elements;
    +	nvfx->pipe.clear = nvfx_clear;
    +	nvfx->pipe.flush = nvfx_flush;
    +
    +	nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
    +	nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
    +
    +	screen->base.channel->user_private = nvfx;
    +	screen->base.channel->flush_notify = nvfx_state_flush_notify;
    +
    +	nvfx->is_nv4x = screen->is_nv4x;
    +
    +	nvfx_init_query_functions(nvfx);
    +	nvfx_init_surface_functions(nvfx);
    +	nvfx_init_state_functions(nvfx);
    +	nvfx_init_transfer_functions(nvfx);
    +
    +	/* Create, configure, and install fallback swtnl path */
    +	nvfx->draw = draw_create();
    +	draw_wide_point_threshold(nvfx->draw, 9999999.0);
    +	draw_wide_line_threshold(nvfx->draw, 9999999.0);
    +	draw_enable_line_stipple(nvfx->draw, FALSE);
    +	draw_enable_point_sprites(nvfx->draw, FALSE);
    +	draw_set_rasterize_stage(nvfx->draw, nvfx_draw_render_stage(nvfx));
    +
    +	return &nvfx->pipe;
    +}
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 46cc7362ea..0bd37a7ae8 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -198,13 +198,9 @@ extern struct nvfx_state_entry nvfx_state_zsa;
     extern void nvfx_init_query_functions(struct nvfx_context *nvfx);
     extern void nvfx_init_surface_functions(struct nvfx_context *nvfx);
     
    -/* nv30_context.c */
    +/* nvfx_context.c */
     struct pipe_context *
    -nv30_create(struct pipe_screen *pscreen, void *priv);
    -
    -/* nv40_context.c */
    -struct pipe_context *
    -nv40_create(struct pipe_screen *pscreen, void *priv);
    +nvfx_create(struct pipe_screen *pscreen, void *priv);
     
     /* nvfx_clear.c */
     extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
    index 0c906ecb1d..8138715cc7 100644
    --- a/src/gallium/drivers/nvfx/nvfx_screen.c
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.c
    @@ -208,7 +208,6 @@ nvfx_screen_destroy(struct pipe_screen *pscreen)
     
     static void nv30_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj* so)
     {
    -	screen->base.base.context_create = nv30_create;
     	int i;
     
     	/* TODO: perhaps we should do some of this on nv40 too? */
    @@ -268,8 +267,6 @@ static void nv30_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj
     
     static void nv40_screen_init(struct nvfx_screen *screen, struct nouveau_stateobj* so)
     {
    -	screen->base.base.context_create = nv40_create;
    -
     	so_method(so, screen->eng3d, NV40TCL_DMA_COLOR2, 2);
     	so_data  (so, screen->base.channel->vram->handle);
     	so_data  (so, screen->base.channel->vram->handle);
    @@ -325,6 +322,7 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
     	pscreen->get_param = nvfx_screen_get_param;
     	pscreen->get_paramf = nvfx_screen_get_paramf;
     	pscreen->is_format_supported = nvfx_screen_surface_format_supported;
    +	pscreen->context_create = nvfx_create;
     
     	switch (dev->chipset & 0xf0) {
     	case 0x30:
    -- 
    cgit v1.2.3
    
    
    From 5bb68e5d174afa7a177c5e972fa80bf66e37f6ab Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 15:07:17 +0100
    Subject: nv30, nv40: partially non-trivially unify nv[34]0_fragtex.c
    
    The bulk files cannot be unified, but the frontend can and allows to
    share some code and simplify state_emit.c
    ---
     src/gallium/drivers/nv30/nv30_fragtex.c    | 45 +--------------------------
     src/gallium/drivers/nv40/nv40_fragtex.c    | 46 +---------------------------
     src/gallium/drivers/nvfx/Makefile          |  1 +
     src/gallium/drivers/nvfx/nvfx_context.h    |  7 +++--
     src/gallium/drivers/nvfx/nvfx_fragtex.c    | 49 ++++++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_state_emit.c | 22 +++++---------
     6 files changed, 64 insertions(+), 106 deletions(-)
     create mode 100644 src/gallium/drivers/nvfx/nvfx_fragtex.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    index ab39dedae6..52f7c52a9b 100644
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ b/src/gallium/drivers/nv30/nv30_fragtex.c
    @@ -57,7 +57,7 @@ nv30_fragtex_format(uint pipe_format)
     }
     
     
    -static struct nouveau_stateobj *
    +struct nouveau_stateobj *
     nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
     {
     	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    @@ -116,46 +116,3 @@ nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
     	return so;
     }
     
    -static boolean
    -nv30_fragtex_validate(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_fragment_program *fp = nvfx->fragprog;
    -	struct nvfx_state *state = &nvfx->state;
    -	struct nouveau_stateobj *so;
    -	unsigned samplers, unit;
    -
    -	samplers = state->fp_samplers & ~fp->samplers;
    -	while (samplers) {
    -		unit = ffs(samplers) - 1;
    -		samplers &= ~(1 << unit);
    -
    -		so = so_new(1, 1, 0);
    -		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
    -		so_data  (so, 0);
    -		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    -		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    -	}
    -
    -	samplers = nvfx->dirty_samplers & fp->samplers;
    -	while (samplers) {
    -		unit = ffs(samplers) - 1;
    -		samplers &= ~(1 << unit);
    -
    -		so = nv30_fragtex_build(nvfx, unit);
    -		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    -		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    -	}
    -
    -	nvfx->state.fp_samplers = fp->samplers;
    -	return FALSE;
    -}
    -
    -struct nvfx_state_entry nv30_state_fragtex = {
    -	.validate = nv30_fragtex_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
    -		.hw = 0
    -	}
    -};
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index 29257173b8..7615095025 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -59,7 +59,7 @@ nv40_fragtex_format(uint pipe_format)
     }
     
     
    -static struct nouveau_stateobj *
    +struct nouveau_stateobj *
     nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
     {
     	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    @@ -126,47 +126,3 @@ nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
     
     	return so;
     }
    -
    -static boolean
    -nv40_fragtex_validate(struct nvfx_context *nvfx)
    -{
    -	struct nvfx_fragment_program *fp = nvfx->fragprog;
    -	struct nvfx_state *state = &nvfx->state;
    -	struct nouveau_stateobj *so;
    -	unsigned samplers, unit;
    -
    -	samplers = state->fp_samplers & ~fp->samplers;
    -	while (samplers) {
    -		unit = ffs(samplers) - 1;
    -		samplers &= ~(1 << unit);
    -
    -		so = so_new(1, 1, 0);
    -		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
    -		so_data  (so, 0);
    -		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    -		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    -	}
    -
    -	samplers = nvfx->dirty_samplers & fp->samplers;
    -	while (samplers) {
    -		unit = ffs(samplers) - 1;
    -		samplers &= ~(1 << unit);
    -
    -		so = nv40_fragtex_build(nvfx, unit);
    -		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    -		so_ref(NULL, &so);
    -		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    -	}
    -
    -	nvfx->state.fp_samplers = fp->samplers;
    -	return FALSE;
    -}
    -
    -struct nvfx_state_entry nv40_state_fragtex = {
    -	.validate = nv40_fragtex_validate,
    -	.dirty = {
    -		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
    -		.hw = 0
    -	}
    -};
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index aa03a155e3..51fa34cfad 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -8,6 +8,7 @@ C_SOURCES = \
     	nvfx_clear.c \
     	nvfx_draw.c \
     	nvfx_fragprog.c \
    +	nvfx_fragtex.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
     	nvfx_screen.c \
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index 0bd37a7ae8..e538904298 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -184,6 +184,7 @@ struct nvfx_state_entry {
     extern struct nvfx_state_entry nvfx_state_blend;
     extern struct nvfx_state_entry nvfx_state_blend_colour;
     extern struct nvfx_state_entry nvfx_state_fragprog;
    +extern struct nvfx_state_entry nvfx_state_fragtex;
     extern struct nvfx_state_entry nvfx_state_framebuffer;
     extern struct nvfx_state_entry nvfx_state_rasterizer;
     extern struct nvfx_state_entry nvfx_state_scissor;
    @@ -220,12 +221,14 @@ extern void nvfx_fragprog_destroy(struct nvfx_context *,
     /* nv30_fragtex.c */
     extern void nv30_init_sampler_functions(struct nvfx_context *nvfx);
     extern void nv30_fragtex_bind(struct nvfx_context *);
    -extern struct nvfx_state_entry nv30_state_fragtex;
    +extern struct nouveau_stateobj *
    +nv30_fragtex_build(struct nvfx_context *nvfx, int unit);
     
     /* nv40_fragtex.c */
     extern void nv40_init_sampler_functions(struct nvfx_context *nvfx);
     extern void nv40_fragtex_bind(struct nvfx_context *);
    -extern struct nvfx_state_entry nv40_state_fragtex;
    +extern struct nouveau_stateobj *
    +nv40_fragtex_build(struct nvfx_context *nvfx, int unit);
     
     /* nvfx_state.c */
     extern void nvfx_init_state_functions(struct nvfx_context *nvfx);
    diff --git a/src/gallium/drivers/nvfx/nvfx_fragtex.c b/src/gallium/drivers/nvfx/nvfx_fragtex.c
    new file mode 100644
    index 0000000000..84e4eb1004
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_fragtex.c
    @@ -0,0 +1,49 @@
    +#include "nvfx_context.h"
    +
    +static boolean
    +nvfx_fragtex_validate(struct nvfx_context *nvfx)
    +{
    +	struct nvfx_fragment_program *fp = nvfx->fragprog;
    +	struct nvfx_state *state = &nvfx->state;
    +	struct nouveau_stateobj *so;
    +	unsigned samplers, unit;
    +
    +	samplers = state->fp_samplers & ~fp->samplers;
    +	while (samplers) {
    +		unit = ffs(samplers) - 1;
    +		samplers &= ~(1 << unit);
    +
    +		so = so_new(1, 1, 0);
    +		so_method(so, nvfx->screen->eng3d, NV34TCL_TX_ENABLE(unit), 1);
    +		so_data  (so, 0);
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    +		so_ref(NULL, &so);
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    +	}
    +
    +	samplers = nvfx->dirty_samplers & fp->samplers;
    +	while (samplers) {
    +		unit = ffs(samplers) - 1;
    +		samplers &= ~(1 << unit);
    +
    +		if(!nvfx->is_nv4x)
    +			so = nv30_fragtex_build(nvfx, unit);
    +		else
    +			so = nv40_fragtex_build(nvfx, unit);
    +
    +		so_ref(so, &nvfx->state.hw[NVFX_STATE_FRAGTEX0 + unit]);
    +		so_ref(NULL, &so);
    +		state->dirty |= (1ULL << (NVFX_STATE_FRAGTEX0 + unit));
    +	}
    +
    +	nvfx->state.fp_samplers = fp->samplers;
    +	return FALSE;
    +}
    +
    +struct nvfx_state_entry nvfx_state_fragtex = {
    +	.validate = nvfx_fragtex_validate,
    +	.dirty = {
    +		.pipe = NVFX_NEW_SAMPLER | NVFX_NEW_FRAGPROG,
    +		.hw = 0
    +	}
    +};
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_emit.c b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    index 9d28b59074..72537388ea 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_emit.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_emit.c
    @@ -2,14 +2,14 @@
     #include "nvfx_state.h"
     #include "draw/draw_context.h"
     
    -#define RENDER_STATES(name, nvxx, vbo) \
    -static struct nvfx_state_entry *name##_render_states[] = { \
    +#define RENDER_STATES(name, vbo) \
    +static struct nvfx_state_entry *name##render_states[] = { \
     	&nvfx_state_framebuffer, \
     	&nvfx_state_rasterizer, \
     	&nvfx_state_scissor, \
     	&nvfx_state_stipple, \
     	&nvfx_state_fragprog, \
    -	&nvxx##_state_fragtex, \
    +	&nvfx_state_fragtex, \
     	&nvfx_state_vertprog, \
     	&nvfx_state_blend, \
     	&nvfx_state_blend_colour, \
    @@ -20,10 +20,8 @@ static struct nvfx_state_entry *name##_render_states[] = { \
     	NULL \
     }
     
    -RENDER_STATES(nv30, nv30, vbo);
    -RENDER_STATES(nv30_swtnl, nv30, vtxfmt);
    -RENDER_STATES(nv40, nv40, vbo);
    -RENDER_STATES(nv40_swtnl, nv40, vtxfmt);
    +RENDER_STATES(, vbo);
    +RENDER_STATES(swtnl_, vtxfmt);
     
     static void
     nvfx_state_do_validate(struct nvfx_context *nvfx,
    @@ -126,10 +124,7 @@ nvfx_state_validate(struct nvfx_context *nvfx)
     		nvfx->render_mode = HW;
     	}
     
    -	if(!nvfx->is_nv4x)
    -		nvfx_state_do_validate(nvfx, nv30_render_states);
    -	else
    -		nvfx_state_do_validate(nvfx, nv40_render_states);
    +	nvfx_state_do_validate(nvfx, render_states);
     
     	if (nvfx->fallback_swtnl || nvfx->fallback_swrast)
     		return FALSE;
    @@ -172,10 +167,7 @@ nvfx_state_validate_swtnl(struct nvfx_context *nvfx)
     		draw_set_vertex_elements(draw, nvfx->vtxelt->num_elements, nvfx->vtxelt->pipe);
     	}
     
    -	if(!nvfx->is_nv4x)
    -		nvfx_state_do_validate(nvfx, nv30_swtnl_render_states);
    -	else
    -		nvfx_state_do_validate(nvfx, nv40_swtnl_render_states);
    +	nvfx_state_do_validate(nvfx, swtnl_render_states);
     
     	if (nvfx->fallback_swrast) {
     		NOUVEAU_ERR("swtnl->swrast 0x%08x\n", nvfx->fallback_swrast);
    -- 
    cgit v1.2.3
    
    
    From 7d210fa05f286eb19398ac2f8c8f631f6f83c859 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Wed, 24 Feb 2010 15:08:48 +0100
    Subject: nv30, nv40: partially non-trivially unify sampler state in
     nv[34]0_state.c
    
    Many things, like texture wrap modes and min/mag filters are common.
    
    Some others, like annisotropy and lod settings, are not.
    ---
     src/gallium/drivers/nv30/Makefile       |   3 +-
     src/gallium/drivers/nv30/nv30_fragtex.c |  30 +++++
     src/gallium/drivers/nv30/nv30_state.c   | 179 ------------------------------
     src/gallium/drivers/nv40/Makefile       |   3 +-
     src/gallium/drivers/nv40/nv40_fragtex.c |  46 ++++++++
     src/gallium/drivers/nv40/nv40_state.c   | 190 --------------------------------
     src/gallium/drivers/nvfx/nvfx_context.h |  10 +-
     src/gallium/drivers/nvfx/nvfx_state.c   |  49 +++++---
     src/gallium/drivers/nvfx/nvfx_state.h   |   8 --
     src/gallium/drivers/nvfx/nvfx_tex.h     | 133 ++++++++++++++++++++++
     10 files changed, 252 insertions(+), 399 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/nv30_state.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_state.c
     create mode 100644 src/gallium/drivers/nvfx/nvfx_tex.h
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    index 0a20de9e7a..70741101d6 100644
    --- a/src/gallium/drivers/nv30/Makefile
    +++ b/src/gallium/drivers/nv30/Makefile
    @@ -4,8 +4,7 @@ include $(TOP)/configs/current
     LIBNAME = nv30
     
     C_SOURCES = \
    -	nv30_fragtex.c \
    -	nv30_state.c
    +	nv30_fragtex.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
     
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    index 52f7c52a9b..081362d150 100644
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ b/src/gallium/drivers/nv30/nv30_fragtex.c
    @@ -2,6 +2,36 @@
     
     #include "nvfx_context.h"
     #include "nouveau/nouveau_util.h"
    +#include "nvfx_tex.h"
    +
    +void
    +nv30_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso)
    +{
    +	if (cso->max_anisotropy >= 8) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
    +	} else
    +	if (cso->max_anisotropy >= 4) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
    +	} else
    +	if (cso->max_anisotropy >= 2) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
    +	}
    +
    +	{
    +		float limit;
    +
    +		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    +		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    +
    +		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/;
    +
    +		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/;
    +	}
    +}
     
     #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
     {                                                                              \
    diff --git a/src/gallium/drivers/nv30/nv30_state.c b/src/gallium/drivers/nv30/nv30_state.c
    deleted file mode 100644
    index bf96f7cf35..0000000000
    --- a/src/gallium/drivers/nv30/nv30_state.c
    +++ /dev/null
    @@ -1,179 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -
    -#include "tgsi/tgsi_parse.h"
    -
    -#include "nv30_context.h"
    -#include "nvfx_state.h"
    -
    -static INLINE unsigned
    -wrap_mode(unsigned wrap) {
    -	unsigned ret;
    -
    -	switch (wrap) {
    -	case PIPE_TEX_WRAP_REPEAT:
    -		ret = NV34TCL_TX_WRAP_S_REPEAT;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_REPEAT:
    -		ret = NV34TCL_TX_WRAP_S_MIRRORED_REPEAT;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP;
    -		break;
    -/*	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
    -		ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
    -		ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP_TO_BORDER;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_CLAMP:
    -		ret = NV34TCL_TX_WRAP_S_MIRROR_CLAMP;
    -		break;*/
    -	default:
    -		NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
    -		ret = NV34TCL_TX_WRAP_S_REPEAT;
    -		break;
    -	}
    -
    -	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
    -}
    -
    -void *
    -nv30_sampler_state_create(struct pipe_context *pipe,
    -			  const struct pipe_sampler_state *cso)
    -{
    -	struct nvfx_sampler_state *ps;
    -	uint32_t filter = 0;
    -
    -	ps = MALLOC(sizeof(struct nvfx_sampler_state));
    -
    -	ps->fmt = 0;
    -	/* TODO: Not all RECTs formats have this bit set, bits 15-8 of format
    -	   are the tx format to use. We should store normalized coord flag
    -	   in sampler state structure, and set appropriate format in
    -	   nvxx_fragtex_build()
    -	 */
    -	/*NV34TCL_TX_FORMAT_RECT*/
    -	/*if (!cso->normalized_coords) {
    -		ps->fmt |= (1<<14) ;
    -	}*/
    -
    -	ps->wrap = ((wrap_mode(cso->wrap_s) << NV34TCL_TX_WRAP_S_SHIFT) |
    -		    (wrap_mode(cso->wrap_t) << NV34TCL_TX_WRAP_T_SHIFT) |
    -		    (wrap_mode(cso->wrap_r) << NV34TCL_TX_WRAP_R_SHIFT));
    -
    -	ps->en = 0;
    -
    -	if (cso->max_anisotropy >= 8) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
    -	} else
    -	if (cso->max_anisotropy >= 4) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
    -	} else
    -	if (cso->max_anisotropy >= 2) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
    -	}
    -
    -	switch (cso->mag_img_filter) {
    -	case PIPE_TEX_FILTER_LINEAR:
    -		filter |= NV34TCL_TX_FILTER_MAGNIFY_LINEAR;
    -		break;
    -	case PIPE_TEX_FILTER_NEAREST:
    -	default:
    -		filter |= NV34TCL_TX_FILTER_MAGNIFY_NEAREST;
    -		break;
    -	}
    -
    -	switch (cso->min_img_filter) {
    -	case PIPE_TEX_FILTER_LINEAR:
    -		switch (cso->min_mip_filter) {
    -		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
    -			break;
    -		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
    -			break;
    -		case PIPE_TEX_MIPFILTER_NONE:
    -		default:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR;
    -			break;
    -		}
    -		break;
    -	case PIPE_TEX_FILTER_NEAREST:
    -	default:
    -		switch (cso->min_mip_filter) {
    -		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
    -		break;
    -		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
    -			break;
    -		case PIPE_TEX_MIPFILTER_NONE:
    -		default:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST;
    -			break;
    -		}
    -		break;
    -	}
    -
    -	ps->filt = filter;
    -
    -	{
    -		float limit;
    -
    -		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    -		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    -
    -		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/;
    -
    -		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/;
    -	}
    -
    -	if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
    -		switch (cso->compare_func) {
    -		case PIPE_FUNC_NEVER:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NEVER;
    -			break;
    -		case PIPE_FUNC_GREATER:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GREATER;
    -			break;
    -		case PIPE_FUNC_EQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_EQUAL;
    -			break;
    -		case PIPE_FUNC_GEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GEQUAL;
    -			break;
    -		case PIPE_FUNC_LESS:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LESS;
    -			break;
    -		case PIPE_FUNC_NOTEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NOTEQUAL;
    -			break;
    -		case PIPE_FUNC_LEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LEQUAL;
    -			break;
    -		case PIPE_FUNC_ALWAYS:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_ALWAYS;
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) |
    -		    (float_to_ubyte(cso->border_color[0]) << 16) |
    -		    (float_to_ubyte(cso->border_color[1]) <<  8) |
    -		    (float_to_ubyte(cso->border_color[2]) <<  0));
    -
    -	return (void *)ps;
    -}
    -
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    index 6e764512cf..8b69f9432d 100644
    --- a/src/gallium/drivers/nv40/Makefile
    +++ b/src/gallium/drivers/nv40/Makefile
    @@ -4,8 +4,7 @@ include $(TOP)/configs/current
     LIBNAME = nv40
     
     C_SOURCES = \
    -	nv40_fragtex.c \
    -	nv40_state.c
    +	nv40_fragtex.c
     
     LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
     
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    index 7615095025..5889b5e40d 100644
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ b/src/gallium/drivers/nv40/nv40_fragtex.c
    @@ -1,5 +1,51 @@
     #include "util/u_format.h"
     #include "nvfx_context.h"
    +#include "nvfx_tex.h"
    +
    +void
    +nv40_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso)
    +{
    +	if (cso->max_anisotropy >= 2) {
    +		/* no idea, binary driver sets it, works without it.. meh.. */
    +		ps->wrap |= (1 << 5);
    +
    +		if (cso->max_anisotropy >= 16) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
    +		} else
    +		if (cso->max_anisotropy >= 12) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
    +		} else
    +		if (cso->max_anisotropy >= 10) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
    +		} else
    +		if (cso->max_anisotropy >= 8) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
    +		} else
    +		if (cso->max_anisotropy >= 6) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
    +		} else
    +		if (cso->max_anisotropy >= 4) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
    +		} else {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
    +		}
    +	}
    +
    +	{
    +		float limit;
    +
    +		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    +		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    +
    +		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit * 256.0) << 7;
    +
    +		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit * 256.0) << 19;
    +	}
    +}
     
     #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw)            \
     {                                                                              \
    diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
    deleted file mode 100644
    index 4d4098bc42..0000000000
    --- a/src/gallium/drivers/nv40/nv40_state.c
    +++ /dev/null
    @@ -1,190 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -
    -#include "draw/draw_context.h"
    -
    -#include "tgsi/tgsi_parse.h"
    -
    -#include "nv40_context.h"
    -#include "nvfx_state.h"
    -
    -static INLINE unsigned
    -wrap_mode(unsigned wrap) {
    -	unsigned ret;
    -
    -	switch (wrap) {
    -	case PIPE_TEX_WRAP_REPEAT:
    -		ret = NV34TCL_TX_WRAP_S_REPEAT;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_REPEAT:
    -		ret = NV34TCL_TX_WRAP_S_MIRRORED_REPEAT;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER;
    -		break;
    -	case PIPE_TEX_WRAP_CLAMP:
    -		ret = NV34TCL_TX_WRAP_S_CLAMP;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
    -		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
    -		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_BORDER;
    -		break;
    -	case PIPE_TEX_WRAP_MIRROR_CLAMP:
    -		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP;
    -		break;
    -	default:
    -		NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
    -		ret = NV34TCL_TX_WRAP_S_REPEAT;
    -		break;
    -	}
    -
    -	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
    -}
    -
    -void *
    -nv40_sampler_state_create(struct pipe_context *pipe,
    -			  const struct pipe_sampler_state *cso)
    -{
    -	struct nvfx_sampler_state *ps;
    -	uint32_t filter = 0;
    -
    -	ps = MALLOC(sizeof(struct nvfx_sampler_state));
    -
    -	ps->fmt = 0;
    -	if (!cso->normalized_coords)
    -		ps->fmt |= NV40TCL_TEX_FORMAT_RECT;
    -
    -	ps->wrap = ((wrap_mode(cso->wrap_s) << NV34TCL_TX_WRAP_S_SHIFT) |
    -		    (wrap_mode(cso->wrap_t) << NV34TCL_TX_WRAP_T_SHIFT) |
    -		    (wrap_mode(cso->wrap_r) << NV34TCL_TX_WRAP_R_SHIFT));
    -
    -	ps->en = 0;
    -	if (cso->max_anisotropy >= 2) {
    -		/* no idea, binary driver sets it, works without it.. meh.. */
    -		ps->wrap |= (1 << 5);
    -
    -		if (cso->max_anisotropy >= 16) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
    -		} else
    -		if (cso->max_anisotropy >= 12) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
    -		} else
    -		if (cso->max_anisotropy >= 10) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
    -		} else
    -		if (cso->max_anisotropy >= 8) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
    -		} else
    -		if (cso->max_anisotropy >= 6) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
    -		} else
    -		if (cso->max_anisotropy >= 4) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
    -		} else {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
    -		}
    -	}
    -
    -	switch (cso->mag_img_filter) {
    -	case PIPE_TEX_FILTER_LINEAR:
    -		filter |= NV34TCL_TX_FILTER_MAGNIFY_LINEAR;
    -		break;
    -	case PIPE_TEX_FILTER_NEAREST:
    -	default:
    -		filter |= NV34TCL_TX_FILTER_MAGNIFY_NEAREST;
    -		break;
    -	}
    -
    -	switch (cso->min_img_filter) {
    -	case PIPE_TEX_FILTER_LINEAR:
    -		switch (cso->min_mip_filter) {
    -		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
    -			break;
    -		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
    -			break;
    -		case PIPE_TEX_MIPFILTER_NONE:
    -		default:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR;
    -			break;
    -		}
    -		break;
    -	case PIPE_TEX_FILTER_NEAREST:
    -	default:
    -		switch (cso->min_mip_filter) {
    -		case PIPE_TEX_MIPFILTER_NEAREST:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
    -		break;
    -		case PIPE_TEX_MIPFILTER_LINEAR:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
    -			break;
    -		case PIPE_TEX_MIPFILTER_NONE:
    -		default:
    -			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST;
    -			break;
    -		}
    -		break;
    -	}
    -
    -	ps->filt = filter;
    -
    -	{
    -		float limit;
    -
    -		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    -		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    -
    -		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit * 256.0) << 7;
    -
    -		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit * 256.0) << 19;
    -	}
    -
    -
    -	if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
    -		switch (cso->compare_func) {
    -		case PIPE_FUNC_NEVER:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NEVER;
    -			break;
    -		case PIPE_FUNC_GREATER:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GREATER;
    -			break;
    -		case PIPE_FUNC_EQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_EQUAL;
    -			break;
    -		case PIPE_FUNC_GEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_GEQUAL;
    -			break;
    -		case PIPE_FUNC_LESS:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LESS;
    -			break;
    -		case PIPE_FUNC_NOTEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_NOTEQUAL;
    -			break;
    -		case PIPE_FUNC_LEQUAL:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_LEQUAL;
    -			break;
    -		case PIPE_FUNC_ALWAYS:
    -			ps->wrap |= NV34TCL_TX_WRAP_RCOMP_ALWAYS;
    -			break;
    -		default:
    -			break;
    -		}
    -	}
    -
    -	ps->bcol = ((float_to_ubyte(cso->border_color[3]) << 24) |
    -		    (float_to_ubyte(cso->border_color[0]) << 16) |
    -		    (float_to_ubyte(cso->border_color[1]) <<  8) |
    -		    (float_to_ubyte(cso->border_color[2]) <<  0));
    -
    -	return (void *)ps;
    -}
    -
    diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
    index e538904298..5eed8a560e 100644
    --- a/src/gallium/drivers/nvfx/nvfx_context.h
    +++ b/src/gallium/drivers/nvfx/nvfx_context.h
    @@ -219,13 +219,19 @@ extern void nvfx_fragprog_destroy(struct nvfx_context *,
     				    struct nvfx_fragment_program *);
     
     /* nv30_fragtex.c */
    -extern void nv30_init_sampler_functions(struct nvfx_context *nvfx);
    +extern void
    +nv30_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso);
     extern void nv30_fragtex_bind(struct nvfx_context *);
     extern struct nouveau_stateobj *
     nv30_fragtex_build(struct nvfx_context *nvfx, int unit);
     
     /* nv40_fragtex.c */
    -extern void nv40_init_sampler_functions(struct nvfx_context *nvfx);
    +extern void
    +nv40_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso);
     extern void nv40_fragtex_bind(struct nvfx_context *);
     extern struct nouveau_stateobj *
     nv40_fragtex_build(struct nvfx_context *nvfx, int unit);
    diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c
    index 7e138afc71..88a9d01c50 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state.c
    @@ -8,6 +8,7 @@
     
     #include "nvfx_context.h"
     #include "nvfx_state.h"
    +#include "nvfx_tex.h"
     
     static void *
     nvfx_blend_state_create(struct pipe_context *pipe,
    @@ -82,8 +83,35 @@ nvfx_blend_state_delete(struct pipe_context *pipe, void *hwcso)
     	FREE(bso);
     }
     
    +static void *
    +nvfx_sampler_state_create(struct pipe_context *pipe,
    +			  const struct pipe_sampler_state *cso)
    +{
    +	struct nvfx_context *nvfx = nvfx_context(pipe);
    +	struct nvfx_sampler_state *ps;
    +
    +	ps = MALLOC(sizeof(struct nvfx_sampler_state));
    +
    +	/* on nv30, we use this as an internal flag */
    +	ps->fmt = cso->normalized_coords ? 0 : NV40TCL_TEX_FORMAT_RECT;
    +	ps->en = 0;
    +	ps->filt = nvfx_tex_filter(cso);
    +	ps->wrap = (nvfx_tex_wrap_mode(cso->wrap_s) << NV34TCL_TX_WRAP_S_SHIFT) |
    +		    (nvfx_tex_wrap_mode(cso->wrap_t) << NV34TCL_TX_WRAP_T_SHIFT) |
    +		    (nvfx_tex_wrap_mode(cso->wrap_r) << NV34TCL_TX_WRAP_R_SHIFT) |
    +		    nvfx_tex_wrap_compare_mode(cso);
    +	ps->bcol = nvfx_tex_border_color(cso->border_color);
    +
    +	if(nvfx->is_nv4x)
    +		nv40_sampler_state_init(pipe, ps, cso);
    +	else
    +		nv30_sampler_state_init(pipe, ps, cso);
    +
    +	return (void *)ps;
    +}
    +
     static void
    -nv40_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
    +nvfx_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
     {
     	struct nvfx_context *nvfx = nvfx_context(pipe);
     	unsigned unit;
    @@ -103,7 +131,7 @@ nv40_sampler_state_bind(struct pipe_context *pipe, unsigned nr, void **sampler)
     }
     
     static void
    -nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
    +nvfx_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
     {
     	FREE(hwcso);
     }
    @@ -543,14 +571,6 @@ nvfx_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
     	/*nvfx->draw_dirty |= NVFX_NEW_ARRAYS;*/
     }
     
    -void *
    -nv30_sampler_state_create(struct pipe_context *pipe,
    -			  const struct pipe_sampler_state *cso);
    -
    -void *
    -nv40_sampler_state_create(struct pipe_context *pipe,
    -			  const struct pipe_sampler_state *cso);
    -
     void
     nvfx_init_state_functions(struct nvfx_context *nvfx)
     {
    @@ -558,12 +578,9 @@ nvfx_init_state_functions(struct nvfx_context *nvfx)
     	nvfx->pipe.bind_blend_state = nvfx_blend_state_bind;
     	nvfx->pipe.delete_blend_state = nvfx_blend_state_delete;
     
    -	if(nvfx->is_nv4x)
    -		nvfx->pipe.create_sampler_state = nv40_sampler_state_create;
    -	else
    -		nvfx->pipe.create_sampler_state = nv30_sampler_state_create;
    -	nvfx->pipe.bind_fragment_sampler_states = nv40_sampler_state_bind;
    -	nvfx->pipe.delete_sampler_state = nv40_sampler_state_delete;
    +	nvfx->pipe.create_sampler_state = nvfx_sampler_state_create;
    +	nvfx->pipe.bind_fragment_sampler_states = nvfx_sampler_state_bind;
    +	nvfx->pipe.delete_sampler_state = nvfx_sampler_state_delete;
     	nvfx->pipe.set_fragment_sampler_textures = nvfx_set_sampler_texture;
     
     	nvfx->pipe.create_rasterizer_state = nvfx_rasterizer_state_create;
    diff --git a/src/gallium/drivers/nvfx/nvfx_state.h b/src/gallium/drivers/nvfx/nvfx_state.h
    index b243b1020f..e585246879 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state.h
    +++ b/src/gallium/drivers/nvfx/nvfx_state.h
    @@ -4,14 +4,6 @@
     #include "pipe/p_state.h"
     #include "tgsi/tgsi_scan.h"
     
    -struct nvfx_sampler_state {
    -	uint32_t fmt;
    -	uint32_t wrap;
    -	uint32_t en;
    -	uint32_t filt;
    -	uint32_t bcol;
    -};
    -
     struct nvfx_vertex_program_exec {
     	uint32_t data[4];
     	boolean has_branch_offset;
    diff --git a/src/gallium/drivers/nvfx/nvfx_tex.h b/src/gallium/drivers/nvfx/nvfx_tex.h
    new file mode 100644
    index 0000000000..69187a79e7
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nvfx_tex.h
    @@ -0,0 +1,133 @@
    +#ifndef NVFX_TEX_H_
    +#define NVFX_TEX_H_
    +
    +static inline unsigned
    +nvfx_tex_wrap_mode(unsigned wrap) {
    +	unsigned ret;
    +
    +	switch (wrap) {
    +	case PIPE_TEX_WRAP_REPEAT:
    +		ret = NV34TCL_TX_WRAP_S_REPEAT;
    +		break;
    +	case PIPE_TEX_WRAP_MIRROR_REPEAT:
    +		ret = NV34TCL_TX_WRAP_S_MIRRORED_REPEAT;
    +		break;
    +	case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
    +		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_EDGE;
    +		break;
    +	case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
    +		ret = NV34TCL_TX_WRAP_S_CLAMP_TO_BORDER;
    +		break;
    +	case PIPE_TEX_WRAP_CLAMP:
    +		ret = NV34TCL_TX_WRAP_S_CLAMP;
    +		break;
    +	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
    +		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_EDGE;
    +		break;
    +	case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
    +		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP_TO_BORDER;
    +		break;
    +	case PIPE_TEX_WRAP_MIRROR_CLAMP:
    +		ret = NV40TCL_TEX_WRAP_S_MIRROR_CLAMP;
    +		break;
    +	default:
    +		NOUVEAU_ERR("unknown wrap mode: %d\n", wrap);
    +		ret = NV34TCL_TX_WRAP_S_REPEAT;
    +		break;
    +	}
    +
    +	return ret >> NV34TCL_TX_WRAP_S_SHIFT;
    +}
    +
    +static inline unsigned
    +nvfx_tex_wrap_compare_mode(const struct pipe_sampler_state* cso)
    +{
    +	if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
    +		switch (cso->compare_func) {
    +		case PIPE_FUNC_NEVER:
    +			return NV34TCL_TX_WRAP_RCOMP_NEVER;
    +		case PIPE_FUNC_GREATER:
    +			return NV34TCL_TX_WRAP_RCOMP_GREATER;
    +		case PIPE_FUNC_EQUAL:
    +			return NV34TCL_TX_WRAP_RCOMP_EQUAL;
    +		case PIPE_FUNC_GEQUAL:
    +			return NV34TCL_TX_WRAP_RCOMP_GEQUAL;
    +		case PIPE_FUNC_LESS:
    +			return NV34TCL_TX_WRAP_RCOMP_LESS;
    +		case PIPE_FUNC_NOTEQUAL:
    +			return NV34TCL_TX_WRAP_RCOMP_NOTEQUAL;
    +		case PIPE_FUNC_LEQUAL:
    +			return NV34TCL_TX_WRAP_RCOMP_LEQUAL;
    +		case PIPE_FUNC_ALWAYS:
    +			return NV34TCL_TX_WRAP_RCOMP_ALWAYS;
    +		default:
    +			break;
    +		}
    +	}
    +	return 0;
    +}
    +
    +static inline unsigned nvfx_tex_filter(const struct pipe_sampler_state* cso)
    +{
    +	unsigned filter = 0;
    +	switch (cso->mag_img_filter) {
    +	case PIPE_TEX_FILTER_LINEAR:
    +		filter |= NV34TCL_TX_FILTER_MAGNIFY_LINEAR;
    +		break;
    +	case PIPE_TEX_FILTER_NEAREST:
    +	default:
    +		filter |= NV34TCL_TX_FILTER_MAGNIFY_NEAREST;
    +		break;
    +	}
    +
    +	switch (cso->min_img_filter) {
    +	case PIPE_TEX_FILTER_LINEAR:
    +		switch (cso->min_mip_filter) {
    +		case PIPE_TEX_MIPFILTER_NEAREST:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_NEAREST;
    +			break;
    +		case PIPE_TEX_MIPFILTER_LINEAR:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR_MIPMAP_LINEAR;
    +			break;
    +		case PIPE_TEX_MIPFILTER_NONE:
    +		default:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_LINEAR;
    +			break;
    +		}
    +		break;
    +	case PIPE_TEX_FILTER_NEAREST:
    +	default:
    +		switch (cso->min_mip_filter) {
    +		case PIPE_TEX_MIPFILTER_NEAREST:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_NEAREST;
    +		break;
    +		case PIPE_TEX_MIPFILTER_LINEAR:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST_MIPMAP_LINEAR;
    +			break;
    +		case PIPE_TEX_MIPFILTER_NONE:
    +		default:
    +			filter |= NV34TCL_TX_FILTER_MINIFY_NEAREST;
    +			break;
    +		}
    +		break;
    +	}
    +	return filter;
    +}
    +
    +static inline unsigned nvfx_tex_border_color(const float* border_color)
    +{
    +	return ((float_to_ubyte(border_color[3]) << 24) |
    +		    (float_to_ubyte(border_color[0]) << 16) |
    +		    (float_to_ubyte(border_color[1]) <<  8) |
    +		    (float_to_ubyte(border_color[2]) <<  0));
    +}
    +
    +struct nvfx_sampler_state {
    +	uint32_t fmt;
    +	uint32_t wrap;
    +	uint32_t en;
    +	uint32_t filt;
    +	uint32_t bcol;
    +};
    +
    +#endif /* NVFX_TEX_H_ */
    -- 
    cgit v1.2.3
    
    
    From f9d09a2e7859a2cf025d71b7c3cb189edb6688c4 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 15:13:12 +0100
    Subject: nv30, nv40: move last files to nvfx/ and rm -rf nv30 nv40
    
    This is the last nvfx unification patch.
    
    nv[34]0_fragtex.c are moved to the common directory
    nv[34]0_shader.h are renamed to nv[34]0_vertprog.h and moved to
    the common directory
    
    The separate nv30 and nv40 directories are removed from the build
    system
    ---
     configure.ac                                 |   2 +-
     src/gallium/drivers/nv30/Makefile            |  11 --
     src/gallium/drivers/nv30/nv30_fragtex.c      | 148 ----------------------
     src/gallium/drivers/nv30/nv30_shader.h       | 169 -------------------------
     src/gallium/drivers/nv40/Makefile            |  11 --
     src/gallium/drivers/nv40/nv40_fragtex.c      | 174 --------------------------
     src/gallium/drivers/nv40/nv40_shader.h       | 178 ---------------------------
     src/gallium/drivers/nvfx/Makefile            |   2 +
     src/gallium/drivers/nvfx/nv30_fragtex.c      | 147 ++++++++++++++++++++++
     src/gallium/drivers/nvfx/nv30_vertprog.h     | 169 +++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nv40_fragtex.c      | 174 ++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nv40_vertprog.h     | 177 ++++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nvfx_draw.c         |   4 +-
     src/gallium/drivers/nvfx/nvfx_vertprog.c     |   4 +-
     src/gallium/winsys/drm/nouveau/dri/Makefile  |   8 --
     src/gallium/winsys/drm/nouveau/egl/Makefile  |  10 +-
     src/gallium/winsys/drm/nouveau/xorg/Makefile |  10 +-
     17 files changed, 676 insertions(+), 722 deletions(-)
     delete mode 100644 src/gallium/drivers/nv30/Makefile
     delete mode 100644 src/gallium/drivers/nv30/nv30_fragtex.c
     delete mode 100644 src/gallium/drivers/nv30/nv30_shader.h
     delete mode 100644 src/gallium/drivers/nv40/Makefile
     delete mode 100644 src/gallium/drivers/nv40/nv40_fragtex.c
     delete mode 100644 src/gallium/drivers/nv40/nv40_shader.h
     create mode 100644 src/gallium/drivers/nvfx/nv30_fragtex.c
     create mode 100644 src/gallium/drivers/nvfx/nv30_vertprog.h
     create mode 100644 src/gallium/drivers/nvfx/nv40_fragtex.c
     create mode 100644 src/gallium/drivers/nvfx/nv40_vertprog.h
    
    (limited to 'src/gallium')
    
    diff --git a/configure.ac b/configure.ac
    index eb271e9d51..0f51097ef6 100644
    --- a/configure.ac
    +++ b/configure.ac
    @@ -1360,7 +1360,7 @@ AC_ARG_ENABLE([gallium-nouveau],
         [enable_gallium_nouveau=no])
     if test "x$enable_gallium_nouveau" = xyes; then
         GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau"
    -    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv30 nv40 nv50"
    +    GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nvfx nv50"
     fi
     
     dnl
    diff --git a/src/gallium/drivers/nv30/Makefile b/src/gallium/drivers/nv30/Makefile
    deleted file mode 100644
    index 70741101d6..0000000000
    --- a/src/gallium/drivers/nv30/Makefile
    +++ /dev/null
    @@ -1,11 +0,0 @@
    -TOP = ../../../..
    -include $(TOP)/configs/current
    -
    -LIBNAME = nv30
    -
    -C_SOURCES = \
    -	nv30_fragtex.c
    -
    -LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    -
    -include ../../Makefile.template
    diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c
    deleted file mode 100644
    index 081362d150..0000000000
    --- a/src/gallium/drivers/nv30/nv30_fragtex.c
    +++ /dev/null
    @@ -1,148 +0,0 @@
    -#include "util/u_format.h"
    -
    -#include "nvfx_context.h"
    -#include "nouveau/nouveau_util.h"
    -#include "nvfx_tex.h"
    -
    -void
    -nv30_sampler_state_init(struct pipe_context *pipe,
    -			  struct nvfx_sampler_state *ps,
    -			  const struct pipe_sampler_state *cso)
    -{
    -	if (cso->max_anisotropy >= 8) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
    -	} else
    -	if (cso->max_anisotropy >= 4) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
    -	} else
    -	if (cso->max_anisotropy >= 2) {
    -		ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
    -	}
    -
    -	{
    -		float limit;
    -
    -		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    -		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    -
    -		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/;
    -
    -		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/;
    -	}
    -}
    -
    -#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
    -{                                                                              \
    -  TRUE,                                                                        \
    -  PIPE_FORMAT_##m,                                                             \
    -  NV34TCL_TX_FORMAT_FORMAT_##tf,                                               \
    -  (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |           \
    -   NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |           \
    -   NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |           \
    -   NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w)            \
    -}
    -
    -struct nv30_texture_format {
    -	boolean defined;
    -	uint	pipe;
    -	int     format;
    -	int     swizzle;
    -};
    -
    -static struct nv30_texture_format
    -nv30_texture_formats[] = {
    -	_(B8G8R8X8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    -	_(B8G8R8A8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	_(B5G5R5A1_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	_(B4G4R4A4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	_(B5G6R5_UNORM  , R5G6B5  ,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    -	_(L8_UNORM      , L8      ,   S1,   S1,   S1,  ONE, X, X, X, X),
    -	_(A8_UNORM      , L8      , ZERO, ZERO, ZERO,   S1, X, X, X, X),
    -	_(I8_UNORM      , L8      ,   S1,   S1,   S1,   S1, X, X, X, X),
    -	_(L8A8_UNORM    , A8L8    ,   S1,   S1,   S1,   S1, X, X, X, Y),
    -	_(Z16_UNORM     , R5G6B5  ,   S1,   S1,   S1,  ONE, X, X, X, X),
    -	_(S8Z24_UNORM   , A8R8G8B8,   S1,   S1,   S1,  ONE, X, X, X, X),
    -	_(DXT1_RGB      , DXT1    ,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    -	_(DXT1_RGBA     , DXT1    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	_(DXT3_RGBA     , DXT3    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	_(DXT5_RGBA     , DXT5    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    -	{},
    -};
    -
    -static struct nv30_texture_format *
    -nv30_fragtex_format(uint pipe_format)
    -{
    -	struct nv30_texture_format *tf = nv30_texture_formats;
    -
    -	while (tf->defined) {
    -		if (tf->pipe == pipe_format)
    -			return tf;
    -		tf++;
    -	}
    -
    -	NOUVEAU_ERR("unknown texture format %s\n", util_format_name(pipe_format));
    -	return NULL;
    -}
    -
    -
    -struct nouveau_stateobj *
    -nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
    -{
    -	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    -	struct nvfx_miptree *nv30mt = nvfx->tex_miptree[unit];
    -	struct pipe_texture *pt = &nv30mt->base;
    -	struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
    -	struct nv30_texture_format *tf;
    -	struct nouveau_stateobj *so;
    -	uint32_t txf, txs;
    -	unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    -
    -	tf = nv30_fragtex_format(pt->format);
    -	if (!tf)
    -		return NULL;
    -
    -	txf  = tf->format;
    -	txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0);
    -	txf |= log2i(pt->width0) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT;
    -	txf |= log2i(pt->height0) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT;
    -	txf |= log2i(pt->depth0) << NV34TCL_TX_FORMAT_BASE_SIZE_W_SHIFT;
    -	txf |= NV34TCL_TX_FORMAT_NO_BORDER | 0x10000;
    -
    -	switch (pt->target) {
    -	case PIPE_TEXTURE_CUBE:
    -		txf |= NV34TCL_TX_FORMAT_CUBIC;
    -		/* fall-through */
    -	case PIPE_TEXTURE_2D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_2D;
    -		break;
    -	case PIPE_TEXTURE_3D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_3D;
    -		break;
    -	case PIPE_TEXTURE_1D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_1D;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown target %d\n", pt->target);
    -		return NULL;
    -	}
    -
    -	txs = tf->swizzle;
    -
    -	so = so_new(1, 8, 2);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    -	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
    -	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
    -		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    -	so_data  (so, ps->wrap);
    -	so_data  (so, NV34TCL_TX_ENABLE_ENABLE | ps->en);
    -	so_data  (so, txs);
    -	so_data  (so, ps->filt | 0x2000 /*voodoo*/);
    -	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
    -		       pt->height0);
    -	so_data  (so, ps->bcol);
    -
    -	return so;
    -}
    -
    diff --git a/src/gallium/drivers/nv30/nv30_shader.h b/src/gallium/drivers/nv30/nv30_shader.h
    deleted file mode 100644
    index f19efb5aa4..0000000000
    --- a/src/gallium/drivers/nv30/nv30_shader.h
    +++ /dev/null
    @@ -1,169 +0,0 @@
    -#ifndef __NV30_SHADER_H__
    -#define __NV30_SHADER_H__
    -
    -/* Vertex programs instruction set
    - *
    - * 128bit opcodes, split into 4 32-bit ones for ease of use.
    - *
    - * Non-native instructions
    - *   ABS - MOV + NV40_VP_INST0_DEST_ABS
    - *   POW - EX2 + MUL + LG2
    - *   SUB - ADD, second source negated
    - *   SWZ - MOV
    - *   XPD -  
    - *
    - * Register access
    - *   - Only one INPUT can be accessed per-instruction (move extras into TEMPs)
    - *   - Only one CONST can be accessed per-instruction (move extras into TEMPs)
    - *
    - * Relative Addressing
    - *   According to the value returned for
    - *   MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB
    - *
    - *   there are only two address registers available.  The destination in the
    - *   ARL instruction is set to TEMP  (The temp isn't actually written).
    - *
    - *   When using vanilla ARB_v_p, the proprietary driver will squish both the
    - *   available ADDRESS regs into the first hardware reg in the X and Y
    - *   components.
    - *
    - *   To use an address reg as an index into consts, the CONST_SRC is set to
    - *   (const_base + offset) and INDEX_CONST is set.
    - *
    - *   To access the second address reg use ADDR_REG_SELECT_1. A particular
    - *   component of the address regs is selected with ADDR_SWZ.
    - *
    - *   Only one address register can be accessed per instruction.
    - *
    - * Conditional execution (see NV_vertex_program{2,3} for details) Conditional
    - * execution of an instruction is enabled by setting COND_TEST_ENABLE, and
    - * selecting the condition which will allow the test to pass with
    - * COND_{FL,LT,...}.  It is possible to swizzle the values in the condition
    - * register, which allows for testing against an individual component.
    - *
    - * Branching:
    - *
    - *   The BRA/CAL instructions seem to follow a slightly different opcode
    - *   layout.  The destination instruction ID (IADDR) overlaps a source field.
    - *   Instruction ID's seem to be numbered based on the UPLOAD_FROM_ID FIFO
    - *   command, and is incremented automatically on each UPLOAD_INST FIFO
    - *   command.
    - *
    - *   Conditional branching is achieved by using the condition tests described
    - *   above.  There doesn't appear to be dedicated looping instructions, but
    - *   this can be done using a temp reg + conditional branching.
    - *
    - *   Subroutines may be uploaded before the main program itself, but the first
    - *   executed instruction is determined by the PROGRAM_START_ID FIFO command.
    - *
    - */
    -
    -/* DWORD 0 */
    -
    -#define NV30_VP_INST_ADDR_REG_SELECT_1        (1 << 24)
    -#define NV30_VP_INST_SRC2_ABS           (1 << 23) /* guess */
    -#define NV30_VP_INST_SRC1_ABS           (1 << 22) /* guess */
    -#define NV30_VP_INST_SRC0_ABS           (1 << 21) /* guess */
    -#define NV30_VP_INST_VEC_RESULT         (1 << 20)
    -#define NV30_VP_INST_DEST_TEMP_ID_SHIFT        16
    -#define NV30_VP_INST_DEST_TEMP_ID_MASK        (0x0F << 16)
    -#define NV30_VP_INST_COND_UPDATE_ENABLE        (1<<15)
    -#define NV30_VP_INST_VEC_DEST_TEMP_MASK      (0xF << 16)
    -#define NV30_VP_INST_COND_TEST_ENABLE        (1<<14)
    -#define NV30_VP_INST_COND_SHIFT          11
    -#define NV30_VP_INST_COND_MASK          (0x07 << 11)
    -#define NV30_VP_INST_COND_SWZ_X_SHIFT        9
    -#define NV30_VP_INST_COND_SWZ_X_MASK        (0x03 <<  9)
    -#define NV30_VP_INST_COND_SWZ_Y_SHIFT        7
    -#define NV30_VP_INST_COND_SWZ_Y_MASK        (0x03 <<  7)
    -#define NV30_VP_INST_COND_SWZ_Z_SHIFT        5
    -#define NV30_VP_INST_COND_SWZ_Z_MASK        (0x03 <<  5)
    -#define NV30_VP_INST_COND_SWZ_W_SHIFT        3
    -#define NV30_VP_INST_COND_SWZ_W_MASK        (0x03 <<  3)
    -#define NV30_VP_INST_COND_SWZ_ALL_SHIFT        3
    -#define NV30_VP_INST_COND_SWZ_ALL_MASK        (0xFF <<  3)
    -#define NV30_VP_INST_ADDR_SWZ_SHIFT        1
    -#define NV30_VP_INST_ADDR_SWZ_MASK        (0x03 <<  1)
    -#define NV30_VP_INST_SCA_OPCODEH_SHIFT        0
    -#define NV30_VP_INST_SCA_OPCODEH_MASK        (0x01 <<  0)
    -
    -/* DWORD 1 */
    -#define NV30_VP_INST_SCA_OPCODEL_SHIFT        28
    -#define NV30_VP_INST_SCA_OPCODEL_MASK        (0x0F << 28)
    -#define NV30_VP_INST_VEC_OPCODE_SHIFT        23
    -#define NV30_VP_INST_VEC_OPCODE_MASK        (0x1F << 23)
    -#define NV30_VP_INST_CONST_SRC_SHIFT        14
    -#define NV30_VP_INST_CONST_SRC_MASK        (0xFF << 14)
    -#define NV30_VP_INST_INPUT_SRC_SHIFT        9    /*NV20*/
    -#define NV30_VP_INST_INPUT_SRC_MASK        (0x0F <<  9)  /*NV20*/
    -#define NV30_VP_INST_SRC0H_SHIFT        0    /*NV20*/
    -#define NV30_VP_INST_SRC0H_MASK          (0x1FF << 0)  /*NV20*/
    -
    -/* Please note: the IADDR fields overlap other fields because they are used
    - * only for branch instructions.  See Branching: label above
    - *
    - * DWORD 2
    - */
    -#define NV30_VP_INST_SRC0L_SHIFT        26    /*NV20*/
    -#define NV30_VP_INST_SRC0L_MASK         (0x3F  <<26)  /* NV30_VP_SRC0_LOW_MASK << 26 */
    -#define NV30_VP_INST_SRC1_SHIFT         11    /*NV20*/
    -#define NV30_VP_INST_SRC1_MASK          (0x7FFF<<11)  /*NV20*/
    -#define NV30_VP_INST_SRC2H_SHIFT        0    /*NV20*/
    -#define NV30_VP_INST_SRC2H_MASK          (0x7FF << 0)  /* NV30_VP_SRC2_HIGH_MASK >> 4*/
    -#define NV30_VP_INST_IADDR_SHIFT        2
    -#define NV30_VP_INST_IADDR_MASK          (0xF <<  28)   /* NV30_VP_SRC2_LOW_MASK << 28 */
    -
    -/* DWORD 3 */
    -#define NV30_VP_INST_SRC2L_SHIFT        28    /*NV20*/
    -#define NV30_VP_INST_SRC2L_MASK          (0x0F  <<28)  /*NV20*/
    -#define NV30_VP_INST_STEMP_WRITEMASK_SHIFT      24
    -#define NV30_VP_INST_STEMP_WRITEMASK_MASK      (0x0F << 24)
    -#define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT      20
    -#define NV30_VP_INST_VTEMP_WRITEMASK_MASK      (0x0F << 20)
    -#define NV30_VP_INST_SDEST_WRITEMASK_SHIFT      16
    -#define NV30_VP_INST_SDEST_WRITEMASK_MASK      (0x0F << 16)
    -#define NV30_VP_INST_VDEST_WRITEMASK_SHIFT      12    /*NV20*/
    -#define NV30_VP_INST_VDEST_WRITEMASK_MASK      (0x0F << 12)  /*NV20*/
    -#define NV30_VP_INST_DEST_SHIFT        2
    -#define NV30_VP_INST_DEST_MASK        (0x0F <<  2)
    -#  define NV30_VP_INST_DEST_POS  0
    -#  define NV30_VP_INST_DEST_BFC0  1
    -#  define NV30_VP_INST_DEST_BFC1  2
    -#  define NV30_VP_INST_DEST_COL0  3
    -#  define NV30_VP_INST_DEST_COL1  4
    -#  define NV30_VP_INST_DEST_FOGC  5
    -#  define NV30_VP_INST_DEST_PSZ   6
    -#  define NV30_VP_INST_DEST_TC(n)  (8+n)
    -
    -/* Useful to split the source selection regs into their pieces */
    -#define NV30_VP_SRC0_HIGH_SHIFT                                                6
    -#define NV30_VP_SRC0_HIGH_MASK                                        0x00007FC0
    -#define NV30_VP_SRC0_LOW_MASK                                         0x0000003F
    -#define NV30_VP_SRC2_HIGH_SHIFT                                                4
    -#define NV30_VP_SRC2_HIGH_MASK                                        0x00007FF0
    -#define NV30_VP_SRC2_LOW_MASK                                         0x0000000F
    -
    -
    -/* Source-register definition - matches NV20 exactly */
    -#define NV30_VP_SRC_NEGATE          (1<<14)
    -#define NV30_VP_SRC_SWZ_X_SHIFT        12
    -#define NV30_VP_SRC_REG_SWZ_X_MASK        (0x03  <<12)
    -#define NV30_VP_SRC_SWZ_Y_SHIFT        10
    -#define NV30_VP_SRC_REG_SWZ_Y_MASK        (0x03  <<10)
    -#define NV30_VP_SRC_SWZ_Z_SHIFT        8
    -#define NV30_VP_SRC_REG_SWZ_Z_MASK        (0x03  << 8)
    -#define NV30_VP_SRC_SWZ_W_SHIFT        6
    -#define NV30_VP_SRC_REG_SWZ_W_MASK        (0x03  << 6)
    -#define NV30_VP_SRC_REG_SWZ_ALL_SHIFT        6
    -#define NV30_VP_SRC_REG_SWZ_ALL_MASK        (0xFF  << 6)
    -#define NV30_VP_SRC_TEMP_SRC_SHIFT        2
    -#define NV30_VP_SRC_REG_TEMP_ID_MASK        (0x0F  << 0)
    -#define NV30_VP_SRC_REG_TYPE_SHIFT        0
    -#define NV30_VP_SRC_REG_TYPE_MASK        (0x03  << 0)
    -#define NV30_VP_SRC_REG_TYPE_TEMP  1
    -#define NV30_VP_SRC_REG_TYPE_INPUT  2
    -#define NV30_VP_SRC_REG_TYPE_CONST  3 /* guess */
    -
    -#include "nvfx_shader.h"
    -
    -#endif
    diff --git a/src/gallium/drivers/nv40/Makefile b/src/gallium/drivers/nv40/Makefile
    deleted file mode 100644
    index 8b69f9432d..0000000000
    --- a/src/gallium/drivers/nv40/Makefile
    +++ /dev/null
    @@ -1,11 +0,0 @@
    -TOP = ../../../..
    -include $(TOP)/configs/current
    -
    -LIBNAME = nv40
    -
    -C_SOURCES = \
    -	nv40_fragtex.c
    -
    -LIBRARY_INCLUDES = -I$(TOP)/src/gallium/drivers/nvfx
    -
    -include ../../Makefile.template
    diff --git a/src/gallium/drivers/nv40/nv40_fragtex.c b/src/gallium/drivers/nv40/nv40_fragtex.c
    deleted file mode 100644
    index 5889b5e40d..0000000000
    --- a/src/gallium/drivers/nv40/nv40_fragtex.c
    +++ /dev/null
    @@ -1,174 +0,0 @@
    -#include "util/u_format.h"
    -#include "nvfx_context.h"
    -#include "nvfx_tex.h"
    -
    -void
    -nv40_sampler_state_init(struct pipe_context *pipe,
    -			  struct nvfx_sampler_state *ps,
    -			  const struct pipe_sampler_state *cso)
    -{
    -	if (cso->max_anisotropy >= 2) {
    -		/* no idea, binary driver sets it, works without it.. meh.. */
    -		ps->wrap |= (1 << 5);
    -
    -		if (cso->max_anisotropy >= 16) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
    -		} else
    -		if (cso->max_anisotropy >= 12) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
    -		} else
    -		if (cso->max_anisotropy >= 10) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
    -		} else
    -		if (cso->max_anisotropy >= 8) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
    -		} else
    -		if (cso->max_anisotropy >= 6) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
    -		} else
    -		if (cso->max_anisotropy >= 4) {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
    -		} else {
    -			ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
    -		}
    -	}
    -
    -	{
    -		float limit;
    -
    -		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    -		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    -
    -		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit * 256.0) << 7;
    -
    -		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    -		ps->en |= (int)(limit * 256.0) << 19;
    -	}
    -}
    -
    -#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw)            \
    -{                                                                              \
    -  TRUE,                                                                        \
    -  PIPE_FORMAT_##m,                                                             \
    -  NV40TCL_TEX_FORMAT_FORMAT_##tf,                                              \
    -  (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |         \
    -   NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |         \
    -   NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |         \
    -   NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w),         \
    -  ((NV34TCL_TX_FILTER_SIGNED_RED*sx) | (NV34TCL_TX_FILTER_SIGNED_GREEN*sy) |       \
    -   (NV34TCL_TX_FILTER_SIGNED_BLUE*sz) | (NV34TCL_TX_FILTER_SIGNED_ALPHA*sw))       \
    -}
    -
    -struct nv40_texture_format {
    -	boolean defined;
    -	uint	pipe;
    -	int     format;
    -	int     swizzle;
    -	int     sign;
    -};
    -
    -static struct nv40_texture_format
    -nv40_texture_formats[] = {
    -	_(B8G8R8X8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    -	_(B8G8R8A8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	_(B5G5R5A1_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	_(B4G4R4A4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	_(B5G6R5_UNORM  , R5G6B5  ,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    -	_(L8_UNORM      , L8      ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    -	_(A8_UNORM      , L8      , ZERO, ZERO, ZERO,   S1, X, X, X, X, 0, 0, 0, 0),
    -	_(R16_SNORM     , A16     , ZERO, ZERO,   S1,  ONE, X, X, X, Y, 1, 1, 1, 1),
    -	_(I8_UNORM      , L8      ,   S1,   S1,   S1,   S1, X, X, X, X, 0, 0, 0, 0),
    -	_(L8A8_UNORM    , A8L8    ,   S1,   S1,   S1,   S1, X, X, X, Y, 0, 0, 0, 0),
    -	_(Z16_UNORM     , Z16     ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    -	_(S8Z24_UNORM   , Z24     ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    -	_(DXT1_RGB      , DXT1    ,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    -	_(DXT1_RGBA     , DXT1    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	_(DXT3_RGBA     , DXT3    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	_(DXT5_RGBA     , DXT5    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    -	{},
    -};
    -
    -static struct nv40_texture_format *
    -nv40_fragtex_format(uint pipe_format)
    -{
    -	struct nv40_texture_format *tf = nv40_texture_formats;
    -
    -	while (tf->defined) {
    -		if (tf->pipe == pipe_format)
    -			return tf;
    -		tf++;
    -	}
    -
    -	NOUVEAU_ERR("unknown texture format %s\n", util_format_name(pipe_format));
    -	return NULL;
    -}
    -
    -
    -struct nouveau_stateobj *
    -nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
    -{
    -	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    -	struct nvfx_miptree *nv40mt = nvfx->tex_miptree[unit];
    -	struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
    -	struct pipe_texture *pt = &nv40mt->base;
    -	struct nv40_texture_format *tf;
    -	struct nouveau_stateobj *so;
    -	uint32_t txf, txs, txp;
    -	unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    -
    -	tf = nv40_fragtex_format(pt->format);
    -	if (!tf)
    -		assert(0);
    -
    -	txf  = ps->fmt;
    -	txf |= tf->format | 0x8000;
    -	txf |= ((pt->last_level + 1) << NV40TCL_TEX_FORMAT_MIPMAP_COUNT_SHIFT);
    -
    -	if (1) /* XXX */
    -		txf |= NV34TCL_TX_FORMAT_NO_BORDER;
    -
    -	switch (pt->target) {
    -	case PIPE_TEXTURE_CUBE:
    -		txf |= NV34TCL_TX_FORMAT_CUBIC;
    -		/* fall-through */
    -	case PIPE_TEXTURE_2D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_2D;
    -		break;
    -	case PIPE_TEXTURE_3D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_3D;
    -		break;
    -	case PIPE_TEXTURE_1D:
    -		txf |= NV34TCL_TX_FORMAT_DIMS_1D;
    -		break;
    -	default:
    -		NOUVEAU_ERR("Unknown target %d\n", pt->target);
    -		return NULL;
    -	}
    -
    -	if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    -		txp = 0;
    -	} else {
    -		txp  = nv40mt->level[0].pitch;
    -		txf |= NV40TCL_TEX_FORMAT_LINEAR;
    -	}
    -
    -	txs = tf->swizzle;
    -
    -	so = so_new(2, 9, 2);
    -	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    -	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
    -	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
    -		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    -	so_data  (so, ps->wrap);
    -	so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
    -	so_data  (so, txs);
    -	so_data  (so, ps->filt | tf->sign | 0x2000 /*voodoo*/);
    -	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
    -		       pt->height0);
    -	so_data  (so, ps->bcol);
    -	so_method(so, nvfx->screen->eng3d, NV40TCL_TEX_SIZE1(unit), 1);
    -	so_data  (so, (pt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
    -
    -	return so;
    -}
    diff --git a/src/gallium/drivers/nv40/nv40_shader.h b/src/gallium/drivers/nv40/nv40_shader.h
    deleted file mode 100644
    index 8d28137e9d..0000000000
    --- a/src/gallium/drivers/nv40/nv40_shader.h
    +++ /dev/null
    @@ -1,178 +0,0 @@
    -#ifndef __NV40_SHADER_H__
    -#define __NV40_SHADER_H__
    -
    -/* Vertex programs instruction set
    - *
    - * The NV40 instruction set is very similar to NV30.  Most fields are in
    - * a slightly different position in the instruction however.
    - *
    - * Merged instructions
    - *     In some cases it is possible to put two instructions into one opcode
    - *     slot.  The rules for when this is OK is not entirely clear to me yet.
    - *
    - *     There are separate writemasks and dest temp register fields for each
    - *     grouping of instructions.  There is however only one field with the
    - *     ID of a result register.  Writing to temp/result regs is selected by
    - *     setting VEC_RESULT/SCA_RESULT.
    - *
    - * Temporary registers
    - *     The source/dest temp register fields have been extended by 1 bit, to
    - *     give a total of 32 temporary registers.
    - *
    - * Relative Addressing
    - *     NV40 can use an address register to index into vertex attribute regs.
    - *     This is done by putting the offset value into INPUT_SRC and setting
    - *     the INDEX_INPUT flag.
    - *
    - * Conditional execution (see NV_vertex_program{2,3} for details)
    - *     There is a second condition code register on NV40, it's use is enabled
    - *     by setting the COND_REG_SELECT_1 flag.
    - *
    - * Texture lookup
    - *     TODO
    - */
    -
    -/* ---- OPCODE BITS 127:96 / data DWORD 0 --- */
    -#define NV40_VP_INST_VEC_RESULT                                        (1 << 30)
    -/* uncertain.. */
    -#define NV40_VP_INST_COND_UPDATE_ENABLE                        ((1 << 14)|1<<29)
    -/* use address reg as index into attribs */
    -#define NV40_VP_INST_INDEX_INPUT                                       (1 << 27)
    -#define NV40_VP_INST_COND_REG_SELECT_1                                 (1 << 25)
    -#define NV40_VP_INST_ADDR_REG_SELECT_1                                 (1 << 24)
    -#define NV40_VP_INST_SRC2_ABS                                          (1 << 23)
    -#define NV40_VP_INST_SRC1_ABS                                          (1 << 22)
    -#define NV40_VP_INST_SRC0_ABS                                          (1 << 21)
    -#define NV40_VP_INST_VEC_DEST_TEMP_SHIFT                                      15
    -#define NV40_VP_INST_VEC_DEST_TEMP_MASK                             (0x1F << 15)
    -#define NV40_VP_INST_COND_TEST_ENABLE                                  (1 << 13)
    -#define NV40_VP_INST_COND_SHIFT                                               10
    -#define NV40_VP_INST_COND_MASK                                       (0x7 << 10)
    -#define NV40_VP_INST_COND_SWZ_X_SHIFT                                          8
    -#define NV40_VP_INST_COND_SWZ_X_MASK                                    (3 << 8)
    -#define NV40_VP_INST_COND_SWZ_Y_SHIFT                                          6
    -#define NV40_VP_INST_COND_SWZ_Y_MASK                                    (3 << 6)
    -#define NV40_VP_INST_COND_SWZ_Z_SHIFT                                          4
    -#define NV40_VP_INST_COND_SWZ_Z_MASK                                    (3 << 4)
    -#define NV40_VP_INST_COND_SWZ_W_SHIFT                                          2
    -#define NV40_VP_INST_COND_SWZ_W_MASK                                    (3 << 2)
    -#define NV40_VP_INST_COND_SWZ_ALL_SHIFT                                        2
    -#define NV40_VP_INST_COND_SWZ_ALL_MASK                               (0xFF << 2)
    -#define NV40_VP_INST_ADDR_SWZ_SHIFT                                            0
    -#define NV40_VP_INST_ADDR_SWZ_MASK                                   (0x03 << 0)
    -#define NV40_VP_INST0_KNOWN ( \
    -                NV40_VP_INST_INDEX_INPUT | \
    -                NV40_VP_INST_COND_REG_SELECT_1 | \
    -                NV40_VP_INST_ADDR_REG_SELECT_1 | \
    -                NV40_VP_INST_SRC2_ABS | \
    -                NV40_VP_INST_SRC1_ABS | \
    -                NV40_VP_INST_SRC0_ABS | \
    -                NV40_VP_INST_VEC_DEST_TEMP_MASK | \
    -                NV40_VP_INST_COND_TEST_ENABLE | \
    -                NV40_VP_INST_COND_MASK | \
    -                NV40_VP_INST_COND_SWZ_ALL_MASK | \
    -                NV40_VP_INST_ADDR_SWZ_MASK)
    -
    -/* ---- OPCODE BITS 95:64 / data DWORD 1 --- */
    -#define NV40_VP_INST_VEC_OPCODE_SHIFT                                         22
    -#define NV40_VP_INST_VEC_OPCODE_MASK                                (0x1F << 22)
    -#define NV40_VP_INST_SCA_OPCODE_SHIFT                                         27
    -#define NV40_VP_INST_SCA_OPCODE_MASK                                (0x1F << 27)
    -#define NV40_VP_INST_CONST_SRC_SHIFT                                          12
    -#define NV40_VP_INST_CONST_SRC_MASK                                 (0xFF << 12)
    -#define NV40_VP_INST_INPUT_SRC_SHIFT                                           8
    -#define NV40_VP_INST_INPUT_SRC_MASK                                  (0x0F << 8)
    -#define NV40_VP_INST_SRC0H_SHIFT                                               0
    -#define NV40_VP_INST_SRC0H_MASK                                      (0xFF << 0)
    -#define NV40_VP_INST1_KNOWN ( \
    -                NV40_VP_INST_VEC_OPCODE_MASK | \
    -                NV40_VP_INST_SCA_OPCODE_MASK | \
    -                NV40_VP_INST_CONST_SRC_MASK  | \
    -                NV40_VP_INST_INPUT_SRC_MASK  | \
    -                NV40_VP_INST_SRC0H_MASK \
    -                )
    -
    -/* ---- OPCODE BITS 63:32 / data DWORD 2 --- */
    -#define NV40_VP_INST_SRC0L_SHIFT                                              23
    -#define NV40_VP_INST_SRC0L_MASK                                    (0x1FF << 23)
    -#define NV40_VP_INST_SRC1_SHIFT                                                6
    -#define NV40_VP_INST_SRC1_MASK                                    (0x1FFFF << 6)
    -#define NV40_VP_INST_SRC2H_SHIFT                                               0
    -#define NV40_VP_INST_SRC2H_MASK                                      (0x3F << 0)
    -#define NV40_VP_INST_IADDRH_SHIFT                                              0
    -#define NV40_VP_INST_IADDRH_MASK                                     (0x1F << 0)
    -
    -/* ---- OPCODE BITS 31:0 / data DWORD 3 --- */
    -#define NV40_VP_INST_IADDRL_SHIFT                                             29
    -#define NV40_VP_INST_IADDRL_MASK                                       (7 << 29)
    -#define NV40_VP_INST_SRC2L_SHIFT                                              21
    -#define NV40_VP_INST_SRC2L_MASK                                    (0x7FF << 21)
    -#define NV40_VP_INST_SCA_WRITEMASK_SHIFT                                      17
    -#define NV40_VP_INST_SCA_WRITEMASK_MASK                              (0xF << 17)
    -#    define NV40_VP_INST_SCA_WRITEMASK_X                               (1 << 20)
    -#    define NV40_VP_INST_SCA_WRITEMASK_Y                               (1 << 19)
    -#    define NV40_VP_INST_SCA_WRITEMASK_Z                               (1 << 18)
    -#    define NV40_VP_INST_SCA_WRITEMASK_W                               (1 << 17)
    -#define NV40_VP_INST_VEC_WRITEMASK_SHIFT                                      13
    -#define NV40_VP_INST_VEC_WRITEMASK_MASK                              (0xF << 13)
    -#    define NV40_VP_INST_VEC_WRITEMASK_X                               (1 << 16)
    -#    define NV40_VP_INST_VEC_WRITEMASK_Y                               (1 << 15)
    -#    define NV40_VP_INST_VEC_WRITEMASK_Z                               (1 << 14)
    -#    define NV40_VP_INST_VEC_WRITEMASK_W                               (1 << 13)
    -#define NV40_VP_INST_SCA_RESULT                                        (1 << 12)
    -#define NV40_VP_INST_SCA_DEST_TEMP_SHIFT                                       7
    -#define NV40_VP_INST_SCA_DEST_TEMP_MASK                              (0x1F << 7)
    -#define NV40_VP_INST_DEST_SHIFT                                                2
    -#define NV40_VP_INST_DEST_MASK                                         (31 << 2)
    -#    define NV40_VP_INST_DEST_POS                                              0
    -#    define NV40_VP_INST_DEST_COL0                                             1
    -#    define NV40_VP_INST_DEST_COL1                                             2
    -#    define NV40_VP_INST_DEST_BFC0                                             3
    -#    define NV40_VP_INST_DEST_BFC1                                             4
    -#    define NV40_VP_INST_DEST_FOGC                                             5
    -#    define NV40_VP_INST_DEST_PSZ                                              6
    -#    define NV40_VP_INST_DEST_TC0                                              7
    -#    define NV40_VP_INST_DEST_TC(n)                                        (7+n)
    -#    define NV40_VP_INST_DEST_TEMP                                          0x1F
    -#define NV40_VP_INST_INDEX_CONST                                        (1 << 1)
    -#define NV40_VP_INST3_KNOWN ( \
    -                NV40_VP_INST_SRC2L_MASK |\
    -                NV40_VP_INST_SCA_WRITEMASK_MASK |\
    -                NV40_VP_INST_VEC_WRITEMASK_MASK |\
    -                NV40_VP_INST_SCA_DEST_TEMP_MASK |\
    -                NV40_VP_INST_DEST_MASK |\
    -                NV40_VP_INST_INDEX_CONST)
    -
    -/* Useful to split the source selection regs into their pieces */
    -#define NV40_VP_SRC0_HIGH_SHIFT                                                9
    -#define NV40_VP_SRC0_HIGH_MASK                                        0x0001FE00
    -#define NV40_VP_SRC0_LOW_MASK                                         0x000001FF
    -#define NV40_VP_SRC2_HIGH_SHIFT                                               11
    -#define NV40_VP_SRC2_HIGH_MASK                                        0x0001F800
    -#define NV40_VP_SRC2_LOW_MASK                                         0x000007FF
    -
    -/* Source selection - these are the bits you fill NV40_VP_INST_SRCn with */
    -#define NV40_VP_SRC_NEGATE                                             (1 << 16)
    -#define NV40_VP_SRC_SWZ_X_SHIFT                                               14
    -#define NV40_VP_SRC_SWZ_X_MASK                                         (3 << 14)
    -#define NV40_VP_SRC_SWZ_Y_SHIFT                                               12
    -#define NV40_VP_SRC_SWZ_Y_MASK                                         (3 << 12)
    -#define NV40_VP_SRC_SWZ_Z_SHIFT                                               10
    -#define NV40_VP_SRC_SWZ_Z_MASK                                         (3 << 10)
    -#define NV40_VP_SRC_SWZ_W_SHIFT                                                8
    -#define NV40_VP_SRC_SWZ_W_MASK                                          (3 << 8)
    -#define NV40_VP_SRC_SWZ_ALL_SHIFT                                              8
    -#define NV40_VP_SRC_SWZ_ALL_MASK                                     (0xFF << 8)
    -#define NV40_VP_SRC_TEMP_SRC_SHIFT                                             2
    -#define NV40_VP_SRC_TEMP_SRC_MASK                                    (0x1F << 2)
    -#define NV40_VP_SRC_REG_TYPE_SHIFT                                             0
    -#define NV40_VP_SRC_REG_TYPE_MASK                                       (3 << 0)
    -#    define NV40_VP_SRC_REG_TYPE_UNK0                                          0
    -#    define NV40_VP_SRC_REG_TYPE_TEMP                                          1
    -#    define NV40_VP_SRC_REG_TYPE_INPUT                                         2
    -#    define NV40_VP_SRC_REG_TYPE_CONST                                         3
    -
    -#include "nvfx_shader.h"
    -
    -#endif
    -
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index 51fa34cfad..e912177b21 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -9,6 +9,8 @@ C_SOURCES = \
     	nvfx_draw.c \
     	nvfx_fragprog.c \
     	nvfx_fragtex.c \
    +	nv30_fragtex.c \
    +	nv40_fragtex.c \
     	nvfx_miptree.c \
     	nvfx_query.c \
     	nvfx_screen.c \
    diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c b/src/gallium/drivers/nvfx/nv30_fragtex.c
    new file mode 100644
    index 0000000000..2b56f45492
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv30_fragtex.c
    @@ -0,0 +1,147 @@
    +#include "util/u_format.h"
    +
    +#include "nvfx_context.h"
    +#include "nouveau/nouveau_util.h"
    +#include "nvfx_tex.h"
    +
    +void
    +nv30_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso)
    +{
    +	if (cso->max_anisotropy >= 8) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_8X;
    +	} else
    +	if (cso->max_anisotropy >= 4) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_4X;
    +	} else
    +	if (cso->max_anisotropy >= 2) {
    +		ps->en |= NV34TCL_TX_ENABLE_ANISO_2X;
    +	}
    +
    +	{
    +		float limit;
    +
    +		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    +		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    +
    +		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit) << 14 /*NV34TCL_TX_ENABLE_MIPMAP_MAX_LOD_SHIFT*/;
    +
    +		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit) << 26 /*NV34TCL_TX_ENABLE_MIPMAP_MIN_LOD_SHIFT*/;
    +	}
    +}
    +
    +#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
    +{                                                                              \
    +  TRUE,                                                                        \
    +  PIPE_FORMAT_##m,                                                             \
    +  NV34TCL_TX_FORMAT_FORMAT_##tf,                                               \
    +  (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |           \
    +   NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |           \
    +   NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |           \
    +   NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w)            \
    +}
    +
    +struct nv30_texture_format {
    +	boolean defined;
    +	uint	pipe;
    +	int     format;
    +	int     swizzle;
    +};
    +
    +static struct nv30_texture_format
    +nv30_texture_formats[] = {
    +	_(B8G8R8X8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    +	_(B8G8R8A8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	_(B5G5R5A1_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	_(B4G4R4A4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	_(B5G6R5_UNORM  , R5G6B5  ,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    +	_(L8_UNORM      , L8      ,   S1,   S1,   S1,  ONE, X, X, X, X),
    +	_(A8_UNORM      , L8      , ZERO, ZERO, ZERO,   S1, X, X, X, X),
    +	_(I8_UNORM      , L8      ,   S1,   S1,   S1,   S1, X, X, X, X),
    +	_(L8A8_UNORM    , A8L8    ,   S1,   S1,   S1,   S1, X, X, X, Y),
    +	_(Z16_UNORM     , R5G6B5  ,   S1,   S1,   S1,  ONE, X, X, X, X),
    +	_(S8Z24_UNORM   , A8R8G8B8,   S1,   S1,   S1,  ONE, X, X, X, X),
    +	_(DXT1_RGB      , DXT1    ,   S1,   S1,   S1,  ONE, X, Y, Z, W),
    +	_(DXT1_RGBA     , DXT1    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	_(DXT3_RGBA     , DXT3    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	_(DXT5_RGBA     , DXT5    ,   S1,   S1,   S1,   S1, X, Y, Z, W),
    +	{},
    +};
    +
    +static struct nv30_texture_format *
    +nv30_fragtex_format(uint pipe_format)
    +{
    +	struct nv30_texture_format *tf = nv30_texture_formats;
    +
    +	while (tf->defined) {
    +		if (tf->pipe == pipe_format)
    +			return tf;
    +		tf++;
    +	}
    +
    +	NOUVEAU_ERR("unknown texture format %s\n", util_format_name(pipe_format));
    +	return NULL;
    +}
    +
    +
    +struct nouveau_stateobj *
    +nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
    +{
    +	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    +	struct nvfx_miptree *nv30mt = nvfx->tex_miptree[unit];
    +	struct pipe_texture *pt = &nv30mt->base;
    +	struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
    +	struct nv30_texture_format *tf;
    +	struct nouveau_stateobj *so;
    +	uint32_t txf, txs;
    +	unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    +
    +	tf = nv30_fragtex_format(pt->format);
    +	if (!tf)
    +		return NULL;
    +
    +	txf  = tf->format;
    +	txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0);
    +	txf |= log2i(pt->width0) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT;
    +	txf |= log2i(pt->height0) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT;
    +	txf |= log2i(pt->depth0) << NV34TCL_TX_FORMAT_BASE_SIZE_W_SHIFT;
    +	txf |= NV34TCL_TX_FORMAT_NO_BORDER | 0x10000;
    +
    +	switch (pt->target) {
    +	case PIPE_TEXTURE_CUBE:
    +		txf |= NV34TCL_TX_FORMAT_CUBIC;
    +		/* fall-through */
    +	case PIPE_TEXTURE_2D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_2D;
    +		break;
    +	case PIPE_TEXTURE_3D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_3D;
    +		break;
    +	case PIPE_TEXTURE_1D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_1D;
    +		break;
    +	default:
    +		NOUVEAU_ERR("Unknown target %d\n", pt->target);
    +		return NULL;
    +	}
    +
    +	txs = tf->swizzle;
    +
    +	so = so_new(1, 8, 2);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    +	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
    +	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
    +		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    +	so_data  (so, ps->wrap);
    +	so_data  (so, NV34TCL_TX_ENABLE_ENABLE | ps->en);
    +	so_data  (so, txs);
    +	so_data  (so, ps->filt | 0x2000 /*voodoo*/);
    +	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
    +		       pt->height0);
    +	so_data  (so, ps->bcol);
    +
    +	return so;
    +}
    diff --git a/src/gallium/drivers/nvfx/nv30_vertprog.h b/src/gallium/drivers/nvfx/nv30_vertprog.h
    new file mode 100644
    index 0000000000..ec0444c07f
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv30_vertprog.h
    @@ -0,0 +1,169 @@
    +#ifndef __NV30_SHADER_H__
    +#define __NV30_SHADER_H__
    +
    +/* Vertex programs instruction set
    + *
    + * 128bit opcodes, split into 4 32-bit ones for ease of use.
    + *
    + * Non-native instructions
    + *   ABS - MOV + NV40_VP_INST0_DEST_ABS
    + *   POW - EX2 + MUL + LG2
    + *   SUB - ADD, second source negated
    + *   SWZ - MOV
    + *   XPD -
    + *
    + * Register access
    + *   - Only one INPUT can be accessed per-instruction (move extras into TEMPs)
    + *   - Only one CONST can be accessed per-instruction (move extras into TEMPs)
    + *
    + * Relative Addressing
    + *   According to the value returned for
    + *   MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB
    + *
    + *   there are only two address registers available.  The destination in the
    + *   ARL instruction is set to TEMP  (The temp isn't actually written).
    + *
    + *   When using vanilla ARB_v_p, the proprietary driver will squish both the
    + *   available ADDRESS regs into the first hardware reg in the X and Y
    + *   components.
    + *
    + *   To use an address reg as an index into consts, the CONST_SRC is set to
    + *   (const_base + offset) and INDEX_CONST is set.
    + *
    + *   To access the second address reg use ADDR_REG_SELECT_1. A particular
    + *   component of the address regs is selected with ADDR_SWZ.
    + *
    + *   Only one address register can be accessed per instruction.
    + *
    + * Conditional execution (see NV_vertex_program{2,3} for details) Conditional
    + * execution of an instruction is enabled by setting COND_TEST_ENABLE, and
    + * selecting the condition which will allow the test to pass with
    + * COND_{FL,LT,...}.  It is possible to swizzle the values in the condition
    + * register, which allows for testing against an individual component.
    + *
    + * Branching:
    + *
    + *   The BRA/CAL instructions seem to follow a slightly different opcode
    + *   layout.  The destination instruction ID (IADDR) overlaps a source field.
    + *   Instruction ID's seem to be numbered based on the UPLOAD_FROM_ID FIFO
    + *   command, and is incremented automatically on each UPLOAD_INST FIFO
    + *   command.
    + *
    + *   Conditional branching is achieved by using the condition tests described
    + *   above.  There doesn't appear to be dedicated looping instructions, but
    + *   this can be done using a temp reg + conditional branching.
    + *
    + *   Subroutines may be uploaded before the main program itself, but the first
    + *   executed instruction is determined by the PROGRAM_START_ID FIFO command.
    + *
    + */
    +
    +/* DWORD 0 */
    +
    +#define NV30_VP_INST_ADDR_REG_SELECT_1        (1 << 24)
    +#define NV30_VP_INST_SRC2_ABS           (1 << 23) /* guess */
    +#define NV30_VP_INST_SRC1_ABS           (1 << 22) /* guess */
    +#define NV30_VP_INST_SRC0_ABS           (1 << 21) /* guess */
    +#define NV30_VP_INST_VEC_RESULT         (1 << 20)
    +#define NV30_VP_INST_DEST_TEMP_ID_SHIFT        16
    +#define NV30_VP_INST_DEST_TEMP_ID_MASK        (0x0F << 16)
    +#define NV30_VP_INST_COND_UPDATE_ENABLE        (1<<15)
    +#define NV30_VP_INST_VEC_DEST_TEMP_MASK      (0xF << 16)
    +#define NV30_VP_INST_COND_TEST_ENABLE        (1<<14)
    +#define NV30_VP_INST_COND_SHIFT          11
    +#define NV30_VP_INST_COND_MASK          (0x07 << 11)
    +#define NV30_VP_INST_COND_SWZ_X_SHIFT        9
    +#define NV30_VP_INST_COND_SWZ_X_MASK        (0x03 <<  9)
    +#define NV30_VP_INST_COND_SWZ_Y_SHIFT        7
    +#define NV30_VP_INST_COND_SWZ_Y_MASK        (0x03 <<  7)
    +#define NV30_VP_INST_COND_SWZ_Z_SHIFT        5
    +#define NV30_VP_INST_COND_SWZ_Z_MASK        (0x03 <<  5)
    +#define NV30_VP_INST_COND_SWZ_W_SHIFT        3
    +#define NV30_VP_INST_COND_SWZ_W_MASK        (0x03 <<  3)
    +#define NV30_VP_INST_COND_SWZ_ALL_SHIFT        3
    +#define NV30_VP_INST_COND_SWZ_ALL_MASK        (0xFF <<  3)
    +#define NV30_VP_INST_ADDR_SWZ_SHIFT        1
    +#define NV30_VP_INST_ADDR_SWZ_MASK        (0x03 <<  1)
    +#define NV30_VP_INST_SCA_OPCODEH_SHIFT        0
    +#define NV30_VP_INST_SCA_OPCODEH_MASK        (0x01 <<  0)
    +
    +/* DWORD 1 */
    +#define NV30_VP_INST_SCA_OPCODEL_SHIFT        28
    +#define NV30_VP_INST_SCA_OPCODEL_MASK        (0x0F << 28)
    +#define NV30_VP_INST_VEC_OPCODE_SHIFT        23
    +#define NV30_VP_INST_VEC_OPCODE_MASK        (0x1F << 23)
    +#define NV30_VP_INST_CONST_SRC_SHIFT        14
    +#define NV30_VP_INST_CONST_SRC_MASK        (0xFF << 14)
    +#define NV30_VP_INST_INPUT_SRC_SHIFT        9    /*NV20*/
    +#define NV30_VP_INST_INPUT_SRC_MASK        (0x0F <<  9)  /*NV20*/
    +#define NV30_VP_INST_SRC0H_SHIFT        0    /*NV20*/
    +#define NV30_VP_INST_SRC0H_MASK          (0x1FF << 0)  /*NV20*/
    +
    +/* Please note: the IADDR fields overlap other fields because they are used
    + * only for branch instructions.  See Branching: label above
    + *
    + * DWORD 2
    + */
    +#define NV30_VP_INST_SRC0L_SHIFT        26    /*NV20*/
    +#define NV30_VP_INST_SRC0L_MASK         (0x3F  <<26)  /* NV30_VP_SRC0_LOW_MASK << 26 */
    +#define NV30_VP_INST_SRC1_SHIFT         11    /*NV20*/
    +#define NV30_VP_INST_SRC1_MASK          (0x7FFF<<11)  /*NV20*/
    +#define NV30_VP_INST_SRC2H_SHIFT        0    /*NV20*/
    +#define NV30_VP_INST_SRC2H_MASK          (0x7FF << 0)  /* NV30_VP_SRC2_HIGH_MASK >> 4*/
    +#define NV30_VP_INST_IADDR_SHIFT        2
    +#define NV30_VP_INST_IADDR_MASK          (0xF <<  28)   /* NV30_VP_SRC2_LOW_MASK << 28 */
    +
    +/* DWORD 3 */
    +#define NV30_VP_INST_SRC2L_SHIFT        28    /*NV20*/
    +#define NV30_VP_INST_SRC2L_MASK          (0x0F  <<28)  /*NV20*/
    +#define NV30_VP_INST_STEMP_WRITEMASK_SHIFT      24
    +#define NV30_VP_INST_STEMP_WRITEMASK_MASK      (0x0F << 24)
    +#define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT      20
    +#define NV30_VP_INST_VTEMP_WRITEMASK_MASK      (0x0F << 20)
    +#define NV30_VP_INST_SDEST_WRITEMASK_SHIFT      16
    +#define NV30_VP_INST_SDEST_WRITEMASK_MASK      (0x0F << 16)
    +#define NV30_VP_INST_VDEST_WRITEMASK_SHIFT      12    /*NV20*/
    +#define NV30_VP_INST_VDEST_WRITEMASK_MASK      (0x0F << 12)  /*NV20*/
    +#define NV30_VP_INST_DEST_SHIFT        2
    +#define NV30_VP_INST_DEST_MASK        (0x0F <<  2)
    +#  define NV30_VP_INST_DEST_POS  0
    +#  define NV30_VP_INST_DEST_BFC0  1
    +#  define NV30_VP_INST_DEST_BFC1  2
    +#  define NV30_VP_INST_DEST_COL0  3
    +#  define NV30_VP_INST_DEST_COL1  4
    +#  define NV30_VP_INST_DEST_FOGC  5
    +#  define NV30_VP_INST_DEST_PSZ   6
    +#  define NV30_VP_INST_DEST_TC(n)  (8+n)
    +
    +/* Useful to split the source selection regs into their pieces */
    +#define NV30_VP_SRC0_HIGH_SHIFT                                                6
    +#define NV30_VP_SRC0_HIGH_MASK                                        0x00007FC0
    +#define NV30_VP_SRC0_LOW_MASK                                         0x0000003F
    +#define NV30_VP_SRC2_HIGH_SHIFT                                                4
    +#define NV30_VP_SRC2_HIGH_MASK                                        0x00007FF0
    +#define NV30_VP_SRC2_LOW_MASK                                         0x0000000F
    +
    +
    +/* Source-register definition - matches NV20 exactly */
    +#define NV30_VP_SRC_NEGATE          (1<<14)
    +#define NV30_VP_SRC_SWZ_X_SHIFT        12
    +#define NV30_VP_SRC_REG_SWZ_X_MASK        (0x03  <<12)
    +#define NV30_VP_SRC_SWZ_Y_SHIFT        10
    +#define NV30_VP_SRC_REG_SWZ_Y_MASK        (0x03  <<10)
    +#define NV30_VP_SRC_SWZ_Z_SHIFT        8
    +#define NV30_VP_SRC_REG_SWZ_Z_MASK        (0x03  << 8)
    +#define NV30_VP_SRC_SWZ_W_SHIFT        6
    +#define NV30_VP_SRC_REG_SWZ_W_MASK        (0x03  << 6)
    +#define NV30_VP_SRC_REG_SWZ_ALL_SHIFT        6
    +#define NV30_VP_SRC_REG_SWZ_ALL_MASK        (0xFF  << 6)
    +#define NV30_VP_SRC_TEMP_SRC_SHIFT        2
    +#define NV30_VP_SRC_REG_TEMP_ID_MASK        (0x0F  << 0)
    +#define NV30_VP_SRC_REG_TYPE_SHIFT        0
    +#define NV30_VP_SRC_REG_TYPE_MASK        (0x03  << 0)
    +#define NV30_VP_SRC_REG_TYPE_TEMP  1
    +#define NV30_VP_SRC_REG_TYPE_INPUT  2
    +#define NV30_VP_SRC_REG_TYPE_CONST  3 /* guess */
    +
    +#include "nvfx_shader.h"
    +
    +#endif
    diff --git a/src/gallium/drivers/nvfx/nv40_fragtex.c b/src/gallium/drivers/nvfx/nv40_fragtex.c
    new file mode 100644
    index 0000000000..5889b5e40d
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv40_fragtex.c
    @@ -0,0 +1,174 @@
    +#include "util/u_format.h"
    +#include "nvfx_context.h"
    +#include "nvfx_tex.h"
    +
    +void
    +nv40_sampler_state_init(struct pipe_context *pipe,
    +			  struct nvfx_sampler_state *ps,
    +			  const struct pipe_sampler_state *cso)
    +{
    +	if (cso->max_anisotropy >= 2) {
    +		/* no idea, binary driver sets it, works without it.. meh.. */
    +		ps->wrap |= (1 << 5);
    +
    +		if (cso->max_anisotropy >= 16) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_16X;
    +		} else
    +		if (cso->max_anisotropy >= 12) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_12X;
    +		} else
    +		if (cso->max_anisotropy >= 10) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_10X;
    +		} else
    +		if (cso->max_anisotropy >= 8) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_8X;
    +		} else
    +		if (cso->max_anisotropy >= 6) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_6X;
    +		} else
    +		if (cso->max_anisotropy >= 4) {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_4X;
    +		} else {
    +			ps->en |= NV40TCL_TEX_ENABLE_ANISO_2X;
    +		}
    +	}
    +
    +	{
    +		float limit;
    +
    +		limit = CLAMP(cso->lod_bias, -16.0, 15.0);
    +		ps->filt |= (int)(cso->lod_bias * 256.0) & 0x1fff;
    +
    +		limit = CLAMP(cso->max_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit * 256.0) << 7;
    +
    +		limit = CLAMP(cso->min_lod, 0.0, 15.0);
    +		ps->en |= (int)(limit * 256.0) << 19;
    +	}
    +}
    +
    +#define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w,sx,sy,sz,sw)            \
    +{                                                                              \
    +  TRUE,                                                                        \
    +  PIPE_FORMAT_##m,                                                             \
    +  NV40TCL_TEX_FORMAT_FORMAT_##tf,                                              \
    +  (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |         \
    +   NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |         \
    +   NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |         \
    +   NV34TCL_TX_SWIZZLE_S1_Z_##ts1z | NV34TCL_TX_SWIZZLE_S1_W_##ts1w),         \
    +  ((NV34TCL_TX_FILTER_SIGNED_RED*sx) | (NV34TCL_TX_FILTER_SIGNED_GREEN*sy) |       \
    +   (NV34TCL_TX_FILTER_SIGNED_BLUE*sz) | (NV34TCL_TX_FILTER_SIGNED_ALPHA*sw))       \
    +}
    +
    +struct nv40_texture_format {
    +	boolean defined;
    +	uint	pipe;
    +	int     format;
    +	int     swizzle;
    +	int     sign;
    +};
    +
    +static struct nv40_texture_format
    +nv40_texture_formats[] = {
    +	_(B8G8R8X8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    +	_(B8G8R8A8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	_(B5G5R5A1_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	_(B4G4R4A4_UNORM, A4R4G4B4,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	_(B5G6R5_UNORM  , R5G6B5  ,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    +	_(L8_UNORM      , L8      ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    +	_(A8_UNORM      , L8      , ZERO, ZERO, ZERO,   S1, X, X, X, X, 0, 0, 0, 0),
    +	_(R16_SNORM     , A16     , ZERO, ZERO,   S1,  ONE, X, X, X, Y, 1, 1, 1, 1),
    +	_(I8_UNORM      , L8      ,   S1,   S1,   S1,   S1, X, X, X, X, 0, 0, 0, 0),
    +	_(L8A8_UNORM    , A8L8    ,   S1,   S1,   S1,   S1, X, X, X, Y, 0, 0, 0, 0),
    +	_(Z16_UNORM     , Z16     ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    +	_(S8Z24_UNORM   , Z24     ,   S1,   S1,   S1,  ONE, X, X, X, X, 0, 0, 0, 0),
    +	_(DXT1_RGB      , DXT1    ,   S1,   S1,   S1,  ONE, X, Y, Z, W, 0, 0, 0, 0),
    +	_(DXT1_RGBA     , DXT1    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	_(DXT3_RGBA     , DXT3    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	_(DXT5_RGBA     , DXT5    ,   S1,   S1,   S1,   S1, X, Y, Z, W, 0, 0, 0, 0),
    +	{},
    +};
    +
    +static struct nv40_texture_format *
    +nv40_fragtex_format(uint pipe_format)
    +{
    +	struct nv40_texture_format *tf = nv40_texture_formats;
    +
    +	while (tf->defined) {
    +		if (tf->pipe == pipe_format)
    +			return tf;
    +		tf++;
    +	}
    +
    +	NOUVEAU_ERR("unknown texture format %s\n", util_format_name(pipe_format));
    +	return NULL;
    +}
    +
    +
    +struct nouveau_stateobj *
    +nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
    +{
    +	struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
    +	struct nvfx_miptree *nv40mt = nvfx->tex_miptree[unit];
    +	struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
    +	struct pipe_texture *pt = &nv40mt->base;
    +	struct nv40_texture_format *tf;
    +	struct nouveau_stateobj *so;
    +	uint32_t txf, txs, txp;
    +	unsigned tex_flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
    +
    +	tf = nv40_fragtex_format(pt->format);
    +	if (!tf)
    +		assert(0);
    +
    +	txf  = ps->fmt;
    +	txf |= tf->format | 0x8000;
    +	txf |= ((pt->last_level + 1) << NV40TCL_TEX_FORMAT_MIPMAP_COUNT_SHIFT);
    +
    +	if (1) /* XXX */
    +		txf |= NV34TCL_TX_FORMAT_NO_BORDER;
    +
    +	switch (pt->target) {
    +	case PIPE_TEXTURE_CUBE:
    +		txf |= NV34TCL_TX_FORMAT_CUBIC;
    +		/* fall-through */
    +	case PIPE_TEXTURE_2D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_2D;
    +		break;
    +	case PIPE_TEXTURE_3D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_3D;
    +		break;
    +	case PIPE_TEXTURE_1D:
    +		txf |= NV34TCL_TX_FORMAT_DIMS_1D;
    +		break;
    +	default:
    +		NOUVEAU_ERR("Unknown target %d\n", pt->target);
    +		return NULL;
    +	}
    +
    +	if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
    +		txp = 0;
    +	} else {
    +		txp  = nv40mt->level[0].pitch;
    +		txf |= NV40TCL_TEX_FORMAT_LINEAR;
    +	}
    +
    +	txs = tf->swizzle;
    +
    +	so = so_new(2, 9, 2);
    +	so_method(so, nvfx->screen->eng3d, NV34TCL_TX_OFFSET(unit), 8);
    +	so_reloc (so, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
    +	so_reloc (so, bo, txf, tex_flags | NOUVEAU_BO_OR,
    +		      NV34TCL_TX_FORMAT_DMA0, NV34TCL_TX_FORMAT_DMA1);
    +	so_data  (so, ps->wrap);
    +	so_data  (so, NV40TCL_TEX_ENABLE_ENABLE | ps->en);
    +	so_data  (so, txs);
    +	so_data  (so, ps->filt | tf->sign | 0x2000 /*voodoo*/);
    +	so_data  (so, (pt->width0 << NV34TCL_TX_NPOT_SIZE_W_SHIFT) |
    +		       pt->height0);
    +	so_data  (so, ps->bcol);
    +	so_method(so, nvfx->screen->eng3d, NV40TCL_TEX_SIZE1(unit), 1);
    +	so_data  (so, (pt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
    +
    +	return so;
    +}
    diff --git a/src/gallium/drivers/nvfx/nv40_vertprog.h b/src/gallium/drivers/nvfx/nv40_vertprog.h
    new file mode 100644
    index 0000000000..7337293bab
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv40_vertprog.h
    @@ -0,0 +1,177 @@
    +#ifndef __NV40_SHADER_H__
    +#define __NV40_SHADER_H__
    +
    +/* Vertex programs instruction set
    + *
    + * The NV40 instruction set is very similar to NV30.  Most fields are in
    + * a slightly different position in the instruction however.
    + *
    + * Merged instructions
    + *     In some cases it is possible to put two instructions into one opcode
    + *     slot.  The rules for when this is OK is not entirely clear to me yet.
    + *
    + *     There are separate writemasks and dest temp register fields for each
    + *     grouping of instructions.  There is however only one field with the
    + *     ID of a result register.  Writing to temp/result regs is selected by
    + *     setting VEC_RESULT/SCA_RESULT.
    + *
    + * Temporary registers
    + *     The source/dest temp register fields have been extended by 1 bit, to
    + *     give a total of 32 temporary registers.
    + *
    + * Relative Addressing
    + *     NV40 can use an address register to index into vertex attribute regs.
    + *     This is done by putting the offset value into INPUT_SRC and setting
    + *     the INDEX_INPUT flag.
    + *
    + * Conditional execution (see NV_vertex_program{2,3} for details)
    + *     There is a second condition code register on NV40, it's use is enabled
    + *     by setting the COND_REG_SELECT_1 flag.
    + *
    + * Texture lookup
    + *     TODO
    + */
    +
    +/* ---- OPCODE BITS 127:96 / data DWORD 0 --- */
    +#define NV40_VP_INST_VEC_RESULT                                        (1 << 30)
    +/* uncertain.. */
    +#define NV40_VP_INST_COND_UPDATE_ENABLE                        ((1 << 14)|1<<29)
    +/* use address reg as index into attribs */
    +#define NV40_VP_INST_INDEX_INPUT                                       (1 << 27)
    +#define NV40_VP_INST_COND_REG_SELECT_1                                 (1 << 25)
    +#define NV40_VP_INST_ADDR_REG_SELECT_1                                 (1 << 24)
    +#define NV40_VP_INST_SRC2_ABS                                          (1 << 23)
    +#define NV40_VP_INST_SRC1_ABS                                          (1 << 22)
    +#define NV40_VP_INST_SRC0_ABS                                          (1 << 21)
    +#define NV40_VP_INST_VEC_DEST_TEMP_SHIFT                                      15
    +#define NV40_VP_INST_VEC_DEST_TEMP_MASK                             (0x1F << 15)
    +#define NV40_VP_INST_COND_TEST_ENABLE                                  (1 << 13)
    +#define NV40_VP_INST_COND_SHIFT                                               10
    +#define NV40_VP_INST_COND_MASK                                       (0x7 << 10)
    +#define NV40_VP_INST_COND_SWZ_X_SHIFT                                          8
    +#define NV40_VP_INST_COND_SWZ_X_MASK                                    (3 << 8)
    +#define NV40_VP_INST_COND_SWZ_Y_SHIFT                                          6
    +#define NV40_VP_INST_COND_SWZ_Y_MASK                                    (3 << 6)
    +#define NV40_VP_INST_COND_SWZ_Z_SHIFT                                          4
    +#define NV40_VP_INST_COND_SWZ_Z_MASK                                    (3 << 4)
    +#define NV40_VP_INST_COND_SWZ_W_SHIFT                                          2
    +#define NV40_VP_INST_COND_SWZ_W_MASK                                    (3 << 2)
    +#define NV40_VP_INST_COND_SWZ_ALL_SHIFT                                        2
    +#define NV40_VP_INST_COND_SWZ_ALL_MASK                               (0xFF << 2)
    +#define NV40_VP_INST_ADDR_SWZ_SHIFT                                            0
    +#define NV40_VP_INST_ADDR_SWZ_MASK                                   (0x03 << 0)
    +#define NV40_VP_INST0_KNOWN ( \
    +                NV40_VP_INST_INDEX_INPUT | \
    +                NV40_VP_INST_COND_REG_SELECT_1 | \
    +                NV40_VP_INST_ADDR_REG_SELECT_1 | \
    +                NV40_VP_INST_SRC2_ABS | \
    +                NV40_VP_INST_SRC1_ABS | \
    +                NV40_VP_INST_SRC0_ABS | \
    +                NV40_VP_INST_VEC_DEST_TEMP_MASK | \
    +                NV40_VP_INST_COND_TEST_ENABLE | \
    +                NV40_VP_INST_COND_MASK | \
    +                NV40_VP_INST_COND_SWZ_ALL_MASK | \
    +                NV40_VP_INST_ADDR_SWZ_MASK)
    +
    +/* ---- OPCODE BITS 95:64 / data DWORD 1 --- */
    +#define NV40_VP_INST_VEC_OPCODE_SHIFT                                         22
    +#define NV40_VP_INST_VEC_OPCODE_MASK                                (0x1F << 22)
    +#define NV40_VP_INST_SCA_OPCODE_SHIFT                                         27
    +#define NV40_VP_INST_SCA_OPCODE_MASK                                (0x1F << 27)
    +#define NV40_VP_INST_CONST_SRC_SHIFT                                          12
    +#define NV40_VP_INST_CONST_SRC_MASK                                 (0xFF << 12)
    +#define NV40_VP_INST_INPUT_SRC_SHIFT                                           8
    +#define NV40_VP_INST_INPUT_SRC_MASK                                  (0x0F << 8)
    +#define NV40_VP_INST_SRC0H_SHIFT                                               0
    +#define NV40_VP_INST_SRC0H_MASK                                      (0xFF << 0)
    +#define NV40_VP_INST1_KNOWN ( \
    +                NV40_VP_INST_VEC_OPCODE_MASK | \
    +                NV40_VP_INST_SCA_OPCODE_MASK | \
    +                NV40_VP_INST_CONST_SRC_MASK  | \
    +                NV40_VP_INST_INPUT_SRC_MASK  | \
    +                NV40_VP_INST_SRC0H_MASK \
    +                )
    +
    +/* ---- OPCODE BITS 63:32 / data DWORD 2 --- */
    +#define NV40_VP_INST_SRC0L_SHIFT                                              23
    +#define NV40_VP_INST_SRC0L_MASK                                    (0x1FF << 23)
    +#define NV40_VP_INST_SRC1_SHIFT                                                6
    +#define NV40_VP_INST_SRC1_MASK                                    (0x1FFFF << 6)
    +#define NV40_VP_INST_SRC2H_SHIFT                                               0
    +#define NV40_VP_INST_SRC2H_MASK                                      (0x3F << 0)
    +#define NV40_VP_INST_IADDRH_SHIFT                                              0
    +#define NV40_VP_INST_IADDRH_MASK                                     (0x1F << 0)
    +
    +/* ---- OPCODE BITS 31:0 / data DWORD 3 --- */
    +#define NV40_VP_INST_IADDRL_SHIFT                                             29
    +#define NV40_VP_INST_IADDRL_MASK                                       (7 << 29)
    +#define NV40_VP_INST_SRC2L_SHIFT                                              21
    +#define NV40_VP_INST_SRC2L_MASK                                    (0x7FF << 21)
    +#define NV40_VP_INST_SCA_WRITEMASK_SHIFT                                      17
    +#define NV40_VP_INST_SCA_WRITEMASK_MASK                              (0xF << 17)
    +#    define NV40_VP_INST_SCA_WRITEMASK_X                               (1 << 20)
    +#    define NV40_VP_INST_SCA_WRITEMASK_Y                               (1 << 19)
    +#    define NV40_VP_INST_SCA_WRITEMASK_Z                               (1 << 18)
    +#    define NV40_VP_INST_SCA_WRITEMASK_W                               (1 << 17)
    +#define NV40_VP_INST_VEC_WRITEMASK_SHIFT                                      13
    +#define NV40_VP_INST_VEC_WRITEMASK_MASK                              (0xF << 13)
    +#    define NV40_VP_INST_VEC_WRITEMASK_X                               (1 << 16)
    +#    define NV40_VP_INST_VEC_WRITEMASK_Y                               (1 << 15)
    +#    define NV40_VP_INST_VEC_WRITEMASK_Z                               (1 << 14)
    +#    define NV40_VP_INST_VEC_WRITEMASK_W                               (1 << 13)
    +#define NV40_VP_INST_SCA_RESULT                                        (1 << 12)
    +#define NV40_VP_INST_SCA_DEST_TEMP_SHIFT                                       7
    +#define NV40_VP_INST_SCA_DEST_TEMP_MASK                              (0x1F << 7)
    +#define NV40_VP_INST_DEST_SHIFT                                                2
    +#define NV40_VP_INST_DEST_MASK                                         (31 << 2)
    +#    define NV40_VP_INST_DEST_POS                                              0
    +#    define NV40_VP_INST_DEST_COL0                                             1
    +#    define NV40_VP_INST_DEST_COL1                                             2
    +#    define NV40_VP_INST_DEST_BFC0                                             3
    +#    define NV40_VP_INST_DEST_BFC1                                             4
    +#    define NV40_VP_INST_DEST_FOGC                                             5
    +#    define NV40_VP_INST_DEST_PSZ                                              6
    +#    define NV40_VP_INST_DEST_TC0                                              7
    +#    define NV40_VP_INST_DEST_TC(n)                                        (7+n)
    +#    define NV40_VP_INST_DEST_TEMP                                          0x1F
    +#define NV40_VP_INST_INDEX_CONST                                        (1 << 1)
    +#define NV40_VP_INST3_KNOWN ( \
    +                NV40_VP_INST_SRC2L_MASK |\
    +                NV40_VP_INST_SCA_WRITEMASK_MASK |\
    +                NV40_VP_INST_VEC_WRITEMASK_MASK |\
    +                NV40_VP_INST_SCA_DEST_TEMP_MASK |\
    +                NV40_VP_INST_DEST_MASK |\
    +                NV40_VP_INST_INDEX_CONST)
    +
    +/* Useful to split the source selection regs into their pieces */
    +#define NV40_VP_SRC0_HIGH_SHIFT                                                9
    +#define NV40_VP_SRC0_HIGH_MASK                                        0x0001FE00
    +#define NV40_VP_SRC0_LOW_MASK                                         0x000001FF
    +#define NV40_VP_SRC2_HIGH_SHIFT                                               11
    +#define NV40_VP_SRC2_HIGH_MASK                                        0x0001F800
    +#define NV40_VP_SRC2_LOW_MASK                                         0x000007FF
    +
    +/* Source selection - these are the bits you fill NV40_VP_INST_SRCn with */
    +#define NV40_VP_SRC_NEGATE                                             (1 << 16)
    +#define NV40_VP_SRC_SWZ_X_SHIFT                                               14
    +#define NV40_VP_SRC_SWZ_X_MASK                                         (3 << 14)
    +#define NV40_VP_SRC_SWZ_Y_SHIFT                                               12
    +#define NV40_VP_SRC_SWZ_Y_MASK                                         (3 << 12)
    +#define NV40_VP_SRC_SWZ_Z_SHIFT                                               10
    +#define NV40_VP_SRC_SWZ_Z_MASK                                         (3 << 10)
    +#define NV40_VP_SRC_SWZ_W_SHIFT                                                8
    +#define NV40_VP_SRC_SWZ_W_MASK                                          (3 << 8)
    +#define NV40_VP_SRC_SWZ_ALL_SHIFT                                              8
    +#define NV40_VP_SRC_SWZ_ALL_MASK                                     (0xFF << 8)
    +#define NV40_VP_SRC_TEMP_SRC_SHIFT                                             2
    +#define NV40_VP_SRC_TEMP_SRC_MASK                                    (0x1F << 2)
    +#define NV40_VP_SRC_REG_TYPE_SHIFT                                             0
    +#define NV40_VP_SRC_REG_TYPE_MASK                                       (3 << 0)
    +#    define NV40_VP_SRC_REG_TYPE_UNK0                                          0
    +#    define NV40_VP_SRC_REG_TYPE_TEMP                                          1
    +#    define NV40_VP_SRC_REG_TYPE_INPUT                                         2
    +#    define NV40_VP_SRC_REG_TYPE_CONST                                         3
    +
    +#include "nvfx_shader.h"
    +
    +#endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    index 8700e14329..7308f0667c 100644
    --- a/src/gallium/drivers/nvfx/nvfx_draw.c
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -9,8 +9,8 @@
     
     #include "nvfx_context.h"
     #define NVFX_SHADER_NO_FUCKEDNESS
    -#include "nv30/nv30_shader.h"
    -#include "nv40/nv40_shader.h"
    +#include "nv30_vertprog.h"
    +#include "nv40_vertprog.h"
     
     /* Simple, but crappy, swtnl path, hopefully we wont need to hit this very
      * often at all.  Uses "quadro style" vertex submission + a fixed vertex
    diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    index 730361a982..3d0e8c23a1 100644
    --- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
    +++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    @@ -33,8 +33,8 @@
     #define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
     #define DEF_SCALE 0
     #define DEF_CTEST 0
    -#include "nv30/nv30_shader.h"
    -#include "nv40/nv40_shader.h"
    +#include "nv30_vertprog.h"
    +#include "nv40_vertprog.h"
     
     #define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
     #define neg(s) nvfx_sr_neg((s))
    diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile
    index 0cc60395ff..50ac3f203e 100644
    --- a/src/gallium/winsys/drm/nouveau/dri/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile
    @@ -3,18 +3,10 @@ include $(TOP)/configs/current
     
     LIBNAME = nouveau_dri.so
     
    -# hideous hack
    --Wl,--start-group:
    --Wl,--end-group:
    -
     PIPE_DRIVERS = \
     	$(TOP)/src/gallium/state_trackers/dri/libdridrm.a \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    -	-Wl,--start-group \
    -	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
    -	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
     	$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
    -	-Wl,--end-group \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a
     
    diff --git a/src/gallium/winsys/drm/nouveau/egl/Makefile b/src/gallium/winsys/drm/nouveau/egl/Makefile
    index 0f5e6d64aa..47d1127615 100644
    --- a/src/gallium/winsys/drm/nouveau/egl/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/egl/Makefile
    @@ -5,17 +5,9 @@ EGL_DRIVER_NAME = nouveau
     EGL_DRIVER_SOURCES = dummy.c
     EGL_DRIVER_LIBS = -ldrm_nouveau
     
    -# hideous hack
    --Wl,--start-group:
    --Wl,--end-group:
    -
     EGL_DRIVER_PIPES = \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    -	-Wl,--start-group \
    -	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
    -	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
    -	$(TOP)/src/gallium/drivers/nv40/libnvfx.a \
    -	-Wl,--end-group \
    +	$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
     	$(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a
    diff --git a/src/gallium/winsys/drm/nouveau/xorg/Makefile b/src/gallium/winsys/drm/nouveau/xorg/Makefile
    index 0607d82a6e..f7f6fe17dd 100644
    --- a/src/gallium/winsys/drm/nouveau/xorg/Makefile
    +++ b/src/gallium/winsys/drm/nouveau/xorg/Makefile
    @@ -15,18 +15,10 @@ INCLUDES = \
     	-I$(TOP)/include \
     	-I$(TOP)/src/egl/main
     
    -# hideous hack
    --Wl,--start-group:
    --Wl,--end-group:
    -
     LIBS = \
     	$(TOP)/src/gallium/state_trackers/xorg/libxorgtracker.a \
     	$(TOP)/src/gallium/winsys/drm/nouveau/drm/libnouveaudrm.a \
    -	--Wl,--start-group \
    -	$(TOP)/src/gallium/drivers/nv30/libnv30.a \
    -	$(TOP)/src/gallium/drivers/nv40/libnv40.a \
    -	$(TOP)/src/gallium/drivers/nv40/libnvfx.a \
    -	--Wl,--end-group \
    +	$(TOP)/src/gallium/drivers/nvfx/libnvfx.a \
     	$(TOP)/src/gallium/drivers/nv50/libnv50.a \
     	$(TOP)/src/gallium/drivers/nouveau/libnouveau.a \
     	$(GALLIUM_AUXILIARIES)
    -- 
    cgit v1.2.3
    
    
    From 0192a4a825d3d04b1588bdabad629a9888f325d6 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Tue, 2 Mar 2010 22:51:39 +0100
    Subject: nvfx: fix viewport state after bypass removal for swtnl
    
    The adjustment of nv30/nv40 after the removal of bypass incorrectly
    removed the hardware viewport bypass code, which we still need for
    swtnl and also forgot to remove NVFX_NEW_RAST from pipe.
    ---
     src/gallium/drivers/nvfx/nvfx_state_viewport.c | 35 ++++++++++++++++++--------
     1 file changed, 24 insertions(+), 11 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_state_viewport.c b/src/gallium/drivers/nvfx/nvfx_state_viewport.c
    index 72057a80f8..82e0e9220b 100644
    --- a/src/gallium/drivers/nvfx/nvfx_state_viewport.c
    +++ b/src/gallium/drivers/nvfx/nvfx_state_viewport.c
    @@ -13,16 +13,29 @@ nvfx_state_viewport_validate(struct nvfx_context *nvfx)
     	so = so_new(2, 9, 0);
     	so_method(so, nvfx->screen->eng3d,
     		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
    -	so_data  (so, fui(vpt->translate[0]));
    -	so_data  (so, fui(vpt->translate[1]));
    -	so_data  (so, fui(vpt->translate[2]));
    -	so_data  (so, fui(vpt->translate[3]));
    -	so_data  (so, fui(vpt->scale[0]));
    -	so_data  (so, fui(vpt->scale[1]));
    -	so_data  (so, fui(vpt->scale[2]));
    -	so_data  (so, fui(vpt->scale[3]));
    -	so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    -	so_data  (so, 1);
    +	if(nvfx->render_mode == HW) {
    +		so_data  (so, fui(vpt->translate[0]));
    +		so_data  (so, fui(vpt->translate[1]));
    +		so_data  (so, fui(vpt->translate[2]));
    +		so_data  (so, fui(vpt->translate[3]));
    +		so_data  (so, fui(vpt->scale[0]));
    +		so_data  (so, fui(vpt->scale[1]));
    +		so_data  (so, fui(vpt->scale[2]));
    +		so_data  (so, fui(vpt->scale[3]));
    +		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    +		so_data  (so, 1);
    +	} else {
    +		so_data  (so, fui(0.0f));
    +		so_data  (so, fui(0.0f));
    +		so_data  (so, fui(0.0f));
    +		so_data  (so, fui(0.0f));
    +		so_data  (so, fui(1.0f));
    +		so_data  (so, fui(1.0f));
    +		so_data  (so, fui(1.0f));
    +		so_data  (so, fui(1.0f));
    +		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
    +		so_data  (so, nvfx->is_nv4x ? 0x110 : 1);
    +	}
     
     	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
     	so_ref(NULL, &so);
    @@ -32,7 +45,7 @@ nvfx_state_viewport_validate(struct nvfx_context *nvfx)
     struct nvfx_state_entry nvfx_state_viewport = {
     	.validate = nvfx_state_viewport_validate,
     	.dirty = {
    -		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_RAST,
    +		.pipe = NVFX_NEW_VIEWPORT,
     		.hw = NVFX_STATE_VIEWPORT
     	}
     };
    -- 
    cgit v1.2.3
    
    
    From e1580ce4c9ec1175296504c0ae9f26d9d8e0e635 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 14:13:17 +0100
    Subject: nvfx: fix quads drawing
    
    The primitive splitting code is totally broken and will be rewritten.
    
    Fix the most important bug now though.
    ---
     src/gallium/drivers/nouveau/nouveau_util.h | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nouveau/nouveau_util.h b/src/gallium/drivers/nouveau/nouveau_util.h
    index 7f16e31c3f..ab7761a31d 100644
    --- a/src/gallium/drivers/nouveau/nouveau_util.h
    +++ b/src/gallium/drivers/nouveau/nouveau_util.h
    @@ -33,7 +33,7 @@ nouveau_vbuf_split(unsigned remaining, unsigned overhead, unsigned vpp,
     		max = max - (max % 3);
     		break;
     	case PIPE_PRIM_QUADS:
    -		max = max & 3;
    +		max = max & ~3;
     		break;
     	case PIPE_PRIM_LINE_LOOP:
     	case PIPE_PRIM_LINE_STRIP:
    -- 
    cgit v1.2.3
    
    
    From dbe63ed3b688fc1b2714d1418a031210c9e00d3b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 20:14:32 +0100
    Subject: nvfx: move nv04_surface_2d.c into nvfx directory
    
    It is only used on pre-nv50 and nvfx is the only Gallium pre-nv50 driver.
    ---
     src/gallium/drivers/nouveau/Makefile          |   3 +-
     src/gallium/drivers/nouveau/nv04_surface_2d.c | 546 --------------------------
     src/gallium/drivers/nouveau/nv04_surface_2d.h |  37 --
     src/gallium/drivers/nvfx/Makefile             |   1 +
     src/gallium/drivers/nvfx/nv04_surface_2d.c    | 545 +++++++++++++++++++++++++
     src/gallium/drivers/nvfx/nv04_surface_2d.h    |  37 ++
     src/gallium/drivers/nvfx/nvfx_miptree.c       |   2 +-
     src/gallium/drivers/nvfx/nvfx_screen.h        |   2 +-
     8 files changed, 586 insertions(+), 587 deletions(-)
     delete mode 100644 src/gallium/drivers/nouveau/nv04_surface_2d.c
     delete mode 100644 src/gallium/drivers/nouveau/nv04_surface_2d.h
     create mode 100644 src/gallium/drivers/nvfx/nv04_surface_2d.c
     create mode 100644 src/gallium/drivers/nvfx/nv04_surface_2d.h
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile
    index 0e02680bc6..0cb66041d5 100644
    --- a/src/gallium/drivers/nouveau/Makefile
    +++ b/src/gallium/drivers/nouveau/Makefile
    @@ -4,7 +4,6 @@ include $(TOP)/configs/current
     LIBNAME = nouveau
     
     C_SOURCES = nouveau_screen.c \
    -	    nouveau_context.c \
    -	    nv04_surface_2d.c
    +	    nouveau_context.c
     
     include ../../Makefile.template
    diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.c b/src/gallium/drivers/nouveau/nv04_surface_2d.c
    deleted file mode 100644
    index 93114465d5..0000000000
    --- a/src/gallium/drivers/nouveau/nv04_surface_2d.c
    +++ /dev/null
    @@ -1,546 +0,0 @@
    -#include "pipe/p_context.h"
    -#include "pipe/p_format.h"
    -#include "util/u_format.h"
    -#include "util/u_math.h"
    -#include "util/u_memory.h"
    -
    -#include "nouveau/nouveau_winsys.h"
    -#include "nouveau/nouveau_util.h"
    -#include "nouveau/nouveau_screen.h"
    -#include "nv04_surface_2d.h"
    -
    -static INLINE int
    -nv04_surface_format(enum pipe_format format)
    -{
    -	switch (format) {
    -	case PIPE_FORMAT_A8_UNORM:
    -	case PIPE_FORMAT_L8_UNORM:
    -	case PIPE_FORMAT_I8_UNORM:
    -		return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
    -	case PIPE_FORMAT_R16_SNORM:
    -	case PIPE_FORMAT_B5G6R5_UNORM:
    -	case PIPE_FORMAT_Z16_UNORM:
    -	case PIPE_FORMAT_L8A8_UNORM:
    -		return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
    -	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -	case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
    -	case PIPE_FORMAT_S8Z24_UNORM:
    -	case PIPE_FORMAT_X8Z24_UNORM:
    -		return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
    -	default:
    -		return -1;
    -	}
    -}
    -
    -static INLINE int
    -nv04_rect_format(enum pipe_format format)
    -{
    -	switch (format) {
    -	case PIPE_FORMAT_A8_UNORM:
    -		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
    -	case PIPE_FORMAT_B5G6R5_UNORM:
    -	case PIPE_FORMAT_L8A8_UNORM:
    -	case PIPE_FORMAT_Z16_UNORM:
    -		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
    -	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -	case PIPE_FORMAT_B8G8R8A8_UNORM:
    -	case PIPE_FORMAT_S8Z24_UNORM:
    -	case PIPE_FORMAT_X8Z24_UNORM:
    -		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
    -	default:
    -		return -1;
    -	}
    -}
    -
    -static INLINE int
    -nv04_scaled_image_format(enum pipe_format format)
    -{
    -	switch (format) {
    -	case PIPE_FORMAT_A8_UNORM:
    -	case PIPE_FORMAT_L8_UNORM:
    -	case PIPE_FORMAT_I8_UNORM:
    -		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
    -	case PIPE_FORMAT_B5G5R5A1_UNORM:
    -		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
    -	case PIPE_FORMAT_B8G8R8A8_UNORM:
    -		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
    -	case PIPE_FORMAT_B8G8R8X8_UNORM:
    -		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
    -	case PIPE_FORMAT_B5G6R5_UNORM:
    -	case PIPE_FORMAT_R16_SNORM:
    -	case PIPE_FORMAT_L8A8_UNORM:
    -		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
    -	default:
    -		return -1;
    -	}
    -}
    -
    -static INLINE unsigned
    -nv04_swizzle_bits_square(unsigned x, unsigned y)
    -{
    -	unsigned u = (x & 0x001) << 0 |
    -	             (x & 0x002) << 1 |
    -	             (x & 0x004) << 2 |
    -	             (x & 0x008) << 3 |
    -	             (x & 0x010) << 4 |
    -	             (x & 0x020) << 5 |
    -	             (x & 0x040) << 6 |
    -	             (x & 0x080) << 7 |
    -	             (x & 0x100) << 8 |
    -	             (x & 0x200) << 9 |
    -	             (x & 0x400) << 10 |
    -	             (x & 0x800) << 11;
    -
    -	unsigned v = (y & 0x001) << 1 |
    -	             (y & 0x002) << 2 |
    -	             (y & 0x004) << 3 |
    -	             (y & 0x008) << 4 |
    -	             (y & 0x010) << 5 |
    -	             (y & 0x020) << 6 |
    -	             (y & 0x040) << 7 |
    -	             (y & 0x080) << 8 |
    -	             (y & 0x100) << 9 |
    -	             (y & 0x200) << 10 |
    -	             (y & 0x400) << 11 |
    -	             (y & 0x800) << 12;
    -	return v | u;
    -}
    -
    -/* rectangular swizzled textures are linear concatenations of swizzled square tiles */
    -static INLINE unsigned
    -nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h)
    -{
    -	unsigned s = MIN2(w, h);
    -	unsigned m = s - 1;
    -	return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m);
    -}
    -
    -static int
    -nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
    -			  struct pipe_surface *dst, int dx, int dy,
    -			  struct pipe_surface *src, int sx, int sy,
    -			  int w, int h)
    -{
    -	struct nouveau_channel *chan = ctx->swzsurf->channel;
    -	struct nouveau_grobj *swzsurf = ctx->swzsurf;
    -	struct nouveau_grobj *sifm = ctx->sifm;
    -	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    -	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    -	const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    -        /* Max width & height may not be the same on all HW, but must be POT */
    -	const unsigned max_w = 1024;
    -	const unsigned max_h = 1024;
    -	unsigned sub_w = w > max_w ? max_w : w;
    -	unsigned sub_h = h > max_h ? max_h : h;
    -	unsigned x;
    -	unsigned y;
    -
    -        /* Swizzled surfaces must be POT  */
    -	assert(util_is_pot(dst->width) && util_is_pot(dst->height));
    -
    -        /* If area is too large to copy in one shot we must copy it in POT chunks to meet alignment requirements */
    -	assert(sub_w == w || util_is_pot(sub_w));
    -	assert(sub_h == h || util_is_pot(sub_h));
    -
    -	MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 +
    -			 ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2);
    -
    -	BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
    -	OUT_RELOCo(chan, dst_bo,
    -	                 NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -
    -	BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1);
    -	OUT_RING  (chan, nv04_surface_format(dst->format) |
    -	                 log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
    -	                 log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
    -
    -	BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
    -	OUT_RELOCo(chan, src_bo,
    -	                 NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    -	BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
    -	OUT_RING  (chan, swzsurf->handle);
    -
    -	for (y = 0; y < h; y += sub_h) {
    -	  sub_h = MIN2(sub_h, h - y);
    -
    -	  for (x = 0; x < w; x += sub_w) {
    -	    sub_w = MIN2(sub_w, w - x);
    -
    -	    assert(!(dst->offset & 63));
    -
    -	    BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
    -	    OUT_RELOCl(chan, dst_bo, dst->offset,
    -                             NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -
    -	    BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
    -	    OUT_RING  (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
    -	    OUT_RING  (chan, nv04_scaled_image_format(src->format));
    -	    OUT_RING  (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
    -	    OUT_RING  (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
    -	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
    -	    OUT_RING  (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
    -	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
    -	    OUT_RING  (chan, 1 << 20);
    -	    OUT_RING  (chan, 1 << 20);
    -
    -	    BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
    -	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w);
    -	    OUT_RING  (chan, src_pitch |
    -			     NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
    -			     NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
    -	    OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
    -                             NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    -	    OUT_RING  (chan, 0);
    -	  }
    -	}
    -
    -	return 0;
    -}
    -
    -static int
    -nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
    -		       struct pipe_surface *dst, int dx, int dy,
    -		       struct pipe_surface *src, int sx, int sy, int w, int h)
    -{
    -	struct nouveau_channel *chan = ctx->m2mf->channel;
    -	struct nouveau_grobj *m2mf = ctx->m2mf;
    -	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    -	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    -	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    -	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    -	unsigned dst_offset = dst->offset + dy * dst_pitch +
    -	                      dx * util_format_get_blocksize(dst->texture->format);
    -	unsigned src_offset = src->offset + sy * src_pitch +
    -	                      sx * util_format_get_blocksize(src->texture->format);
    -
    -	MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2);
    -	BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
    -	OUT_RELOCo(chan, src_bo,
    -		   NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    -	OUT_RELOCo(chan, dst_bo,
    -		   NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -
    -	while (h) {
    -		int count = (h > 2047) ? 2047 : h;
    -
    -		BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
    -		OUT_RELOCl(chan, src_bo, src_offset,
    -			   NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
    -		OUT_RELOCl(chan, dst_bo, dst_offset,
    -			   NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
    -		OUT_RING  (chan, src_pitch);
    -		OUT_RING  (chan, dst_pitch);
    -		OUT_RING  (chan, w * util_format_get_blocksize(src->texture->format));
    -		OUT_RING  (chan, count);
    -		OUT_RING  (chan, 0x0101);
    -		OUT_RING  (chan, 0);
    -
    -		h -= count;
    -		src_offset += src_pitch * count;
    -		dst_offset += dst_pitch * count;
    -	}
    -
    -	return 0;
    -}
    -
    -static int
    -nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    -		       int dx, int dy, struct pipe_surface *src, int sx, int sy,
    -		       int w, int h)
    -{
    -	struct nouveau_channel *chan = ctx->surf2d->channel;
    -	struct nouveau_grobj *surf2d = ctx->surf2d;
    -	struct nouveau_grobj *blit = ctx->blit;
    -	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    -	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    -	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    -	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    -	int format;
    -
    -	format = nv04_surface_format(dst->format);
    -	if (format < 0)
    -		return 1;
    -
    -	MARK_RING (chan, 12, 4);
    -	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    -	OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    -	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
    -	OUT_RING  (chan, format);
    -	OUT_RING  (chan, (dst_pitch << 16) | src_pitch);
    -	OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    -	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -
    -	BEGIN_RING(chan, blit, 0x0300, 3);
    -	OUT_RING  (chan, (sy << 16) | sx);
    -	OUT_RING  (chan, (dy << 16) | dx);
    -	OUT_RING  (chan, ( h << 16) |  w);
    -
    -	return 0;
    -}
    -
    -static void
    -nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    -		  int dx, int dy, struct pipe_surface *src, int sx, int sy,
    -		  int w, int h)
    -{
    -	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    -	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    -	int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
    -	int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
    -
    -	assert(src->format == dst->format);
    -
    -	/* Setup transfer to swizzle the texture to vram if needed */
    -        if (src_linear && !dst_linear && w > 1 && h > 1) {
    -           nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
    -           return;
    -        }
    -
    -	/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
    -	 * to NV_MEMORY_TO_MEMORY_FORMAT in this case.
    -	 */
    -	if ((src->offset & 63) || (dst->offset & 63) ||
    -	    (src_pitch & 63) || (dst_pitch & 63)) {
    -		nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
    -		return;
    -	}
    -
    -	nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h);
    -}
    -
    -static void
    -nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    -		  int dx, int dy, int w, int h, unsigned value)
    -{
    -	struct nouveau_channel *chan = ctx->surf2d->channel;
    -	struct nouveau_grobj *surf2d = ctx->surf2d;
    -	struct nouveau_grobj *rect = ctx->rect;
    -	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    -	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    -	int cs2d_format, gdirect_format;
    -
    -	cs2d_format = nv04_surface_format(dst->format);
    -	assert(cs2d_format >= 0);
    -
    -	gdirect_format = nv04_rect_format(dst->format);
    -	assert(gdirect_format >= 0);
    -
    -	MARK_RING (chan, 16, 4);
    -	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    -	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
    -	OUT_RING  (chan, cs2d_format);
    -	OUT_RING  (chan, (dst_pitch << 16) | dst_pitch);
    -	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    -
    -	BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1);
    -	OUT_RING  (chan, gdirect_format);
    -	BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1);
    -	OUT_RING  (chan, value);
    -	BEGIN_RING(chan, rect,
    -		   NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2);
    -	OUT_RING  (chan, (dx << 16) | dy);
    -	OUT_RING  (chan, ( w << 16) |  h);
    -}
    -
    -void
    -nv04_surface_2d_takedown(struct nv04_surface_2d **pctx)
    -{
    -	struct nv04_surface_2d *ctx;
    -
    -	if (!pctx || !*pctx)
    -		return;
    -	ctx = *pctx;
    -	*pctx = NULL;
    -
    -	nouveau_notifier_free(&ctx->ntfy);
    -	nouveau_grobj_free(&ctx->m2mf);
    -	nouveau_grobj_free(&ctx->surf2d);
    -	nouveau_grobj_free(&ctx->swzsurf);
    -	nouveau_grobj_free(&ctx->rect);
    -	nouveau_grobj_free(&ctx->blit);
    -	nouveau_grobj_free(&ctx->sifm);
    -
    -	FREE(ctx);
    -}
    -
    -struct nv04_surface_2d *
    -nv04_surface_2d_init(struct nouveau_screen *screen)
    -{
    -	struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d);
    -	struct nouveau_channel *chan = screen->channel;
    -	unsigned handle = 0x88000000, class;
    -	int ret;
    -
    -	if (!ctx)
    -		return NULL;
    -
    -	ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
    -	OUT_RING  (chan, ctx->ntfy->handle);
    -
    -	if (chan->device->chipset < 0x10)
    -		class = NV04_CONTEXT_SURFACES_2D;
    -	else
    -		class = NV10_CONTEXT_SURFACES_2D;
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	BEGIN_RING(chan, ctx->surf2d,
    -			 NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    -	OUT_RING  (chan, chan->vram->handle);
    -	OUT_RING  (chan, chan->vram->handle);
    -
    -	if (chan->device->chipset < 0x10)
    -		class = NV04_IMAGE_BLIT;
    -	else
    -		class = NV12_IMAGE_BLIT;
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1);
    -	OUT_RING  (chan, ctx->ntfy->handle);
    -	BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1);
    -	OUT_RING  (chan, ctx->surf2d->handle);
    -	BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1);
    -	OUT_RING  (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY);
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
    -				  &ctx->rect);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
    -	OUT_RING  (chan, ctx->ntfy->handle);
    -	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
    -	OUT_RING  (chan, ctx->surf2d->handle);
    -	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
    -	OUT_RING  (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY);
    -	BEGIN_RING(chan, ctx->rect,
    -			 NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
    -	OUT_RING  (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
    -
    -	switch (chan->device->chipset & 0xf0) {
    -	case 0x00:
    -	case 0x10:
    -		class = NV04_SWIZZLED_SURFACE;
    -		break;
    -	case 0x20:
    -		class = NV20_SWIZZLED_SURFACE;
    -		break;
    -	case 0x30:
    -		class = NV30_SWIZZLED_SURFACE;
    -		break;
    -	case 0x40:
    -	case 0x60:
    -		class = NV40_SWIZZLED_SURFACE;
    -		break;
    -	default:
    -		/* Famous last words: this really can't happen.. */
    -		assert(0);
    -		break;
    -	}
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	switch (chan->device->chipset & 0xf0) {
    -	case 0x10:
    -	case 0x20:
    -		class = NV10_SCALED_IMAGE_FROM_MEMORY;
    -		break;
    -	case 0x30:
    -		class = NV30_SCALED_IMAGE_FROM_MEMORY;
    -		break;
    -	case 0x40:
    -	case 0x60:
    -		class = NV40_SCALED_IMAGE_FROM_MEMORY;
    -		break;
    -	default:
    -		class = NV04_SCALED_IMAGE_FROM_MEMORY;
    -		break;
    -	}
    -
    -	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm);
    -	if (ret) {
    -		nv04_surface_2d_takedown(&ctx);
    -		return NULL;
    -	}
    -
    -	ctx->copy = nv04_surface_copy;
    -	ctx->fill = nv04_surface_fill;
    -	return ctx;
    -}
    -
    -struct nv04_surface*
    -nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
    -{
    -	int temp_flags;
    -
    -	// printf("creating temp, flags is %i!\n", flags);
    -
    -	if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
    -	{
    -		temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
    -		ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
    -	}
    -	else
    -	{
    -		temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
    -		ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
    -	}
    -
    -	ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
    -
    -	struct pipe_texture templ;
    -	memset(&templ, 0, sizeof(templ));
    -	templ.format = ns->base.texture->format;
    -	templ.target = PIPE_TEXTURE_2D;
    -	templ.width0 = ns->base.width;
    -	templ.height0 = ns->base.height;
    -	templ.depth0 = 1;
    -	templ.last_level = 0;
    -
    -	// TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
    -	templ.nr_samples = ns->base.texture->nr_samples;
    -
    -	templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
    -
    -	struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
    -	struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
    -	temp_ns->backing = ns;
    -
    -	if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
    -		eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
    -
    -	return temp_ns;
    -}
    -
    diff --git a/src/gallium/drivers/nouveau/nv04_surface_2d.h b/src/gallium/drivers/nouveau/nv04_surface_2d.h
    deleted file mode 100644
    index ce696a11a3..0000000000
    --- a/src/gallium/drivers/nouveau/nv04_surface_2d.h
    +++ /dev/null
    @@ -1,37 +0,0 @@
    -#ifndef __NV04_SURFACE_2D_H__
    -#define __NV04_SURFACE_2D_H__
    -
    -struct nv04_surface {
    -	struct pipe_surface base;
    -	unsigned pitch;
    -	struct nv04_surface* backing;
    -};
    -
    -struct nv04_surface_2d {
    -	struct nouveau_notifier *ntfy;
    -	struct nouveau_grobj *surf2d;
    -	struct nouveau_grobj *swzsurf;
    -	struct nouveau_grobj *m2mf;
    -	struct nouveau_grobj *rect;
    -	struct nouveau_grobj *blit;
    -	struct nouveau_grobj *sifm;
    -
    -	struct pipe_buffer *(*buf)(struct pipe_surface *);
    -
    -	void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst,
    -		     int dx, int dy, struct pipe_surface *src, int sx, int sy,
    -		     int w, int h);
    -	void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst,
    -		     int dx, int dy, int w, int h, unsigned value);
    -};
    -
    -struct nv04_surface_2d *
    -nv04_surface_2d_init(struct nouveau_screen *screen);
    -
    -void
    -nv04_surface_2d_takedown(struct nv04_surface_2d **);
    -
    -struct nv04_surface*
    -nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns);
    -
    -#endif
    diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
    index e912177b21..dfe97e6ed5 100644
    --- a/src/gallium/drivers/nvfx/Makefile
    +++ b/src/gallium/drivers/nvfx/Makefile
    @@ -4,6 +4,7 @@ include $(TOP)/configs/current
     LIBNAME = nvfx
     
     C_SOURCES = \
    +	nv04_surface_2d.c \
     	nvfx_context.c \
     	nvfx_clear.c \
     	nvfx_draw.c \
    diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.c b/src/gallium/drivers/nvfx/nv04_surface_2d.c
    new file mode 100644
    index 0000000000..ed18c9f24d
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv04_surface_2d.c
    @@ -0,0 +1,545 @@
    +#include "pipe/p_context.h"
    +#include "pipe/p_format.h"
    +#include "util/u_format.h"
    +#include "util/u_math.h"
    +#include "util/u_memory.h"
    +
    +#include "nouveau/nouveau_winsys.h"
    +#include "nouveau/nouveau_util.h"
    +#include "nouveau/nouveau_screen.h"
    +#include "nv04_surface_2d.h"
    +
    +static INLINE int
    +nv04_surface_format(enum pipe_format format)
    +{
    +	switch (format) {
    +	case PIPE_FORMAT_A8_UNORM:
    +	case PIPE_FORMAT_L8_UNORM:
    +	case PIPE_FORMAT_I8_UNORM:
    +		return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
    +	case PIPE_FORMAT_R16_SNORM:
    +	case PIPE_FORMAT_B5G6R5_UNORM:
    +	case PIPE_FORMAT_Z16_UNORM:
    +	case PIPE_FORMAT_L8A8_UNORM:
    +		return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
    +	case PIPE_FORMAT_B8G8R8X8_UNORM:
    +	case PIPE_FORMAT_B8G8R8A8_UNORM:
    +		return NV04_CONTEXT_SURFACES_2D_FORMAT_A8R8G8B8;
    +	case PIPE_FORMAT_S8Z24_UNORM:
    +	case PIPE_FORMAT_X8Z24_UNORM:
    +		return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
    +	default:
    +		return -1;
    +	}
    +}
    +
    +static INLINE int
    +nv04_rect_format(enum pipe_format format)
    +{
    +	switch (format) {
    +	case PIPE_FORMAT_A8_UNORM:
    +		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
    +	case PIPE_FORMAT_B5G6R5_UNORM:
    +	case PIPE_FORMAT_L8A8_UNORM:
    +	case PIPE_FORMAT_Z16_UNORM:
    +		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
    +	case PIPE_FORMAT_B8G8R8X8_UNORM:
    +	case PIPE_FORMAT_B8G8R8A8_UNORM:
    +	case PIPE_FORMAT_S8Z24_UNORM:
    +	case PIPE_FORMAT_X8Z24_UNORM:
    +		return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
    +	default:
    +		return -1;
    +	}
    +}
    +
    +static INLINE int
    +nv04_scaled_image_format(enum pipe_format format)
    +{
    +	switch (format) {
    +	case PIPE_FORMAT_A8_UNORM:
    +	case PIPE_FORMAT_L8_UNORM:
    +	case PIPE_FORMAT_I8_UNORM:
    +		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_Y8;
    +	case PIPE_FORMAT_B5G5R5A1_UNORM:
    +		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A1R5G5B5;
    +	case PIPE_FORMAT_B8G8R8A8_UNORM:
    +		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_A8R8G8B8;
    +	case PIPE_FORMAT_B8G8R8X8_UNORM:
    +		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_X8R8G8B8;
    +	case PIPE_FORMAT_B5G6R5_UNORM:
    +	case PIPE_FORMAT_R16_SNORM:
    +	case PIPE_FORMAT_L8A8_UNORM:
    +		return NV03_SCALED_IMAGE_FROM_MEMORY_COLOR_FORMAT_R5G6B5;
    +	default:
    +		return -1;
    +	}
    +}
    +
    +static INLINE unsigned
    +nv04_swizzle_bits_square(unsigned x, unsigned y)
    +{
    +	unsigned u = (x & 0x001) << 0 |
    +	             (x & 0x002) << 1 |
    +	             (x & 0x004) << 2 |
    +	             (x & 0x008) << 3 |
    +	             (x & 0x010) << 4 |
    +	             (x & 0x020) << 5 |
    +	             (x & 0x040) << 6 |
    +	             (x & 0x080) << 7 |
    +	             (x & 0x100) << 8 |
    +	             (x & 0x200) << 9 |
    +	             (x & 0x400) << 10 |
    +	             (x & 0x800) << 11;
    +
    +	unsigned v = (y & 0x001) << 1 |
    +	             (y & 0x002) << 2 |
    +	             (y & 0x004) << 3 |
    +	             (y & 0x008) << 4 |
    +	             (y & 0x010) << 5 |
    +	             (y & 0x020) << 6 |
    +	             (y & 0x040) << 7 |
    +	             (y & 0x080) << 8 |
    +	             (y & 0x100) << 9 |
    +	             (y & 0x200) << 10 |
    +	             (y & 0x400) << 11 |
    +	             (y & 0x800) << 12;
    +	return v | u;
    +}
    +
    +/* rectangular swizzled textures are linear concatenations of swizzled square tiles */
    +static INLINE unsigned
    +nv04_swizzle_bits(unsigned x, unsigned y, unsigned w, unsigned h)
    +{
    +	unsigned s = MIN2(w, h);
    +	unsigned m = s - 1;
    +	return (((x | y) & ~m) * s) | nv04_swizzle_bits_square(x & m, y & m);
    +}
    +
    +static int
    +nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
    +			  struct pipe_surface *dst, int dx, int dy,
    +			  struct pipe_surface *src, int sx, int sy,
    +			  int w, int h)
    +{
    +	struct nouveau_channel *chan = ctx->swzsurf->channel;
    +	struct nouveau_grobj *swzsurf = ctx->swzsurf;
    +	struct nouveau_grobj *sifm = ctx->sifm;
    +	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    +	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    +	const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    +        /* Max width & height may not be the same on all HW, but must be POT */
    +	const unsigned max_w = 1024;
    +	const unsigned max_h = 1024;
    +	unsigned sub_w = w > max_w ? max_w : w;
    +	unsigned sub_h = h > max_h ? max_h : h;
    +	unsigned x;
    +	unsigned y;
    +
    +        /* Swizzled surfaces must be POT  */
    +	assert(util_is_pot(dst->width) && util_is_pot(dst->height));
    +
    +        /* If area is too large to copy in one shot we must copy it in POT chunks to meet alignment requirements */
    +	assert(sub_w == w || util_is_pot(sub_w));
    +	assert(sub_h == h || util_is_pot(sub_h));
    +
    +	MARK_RING (chan, 8 + ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*17, 2 +
    +			 ((w+sub_w)/sub_w)*((h+sub_h)/sub_h)*2);
    +
    +	BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_DMA_IMAGE, 1);
    +	OUT_RELOCo(chan, dst_bo,
    +	                 NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +
    +	BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_FORMAT, 1);
    +	OUT_RING  (chan, nv04_surface_format(dst->format) |
    +	                 log2i(dst->width) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_U_SHIFT |
    +	                 log2i(dst->height) << NV04_SWIZZLED_SURFACE_FORMAT_BASE_SIZE_V_SHIFT);
    +
    +	BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_DMA_IMAGE, 1);
    +	OUT_RELOCo(chan, src_bo,
    +	                 NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    +	BEGIN_RING(chan, sifm, NV04_SCALED_IMAGE_FROM_MEMORY_SURFACE, 1);
    +	OUT_RING  (chan, swzsurf->handle);
    +
    +	for (y = 0; y < h; y += sub_h) {
    +	  sub_h = MIN2(sub_h, h - y);
    +
    +	  for (x = 0; x < w; x += sub_w) {
    +	    sub_w = MIN2(sub_w, w - x);
    +
    +	    assert(!(dst->offset & 63));
    +
    +	    BEGIN_RING(chan, swzsurf, NV04_SWIZZLED_SURFACE_OFFSET, 1);
    +	    OUT_RELOCl(chan, dst_bo, dst->offset,
    +                             NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +
    +	    BEGIN_RING(chan, sifm, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION, 9);
    +	    OUT_RING  (chan, NV05_SCALED_IMAGE_FROM_MEMORY_COLOR_CONVERSION_TRUNCATE);
    +	    OUT_RING  (chan, nv04_scaled_image_format(src->format));
    +	    OUT_RING  (chan, NV03_SCALED_IMAGE_FROM_MEMORY_OPERATION_SRCCOPY);
    +	    OUT_RING  (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_POINT_Y_SHIFT));
    +	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_CLIP_SIZE_H_SHIFT | sub_w);
    +	    OUT_RING  (chan, (x + dx) | ((y + dy) << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_POINT_Y_SHIFT));
    +	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_OUT_SIZE_H_SHIFT | sub_w);
    +	    OUT_RING  (chan, 1 << 20);
    +	    OUT_RING  (chan, 1 << 20);
    +
    +	    BEGIN_RING(chan, sifm, NV03_SCALED_IMAGE_FROM_MEMORY_SIZE, 4);
    +	    OUT_RING  (chan, sub_h << NV03_SCALED_IMAGE_FROM_MEMORY_SIZE_H_SHIFT | sub_w);
    +	    OUT_RING  (chan, src_pitch |
    +			     NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_ORIGIN_CENTER |
    +			     NV03_SCALED_IMAGE_FROM_MEMORY_FORMAT_FILTER_POINT_SAMPLE);
    +	    OUT_RELOCl(chan, src_bo, src->offset + (sy+y) * src_pitch + (sx+x) * util_format_get_blocksize(src->texture->format),
    +                             NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    +	    OUT_RING  (chan, 0);
    +	  }
    +	}
    +
    +	return 0;
    +}
    +
    +static int
    +nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
    +		       struct pipe_surface *dst, int dx, int dy,
    +		       struct pipe_surface *src, int sx, int sy, int w, int h)
    +{
    +	struct nouveau_channel *chan = ctx->m2mf->channel;
    +	struct nouveau_grobj *m2mf = ctx->m2mf;
    +	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    +	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    +	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    +	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    +	unsigned dst_offset = dst->offset + dy * dst_pitch +
    +	                      dx * util_format_get_blocksize(dst->texture->format);
    +	unsigned src_offset = src->offset + sy * src_pitch +
    +	                      sx * util_format_get_blocksize(src->texture->format);
    +
    +	MARK_RING (chan, 3 + ((h / 2047) + 1) * 9, 2 + ((h / 2047) + 1) * 2);
    +	BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
    +	OUT_RELOCo(chan, src_bo,
    +		   NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    +	OUT_RELOCo(chan, dst_bo,
    +		   NOUVEAU_BO_GART | NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +
    +	while (h) {
    +		int count = (h > 2047) ? 2047 : h;
    +
    +		BEGIN_RING(chan, m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_OFFSET_IN, 8);
    +		OUT_RELOCl(chan, src_bo, src_offset,
    +			   NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
    +		OUT_RELOCl(chan, dst_bo, dst_offset,
    +			   NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
    +		OUT_RING  (chan, src_pitch);
    +		OUT_RING  (chan, dst_pitch);
    +		OUT_RING  (chan, w * util_format_get_blocksize(src->texture->format));
    +		OUT_RING  (chan, count);
    +		OUT_RING  (chan, 0x0101);
    +		OUT_RING  (chan, 0);
    +
    +		h -= count;
    +		src_offset += src_pitch * count;
    +		dst_offset += dst_pitch * count;
    +	}
    +
    +	return 0;
    +}
    +
    +static int
    +nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    +		       int dx, int dy, struct pipe_surface *src, int sx, int sy,
    +		       int w, int h)
    +{
    +	struct nouveau_channel *chan = ctx->surf2d->channel;
    +	struct nouveau_grobj *surf2d = ctx->surf2d;
    +	struct nouveau_grobj *blit = ctx->blit;
    +	struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
    +	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    +	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    +	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    +	int format;
    +
    +	format = nv04_surface_format(dst->format);
    +	if (format < 0)
    +		return 1;
    +
    +	MARK_RING (chan, 12, 4);
    +	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    +	OUT_RELOCo(chan, src_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    +	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
    +	OUT_RING  (chan, format);
    +	OUT_RING  (chan, (dst_pitch << 16) | src_pitch);
    +	OUT_RELOCl(chan, src_bo, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
    +	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +
    +	BEGIN_RING(chan, blit, 0x0300, 3);
    +	OUT_RING  (chan, (sy << 16) | sx);
    +	OUT_RING  (chan, (dy << 16) | dx);
    +	OUT_RING  (chan, ( h << 16) |  w);
    +
    +	return 0;
    +}
    +
    +static void
    +nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    +		  int dx, int dy, struct pipe_surface *src, int sx, int sy,
    +		  int w, int h)
    +{
    +	unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
    +	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    +	int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
    +	int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
    +
    +	assert(src->format == dst->format);
    +
    +	/* Setup transfer to swizzle the texture to vram if needed */
    +        if (src_linear && !dst_linear && w > 1 && h > 1) {
    +           nv04_surface_copy_swizzle(ctx, dst, dx, dy, src, sx, sy, w, h);
    +           return;
    +        }
    +
    +	/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
    +	 * to NV_MEMORY_TO_MEMORY_FORMAT in this case.
    +	 */
    +	if ((src->offset & 63) || (dst->offset & 63) ||
    +	    (src_pitch & 63) || (dst_pitch & 63)) {
    +		nv04_surface_copy_m2mf(ctx, dst, dx, dy, src, sx, sy, w, h);
    +		return;
    +	}
    +
    +	nv04_surface_copy_blit(ctx, dst, dx, dy, src, sx, sy, w, h);
    +}
    +
    +static void
    +nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
    +		  int dx, int dy, int w, int h, unsigned value)
    +{
    +	struct nouveau_channel *chan = ctx->surf2d->channel;
    +	struct nouveau_grobj *surf2d = ctx->surf2d;
    +	struct nouveau_grobj *rect = ctx->rect;
    +	struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
    +	unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
    +	int cs2d_format, gdirect_format;
    +
    +	cs2d_format = nv04_surface_format(dst->format);
    +	assert(cs2d_format >= 0);
    +
    +	gdirect_format = nv04_rect_format(dst->format);
    +	assert(gdirect_format >= 0);
    +
    +	MARK_RING (chan, 16, 4);
    +	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    +	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +	OUT_RELOCo(chan, dst_bo, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +	BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
    +	OUT_RING  (chan, cs2d_format);
    +	OUT_RING  (chan, (dst_pitch << 16) | dst_pitch);
    +	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +	OUT_RELOCl(chan, dst_bo, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
    +
    +	BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1);
    +	OUT_RING  (chan, gdirect_format);
    +	BEGIN_RING(chan, rect, NV04_GDI_RECTANGLE_TEXT_COLOR1_A, 1);
    +	OUT_RING  (chan, value);
    +	BEGIN_RING(chan, rect,
    +		   NV04_GDI_RECTANGLE_TEXT_UNCLIPPED_RECTANGLE_POINT(0), 2);
    +	OUT_RING  (chan, (dx << 16) | dy);
    +	OUT_RING  (chan, ( w << 16) |  h);
    +}
    +
    +void
    +nv04_surface_2d_takedown(struct nv04_surface_2d **pctx)
    +{
    +	struct nv04_surface_2d *ctx;
    +
    +	if (!pctx || !*pctx)
    +		return;
    +	ctx = *pctx;
    +	*pctx = NULL;
    +
    +	nouveau_notifier_free(&ctx->ntfy);
    +	nouveau_grobj_free(&ctx->m2mf);
    +	nouveau_grobj_free(&ctx->surf2d);
    +	nouveau_grobj_free(&ctx->swzsurf);
    +	nouveau_grobj_free(&ctx->rect);
    +	nouveau_grobj_free(&ctx->blit);
    +	nouveau_grobj_free(&ctx->sifm);
    +
    +	FREE(ctx);
    +}
    +
    +struct nv04_surface_2d *
    +nv04_surface_2d_init(struct nouveau_screen *screen)
    +{
    +	struct nv04_surface_2d *ctx = CALLOC_STRUCT(nv04_surface_2d);
    +	struct nouveau_channel *chan = screen->channel;
    +	unsigned handle = 0x88000000, class;
    +	int ret;
    +
    +	if (!ctx)
    +		return NULL;
    +
    +	ret = nouveau_notifier_alloc(chan, handle++, 1, &ctx->ntfy);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, 0x0039, &ctx->m2mf);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	BEGIN_RING(chan, ctx->m2mf, NV04_MEMORY_TO_MEMORY_FORMAT_DMA_NOTIFY, 1);
    +	OUT_RING  (chan, ctx->ntfy->handle);
    +
    +	if (chan->device->chipset < 0x10)
    +		class = NV04_CONTEXT_SURFACES_2D;
    +	else
    +		class = NV10_CONTEXT_SURFACES_2D;
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->surf2d);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	BEGIN_RING(chan, ctx->surf2d,
    +			 NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
    +	OUT_RING  (chan, chan->vram->handle);
    +	OUT_RING  (chan, chan->vram->handle);
    +
    +	if (chan->device->chipset < 0x10)
    +		class = NV04_IMAGE_BLIT;
    +	else
    +		class = NV12_IMAGE_BLIT;
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->blit);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_DMA_NOTIFY, 1);
    +	OUT_RING  (chan, ctx->ntfy->handle);
    +	BEGIN_RING(chan, ctx->blit, NV04_IMAGE_BLIT_SURFACE, 1);
    +	OUT_RING  (chan, ctx->surf2d->handle);
    +	BEGIN_RING(chan, ctx->blit, NV01_IMAGE_BLIT_OPERATION, 1);
    +	OUT_RING  (chan, NV01_IMAGE_BLIT_OPERATION_SRCCOPY);
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, NV04_GDI_RECTANGLE_TEXT,
    +				  &ctx->rect);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_DMA_NOTIFY, 1);
    +	OUT_RING  (chan, ctx->ntfy->handle);
    +	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_SURFACE, 1);
    +	OUT_RING  (chan, ctx->surf2d->handle);
    +	BEGIN_RING(chan, ctx->rect, NV04_GDI_RECTANGLE_TEXT_OPERATION, 1);
    +	OUT_RING  (chan, NV04_GDI_RECTANGLE_TEXT_OPERATION_SRCCOPY);
    +	BEGIN_RING(chan, ctx->rect,
    +			 NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
    +	OUT_RING  (chan, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
    +
    +	switch (chan->device->chipset & 0xf0) {
    +	case 0x00:
    +	case 0x10:
    +		class = NV04_SWIZZLED_SURFACE;
    +		break;
    +	case 0x20:
    +		class = NV20_SWIZZLED_SURFACE;
    +		break;
    +	case 0x30:
    +		class = NV30_SWIZZLED_SURFACE;
    +		break;
    +	case 0x40:
    +	case 0x60:
    +		class = NV40_SWIZZLED_SURFACE;
    +		break;
    +	default:
    +		/* Famous last words: this really can't happen.. */
    +		assert(0);
    +		break;
    +	}
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->swzsurf);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	switch (chan->device->chipset & 0xf0) {
    +	case 0x10:
    +	case 0x20:
    +		class = NV10_SCALED_IMAGE_FROM_MEMORY;
    +		break;
    +	case 0x30:
    +		class = NV30_SCALED_IMAGE_FROM_MEMORY;
    +		break;
    +	case 0x40:
    +	case 0x60:
    +		class = NV40_SCALED_IMAGE_FROM_MEMORY;
    +		break;
    +	default:
    +		class = NV04_SCALED_IMAGE_FROM_MEMORY;
    +		break;
    +	}
    +
    +	ret = nouveau_grobj_alloc(chan, handle++, class, &ctx->sifm);
    +	if (ret) {
    +		nv04_surface_2d_takedown(&ctx);
    +		return NULL;
    +	}
    +
    +	ctx->copy = nv04_surface_copy;
    +	ctx->fill = nv04_surface_fill;
    +	return ctx;
    +}
    +
    +struct nv04_surface*
    +nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
    +{
    +	int temp_flags;
    +
    +	// printf("creating temp, flags is %i!\n", flags);
    +
    +	if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
    +	{
    +		temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
    +		ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
    +	}
    +	else
    +	{
    +		temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
    +		ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
    +	}
    +
    +	ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
    +
    +	struct pipe_texture templ;
    +	memset(&templ, 0, sizeof(templ));
    +	templ.format = ns->base.texture->format;
    +	templ.target = PIPE_TEXTURE_2D;
    +	templ.width0 = ns->base.width;
    +	templ.height0 = ns->base.height;
    +	templ.depth0 = 1;
    +	templ.last_level = 0;
    +
    +	// TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
    +	templ.nr_samples = ns->base.texture->nr_samples;
    +
    +	templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
    +
    +	struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
    +	struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
    +	temp_ns->backing = ns;
    +
    +	if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
    +		eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
    +
    +	return temp_ns;
    +}
    diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.h b/src/gallium/drivers/nvfx/nv04_surface_2d.h
    new file mode 100644
    index 0000000000..ce696a11a3
    --- /dev/null
    +++ b/src/gallium/drivers/nvfx/nv04_surface_2d.h
    @@ -0,0 +1,37 @@
    +#ifndef __NV04_SURFACE_2D_H__
    +#define __NV04_SURFACE_2D_H__
    +
    +struct nv04_surface {
    +	struct pipe_surface base;
    +	unsigned pitch;
    +	struct nv04_surface* backing;
    +};
    +
    +struct nv04_surface_2d {
    +	struct nouveau_notifier *ntfy;
    +	struct nouveau_grobj *surf2d;
    +	struct nouveau_grobj *swzsurf;
    +	struct nouveau_grobj *m2mf;
    +	struct nouveau_grobj *rect;
    +	struct nouveau_grobj *blit;
    +	struct nouveau_grobj *sifm;
    +
    +	struct pipe_buffer *(*buf)(struct pipe_surface *);
    +
    +	void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst,
    +		     int dx, int dy, struct pipe_surface *src, int sx, int sy,
    +		     int w, int h);
    +	void (*fill)(struct nv04_surface_2d *, struct pipe_surface *dst,
    +		     int dx, int dy, int w, int h, unsigned value);
    +};
    +
    +struct nv04_surface_2d *
    +nv04_surface_2d_init(struct nouveau_screen *screen);
    +
    +void
    +nv04_surface_2d_takedown(struct nv04_surface_2d **);
    +
    +struct nv04_surface*
    +nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns);
    +
    +#endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c
    index 5dced8dae4..0f5ed61aab 100644
    --- a/src/gallium/drivers/nvfx/nvfx_miptree.c
    +++ b/src/gallium/drivers/nvfx/nvfx_miptree.c
    @@ -5,7 +5,7 @@
     #include "util/u_math.h"
     
     #include "nvfx_context.h"
    -#include "../nouveau/nv04_surface_2d.h"
    +#include "nv04_surface_2d.h"
     
     
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h
    index e076b876b0..c0b4b9899d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_screen.h
    +++ b/src/gallium/drivers/nvfx/nvfx_screen.h
    @@ -2,7 +2,7 @@
     #define __NVFX_SCREEN_H__
     
     #include "nouveau/nouveau_screen.h"
    -#include "nouveau/nv04_surface_2d.h"
    +#include "nv04_surface_2d.h"
     
     struct nvfx_screen {
     	struct nouveau_screen base;
    -- 
    cgit v1.2.3
    
    
    From d40a069206ea76feafe35c417d79c8bd5d62b4c1 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 11:44:31 +0100
    Subject: nvfx: add NOUVEAU_SWTNL to force swtnl at runtime
    
    Replace the FORCE_SWTNL macro with a NOUVEAU_SWTNL environment variable.
    ---
     src/gallium/drivers/nvfx/nvfx_vbo.c | 13 ++++++++++---
     1 file changed, 10 insertions(+), 3 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c
    index 9d501ef1da..54369f9b64 100644
    --- a/src/gallium/drivers/nvfx/nvfx_vbo.c
    +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c
    @@ -10,7 +10,14 @@
     #include "nouveau/nouveau_pushbuf.h"
     #include "nouveau/nouveau_util.h"
     
    -#define FORCE_SWTNL 0
    +static boolean
    +nvfx_force_swtnl(struct nvfx_context *nvfx)
    +{
    +	static int force_swtnl = -1;
    +	if(force_swtnl < 0)
    +		force_swtnl = debug_get_bool_option("NOUVEAU_SWTNL", 0);
    +	return force_swtnl;
    +}
     
     static INLINE int
     nvfx_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
    @@ -175,7 +182,7 @@ nvfx_draw_arrays(struct pipe_context *pipe,
     	unsigned restart = 0;
     
     	nvfx_vbo_set_idxbuf(nvfx, NULL, 0);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    +	if (nvfx_force_swtnl(nvfx) || !nvfx_state_validate(nvfx)) {
     		nvfx_draw_elements_swtnl(pipe, NULL, 0,
                                                mode, start, count);
                     return;
    @@ -465,7 +472,7 @@ nvfx_draw_elements(struct pipe_context *pipe,
     	boolean idxbuf;
     
     	idxbuf = nvfx_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
    -	if (FORCE_SWTNL || !nvfx_state_validate(nvfx)) {
    +	if (nvfx_force_swtnl(nvfx) || !nvfx_state_validate(nvfx)) {
     		nvfx_draw_elements_swtnl(pipe, NULL, 0,
                                                mode, start, count);
     		return;
    -- 
    cgit v1.2.3
    
    
    From ad2d0c26393760ebc7af52de9f693654381431f3 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 12:35:18 +0100
    Subject: nvfx: draw: create draw vp with ureg
    
    This avoids duplicating the vertex program generation logic and
    makes the same code work for both nv30 and nv40.
    ---
     src/gallium/drivers/nvfx/nvfx_draw.c | 67 +++++++++++++-----------------------
     1 file changed, 24 insertions(+), 43 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    index 7308f0667c..494d5435d6 100644
    --- a/src/gallium/drivers/nvfx/nvfx_draw.c
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -1,5 +1,6 @@
     #include "pipe/p_shader_tokens.h"
     #include "util/u_inlines.h"
    +#include "tgsi/tgsi_ureg.h"
     
     #include "util/u_pack_color.h"
     
    @@ -173,50 +174,30 @@ nvfx_render_destroy(struct draw_stage *draw)
     	FREE(draw);
     }
     
    -static INLINE void
    -emit_mov(struct nvfx_vertex_program *vp,
    -	 unsigned dst, unsigned src, unsigned vor, unsigned mask)
    -{
    -	struct nvfx_vertex_program_exec *inst;
    -
    -	vp->insns = realloc(vp->insns,
    -			    sizeof(struct nvfx_vertex_program_exec) *
    -			    ++vp->nr_insns);
    -	inst = &vp->insns[vp->nr_insns - 1];
    -
    -	inst->data[0] = 0x401f9c6c;
    -	inst->data[1] = 0x0040000d | (src << 8);
    -	inst->data[2] = 0x8106c083;
    -	inst->data[3] = 0x6041ff80 | (dst << 2) | (mask << 13);
    -	inst->const_index = -1;
    -	inst->has_branch_offset = FALSE;
    -
    -	vp->ir |= (1 << src);
    -	if (vor != ~0)
    -		vp->or |= (1 << vor);
    -}
    -
     static struct nvfx_vertex_program *
    -create_drawvp(struct nvfx_context *nvfx)
    +nvfx_create_drawvp(struct nvfx_context *nvfx)
     {
    -	struct nvfx_vertex_program *vp = CALLOC_STRUCT(nvfx_vertex_program);
    -	unsigned i;
    -
    -	// nv30 support comes in a later patch
    -	assert(nvfx->is_nv4x);
    -
    -	emit_mov(vp, NVFX_VP(INST_DEST_POS), 0, ~0, 0xf);
    -	emit_mov(vp, NVFX_VP(INST_DEST_COL0), 3, 0, 0xf);
    -	emit_mov(vp, NVFX_VP(INST_DEST_COL1), 4, 1, 0xf);
    -	emit_mov(vp, NVFX_VP(INST_DEST_BFC0), 3, 2, 0xf);
    -	emit_mov(vp, NVFX_VP(INST_DEST_BFC1), 4, 3, 0xf);
    -	emit_mov(vp, NVFX_VP(INST_DEST_FOGC), 5, 4, 0x8);
    -	for (i = 0; i < 8; i++)
    -		emit_mov(vp, NVFX_VP(INST_DEST_TC(i)), 8 + i, 14 + i, 0xf);
    -
    -	vp->insns[vp->nr_insns - 1].data[3] |= 1;
    -	vp->translated = TRUE;
    -	return vp;
    +	struct ureg_program *ureg;
    +	uint i;
    +
    +	ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
    +	if (ureg == NULL)
    +		return NULL;
    +
    +	ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0), ureg_DECL_vs_input(ureg, 0));
    +	ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0), ureg_DECL_vs_input(ureg, 3));
    +	ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 1), ureg_DECL_vs_input(ureg, 4));
    +	ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_BCOLOR, 0), ureg_DECL_vs_input(ureg, 3));
    +	ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_BCOLOR, 1), ureg_DECL_vs_input(ureg, 4));
    +	ureg_MOV(ureg,
    +		   ureg_writemask(ureg_DECL_output(ureg, TGSI_SEMANTIC_FOG, 1), TGSI_WRITEMASK_X),
    +		   ureg_DECL_vs_input(ureg, 5));
    +	for (i = 0; i < 8; ++i)
    +		ureg_MOV(ureg, ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, i), ureg_DECL_vs_input(ureg, 8 + i));
    +
    +	ureg_END( ureg );
    +
    +	return ureg_create_shader_and_destroy( ureg, &nvfx->pipe );
     }
     
     struct draw_stage *
    @@ -225,7 +206,7 @@ nvfx_draw_render_stage(struct nvfx_context *nvfx)
     	struct nvfx_render_stage *render = CALLOC_STRUCT(nvfx_render_stage);
     
     	if (!nvfx->swtnl.vertprog)
    -		nvfx->swtnl.vertprog = create_drawvp(nvfx);
    +		nvfx->swtnl.vertprog = nvfx_create_drawvp(nvfx);
     
     	render->nvfx = nvfx;
     	render->stage.draw = nvfx->draw;
    -- 
    cgit v1.2.3
    
    
    From ac7ae8bc6ae0d364103d655482a522c12504816b Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 13:15:24 +0100
    Subject: nvfx: draw: make perspective corrective texturing work
    
    We must divide everything in the position by w, and emit position as
    a 4-component vector.
    
    Not sure why we must divide, but it works (see progs/redbook/checker).
    ---
     src/gallium/drivers/nvfx/nvfx_draw.c | 9 ++++++++-
     1 file changed, 8 insertions(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    index 494d5435d6..4e0575885d 100644
    --- a/src/gallium/drivers/nvfx/nvfx_draw.c
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -67,6 +67,13 @@ nvfx_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
     			OUT_RING  (chan, fui(v->data[idx][2]));
     			OUT_RING  (chan, fui(v->data[idx][3]));
     			break;
    +		case 0xff:
    +			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4F_X(hw), 4);
    +			OUT_RING  (chan, fui(v->data[idx][0] / v->data[idx][3]));
    +			OUT_RING  (chan, fui(v->data[idx][1] / v->data[idx][3]));
    +			OUT_RING  (chan, fui(v->data[idx][2] / v->data[idx][3]));
    +			OUT_RING  (chan, fui(1.0f / v->data[idx][3]));
    +			break;
     		case EMIT_4UB:
     			BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
     			OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][0]),
    @@ -330,7 +337,7 @@ nvfx_state_vtxfmt_validate(struct nvfx_context *nvfx)
     		emit_attrib(nvfx, 5, EMIT_1F, TGSI_SEMANTIC_FOG, 0);
     	}
     
    -	emit_attrib(nvfx, 0, EMIT_3F, TGSI_SEMANTIC_POSITION, 0);
    +	emit_attrib(nvfx, 0, 0xff, TGSI_SEMANTIC_POSITION, 0);
     
     	return FALSE;
     }
    -- 
    cgit v1.2.3
    
    
    From 152dffd3e196208a85148c4a2f7a9a6df44f3bff Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 13:18:10 +0100
    Subject: nvfx: draw: emit color as floating point
    
    Don't lose precision by converting to u8.
    ---
     src/gallium/drivers/nvfx/nvfx_draw.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    index 4e0575885d..aea0baadf9 100644
    --- a/src/gallium/drivers/nvfx/nvfx_draw.c
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -324,7 +324,7 @@ nvfx_state_vtxfmt_validate(struct nvfx_context *nvfx)
     	for (i = 0; i < 2; i++) {
     		if (!(colour & (1 << i)))
     			continue;
    -		emit_attrib(nvfx, 3 + i, EMIT_4UB, TGSI_SEMANTIC_COLOR, i);
    +		emit_attrib(nvfx, 3 + i, EMIT_4F, TGSI_SEMANTIC_COLOR, i);
     	}
     
     	for (i = 0; i < 8; i++) {
    -- 
    cgit v1.2.3
    
    
    From a174db480b9dbe3ae3475ce0cf4b3591234e8f05 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 22 Feb 2010 13:22:24 +0100
    Subject: nvfx: draw: make swtnl draw_elements actually work.
    
    It was totally broken: the index buffer was passed as NULL!
    ---
     src/gallium/drivers/nvfx/nvfx_vbo.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c
    index 54369f9b64..257087f8f6 100644
    --- a/src/gallium/drivers/nvfx/nvfx_vbo.c
    +++ b/src/gallium/drivers/nvfx/nvfx_vbo.c
    @@ -473,7 +473,7 @@ nvfx_draw_elements(struct pipe_context *pipe,
     
     	idxbuf = nvfx_vbo_set_idxbuf(nvfx, indexBuffer, indexSize);
     	if (nvfx_force_swtnl(nvfx) || !nvfx_state_validate(nvfx)) {
    -		nvfx_draw_elements_swtnl(pipe, NULL, 0,
    +		nvfx_draw_elements_swtnl(pipe, indexBuffer, indexSize,
                                                mode, start, count);
     		return;
     	}
    -- 
    cgit v1.2.3
    
    
    From 49f2a89956203a99be37a6fb18a1fab79c5e5429 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sun, 21 Feb 2010 18:17:03 +0100
    Subject: nvfx: clean up shader header
    
    Currently the behavior of shader.h depends on some constants that
    are defined differently in vertex and fragment programs.
    
    This patch cleans that up by splitting the relevant symbols in
    vertex program and fragment program variants
    ---
     src/gallium/drivers/nvfx/nvfx_draw.c     |  1 -
     src/gallium/drivers/nvfx/nvfx_fragprog.c | 91 +++++++++++++-------------------
     src/gallium/drivers/nvfx/nvfx_shader.h   | 56 ++++++++++++++------
     src/gallium/drivers/nvfx/nvfx_vertprog.c | 47 ++++++-----------
     4 files changed, 92 insertions(+), 103 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
    index aea0baadf9..5379b29efd 100644
    --- a/src/gallium/drivers/nvfx/nvfx_draw.c
    +++ b/src/gallium/drivers/nvfx/nvfx_draw.c
    @@ -9,7 +9,6 @@
     #include "draw/draw_pipe.h"
     
     #include "nvfx_context.h"
    -#define NVFX_SHADER_NO_FUCKEDNESS
     #include "nv30_vertprog.h"
     #include "nv40_vertprog.h"
     
    diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    index ecc193877b..8066528a5b 100644
    --- a/src/gallium/drivers/nvfx/nvfx_fragprog.c
    +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    @@ -8,25 +8,8 @@
     #include "tgsi/tgsi_util.h"
     
     #include "nvfx_context.h"
    -
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 1
    -#define MASK_Y 2
    -#define MASK_Z 4
    -#define MASK_W 8
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE NVFX_FP_OP_DST_SCALE_1X
    -#define DEF_CTEST NVFX_FP_OP_COND_TR
     #include "nvfx_shader.h"
     
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
    -
     #define MAX_CONSTS 128
     #define MAX_IMM 32
     struct nvfx_fpc {
    @@ -308,10 +291,10 @@ tgsi_mask(uint tgsi)
     {
     	int mask = 0;
     
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    +	if (tgsi & TGSI_WRITEMASK_X) mask |= NVFX_FP_MASK_X;
    +	if (tgsi & TGSI_WRITEMASK_Y) mask |= NVFX_FP_MASK_Y;
    +	if (tgsi & TGSI_WRITEMASK_Z) mask |= NVFX_FP_MASK_Z;
    +	if (tgsi & TGSI_WRITEMASK_W) mask |= NVFX_FP_MASK_W;
     	return mask;
     }
     
    @@ -337,7 +320,7 @@ src_native_swz(struct nvfx_fpc *fpc, const struct tgsi_full_src_register *fsrc,
     		}
     	}
     
    -	if (mask == MASK_ALL)
    +	if (mask == NVFX_FP_MASK_ALL)
     		return TRUE;
     
     	*src = temp(fpc);
    @@ -393,7 +376,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     				src[i] = tgsi_src(fpc, fsrc);
     			} else {
     				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				arith(fpc, 0, MOV, src[i], NVFX_FP_MASK_ALL,
     				      tgsi_src(fpc, fsrc), none, none);
     			}
     			break;
    @@ -404,7 +387,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     				src[i] = tgsi_src(fpc, fsrc);
     			} else {
     				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				arith(fpc, 0, MOV, src[i], NVFX_FP_MASK_ALL,
     				      tgsi_src(fpc, fsrc), none, none);
     			}
     			break;
    @@ -415,7 +398,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     				src[i] = tgsi_src(fpc, fsrc);
     			} else {
     				src[i] = temp(fpc);
    -				arith(fpc, 0, MOV, src[i], MASK_ALL,
    +				arith(fpc, 0, MOV, src[i], NVFX_FP_MASK_ALL,
     				      tgsi_src(fpc, fsrc), none, none);
     			}
     			break;
    @@ -448,22 +431,22 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     		tmp = nvfx_sr(NVFXSR_NONE, 0);
     		tmp.cc_update = 1;
     		arith(fpc, 0, MOV, tmp, 0xf, src[0], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_GE;
    +		dst.cc_test = NVFX_COND_GE;
     		arith(fpc, sat, MOV, dst, mask, src[2], none, none);
    -		dst.cc_test = NVFX_VP_INST_COND_LT;
    +		dst.cc_test = NVFX_COND_LT;
     		arith(fpc, sat, MOV, dst, mask, src[1], none, none);
     		break;
     	case TGSI_OPCODE_COS:
     		arith(fpc, sat, COS, dst, mask, src[0], none, none);
     		break;
     	case TGSI_OPCODE_DDX:
    -		if (mask & (MASK_Z | MASK_W)) {
    +		if (mask & (NVFX_FP_MASK_Z | NVFX_FP_MASK_W)) {
     			tmp = temp(fpc);
    -			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y,
    +			arith(fpc, sat, DDX, tmp, NVFX_FP_MASK_X | NVFX_FP_MASK_Y,
     			      swz(src[0], Z, W, Z, W), none, none);
    -			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    +			arith(fpc, 0, MOV, tmp, NVFX_FP_MASK_Z | NVFX_FP_MASK_W,
     			      swz(tmp, X, Y, X, Y), none, none);
    -			arith(fpc, sat, DDX, tmp, MASK_X | MASK_Y, src[0],
    +			arith(fpc, sat, DDX, tmp, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, src[0],
     			      none, none);
     			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
     		} else {
    @@ -471,13 +454,13 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     		}
     		break;
     	case TGSI_OPCODE_DDY:
    -		if (mask & (MASK_Z | MASK_W)) {
    +		if (mask & (NVFX_FP_MASK_Z | NVFX_FP_MASK_W)) {
     			tmp = temp(fpc);
    -			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y,
    +			arith(fpc, sat, DDY, tmp, NVFX_FP_MASK_X | NVFX_FP_MASK_Y,
     			      swz(src[0], Z, W, Z, W), none, none);
    -			arith(fpc, 0, MOV, tmp, MASK_Z | MASK_W,
    +			arith(fpc, 0, MOV, tmp, NVFX_FP_MASK_Z | NVFX_FP_MASK_W,
     			      swz(tmp, X, Y, X, Y), none, none);
    -			arith(fpc, sat, DDY, tmp, MASK_X | MASK_Y, src[0],
    +			arith(fpc, sat, DDY, tmp, NVFX_FP_MASK_X | NVFX_FP_MASK_Y, src[0],
     			      none, none);
     			arith(fpc, 0, MOV, dst, mask, tmp, none, none);
     		} else {
    @@ -492,7 +475,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     		break;
     	case TGSI_OPCODE_DPH:
     		tmp = temp(fpc);
    -		arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[1], none);
    +		arith(fpc, 0, DP3, tmp, NVFX_FP_MASK_X, src[0], src[1], none);
     		arith(fpc, sat, ADD, dst, mask, swz(tmp, X, X, X, X),
     		      swz(src[1], W, W, W, W), none);
     		break;
    @@ -514,8 +497,8 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     	case TGSI_OPCODE_KIL:
     		dst = nvfx_sr(NVFXSR_NONE, 0);
     		dst.cc_update = 1;
    -		arith(fpc, 0, MOV, dst, MASK_ALL, src[0], none, none);
    -		dst.cc_update = 0; dst.cc_test = NVFX_FP_OP_COND_LT;
    +		arith(fpc, 0, MOV, dst, NVFX_FP_MASK_ALL, src[0], none, none);
    +		dst.cc_update = 0; dst.cc_test = NVFX_COND_LT;
     		arith(fpc, 0, KIL, dst, 0, none, none, none);
     		break;
     	case TGSI_OPCODE_LG2:
    @@ -551,9 +534,9 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     			arith(fpc, sat, POW_NV30, dst, mask, src[0], src[1], none);
     		else {
     			tmp = temp(fpc);
    -			arith(fpc, 0, LG2, tmp, MASK_X,
    +			arith(fpc, 0, LG2, tmp, NVFX_FP_MASK_X,
     			      swz(src[0], X, X, X, X), none, none);
    -			arith(fpc, 0, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +			arith(fpc, 0, MUL, tmp, NVFX_FP_MASK_X, swz(tmp, X, X, X, X),
     			      swz(src[1], X, X, X, X), none);
     			arith(fpc, sat, EX2, dst, mask,
     			      swz(tmp, X, X, X, X), none, none);
    @@ -570,9 +553,9 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     			arith(fpc, 0, RFL_NV30, dst, mask, src[0], src[1], none);
     		else {
     			tmp = temp(fpc);
    -			arith(fpc, 0, DP3, tmp, MASK_X, src[0], src[0], none);
    -			arith(fpc, 0, DP3, tmp, MASK_Y, src[0], src[1], none);
    -			arith(fpc, 0, DIV, scale(tmp, 2X), MASK_Z,
    +			arith(fpc, 0, DP3, tmp, NVFX_FP_MASK_X, src[0], src[0], none);
    +			arith(fpc, 0, DP3, tmp, NVFX_FP_MASK_Y, src[0], src[1], none);
    +			arith(fpc, 0, DIV, scale(tmp, 2X), NVFX_FP_MASK_Z,
     			      swz(tmp, Y, Y, Y, Y), swz(tmp, X, X, X, X), none);
     			arith(fpc, sat, MAD, dst, mask,
     			      swz(tmp, Z, Z, Z, Z), src[0], neg(src[1]));
    @@ -583,7 +566,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     			arith(fpc, sat, RSQ_NV30, dst, mask, abs(swz(src[0], X, X, X, X)), none, none);
     		else {
     			tmp = temp(fpc);
    -			arith(fpc, 0, LG2, scale(tmp, INV_2X), MASK_X,
    +			arith(fpc, 0, LG2, scale(tmp, INV_2X), NVFX_FP_MASK_X,
     			      abs(swz(src[0], X, X, X, X)), none, none);
     			arith(fpc, sat, EX2, dst, mask,
     			      neg(swz(tmp, X, X, X, X)), none, none);
    @@ -591,25 +574,25 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     		break;
     	case TGSI_OPCODE_SCS:
     		/* avoid overwriting the source */
    -		if(src[0].swz[SWZ_X] != SWZ_X)
    +		if(src[0].swz[NVFX_SWZ_X] != NVFX_SWZ_X)
     		{
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    +			if (mask & NVFX_FP_MASK_X) {
    +				arith(fpc, sat, COS, dst, NVFX_FP_MASK_X,
     				      swz(src[0], X, X, X, X), none, none);
     			}
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    +			if (mask & NVFX_FP_MASK_Y) {
    +				arith(fpc, sat, SIN, dst, NVFX_FP_MASK_Y,
     				      swz(src[0], X, X, X, X), none, none);
     			}
     		}
     		else
     		{
    -			if (mask & MASK_Y) {
    -				arith(fpc, sat, SIN, dst, MASK_Y,
    +			if (mask & NVFX_FP_MASK_Y) {
    +				arith(fpc, sat, SIN, dst, NVFX_FP_MASK_Y,
     				      swz(src[0], X, X, X, X), none, none);
     			}
    -			if (mask & MASK_X) {
    -				arith(fpc, sat, COS, dst, MASK_X,
    +			if (mask & NVFX_FP_MASK_X) {
    +				arith(fpc, sat, COS, dst, NVFX_FP_MASK_X,
     				      swz(src[0], X, X, X, X), none, none);
     			}
     		}
    @@ -657,7 +640,7 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     		tmp = temp(fpc);
     		arith(fpc, 0, MUL, tmp, mask,
     		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(fpc, sat, MAD, dst, (mask & ~MASK_W),
    +		arith(fpc, sat, MAD, dst, (mask & ~NVFX_FP_MASK_W),
     		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
     		      neg(tmp));
     		break;
    diff --git a/src/gallium/drivers/nvfx/nvfx_shader.h b/src/gallium/drivers/nvfx/nvfx_shader.h
    index 191131a40a..0b2f044f7f 100644
    --- a/src/gallium/drivers/nvfx/nvfx_shader.h
    +++ b/src/gallium/drivers/nvfx/nvfx_shader.h
    @@ -9,15 +9,6 @@
     #define NVFX_VP_INST_SLOT_VEC 0
     #define NVFX_VP_INST_SLOT_SCA 1
     
    -#define NVFX_VP_INST_COND_FL  0 /* guess */
    -#define NVFX_VP_INST_COND_LT  1
    -#define NVFX_VP_INST_COND_EQ  2
    -#define NVFX_VP_INST_COND_LE  3
    -#define NVFX_VP_INST_COND_GT  4
    -#define NVFX_VP_INST_COND_NE  5
    -#define NVFX_VP_INST_COND_GE  6
    -#define NVFX_VP_INST_COND_TR  7 /* guess */
    -
     #define NVFX_VP_INST_IN_POS  0    /* These seem to match the bindings specified in */
     #define NVFX_VP_INST_IN_WEIGHT  1    /* the ARB_v_p spec (2.14.3.1) */
     #define NVFX_VP_INST_IN_NORMAL  2
    @@ -327,13 +318,45 @@
     #  define NVFX_FP_SWIZZLE_W  3
     #define NVFX_FP_REG_NEGATE          (1 << 17)
     
    -#ifndef NVFX_SHADER_NO_FUCKEDNESS
     #define NVFXSR_NONE	0
     #define NVFXSR_OUTPUT	1
     #define NVFXSR_INPUT	2
     #define NVFXSR_TEMP	3
     #define NVFXSR_CONST	4
     
    +#define NVFX_COND_FL  0
    +#define NVFX_COND_LT  1
    +#define NVFX_COND_EQ  2
    +#define NVFX_COND_LE  3
    +#define NVFX_COND_GT  4
    +#define NVFX_COND_NE  5
    +#define NVFX_COND_GE  6
    +#define NVFX_COND_TR  7
    +
    +/* Yes, this are ordered differently... */
    +
    +#define NVFX_VP_MASK_X 8
    +#define NVFX_VP_MASK_Y 4
    +#define NVFX_VP_MASK_Z 2
    +#define NVFX_VP_MASK_W 1
    +#define NVFX_VP_MASK_ALL 0xf
    +
    +#define NVFX_FP_MASK_X 1
    +#define NVFX_FP_MASK_Y 2
    +#define NVFX_FP_MASK_Z 4
    +#define NVFX_FP_MASK_W 8
    +#define NVFX_FP_MASK_ALL 0xf
    +
    +#define NVFX_SWZ_X 0
    +#define NVFX_SWZ_Y 1
    +#define NVFX_SWZ_Z 2
    +#define NVFX_SWZ_W 3
    +
    +#define swz(s,x,y,z,w) nvfx_sr_swz((s), NVFX_SWZ_##x, NVFX_SWZ_##y, NVFX_SWZ_##z, NVFX_SWZ_##w)
    +#define neg(s) nvfx_sr_neg((s))
    +#define abs(s) nvfx_sr_abs((s))
    +#define scale(s,v) nvfx_sr_scale((s), NVFX_FP_OP_DST_SCALE_##v)
    +
     struct nvfx_sreg {
     	int type;
     	int index;
    @@ -357,13 +380,13 @@ nvfx_sr(int type, int index)
     	struct nvfx_sreg temp = {
     		.type = type,
     		.index = index,
    -		.dst_scale = DEF_SCALE,
    +		.dst_scale = 0,
     		.abs = 0,
     		.negate = 0,
     		.swz = { 0, 1, 2, 3 },
     		.cc_update = 0,
     		.cc_update_reg = 0,
    -		.cc_test = DEF_CTEST,
    +		.cc_test = NVFX_COND_TR,
     		.cc_test_reg = 0,
     		.cc_swz = { 0, 1, 2, 3 },
     	};
    @@ -375,10 +398,10 @@ nvfx_sr_swz(struct nvfx_sreg src, int x, int y, int z, int w)
     {
     	struct nvfx_sreg dst = src;
     
    -	dst.swz[SWZ_X] = src.swz[x];
    -	dst.swz[SWZ_Y] = src.swz[y];
    -	dst.swz[SWZ_Z] = src.swz[z];
    -	dst.swz[SWZ_W] = src.swz[w];
    +	dst.swz[NVFX_SWZ_X] = src.swz[x];
    +	dst.swz[NVFX_SWZ_Y] = src.swz[y];
    +	dst.swz[NVFX_SWZ_Z] = src.swz[z];
    +	dst.swz[NVFX_SWZ_W] = src.swz[w];
     	return dst;
     }
     
    @@ -402,6 +425,5 @@ nvfx_sr_scale(struct nvfx_sreg src, int scale)
     	src.dst_scale = scale;
     	return src;
     }
    -#endif
     
     #endif
    diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    index 3d0e8c23a1..e5e49bf0c2 100644
    --- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
    +++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    @@ -22,24 +22,9 @@
      *  4. bugs
      */
     
    -#define SWZ_X 0
    -#define SWZ_Y 1
    -#define SWZ_Z 2
    -#define SWZ_W 3
    -#define MASK_X 8
    -#define MASK_Y 4
    -#define MASK_Z 2
    -#define MASK_W 1
    -#define MASK_ALL (MASK_X|MASK_Y|MASK_Z|MASK_W)
    -#define DEF_SCALE 0
    -#define DEF_CTEST 0
     #include "nv30_vertprog.h"
     #include "nv40_vertprog.h"
     
    -#define swz(s,x,y,z,w) nvfx_sr_swz((s), SWZ_##x, SWZ_##y, SWZ_##z, SWZ_##w)
    -#define neg(s) nvfx_sr_neg((s))
    -#define abs(s) nvfx_sr_abs((s))
    -
     #define NVFX_VP_INST_DEST_CLIP(n) ((~0 - 6) + (n))
     
     struct nvfx_vpc {
    @@ -307,7 +292,7 @@ nvfx_vp_arith(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, int slot, int op,
     
     	hw = vpc->vpi->data;
     
    -	hw[0] |= (NVFX_VP_INST_COND_TR << NVFX_VP(INST_COND_SHIFT));
    +	hw[0] |= (NVFX_COND_TR << NVFX_VP(INST_COND_SHIFT));
     	hw[0] |= ((0 << NVFX_VP(INST_COND_SWZ_X_SHIFT)) |
     		  (1 << NVFX_VP(INST_COND_SWZ_Y_SHIFT)) |
     		  (2 << NVFX_VP(INST_COND_SWZ_Z_SHIFT)) |
    @@ -405,10 +390,10 @@ tgsi_mask(uint tgsi)
     {
     	int mask = 0;
     
    -	if (tgsi & TGSI_WRITEMASK_X) mask |= MASK_X;
    -	if (tgsi & TGSI_WRITEMASK_Y) mask |= MASK_Y;
    -	if (tgsi & TGSI_WRITEMASK_Z) mask |= MASK_Z;
    -	if (tgsi & TGSI_WRITEMASK_W) mask |= MASK_W;
    +	if (tgsi & TGSI_WRITEMASK_X) mask |= NVFX_VP_MASK_X;
    +	if (tgsi & TGSI_WRITEMASK_Y) mask |= NVFX_VP_MASK_Y;
    +	if (tgsi & TGSI_WRITEMASK_Z) mask |= NVFX_VP_MASK_Z;
    +	if (tgsi & TGSI_WRITEMASK_W) mask |= NVFX_VP_MASK_W;
     	return mask;
     }
     
    @@ -434,7 +419,7 @@ src_native_swz(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, const struct tgs
     		}
     	}
     
    -	if (mask == MASK_ALL)
    +	if (mask == NVFX_VP_MASK_ALL)
     		return TRUE;
     
     	*src = temp(vpc);
    @@ -490,7 +475,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], NVFX_VP_MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -501,7 +486,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], NVFX_VP_MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -512,7 +497,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     				src[i] = tgsi_src(vpc, fsrc);
     			} else {
     				src[i] = temp(vpc);
    -				arith(vpc, VEC, MOV, src[i], MASK_ALL,
    +				arith(vpc, VEC, MOV, src[i], NVFX_VP_MASK_ALL,
     				      tgsi_src(vpc, fsrc), none, none);
     			}
     			break;
    @@ -588,9 +573,9 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     		break;
     	case TGSI_OPCODE_POW:
     		tmp = temp(vpc);
    -		arith(vpc, SCA, LG2, tmp, MASK_X, none, none,
    +		arith(vpc, SCA, LG2, tmp, NVFX_VP_MASK_X, none, none,
     		      swz(src[0], X, X, X, X));
    -		arith(vpc, VEC, MUL, tmp, MASK_X, swz(tmp, X, X, X, X),
    +		arith(vpc, VEC, MUL, tmp, NVFX_VP_MASK_X, swz(tmp, X, X, X, X),
     		      swz(src[1], X, X, X, X), none);
     		arith(vpc, SCA, EX2, dst, mask, none, none,
     		      swz(tmp, X, X, X, X));
    @@ -619,7 +604,7 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     		tmp = temp(vpc);
     		arith(vpc, VEC, MUL, tmp, mask,
     		      swz(src[0], Z, X, Y, Y), swz(src[1], Y, Z, X, X), none);
    -		arith(vpc, VEC, MAD, dst, (mask & ~MASK_W),
    +		arith(vpc, VEC, MAD, dst, (mask & ~NVFX_VP_MASK_W),
     		      swz(src[0], Y, Z, X, X), swz(src[1], Z, X, Y, Y),
     		      neg(tmp));
     		break;
    @@ -849,7 +834,7 @@ nvfx_vertprog_translate(struct nvfx_context *nvfx,
     						NVFX_VP(INST_DEST_POS));
     		struct nvfx_sreg htmp = vpc->r_result[vpc->hpos_idx];
     
    -		arith(vpc, VEC, MOV, hpos, MASK_ALL, htmp, none, none);
    +		arith(vpc, VEC, MOV, hpos, NVFX_VP_MASK_ALL, htmp, none, none);
     	}
     
     	/* Insert code to handle user clip planes */
    @@ -865,9 +850,9 @@ nvfx_vertprog_translate(struct nvfx_context *nvfx,
     		unsigned mask;
     
     		switch (i) {
    -		case 0: case 3: mask = MASK_Y; break;
    -		case 1: case 4: mask = MASK_Z; break;
    -		case 2: case 5: mask = MASK_W; break;
    +		case 0: case 3: mask = NVFX_VP_MASK_Y; break;
    +		case 1: case 4: mask = NVFX_VP_MASK_Z; break;
    +		case 2: case 5: mask = NVFX_VP_MASK_W; break;
     		default:
     			NOUVEAU_ERR("invalid clip dist #%d\n", i);
     			goto out_err;
    -- 
    cgit v1.2.3
    
    
    From 9b3a908736130a62d79305586364f625a88a69ee Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Sat, 13 Mar 2010 17:42:57 +0100
    Subject: nvfx: remove src_native_swz, which was a no-op
    
    src_native_swz was used to translate 0/1 swizzles back when Gallium
    supported them.
    
    That support was later removed from Gallium, and the function currently
    always returns true.
    
    Remove it.
    ---
     src/gallium/drivers/nvfx/nvfx_fragprog.c | 44 --------------------------------
     src/gallium/drivers/nvfx/nvfx_vertprog.c | 44 --------------------------------
     2 files changed, 88 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    index 8066528a5b..76351430f4 100644
    --- a/src/gallium/drivers/nvfx/nvfx_fragprog.c
    +++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
    @@ -298,39 +298,6 @@ tgsi_mask(uint tgsi)
     	return mask;
     }
     
    -static boolean
    -src_native_swz(struct nvfx_fpc *fpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nvfx_sreg *src)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg tgsi = tgsi_src(fpc, fsrc);
    -	uint mask = 0;
    -	uint c;
    -
    -	for (c = 0; c < 4; c++) {
    -		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    -		case TGSI_SWIZZLE_X:
    -		case TGSI_SWIZZLE_Y:
    -		case TGSI_SWIZZLE_Z:
    -		case TGSI_SWIZZLE_W:
    -			mask |= (1 << c);
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	if (mask == NVFX_FP_MASK_ALL)
    -		return TRUE;
    -
    -	*src = temp(fpc);
    -
    -	if (mask)
    -		arith(fpc, 0, MOV, *src, mask, tgsi, none, none);
    -
    -	return FALSE;
    -}
    -
     static boolean
     nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     				const struct tgsi_full_instruction *finst)
    @@ -358,17 +325,6 @@ nvfx_fragprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_fpc *fpc,
     
     		fsrc = &finst->Src[i];
     
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_TEMPORARY:
    -			if (!src_native_swz(fpc, fsrc, &src[i]))
    -				continue;
    -			break;
    -		default:
    -			break;
    -		}
    -
     		switch (fsrc->Register.File) {
     		case TGSI_FILE_INPUT:
     			if (ai == -1 || ai == fsrc->Register.Index) {
    diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    index e5e49bf0c2..2d243be16a 100644
    --- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
    +++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
    @@ -397,39 +397,6 @@ tgsi_mask(uint tgsi)
     	return mask;
     }
     
    -static boolean
    -src_native_swz(struct nvfx_context* nvfx, struct nvfx_vpc *vpc, const struct tgsi_full_src_register *fsrc,
    -	       struct nvfx_sreg *src)
    -{
    -	const struct nvfx_sreg none = nvfx_sr(NVFXSR_NONE, 0);
    -	struct nvfx_sreg tgsi = tgsi_src(vpc, fsrc);
    -	uint mask = 0;
    -	uint c;
    -
    -	for (c = 0; c < 4; c++) {
    -		switch (tgsi_util_get_full_src_register_swizzle(fsrc, c)) {
    -		case TGSI_SWIZZLE_X:
    -		case TGSI_SWIZZLE_Y:
    -		case TGSI_SWIZZLE_Z:
    -		case TGSI_SWIZZLE_W:
    -			mask |= tgsi_mask(1 << c);
    -			break;
    -		default:
    -			assert(0);
    -		}
    -	}
    -
    -	if (mask == NVFX_VP_MASK_ALL)
    -		return TRUE;
    -
    -	*src = temp(vpc);
    -
    -	if (mask)
    -		arith(vpc, VEC, MOV, *src, mask, tgsi, none, none);
    -
    -	return FALSE;
    -}
    -
     static boolean
     nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     				const struct tgsi_full_instruction *finst)
    @@ -457,17 +424,6 @@ nvfx_vertprog_parse_instruction(struct nvfx_context* nvfx, struct nvfx_vpc *vpc,
     
     		fsrc = &finst->Src[i];
     
    -		switch (fsrc->Register.File) {
    -		case TGSI_FILE_INPUT:
    -		case TGSI_FILE_CONSTANT:
    -		case TGSI_FILE_TEMPORARY:
    -			if (!src_native_swz(nvfx, vpc, fsrc, &src[i]))
    -				continue;
    -			break;
    -		default:
    -			break;
    -		}
    -
     		switch (fsrc->Register.File) {
     		case TGSI_FILE_INPUT:
     			if (ai == -1 || ai == fsrc->Register.Index) {
    -- 
    cgit v1.2.3
    
    
    From a899c5a76ee056e237b19d97afaadd84bca9649f Mon Sep 17 00:00:00 2001
    From: Ben Skeggs 
    Date: Mon, 15 Mar 2010 16:52:25 +1000
    Subject: nv50: reset vbo_fifo before each validate
    
    ---
     src/gallium/drivers/nv50/nv50_vbo.c | 1 +
     1 file changed, 1 insertion(+)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
    index 6b9c1ee231..5047286806 100644
    --- a/src/gallium/drivers/nv50/nv50_vbo.c
    +++ b/src/gallium/drivers/nv50/nv50_vbo.c
    @@ -549,6 +549,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
     	if (nv50->vtxbuf_nr == 0)
     		return NULL;
     
    +	nv50->vbo_fifo = 0;
     	if (nv50->screen->force_push ||
     	    nv50->vertprog->cfg.edgeflag_in < 16)
     		nv50->vbo_fifo = 0xffff;
    -- 
    cgit v1.2.3
    
    
    From 68e58a96e80865878e6881dc4d34fcc3ec24eb19 Mon Sep 17 00:00:00 2001
    From: Dave Airlie 
    Date: Fri, 12 Feb 2010 15:39:51 +1000
    Subject: r300g: rebuild screen/winsys interface
    
    This creates a cleaner winsys and drop the simple screen stuff.
    
    It makes r300g use pb_bufmgr structs.
    
    It also tries to avoid overheads from mapping too often.
    
    v5: clean warnings
    
    v6: break out of cache check on first buffer - since most likely
    the first busy one implies all after it are busy.
    
    v7: cleanup a bit
    
    v8-merged: drop cman for now to just get all the interface changes in first.
    rework to changes that happened upstream
    
    Signed-off-by: Dave Airlie 
    ---
     src/gallium/drivers/r300/Makefile                  |   1 +
     src/gallium/drivers/r300/r300_context.c            |  34 +-
     src/gallium/drivers/r300/r300_context.h            |   9 +-
     src/gallium/drivers/r300/r300_cs.h                 |  22 +-
     src/gallium/drivers/r300/r300_emit.c               |  73 ++--
     src/gallium/drivers/r300/r300_render.c             |  20 +-
     src/gallium/drivers/r300/r300_screen.c             |  30 +-
     src/gallium/drivers/r300/r300_screen.h             |   5 +-
     src/gallium/drivers/r300/r300_screen_buffer.c      | 314 ++++++++++++++++++
     src/gallium/drivers/r300/r300_screen_buffer.h      |  99 ++++++
     src/gallium/drivers/r300/r300_state.c              |  28 +-
     src/gallium/drivers/r300/r300_texture.c            |  52 ++-
     src/gallium/drivers/r300/r300_texture.h            |   4 +-
     src/gallium/drivers/r300/r300_transfer.c           |  12 +-
     src/gallium/drivers/r300/r300_winsys.h             | 146 +++++++-
     src/gallium/winsys/drm/radeon/core/Makefile        |   2 +-
     src/gallium/winsys/drm/radeon/core/radeon_buffer.h |  66 ++--
     src/gallium/winsys/drm/radeon/core/radeon_drm.c    |  41 ++-
     src/gallium/winsys/drm/radeon/core/radeon_drm.h    |  16 +
     .../winsys/drm/radeon/core/radeon_drm_buffer.c     | 368 +++++++++++++++++++++
     src/gallium/winsys/drm/radeon/core/radeon_r300.c   | 301 +++++++++++++----
     src/gallium/winsys/drm/radeon/core/radeon_r300.h   |   2 +-
     src/gallium/winsys/drm/radeon/core/radeon_winsys.h |  99 ++----
     23 files changed, 1465 insertions(+), 279 deletions(-)
     create mode 100644 src/gallium/drivers/r300/r300_screen_buffer.c
     create mode 100644 src/gallium/drivers/r300/r300_screen_buffer.h
     create mode 100644 src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
    index 61b54af4dd..a6529b2060 100644
    --- a/src/gallium/drivers/r300/Makefile
    +++ b/src/gallium/drivers/r300/Makefile
    @@ -14,6 +14,7 @@ C_SOURCES = \
     	r300_query.c \
     	r300_render.c \
     	r300_screen.c \
    +	r300_screen_buffer.c \
     	r300_state.c \
     	r300_state_derived.c \
     	r300_state_invariant.c \
    diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
    index ed24fb54ab..d994a46ccf 100644
    --- a/src/gallium/drivers/r300/r300_context.c
    +++ b/src/gallium/drivers/r300/r300_context.c
    @@ -24,6 +24,7 @@
     
     #include "util/u_memory.h"
     #include "util/u_simple_list.h"
    +#include "util/u_upload_mgr.h"
     
     #include "r300_blit.h"
     #include "r300_context.h"
    @@ -55,6 +56,9 @@ static void r300_destroy_context(struct pipe_context* context)
             FREE(query);
         }
     
    +    u_upload_destroy(r300->upload_vb);
    +    u_upload_destroy(r300->upload_ib);
    +
         FREE(r300->blend_color_state.state);
         FREE(r300->clip_state.state);
         FREE(r300->fb_state.state);
    @@ -72,8 +76,7 @@ r300_is_texture_referenced(struct pipe_context *pipe,
                                struct pipe_texture *texture,
                                unsigned face, unsigned level)
     {
    -    return pipe->is_buffer_referenced(pipe,
    -                                      ((struct r300_texture *)texture)->buffer);
    +    return 0;
     }
     
     static unsigned int
    @@ -157,14 +160,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     {
         struct r300_context* r300 = CALLOC_STRUCT(r300_context);
         struct r300_screen* r300screen = r300_screen(screen);
    -    struct radeon_winsys* radeon_winsys = r300screen->radeon_winsys;
    +    struct r300_winsys_screen *rws = r300screen->rws;
     
         if (!r300)
             return NULL;
     
    -    r300->winsys = radeon_winsys;
    +    r300->rws = rws;
     
    -    r300->context.winsys = (struct pipe_winsys*)radeon_winsys;
    +    r300->context.winsys = (struct pipe_winsys*)rws;
         r300->context.screen = screen;
         r300->context.priv = priv;
     
    @@ -214,10 +217,29 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
     
         r300->invariant_state.dirty = TRUE;
     
    -    r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300);
    +    rws->set_flush_cb(r300->rws, r300_flush_cb, r300);
         r300->dirty_hw++;
     
         r300->blitter = util_blitter_create(&r300->context);
     
    +    r300->upload_ib = u_upload_create(screen,
    +				      32 * 1024, 16,
    +				      PIPE_BUFFER_USAGE_INDEX);
    +
    +    if (r300->upload_ib == NULL)
    +        goto no_upload_ib;
    +
    +    r300->upload_vb = u_upload_create(screen,
    +				      128 * 1024, 16,
    +				      PIPE_BUFFER_USAGE_VERTEX);
    +    if (r300->upload_vb == NULL)
    +        goto no_upload_vb;
    +
         return &r300->context;
    +
    + no_upload_ib:
    +    u_upload_destroy(r300->upload_ib);
    + no_upload_vb:
    +    FREE(r300);
    +    return NULL;
     }
    diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
    index 03b09603c7..db2f74e074 100644
    --- a/src/gallium/drivers/r300/r300_context.h
    +++ b/src/gallium/drivers/r300/r300_context.h
    @@ -32,6 +32,7 @@
     
     #include "r300_screen.h"
     
    +struct u_upload_mgr;
     struct r300_context;
     
     struct r300_fragment_shader;
    @@ -268,7 +269,7 @@ struct r300_texture {
         boolean is_npot;
     
         /* Pipe buffer backing this texture. */
    -    struct pipe_buffer* buffer;
    +    struct r300_winsys_buffer *buffer;
     
         /* Registers carrying texture format data. */
         struct r300_texture_format_state state;
    @@ -302,7 +303,7 @@ struct r300_context {
         struct pipe_context context;
     
         /* The interface to the windowing system, etc. */
    -    struct radeon_winsys* winsys;
    +    struct r300_winsys_screen *rws;
         /* Draw module. Used mostly for SW TCL. */
         struct draw_context* draw;
         /* Accelerated blit support. */
    @@ -368,6 +369,7 @@ struct r300_context {
         int vertex_buffer_max_index;
         /* Vertex elements for Gallium. */
         struct r300_vertex_element_state *velems;
    +    bool any_user_vbs;
     
         /* Vertex info for Draw. */
         struct vertex_info vertex_info;
    @@ -388,6 +390,9 @@ struct r300_context {
         uint32_t zbuffer_bpp;
         /* Whether scissor is enabled. */
         boolean scissor_enabled;
    +    /* upload managers */
    +    struct u_upload_mgr *upload_vb;
    +    struct u_upload_mgr *upload_ib;
     };
     
     /* Convenience cast wrapper. */
    diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
    index 151f72b0fe..ad07efbffd 100644
    --- a/src/gallium/drivers/r300/r300_cs.h
    +++ b/src/gallium/drivers/r300/r300_cs.h
    @@ -51,7 +51,7 @@
     
     #define CS_LOCALS(context) \
         struct r300_context* const cs_context_copy = (context); \
    -    struct radeon_winsys* cs_winsys = cs_context_copy->winsys; \
    +    struct r300_winsys_screen *cs_winsys = cs_context_copy->rws; \
         int cs_count = 0; (void) cs_count;
     
     #define CHECK_CS(size) \
    @@ -105,22 +105,34 @@
         cs_count--; \
     } while (0)
     
    -#define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \
    +#define OUT_CS_BUF_RELOC(bo, offset, rd, wd, flags) do { \
         DBG(cs_context_copy, DBG_CS, "r300: writing relocation for buffer %p, offset %d, " \
                 "domains (%d, %d, %d)\n", \
             bo, offset, rd, wd, flags); \
         assert(bo); \
         cs_winsys->write_cs_dword(cs_winsys, offset); \
    -    cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
    +    r300_buffer_write_reloc(cs_winsys, r300_buffer(bo), rd, wd, flags);	\
         cs_count -= 3; \
     } while (0)
     
    -#define OUT_CS_RELOC_NO_OFFSET(bo, rd, wd, flags) do { \
    +
    +#define OUT_CS_TEX_RELOC(tex, offset, rd, wd, flags) do { \
    +    DBG(cs_context_copy, DBG_CS, "r300: writing relocation for texture %p, offset %d, " \
    +            "domains (%d, %d, %d)\n", \
    +        tex, offset, rd, wd, flags); \
    +    assert(tex); \
    +    cs_winsys->write_cs_dword(cs_winsys, offset); \
    +    r300_texture_write_reloc(cs_winsys, tex, rd, wd, flags);	\
    +    cs_count -= 3; \
    +} while (0)
    +
    +
    +#define OUT_CS_BUF_RELOC_NO_OFFSET(bo, rd, wd, flags) do { \
         DBG(cs_context_copy, DBG_CS, "r300: writing relocation for buffer %p, " \
                 "domains (%d, %d, %d)\n", \
             bo, rd, wd, flags); \
         assert(bo); \
    -    cs_winsys->write_cs_reloc(cs_winsys, bo, rd, wd, flags); \
    +    r300_buffer_write_reloc(cs_winsys, r300_buffer(bo), rd, wd, flags);	\
         cs_count -= 2; \
     } while (0)
     
    diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
    index f8242625fe..d8c64dd900 100644
    --- a/src/gallium/drivers/r300/r300_emit.c
    +++ b/src/gallium/drivers/r300/r300_emit.c
    @@ -32,6 +32,8 @@
     #include "r300_emit.h"
     #include "r300_fs.h"
     #include "r300_screen.h"
    +#include "r300_screen_buffer.h"
    +#include "r300_state_inlines.h"
     #include "r300_vs.h"
     
     void r300_emit_blend_state(struct r300_context* r300,
    @@ -415,10 +417,10 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
             assert(tex && tex->buffer && "cbuf is marked, but NULL!");
     
             OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
    -        OUT_CS_RELOC(tex->buffer, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
    +        OUT_CS_TEX_RELOC(tex, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
     
             OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0 + (4 * i), 1);
    -        OUT_CS_RELOC(tex->buffer, tex->fb_state.colorpitch[surf->level],
    +        OUT_CS_TEX_RELOC(tex, tex->fb_state.colorpitch[surf->level],
                          0, RADEON_GEM_DOMAIN_VRAM, 0);
     
             OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i), tex->fb_state.us_out_fmt);
    @@ -434,12 +436,12 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
             assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
     
             OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
    -        OUT_CS_RELOC(tex->buffer, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
    +        OUT_CS_TEX_RELOC(tex, surf->offset, 0, RADEON_GEM_DOMAIN_VRAM, 0);
     
             OUT_CS_REG(R300_ZB_FORMAT, tex->fb_state.zb_format);
     
             OUT_CS_REG_SEQ(R300_ZB_DEPTHPITCH, 1);
    -        OUT_CS_RELOC(tex->buffer, tex->fb_state.depthpitch[surf->level],
    +        OUT_CS_TEX_RELOC(tex, tex->fb_state.depthpitch[surf->level],
                          0, RADEON_GEM_DOMAIN_VRAM, 0);
         }
     
    @@ -491,13 +493,13 @@ static void r300_emit_query_finish(struct r300_context *r300,
                 /* pipe 3 only */
                 OUT_CS_REG(R300_SU_REG_DEST, 1 << 3);
                 OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -            OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 3),
    +            OUT_CS_BUF_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 3),
                         0, RADEON_GEM_DOMAIN_GTT, 0);
             case 3:
                 /* pipe 2 only */
                 OUT_CS_REG(R300_SU_REG_DEST, 1 << 2);
                 OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -            OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 2),
    +            OUT_CS_BUF_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 2),
                         0, RADEON_GEM_DOMAIN_GTT, 0);
             case 2:
                 /* pipe 1 only */
    @@ -505,13 +507,13 @@ static void r300_emit_query_finish(struct r300_context *r300,
                 OUT_CS_REG(R300_SU_REG_DEST,
                         1 << (caps->high_second_pipe ? 3 : 1));
                 OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -            OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 1),
    +            OUT_CS_BUF_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 1),
                         0, RADEON_GEM_DOMAIN_GTT, 0);
             case 1:
                 /* pipe 0 only */
                 OUT_CS_REG(R300_SU_REG_DEST, 1 << 0);
                 OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -            OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 0),
    +            OUT_CS_BUF_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 0),
                         0, RADEON_GEM_DOMAIN_GTT, 0);
                 break;
             default:
    @@ -533,7 +535,7 @@ static void rv530_emit_query_single(struct r300_context *r300,
         BEGIN_CS(8);
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
         OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -    OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
    +    OUT_CS_BUF_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
         END_CS;
     }
    @@ -546,10 +548,10 @@ static void rv530_emit_query_double(struct r300_context *r300,
         BEGIN_CS(14);
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_0);
         OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -    OUT_CS_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
    +    OUT_CS_BUF_RELOC(r300->oqbo, query->offset, 0, RADEON_GEM_DOMAIN_GTT, 0);
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_1);
         OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1);
    -    OUT_CS_RELOC(r300->oqbo, query->offset + sizeof(uint32_t), 0, RADEON_GEM_DOMAIN_GTT, 0);
    +    OUT_CS_BUF_RELOC(r300->oqbo, query->offset + sizeof(uint32_t), 0, RADEON_GEM_DOMAIN_GTT, 0);
         OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL);
         END_CS;
     }
    @@ -747,7 +749,7 @@ void r300_emit_textures_state(struct r300_context *r300,
                 OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]);
     
                 OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1);
    -            OUT_CS_RELOC(allstate->textures[i]->buffer, texstate->tile_config,
    +            OUT_CS_TEX_RELOC(allstate->textures[i], texstate->tile_config,
                              RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
             }
         }
    @@ -788,8 +790,8 @@ void r300_emit_aos(struct r300_context* r300, unsigned offset)
         }
     
         for (i = 0; i < aos_count; i++) {
    -        OUT_CS_RELOC_NO_OFFSET(vbuf[velem[i].vertex_buffer_index].buffer,
    -                               RADEON_GEM_DOMAIN_GTT, 0, 0);
    +        OUT_CS_BUF_RELOC_NO_OFFSET(vbuf[velem[i].vertex_buffer_index].buffer,
    +				   RADEON_GEM_DOMAIN_GTT, 0, 0);
         }
         END_CS;
     }
    @@ -814,7 +816,7 @@ void r300_emit_vertex_buffer(struct r300_context* r300)
         OUT_CS(r300->vertex_info.size |
                 (r300->vertex_info.size << 8));
         OUT_CS(r300->vbo_offset);
    -    OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
    +    OUT_CS_BUF_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0);
         END_CS;
     }
     
    @@ -1009,16 +1011,22 @@ void r300_emit_buffer_validate(struct r300_context *r300,
         unsigned i;
         boolean invalid = FALSE;
     
    +    /* upload buffers first */
    +    if (r300->any_user_vbs) {
    +        r300_upload_user_buffers(r300);
    +        r300->any_user_vbs = false;
    +    }
    +
         /* Clean out BOs. */
    -    r300->winsys->reset_bos(r300->winsys);
    +    r300->rws->reset_bos(r300->rws);
     
     validate:
         /* Color buffers... */
         for (i = 0; i < fb->nr_cbufs; i++) {
             tex = (struct r300_texture*)fb->cbufs[i]->texture;
             assert(tex && tex->buffer && "cbuf is marked, but NULL!");
    -        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
    -                    0, RADEON_GEM_DOMAIN_VRAM)) {
    +        if (!r300_add_texture(r300->rws, tex,
    +			      0, RADEON_GEM_DOMAIN_VRAM)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
    @@ -1027,8 +1035,8 @@ validate:
         if (fb->zsbuf) {
             tex = (struct r300_texture*)fb->zsbuf->texture;
             assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
    -        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
    -                    0, RADEON_GEM_DOMAIN_VRAM)) {
    +        if (!r300_add_texture(r300->rws, tex,
    +			      0, RADEON_GEM_DOMAIN_VRAM)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
    @@ -1038,24 +1046,24 @@ validate:
             tex = texstate->textures[i];
             if (!tex || !texstate->sampler_states[i])
                 continue;
    -        if (!r300->winsys->add_buffer(r300->winsys, tex->buffer,
    -                    RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
    +        if (!r300_add_texture(r300->rws, tex,
    +			      RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
         }
         /* ...occlusion query buffer... */
         if (r300->dirty_state & R300_NEW_QUERY) {
    -        if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo,
    -                    0, RADEON_GEM_DOMAIN_GTT)) {
    +        if (!r300_add_buffer(r300->rws, r300->oqbo,
    +			     0, RADEON_GEM_DOMAIN_GTT)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
         }
         /* ...vertex buffer for SWTCL path... */
         if (r300->vbo) {
    -        if (!r300->winsys->add_buffer(r300->winsys, r300->vbo,
    -                    RADEON_GEM_DOMAIN_GTT, 0)) {
    +        if (!r300_add_buffer(r300->rws, r300->vbo,
    +			     RADEON_GEM_DOMAIN_GTT, 0)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
    @@ -1065,23 +1073,22 @@ validate:
             for (i = 0; i < r300->velems->count; i++) {
                 pbuf = vbuf[velem[i].vertex_buffer_index].buffer;
     
    -            if (!r300->winsys->add_buffer(r300->winsys, pbuf,
    -                                          RADEON_GEM_DOMAIN_GTT, 0)) {
    -                r300->context.flush(&r300->context, 0, NULL);
    +            if (!r300_add_buffer(r300->rws, pbuf,
    +				 RADEON_GEM_DOMAIN_GTT, 0)) {
    +		r300->context.flush(&r300->context, 0, NULL);
                     goto validate;
                 }
             }
         }
         /* ...and index buffer for HWTCL path. */
         if (index_buffer) {
    -        if (!r300->winsys->add_buffer(r300->winsys, index_buffer,
    -                                      RADEON_GEM_DOMAIN_GTT, 0)) {
    +        if (!r300_add_buffer(r300->rws, index_buffer,
    +			     RADEON_GEM_DOMAIN_GTT, 0)) {
                 r300->context.flush(&r300->context, 0, NULL);
                 goto validate;
             }
         }
    -
    -    if (!r300->winsys->validate(r300->winsys)) {
    +    if (!r300->rws->validate(r300->rws)) {
             r300->context.flush(&r300->context, 0, NULL);
             if (invalid) {
                 /* Well, hell. */
    diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
    index 971e7f3521..47100c83b0 100644
    --- a/src/gallium/drivers/r300/r300_render.c
    +++ b/src/gallium/drivers/r300/r300_render.c
    @@ -30,10 +30,12 @@
     
     #include "util/u_format.h"
     #include "util/u_memory.h"
    +#include "util/u_upload_mgr.h"
     #include "util/u_prim.h"
     
     #include "r300_cs.h"
     #include "r300_context.h"
    +#include "r300_screen_buffer.h"
     #include "r300_emit.h"
     #include "r300_reg.h"
     #include "r300_render.h"
    @@ -123,7 +125,7 @@ static uint32_t r300_provoking_vertex_fixes(struct r300_context *r300,
     static boolean r300_reserve_cs_space(struct r300_context *r300,
                                          unsigned dwords)
     {
    -    if (!r300->winsys->check_cs(r300->winsys, dwords)) {
    +    if (!r300->rws->check_cs(r300->rws, dwords)) {
             r300->context.flush(&r300->context, 0, NULL);
             return TRUE;
         }
    @@ -153,15 +155,14 @@ static boolean immd_is_good_idea(struct r300_context *r300,
             if (!checked[vbi]) {
                 vbuf = &r300->vertex_buffer[vbi];
     
    -            if (r300->winsys->is_buffer_referenced(r300->winsys,
    -                                                   vbuf->buffer)) {
    +            if (r300_buffer_is_referenced(r300,
    +					  vbuf->buffer)) {
                     /* It's a very bad idea to map it... */
                     return FALSE;
                 }
                 checked[vbi] = TRUE;
             }
         }
    -
         return TRUE;
     }
     
    @@ -345,8 +346,8 @@ static void r300_emit_draw_elements(struct r300_context *r300,
         OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2) |
                (0 << R300_INDX_BUFFER_SKIP_SHIFT));
         OUT_CS(offset_dwords << 2);
    -    OUT_CS_RELOC(indexBuffer, count_dwords,
    -        RADEON_GEM_DOMAIN_GTT, 0, 0);
    +    OUT_CS_BUF_RELOC(indexBuffer, count_dwords,
    +		     RADEON_GEM_DOMAIN_GTT, 0, 0);
     
         END_CS;
     }
    @@ -413,12 +414,16 @@ void r300_draw_range_elements(struct pipe_context* pipe,
     
         r300_update_derived_state(r300);
     
    +    r300_upload_index_buffer(r300, &indexBuffer, indexSize, start, count);
    +
         /* 128 dwords for emit_aos and emit_draw_elements */
         r300_reserve_cs_space(r300, r300_get_num_dirty_dwords(r300) + 128);
         r300_emit_buffer_validate(r300, TRUE, indexBuffer);
         r300_emit_dirty_state(r300);
         r300_emit_aos(r300, 0);
     
    +    u_upload_flush(r300->upload_vb);
    +    u_upload_flush(r300->upload_ib);
         if (alt_num_verts || count <= 65535) {
             r300_emit_draw_elements(r300, indexBuffer, indexSize, minIndex,
                                     maxIndex, mode, start, count);
    @@ -441,7 +446,7 @@ void r300_draw_range_elements(struct pipe_context* pipe,
         }
     
         if (indexBuffer != orgIndexBuffer) {
    -        pipe->screen->buffer_destroy(indexBuffer);
    +        pipe_buffer_reference( &indexBuffer, NULL );
         }
     }
     
    @@ -505,6 +510,7 @@ void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,
                     }
                 } while (count);
             }
    +	u_upload_flush(r300->upload_vb);
         }
     }
     
    diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
    index b6282fccd7..3e31688f8e 100644
    --- a/src/gallium/drivers/r300/r300_screen.c
    +++ b/src/gallium/drivers/r300/r300_screen.c
    @@ -23,13 +23,14 @@
     
     #include "util/u_format.h"
     #include "util/u_memory.h"
    -#include "util/u_simple_screen.h"
     
     #include "r300_context.h"
     #include "r300_texture.h"
     
     #include "radeon_winsys.h"
     
    +#include "r300_screen_buffer.h"
    +
     /* Return the identifier behind whom the brave coders responsible for this
      * amalgamation of code, sweat, and duct tape, routinely obscure their names.
      *
    @@ -253,15 +254,19 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
     static void r300_destroy_screen(struct pipe_screen* pscreen)
     {
         struct r300_screen* r300screen = r300_screen(pscreen);
    +    struct r300_winsys_screen *rws = r300_winsys_screen(pscreen);
    +
    +    if (rws)
    +      rws->destroy(rws);
     
         FREE(r300screen->caps);
         FREE(r300screen);
     }
     
    -struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys)
    +struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws)
     {
    -    struct r300_screen* r300screen = CALLOC_STRUCT(r300_screen);
    -    struct r300_capabilities* caps = CALLOC_STRUCT(r300_capabilities);
    +    struct r300_screen *r300screen = CALLOC_STRUCT(r300_screen);
    +    struct r300_capabilities *caps = CALLOC_STRUCT(r300_capabilities);
     
         if (!r300screen || !caps) {
             FREE(r300screen);
    @@ -269,16 +274,16 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys)
             return NULL;
         }
     
    -    caps->pci_id = radeon_winsys->pci_id;
    -    caps->num_frag_pipes = radeon_winsys->gb_pipes;
    -    caps->num_z_pipes = radeon_winsys->z_pipes;
    +    caps->pci_id = rws->get_value(rws, R300_VID_PCI_ID);
    +    caps->num_frag_pipes = rws->get_value(rws, R300_VID_GB_PIPES);
    +    caps->num_z_pipes = rws->get_value(rws, R300_VID_Z_PIPES);
     
         r300_init_debug(r300screen);
         r300_parse_chipset(caps);
     
         r300screen->caps = caps;
    -    r300screen->radeon_winsys = radeon_winsys;
    -    r300screen->screen.winsys = (struct pipe_winsys*)radeon_winsys;
    +    r300screen->rws = rws;
    +    r300screen->screen.winsys = (struct pipe_winsys*)rws;
         r300screen->screen.destroy = r300_destroy_screen;
         r300screen->screen.get_name = r300_get_name;
         r300screen->screen.get_vendor = r300_get_vendor;
    @@ -288,8 +293,13 @@ struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys)
         r300screen->screen.context_create = r300_create_context;
     
         r300_init_screen_texture_functions(&r300screen->screen);
    -    u_simple_screen_init(&r300screen->screen);
     
    +    r300_screen_init_buffer_functions(r300screen);
         return &r300screen->screen;
     }
     
    +struct r300_winsys_screen *
    +r300_winsys_screen(struct pipe_screen *screen)
    +{
    +    return r300_screen(screen)->rws;
    +}
    diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
    index abc1303e12..1ccc0bfb7a 100644
    --- a/src/gallium/drivers/r300/r300_screen.h
    +++ b/src/gallium/drivers/r300/r300_screen.h
    @@ -36,7 +36,7 @@ struct r300_screen {
         /* Parent class */
         struct pipe_screen screen;
     
    -    struct radeon_winsys* radeon_winsys;
    +    struct r300_winsys_screen *rws;
     
         /* Chipset capabilities */
         struct r300_capabilities* caps;
    @@ -51,9 +51,6 @@ static INLINE struct r300_screen* r300_screen(struct pipe_screen* screen) {
         return (struct r300_screen*)screen;
     }
     
    -/* Creates a new r300 screen. */
    -struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys);
    -
     /* Debug functionality. */
     
     /**
    diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
    new file mode 100644
    index 0000000000..b97d0d76a4
    --- /dev/null
    +++ b/src/gallium/drivers/r300/r300_screen_buffer.c
    @@ -0,0 +1,314 @@
    +/*
    + * Copyright 2010 Red Hat Inc.
    + *
    + * Permission is hereby granted, free of charge, to any person obtaining a
    + * copy of this software and associated documentation files (the "Software"),
    + * to deal in the Software without restriction, including without limitation
    + * on the rights to use, copy, modify, merge, publish, distribute, sub
    + * license, and/or sell copies of the Software, and to permit persons to whom
    + * the Software is furnished to do so, subject to the following conditions:
    + *
    + * The above copyright notice and this permission notice (including the next
    + * paragraph) shall be included in all copies or substantial portions of the
    + * Software.
    + *
    + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
    + * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
    + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
    + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
    + * USE OR OTHER DEALINGS IN THE SOFTWARE.
    + *
    + * Authors: Dave Airlie
    + */
    +#include 
    +
    +#include "util/u_inlines.h"
    +#include "util/u_format.h"
    +#include "util/u_memory.h"
    +#include "util/u_upload_mgr.h"
    +#include "util/u_math.h"
    +
    +#include "r300_screen_buffer.h"
    +
    +#include "r300_winsys.h"
    +
    +boolean r300_buffer_is_referenced(struct r300_context *r300,
    +				  struct pipe_buffer *buf)
    +{
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +    if (r300_buffer_is_user_buffer(buf))
    +	return FALSE;
    +
    +    return r300->rws->is_buffer_referenced(r300->rws, rbuf->buf);
    +    
    +}
    +int r300_upload_index_buffer(struct r300_context *r300,
    +			     struct pipe_buffer **index_buffer,
    +			     unsigned index_size,
    +			     unsigned start,
    +			     unsigned count)
    +{
    +   struct pipe_buffer *upload_buffer = NULL;
    +   unsigned index_offset = start * index_size;
    +   int ret = 0;
    +
    +    if (r300_buffer_is_user_buffer(*index_buffer)) {
    +	ret = u_upload_buffer(r300->upload_ib,
    +			      index_offset,
    +			      count * index_size,
    +			      *index_buffer,
    +			      &index_offset,
    +			      &upload_buffer);
    +	if (ret) {
    +	    goto done;
    +	}
    +	*index_buffer = upload_buffer;
    +    }
    + done:
    +    //    if (upload_buffer)
    +    //	pipe_buffer_reference(&upload_buffer, NULL);
    +    return ret;
    +}
    +
    +int r300_upload_user_buffers(struct r300_context *r300)
    +{
    +    enum pipe_error ret = PIPE_OK;
    +    int i, nr;
    +
    +    nr = r300->vertex_buffer_count;
    +
    +    for (i = 0; i < nr; i++) {
    +
    +	if (r300_buffer_is_user_buffer(r300->vertex_buffer[i].buffer)) {
    +	    struct pipe_buffer *upload_buffer = NULL;
    +	    unsigned offset = 0; /*r300->vertex_buffer[i].buffer_offset * 4;*/
    +	    unsigned size = r300->vertex_buffer[i].buffer->size;
    +	    unsigned upload_offset;
    +	    ret = u_upload_buffer(r300->upload_vb,
    +				  offset, size,
    +				  r300->vertex_buffer[i].buffer,
    +				  &upload_offset, &upload_buffer);
    +	    if (ret)
    +		return ret;
    +
    +	    pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
    +	    r300->vertex_buffer[i].buffer = upload_buffer;
    +	    r300->vertex_buffer[i].buffer_offset = upload_offset;
    +	}
    +    }
    +    return ret;
    +}
    +
    +static struct r300_winsys_buffer *
    +r300_winsys_buffer_create(struct r300_screen *r300screen,
    +			  unsigned alignment,
    +			  unsigned usage,
    +			  unsigned size)
    +{
    +    struct r300_winsys_screen *rws = r300screen->rws;
    +    struct r300_winsys_buffer *buf;
    +
    +    buf = rws->buffer_create(rws, alignment, usage, size);
    +    return buf;
    +}
    +
    +static void r300_winsys_buffer_destroy(struct r300_screen *r300screen,
    +				       struct r300_buffer *rbuf)
    +{
    +    struct r300_winsys_screen *rws = r300screen->rws;
    +
    +    if (rbuf->buf) {
    +	rws->buffer_reference(rws, &rbuf->buf, NULL);
    +	rbuf->buf = NULL;
    +    }
    +}
    +
    +static struct pipe_buffer *r300_buffer_create(struct pipe_screen *screen,
    +					      unsigned alignment,
    +					      unsigned usage,
    +					      unsigned size)
    +{
    +    struct r300_screen *r300screen = r300_screen(screen);
    +    struct r300_buffer *rbuf;
    +
    +    rbuf = CALLOC_STRUCT(r300_buffer);
    +    if (!rbuf)
    +	goto error1;
    +
    +    rbuf->magic = R300_BUFFER_MAGIC;
    +
    +    pipe_reference_init(&rbuf->base.reference, 1);
    +    rbuf->base.screen = screen;
    +    rbuf->base.alignment = alignment;
    +    rbuf->base.usage = usage;
    +    rbuf->base.size = size;
    +
    +    rbuf->buf = r300_winsys_buffer_create(r300screen,
    +					  alignment,
    +					  usage,
    +					  size);
    +
    +    if (!rbuf->buf)
    +	goto error2;
    +
    +    return &rbuf->base;
    +error2:
    +    FREE(rbuf);
    +error1:
    +    return NULL;
    +}
    +
    +
    +static struct pipe_buffer *r300_user_buffer_create(struct pipe_screen *screen,
    +						   void *ptr,
    +						   unsigned bytes)
    +{
    +    struct r300_buffer *rbuf;
    +
    +    rbuf = CALLOC_STRUCT(r300_buffer);
    +    if (!rbuf)
    +	goto no_rbuf;
    +
    +    rbuf->magic = R300_BUFFER_MAGIC;
    +
    +    pipe_reference_init(&rbuf->base.reference, 1);
    +    rbuf->base.screen = screen;
    +    rbuf->base.alignment = 1;
    +    rbuf->base.usage = 0;
    +    rbuf->base.size = bytes;
    +
    +    rbuf->user_buffer = ptr;
    +    return &rbuf->base;
    +
    +no_rbuf:
    +    return NULL;
    +}
    +
    +static void r300_buffer_destroy(struct pipe_buffer *buf)
    +{
    +    struct r300_screen *r300screen = r300_screen(buf->screen);
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +
    +    r300_winsys_buffer_destroy(r300screen, rbuf);
    +    FREE(rbuf);
    +}
    +
    +static void *
    +r300_buffer_map_range(struct pipe_screen *screen,
    +		      struct pipe_buffer *buf,
    +		      unsigned offset, unsigned length,
    +		      unsigned usage )
    +{
    +    struct r300_screen *r300screen = r300_screen(screen);
    +    struct r300_winsys_screen *rws = r300screen->rws;
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +    void *map;
    +    int flush = 0;
    +    int i;
    +
    +    if (rbuf->user_buffer)
    +	return rbuf->user_buffer;
    +
    +    if (rbuf->base.usage & PIPE_BUFFER_USAGE_CONSTANT)
    +	goto just_map;
    +
    +    /* check if the mapping is to a range we already flushed */
    +    if (usage & PIPE_BUFFER_USAGE_DISCARD) {
    +	for (i = 0; i < rbuf->num_ranges; i++) {
    +
    +	    if ((offset >= rbuf->ranges[i].start) &&
    +		(offset < rbuf->ranges[i].end))
    +		flush = 1;
    +	    
    +	    if (flush) {
    +		/* unreference this hw buffer and allocate a new one */
    +		rws->buffer_reference(rws, &rbuf->buf, NULL);
    +
    +		rbuf->num_ranges = 0;
    +		rbuf->map = NULL;
    +		rbuf->buf = r300_winsys_buffer_create(r300screen,
    +						      rbuf->base.alignment,
    +						      rbuf->base.usage,
    +						      rbuf->base.size);
    +		break;
    +	    }
    +	}
    +    }
    +just_map:
    +    map = rws->buffer_map(rws, rbuf->buf, usage | R300_USAGE_FLAG_DONT_SYNC);
    +   
    +    return map;
    +}
    +
    +static void 
    +r300_buffer_flush_mapped_range( struct pipe_screen *screen,
    +				struct pipe_buffer *buf,
    +				unsigned offset,
    +				unsigned length )
    +{
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +    int i;
    +
    +    if (rbuf->user_buffer)
    +	return;
    +
    +    if (rbuf->base.usage & PIPE_BUFFER_USAGE_CONSTANT)
    +	return;
    +
    +    /* mark the range as used */
    +    for(i = 0; i < rbuf->num_ranges; ++i) {
    +	if(offset <= rbuf->ranges[i].end && rbuf->ranges[i].start <= (offset+length)) {
    +	    rbuf->ranges[i].start = MIN2(rbuf->ranges[i].start, offset);
    +	    rbuf->ranges[i].end   = MAX2(rbuf->ranges[i].end, (offset+length));
    +	    return;
    +	}
    +    }
    +
    +    rbuf->ranges[rbuf->num_ranges].start = offset;
    +    rbuf->ranges[rbuf->num_ranges].end = offset+length;
    +    rbuf->num_ranges++;
    +}
    +
    +static void *
    +r300_buffer_map(struct pipe_screen *screen,
    +		struct pipe_buffer *buf,
    +		unsigned usage)
    +{
    +    struct r300_screen *r300screen = r300_screen(screen);
    +    struct r300_winsys_screen *rws = r300screen->rws;
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +    void *map;
    +
    +   if (rbuf->user_buffer)
    +      return rbuf->user_buffer;
    +
    +    map = rws->buffer_map(rws, rbuf->buf, usage);
    +
    +    return map;
    +}
    +
    +static void
    +r300_buffer_unmap(struct pipe_screen *screen,
    +		  struct pipe_buffer *buf)
    +{
    +    struct r300_screen *r300screen = r300_screen(screen);
    +    struct r300_winsys_screen *rws = r300screen->rws;
    +    struct r300_buffer *rbuf = r300_buffer(buf);
    +
    +    if (rbuf->buf) {
    +        rws->buffer_unmap(rws, rbuf->buf);
    +    }
    +}
    +
    +void r300_screen_init_buffer_functions(struct r300_screen *r300screen)
    +{
    +    r300screen->screen.buffer_create = r300_buffer_create;
    +    r300screen->screen.user_buffer_create = r300_user_buffer_create;
    +    r300screen->screen.buffer_map = r300_buffer_map;
    +    r300screen->screen.buffer_map_range = r300_buffer_map_range;
    +    r300screen->screen.buffer_flush_mapped_range = r300_buffer_flush_mapped_range;
    +    r300screen->screen.buffer_unmap = r300_buffer_unmap;
    +    r300screen->screen.buffer_destroy = r300_buffer_destroy;
    +}
    diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
    new file mode 100644
    index 0000000000..0cf349c25c
    --- /dev/null
    +++ b/src/gallium/drivers/r300/r300_screen_buffer.h
    @@ -0,0 +1,99 @@
    +#ifndef R300_SCREEN_BUFFER_H
    +#define R300_SCREEN_BUFFER_H
    +#include 
    +#include "pipe/p_compiler.h"
    +#include "pipe/p_state.h"
    +#include "r300_screen.h"
    +
    +#include "r300_winsys.h"
    +#include "r300_context.h"
    +
    +#define R300_BUFFER_MAGIC 0xabcd1234
    +
    +struct r300_buffer_range {
    +    uint32_t start;
    +    uint32_t end;
    +};
    +#define R300_BUFFER_MAX_RANGES 32
    +
    +struct r300_buffer
    +{
    +    struct pipe_buffer base;
    +
    +    uint32_t magic;
    +
    +    struct r300_winsys_buffer *buf;
    +
    +    void *user_buffer;
    +    struct r300_buffer_range ranges[R300_BUFFER_MAX_RANGES];
    +    unsigned num_ranges;
    +
    +    void *map;
    +};
    +
    +static INLINE struct r300_buffer *
    +r300_buffer(struct pipe_buffer *buffer)
    +{
    +    if (buffer) {
    +	assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
    +	return (struct r300_buffer *)buffer;
    +    }
    +    return NULL;
    +}
    +
    +static INLINE boolean 
    +r300_buffer_is_user_buffer(struct pipe_buffer *buffer)
    +{
    +    return r300_buffer(buffer)->user_buffer ? true : false;
    +}
    +
    +static INLINE boolean r300_add_buffer(struct r300_winsys_screen *rws,
    +				      struct pipe_buffer *buffer,
    +				      int rd, int wr)
    +{
    +    struct r300_buffer *buf = r300_buffer(buffer);
    +
    +    if (!buf->buf)
    +	return true;
    +
    +    return rws->add_buffer(rws, buf->buf, rd, wr);
    +}
    +
    +
    +static INLINE boolean r300_add_texture(struct r300_winsys_screen *rws,
    +				       struct r300_texture *tex,
    +				       int rd, int wr)
    +{
    +    return rws->add_buffer(rws, tex->buffer, rd, wr);
    +}
    +
    +void r300_screen_init_buffer_functions(struct r300_screen *r300screen);
    +
    +static INLINE void r300_buffer_write_reloc(struct r300_winsys_screen *rws,
    +				      struct r300_buffer *buf,
    +				      uint32_t rd, uint32_t wd, uint32_t flags)
    +{
    +    if (!buf->buf)
    +	return;
    +
    +    rws->write_cs_reloc(rws, buf->buf, rd, wd, flags);
    +}
    +
    +static INLINE void r300_texture_write_reloc(struct r300_winsys_screen *rws,
    +					    struct r300_texture *texture,
    +					    uint32_t rd, uint32_t wd, uint32_t flags)
    +{
    +    rws->write_cs_reloc(rws, texture->buffer, rd, wd, flags);
    +}
    +
    +int r300_upload_user_buffers(struct r300_context *r300);
    +
    +int r300_upload_index_buffer(struct r300_context *r300,
    +			     struct pipe_buffer **index_buffer,
    +			     unsigned index_size,
    +			     unsigned start,
    +			     unsigned count);
    +
    +boolean r300_buffer_is_referenced(struct r300_context *r300,
    +				  struct pipe_buffer *buf);
    +#endif
    diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
    index 3098145dfb..712e9280e3 100644
    --- a/src/gallium/drivers/r300/r300_state.c
    +++ b/src/gallium/drivers/r300/r300_state.c
    @@ -34,6 +34,7 @@
     #include "r300_context.h"
     #include "r300_reg.h"
     #include "r300_screen.h"
    +#include "r300_screen_buffer.h"
     #include "r300_state_inlines.h"
     #include "r300_fs.h"
     #include "r300_vs.h"
    @@ -525,7 +526,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
             tex = (struct r300_texture*)old_state->cbufs[i]->texture;
     
             if (tex) {
    -            r300->winsys->buffer_set_tiling(r300->winsys, tex->buffer,
    +            r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                                 tex->pitch[0],
                                                 tex->microtile != 0,
                                                 tex->macrotile != 0);
    @@ -537,7 +538,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
             tex = (struct r300_texture*)old_state->zsbuf->texture;
     
             if (tex) {
    -            r300->winsys->buffer_set_tiling(r300->winsys, tex->buffer,
    +            r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                                 tex->pitch[0],
                                                 tex->microtile != 0,
                                                 tex->macrotile != 0);
    @@ -549,7 +550,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
             tex = (struct r300_texture*)new_state->cbufs[i]->texture;
             level = new_state->cbufs[i]->level;
     
    -        r300->winsys->buffer_set_tiling(r300->winsys, tex->buffer,
    +        r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                             tex->pitch[level],
                                             tex->microtile != 0,
                                             tex->mip_macrotile[level] != 0);
    @@ -558,7 +559,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
             tex = (struct r300_texture*)new_state->zsbuf->texture;
             level = new_state->zsbuf->level;
     
    -        r300->winsys->buffer_set_tiling(r300->winsys, tex->buffer,
    +        r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
                                             tex->pitch[level],
                                             tex->microtile != 0,
                                             tex->mip_macrotile[level] != 0);
    @@ -1040,17 +1041,30 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
                                         const struct pipe_vertex_buffer* buffers)
     {
         struct r300_context* r300 = r300_context(pipe);
    -    unsigned i, max_index = (1 << 24) - 1;
    +    int i;
    +    unsigned max_index = (1 << 24) - 1;
    +    boolean any_user_buffer = false;
     
    -    memcpy(r300->vertex_buffer, buffers,
    -        sizeof(struct pipe_vertex_buffer) * count);
    +    if (count == r300->vertex_buffer_count &&
    +	memcmp(r300->vertex_buffer, buffers, count * sizeof(buffers[0])) == 0)
    +        return;
     
         for (i = 0; i < count; i++) {
    +	pipe_buffer_reference(&r300->vertex_buffer[i].buffer, buffers[i].buffer);
    +	if (r300_buffer_is_user_buffer(buffers[i].buffer))
    +	    any_user_buffer = true;
             max_index = MIN2(buffers[i].max_index, max_index);
         }
     
    +    for ( ; i < r300->vertex_buffer_count; i++)
    +	pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
    +
    +    memcpy(r300->vertex_buffer, buffers,
    +	   sizeof(struct pipe_vertex_buffer) * count);
    +
         r300->vertex_buffer_count = count;
         r300->vertex_buffer_max_index = max_index;
    +    r300->any_user_vbs = any_user_buffer;
     
         if (r300->draw) {
             draw_flush(r300->draw);
    diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
    index 04124afd4d..7c7656068b 100644
    --- a/src/gallium/drivers/r300/r300_texture.c
    +++ b/src/gallium/drivers/r300/r300_texture.c
    @@ -773,7 +773,7 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
     {
         struct r300_texture* tex = CALLOC_STRUCT(r300_texture);
         struct r300_screen* rscreen = r300_screen(screen);
    -    struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys;
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
     
         if (!tex) {
             return NULL;
    @@ -790,13 +790,13 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
         r300_setup_miptree(rscreen, tex);
         r300_setup_texture_state(rscreen, tex);
     
    -    tex->buffer = screen->buffer_create(screen, 2048,
    -                                        PIPE_BUFFER_USAGE_PIXEL,
    -                                        tex->size);
    -    winsys->buffer_set_tiling(winsys, tex->buffer,
    -                              tex->pitch[0],
    -                              tex->microtile != R300_BUFFER_LINEAR,
    -                              tex->macrotile != R300_BUFFER_LINEAR);
    +    tex->buffer = rws->buffer_create(rws, 2048,
    +				     PIPE_BUFFER_USAGE_PIXEL,
    +				     tex->size);
    +    rws->buffer_set_tiling(rws, tex->buffer,
    +			   tex->pitch[0],
    +			   tex->microtile != R300_BUFFER_LINEAR,
    +			   tex->macrotile != R300_BUFFER_LINEAR);
     
         if (!tex->buffer) {
             FREE(tex);
    @@ -809,9 +809,9 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
     static void r300_texture_destroy(struct pipe_texture* texture)
     {
         struct r300_texture* tex = (struct r300_texture*)texture;
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)texture->screen->winsys;
     
    -    pipe_buffer_reference(&tex->buffer, NULL);
    -
    +    rws->buffer_reference(rws, &tex->buffer, NULL);
         FREE(tex);
     }
     
    @@ -857,9 +857,9 @@ static struct pipe_texture*
                                  const struct pipe_texture* base,
                                  struct winsys_handle *whandle)
     {
    -    struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys;
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen*)screen->winsys;
         struct r300_screen* rscreen = r300_screen(screen);
    -    struct pipe_buffer *buffer;
    +    struct r300_winsys_buffer *buffer;
         struct r300_texture* tex;
         unsigned stride;
     
    @@ -870,7 +870,7 @@ static struct pipe_texture*
             return NULL;
         }
     
    -    buffer = winsys->buffer_from_handle(winsys, screen, whandle, &stride);
    +    buffer = rws->buffer_from_handle(rws, screen, whandle, &stride);
         if (!buffer) {
             return NULL;
         }
    @@ -901,7 +901,7 @@ static boolean
                                 struct pipe_texture *texture,
                                 struct winsys_handle *whandle)
     {
    -    struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys;
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
         struct r300_texture* tex = (struct r300_texture*)texture;
         unsigned stride;
     
    @@ -911,7 +911,7 @@ static boolean
     
         stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
     
    -    winsys->buffer_get_handle(winsys, tex->buffer, stride, whandle);
    +    rws->buffer_get_handle(rws, tex->buffer, stride, whandle);
     
         return TRUE;
     }
    @@ -977,3 +977,25 @@ void r300_init_screen_texture_functions(struct pipe_screen* screen)
         screen->video_surface_destroy= r300_video_surface_destroy;
     }
     
    +boolean r300_get_texture_buffer(struct pipe_screen* screen,
    +                                struct pipe_texture* texture,
    +                                struct r300_winsys_buffer** buffer,
    +                                unsigned* stride)
    +{
    +    struct r300_texture* tex = (struct r300_texture*)texture;
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
    +    struct r300_winsys_buffer *buf;
    +
    +    if (!tex) {
    +        return FALSE;
    +    }
    +
    +    rws->buffer_reference(rws, &buf, tex->buffer);
    +
    +    if (stride) {
    +        *stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
    +    }
    +
    +    *buffer = buf;
    +    return TRUE;
    +}
    diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
    index 138b62784e..60c7fa8342 100644
    --- a/src/gallium/drivers/r300/r300_texture.h
    +++ b/src/gallium/drivers/r300/r300_texture.h
    @@ -63,8 +63,8 @@ r300_video_surface(struct pipe_video_surface *pvs)
     /* Used internally for texture_is_referenced()
      */
     boolean r300_get_texture_buffer(struct pipe_screen* screen,
    -                                struct pipe_texture* texture,
    -                                struct pipe_buffer** buffer,
    +                                struct pipe_texture *texture,
    +                                struct r300_winsys_buffer** buffer,
                                     unsigned* stride);
     
     #endif /* R300_TEXTURE_H */
    diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c
    index 495e3dee76..987a040698 100644
    --- a/src/gallium/drivers/r300/r300_transfer.c
    +++ b/src/gallium/drivers/r300/r300_transfer.c
    @@ -26,6 +26,8 @@
     #include "r300_texture.h"
     #include "r300_screen.h"
     
    +#include "r300_winsys.h"
    +
     #include "util/u_memory.h"
     #include "util/u_format.h"
     
    @@ -225,6 +227,7 @@ static void r300_tex_transfer_destroy(struct pipe_context *ctx,
     static void* r300_transfer_map(struct pipe_context *ctx,
                                    struct pipe_transfer *transfer)
     {
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
         struct r300_transfer *r300transfer = r300_transfer(transfer);
         struct r300_texture *tex = (struct r300_texture*)transfer->texture;
         char *map;
    @@ -233,12 +236,12 @@ static void* r300_transfer_map(struct pipe_context *ctx,
         if (r300transfer->detiled_texture) {
             /* The detiled texture is of the same size as the region being mapped
              * (no offset needed). */
    -        return pipe_buffer_map(ctx->screen,
    +        return rws->buffer_map(rws,
                                    r300transfer->detiled_texture->buffer,
                                    pipe_transfer_buffer_flags(transfer));
         } else {
             /* Tiling is disabled. */
    -        map = pipe_buffer_map(ctx->screen, tex->buffer,
    +        map = rws->buffer_map(rws, tex->buffer,
                                   pipe_transfer_buffer_flags(transfer));
     
             if (!map) {
    @@ -254,13 +257,14 @@ static void* r300_transfer_map(struct pipe_context *ctx,
     static void r300_transfer_unmap(struct pipe_context *ctx,
                                     struct pipe_transfer *transfer)
     {
    +    struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
         struct r300_transfer *r300transfer = r300_transfer(transfer);
         struct r300_texture *tex = (struct r300_texture*)transfer->texture;
     
         if (r300transfer->detiled_texture) {
    -        pipe_buffer_unmap(ctx->screen, r300transfer->detiled_texture->buffer);
    +	rws->buffer_unmap(rws, r300transfer->detiled_texture->buffer);
         } else {
    -        pipe_buffer_unmap(ctx->screen, tex->buffer);
    +        rws->buffer_unmap(rws, tex->buffer);
         }
     }
     
    diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
    index ddf2b79003..e5183a8239 100644
    --- a/src/gallium/drivers/r300/r300_winsys.h
    +++ b/src/gallium/drivers/r300/r300_winsys.h
    @@ -23,10 +23,6 @@
     #ifndef R300_WINSYS_H
     #define R300_WINSYS_H
     
    -#ifdef __cplusplus
    -extern "C" {
    -#endif
    -
     /* The public interface header for the r300 pipe driver.
      * Any winsys hosting this pipe needs to implement r300_winsys and then
      * call r300_create_screen to start things. */
    @@ -34,14 +30,146 @@ extern "C" {
     #include "pipe/p_defines.h"
     #include "pipe/p_state.h"
     
    -struct radeon_winsys;
    +struct r300_winsys_screen;
     
     /* Creates a new r300 screen. */
    -struct pipe_screen* r300_create_screen(struct radeon_winsys* radeon_winsys);
    +struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws);
    +
    +struct r300_winsys_buffer;
    +
    +
    +boolean r300_get_texture_buffer(struct pipe_screen* screen,
    +                                struct pipe_texture* texture,
    +                                struct r300_winsys_buffer** buffer,
    +                                unsigned *stride);
    +
    +enum r300_value_id {
    +    R300_VID_PCI_ID,
    +    R300_VID_GB_PIPES,
    +    R300_VID_Z_PIPES,
    +};
    +
    +#define R300_USAGE_FLAG_DONT_SYNC (1 << 17)
    +
    +struct r300_winsys_screen {
    +    void (*destroy)(struct r300_winsys_screen *ws);
    +    
    +    /**
    +     * Buffer management. Buffer attributes are mostly fixed over its lifetime.
    +     *
    +     * Remember that gallium gets to choose the interface it needs, and the
    +     * window systems must then implement that interface (rather than the
    +     * other way around...).
    +     *
    +     * usage is a bitmask of R300_WINSYS_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
    +     * usage argument is only an optimization hint, not a guarantee, therefore
    +     * proper behavior must be observed in all circumstances.
    +     *
    +     * alignment indicates the client's alignment requirements, eg for
    +     * SSE instructions.
    +     */
    +    struct r300_winsys_buffer *(*buffer_create)(struct r300_winsys_screen *ws,
    +						unsigned alignment,
    +						unsigned usage,
    +						unsigned size);
    +    
    +    /**
    +     * Map the entire data store of a buffer object into the client's address.
    +     * flags is bitmask of R300_WINSYS_BUFFER_USAGE_CPU_READ/WRITE flags.
    +     */
    +    void *(*buffer_map)( struct r300_winsys_screen *ws,
    +			 struct r300_winsys_buffer *buf,
    +			 unsigned usage);
    +
    +    void (*buffer_unmap)( struct r300_winsys_screen *ws,
    +			  struct r300_winsys_buffer *buf );
    +
    +    void (*buffer_destroy)( struct r300_winsys_buffer *buf );
    +
    +
    +    void (*buffer_reference)(struct r300_winsys_screen *rws,
    +			     struct r300_winsys_buffer **pdst,
    +			     struct r300_winsys_buffer *src);
    +
    +    boolean (*buffer_references)(struct r300_winsys_buffer *a,
    +				 struct r300_winsys_buffer *b);
    +
    +    void (*buffer_flush_range)(struct r300_winsys_screen *rws,
    +			       struct r300_winsys_buffer *buf,
    +			       unsigned offset,
    +			       unsigned length);
    +
    +    /* Add a pipe_buffer to the list of buffer objects to validate. */
    +    boolean (*add_buffer)(struct r300_winsys_screen *winsys,
    +                          struct r300_winsys_buffer *buf,
    +                          uint32_t rd,
    +                          uint32_t wd);
    +
    +
    +    /* Revalidate all currently setup pipe_buffers.
    +     * Returns TRUE if a flush is required. */
    +    boolean (*validate)(struct r300_winsys_screen* winsys);
    +
    +    /* Check to see if there's room for commands. */
    +    boolean (*check_cs)(struct r300_winsys_screen* winsys, int size);
    +
    +    /* Start a command emit. */
    +    void (*begin_cs)(struct r300_winsys_screen* winsys,
    +                     int size,
    +                     const char* file,
    +                     const char* function,
    +                     int line);
    +
    +    /* Write a dword to the command buffer. */
    +    void (*write_cs_dword)(struct r300_winsys_screen* winsys, uint32_t dword);
    +
    +    /* Write a relocated dword to the command buffer. */
    +    void (*write_cs_reloc)(struct r300_winsys_screen *winsys,
    +                           struct r300_winsys_buffer *buf,
    +                           uint32_t rd,
    +                           uint32_t wd,
    +                           uint32_t flags);
    +
    +    /* Finish a command emit. */
    +    void (*end_cs)(struct r300_winsys_screen* winsys,
    +                   const char* file,
    +                   const char* function,
    +                   int line);
    +
    +    /* Flush the CS. */
    +    void (*flush_cs)(struct r300_winsys_screen* winsys);
    +
    +    /* winsys flush - callback from winsys when flush required */
    +    void (*set_flush_cb)(struct r300_winsys_screen *winsys,
    +			 void (*flush_cb)(void *), void *data);
    +
    +    void (*reset_bos)(struct r300_winsys_screen *winsys);
    +
    +    void (*buffer_set_tiling)(struct r300_winsys_screen *winsys,
    +                              struct r300_winsys_buffer *buffer,
    +                              uint32_t pitch,
    +                              boolean microtiled,
    +                              boolean macrotiled);
    +
    +    uint32_t (*get_value)(struct r300_winsys_screen *winsys,
    +			  enum r300_value_id vid);
    +
    +    struct r300_winsys_buffer *(*buffer_from_handle)(struct r300_winsys_screen *winsys,
    +						     struct pipe_screen *screen,
    +						     struct winsys_handle *whandle,
    +						     unsigned *stride);
    +    boolean (*buffer_get_handle)(struct r300_winsys_screen *winsys,
    +				 struct r300_winsys_buffer *buffer,
    +				 unsigned stride,
    +				 struct winsys_handle *whandle);
    +
    +    boolean (*is_buffer_referenced)(struct r300_winsys_screen *winsys,
    +                                    struct r300_winsys_buffer *buffer);
     
    +  
    +};
     
    -#ifdef __cplusplus
    -}
    -#endif
    +struct r300_winsys_screen *
    +r300_winsys_screen(struct pipe_screen *screen);
     
     #endif /* R300_WINSYS_H */
    diff --git a/src/gallium/winsys/drm/radeon/core/Makefile b/src/gallium/winsys/drm/radeon/core/Makefile
    index 860cbb6dbf..13bbbf730d 100644
    --- a/src/gallium/winsys/drm/radeon/core/Makefile
    +++ b/src/gallium/winsys/drm/radeon/core/Makefile
    @@ -5,7 +5,7 @@ include $(TOP)/configs/current
     LIBNAME = radeonwinsys
     
     C_SOURCES = \
    -	radeon_buffer.c \
    +	radeon_drm_buffer.c \
     	radeon_drm.c \
     	radeon_r300.c
     
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
    index f776e2d900..e1fcfcfcca 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_buffer.h
    @@ -30,48 +30,56 @@
     #ifndef RADEON_BUFFER_H
     #define RADEON_BUFFER_H
     
    +#include 
    +
    +#include "pipe/p_defines.h"
    +#include "util/u_inlines.h"
    +
     #include "pipebuffer/pb_buffer.h"
    +#include "pipebuffer/pb_bufmgr.h"
     
     #include "radeon_bo.h"
     #include "radeon_cs.h"
     
     #include "radeon_winsys.h"
     
    -struct radeon_pipe_buffer {
    -    struct pipe_buffer  base;
    -    /* Pointer to GPU-backed BO. */
    -    struct radeon_bo    *bo;
    -    /* Pointer to fallback PB buffer. */
    -    struct pb_buffer    *pb;
    -    boolean flinked;
    -    uint32_t flink;
    -};
     
     #define RADEON_MAX_BOS 24
     
    -struct radeon_winsys_priv {
    -    /* DRM FD */
    -    int fd;
    +static INLINE struct pb_buffer *
    +radeon_pb_buffer(struct r300_winsys_buffer *buffer)
    +{
    +    return (struct pb_buffer *)buffer;
    +}
     
    -    /* Radeon BO manager. */
    -    struct radeon_bo_manager* bom;
    +static INLINE struct r300_winsys_buffer *
    +radeon_libdrm_winsys_buffer(struct pb_buffer *buffer)
    +{
    +    return (struct r300_winsys_buffer *)buffer;
    +}
     
    -    /* Radeon CS manager. */
    -    struct radeon_cs_manager* csm;
    +struct pb_manager *
    +radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws);
     
    -    /* Current CS. */
    -    struct radeon_cs* cs;
    +boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
    +				     uint32_t rd, uint32_t wd);
     
    -    /* Flush CB */
    -    void (*flush_cb)(void *);
    -    void *flush_data;
    -};
     
    -struct radeon_winsys* radeon_pipe_winsys(int fb);
    -#if 0
    -struct pipe_surface *radeon_surface_from_handle(struct radeon_context *radeon_context,
    -                                             uint32_t handle,
    -                                             enum pipe_format format,
    -                                             int w, int h, int pitch);
    -#endif
    +void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
    +				   uint32_t rd, uint32_t wd,
    +				   uint32_t flags);
    +
    +struct radeon_libdrm_winsys* radeon_pipe_winsys(int fd);
    +
    +struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
    +							      uint32_t handle);
    +
    +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch);
    +
    +void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr);
    +
    +boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
    +				     struct winsys_handle *whandle);
    +
    +boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf);
     #endif
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
    index 97edb6a47e..d70173e805 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c
    @@ -41,8 +41,22 @@
     #include "xf86drm.h"
     #include 
     
    +static struct radeon_libdrm_winsys *
    +radeon_winsys_create(int fd)
    +{
    +    struct radeon_libdrm_winsys *rws;
    +
    +    rws = CALLOC_STRUCT(radeon_libdrm_winsys);
    +    if (rws == NULL) {
    +        return NULL;
    +    }
    +
    +    rws->fd = fd;
    +    return rws;
    +}
    +
     /* Helper function to do the ioctls needed for setup and init. */
    -static void do_ioctls(int fd, struct radeon_winsys* winsys)
    +static void do_ioctls(int fd, struct radeon_libdrm_winsys* winsys)
     {
         struct drm_radeon_gem_info gem_info = {0};
         struct drm_radeon_info info = {0};
    @@ -133,19 +147,28 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
                                              int drmFB,
                                              struct drm_create_screen_arg *arg)
     {
    -    struct radeon_winsys* rwinsys = radeon_pipe_winsys(drmFB);
    -    do_ioctls(drmFB, rwinsys);
    +    struct radeon_libdrm_winsys* rws; 
    +    boolean ret;
    +
    +    rws = radeon_winsys_create(drmFB);
    +    if (!rws)
    +	return NULL;
    +
    +    do_ioctls(drmFB, rws);
     
         /* The state tracker can organize a softpipe fallback if no hw
          * driver is found.
          */
    -    if (is_r3xx(rwinsys->pci_id)) {
    -        radeon_setup_winsys(drmFB, rwinsys);
    -        return r300_create_screen(rwinsys);
    -    } else {
    -        FREE(rwinsys);
    -        return NULL;
    +    if (is_r3xx(rws->pci_id)) {
    +        ret = radeon_setup_winsys(drmFB, rws);
    +	if (ret == FALSE)
    +	    goto fail;
    +        return r300_create_screen(&rws->base);
         }
    +
    +fail:
    +    FREE(rws);
    +    return NULL;
     }
     
     static void radeon_drm_api_destroy(struct drm_api *api)
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
    index 78451b6f01..2dc077c052 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h
    @@ -37,6 +37,22 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
                                              int drmFB,
     					 struct drm_create_screen_arg *arg);
     
    +boolean radeon_buffer_from_texture(struct drm_api* api,
    +                                   struct pipe_screen* screen,
    +                                   struct pipe_texture* texture,
    +                                   struct pipe_buffer** buffer,
    +                                   unsigned* stride);
    +
    +boolean radeon_handle_from_buffer(struct drm_api* api,
    +                                  struct pipe_screen* screen,
    +                                  struct pipe_buffer* buffer,
    +                                  unsigned* handle);
    +
    +boolean radeon_global_handle_from_buffer(struct drm_api* api,
    +                                         struct pipe_screen* screen,
    +                                         struct pipe_buffer* buffer,
    +                                         unsigned* handle);
    +
     void radeon_destroy_drm_api(struct drm_api* api);
     
     /* Guess at whether this chipset should use r300g.
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
    new file mode 100644
    index 0000000000..cc56a2bb8f
    --- /dev/null
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
    @@ -0,0 +1,368 @@
    +
    +#include 
    +#include "radeon_drm.h"
    +#include "radeon_bo_gem.h"
    +#include "radeon_cs_gem.h"
    +#include "radeon_buffer.h"
    +
    +#include "util/u_inlines.h"
    +#include "util/u_memory.h"
    +#include "util/u_simple_list.h"
    +#include "pipebuffer/pb_buffer.h"
    +#include "pipebuffer/pb_bufmgr.h"
    +
    +#include "radeon_winsys.h"
    +struct radeon_drm_bufmgr;
    +
    +struct radeon_drm_buffer {
    +    struct pb_buffer base;
    +    struct radeon_drm_bufmgr *mgr;
    +
    +    struct radeon_bo *bo;
    +
    +    boolean flinked;
    +    uint32_t flink;
    +
    +    boolean mapped;
    +    struct radeon_drm_buffer *next, *prev;
    +};
    +
    +extern const struct pb_vtbl radeon_drm_buffer_vtbl;
    +
    +
    +static INLINE struct radeon_drm_buffer *
    +radeon_drm_buffer(struct pb_buffer *buf)
    +{
    +    assert(buf);
    +    assert(buf->vtbl == &radeon_drm_buffer_vtbl);
    +    return (struct radeon_drm_buffer *)buf;
    +}
    +
    +struct radeon_drm_bufmgr {
    +    struct pb_manager base;
    +    struct radeon_libdrm_winsys *rws;
    +    struct radeon_drm_buffer buffer_map_list;
    +};
    +
    +static INLINE struct radeon_drm_bufmgr *
    +radeon_drm_bufmgr(struct pb_manager *mgr)
    +{
    +    assert(mgr);
    +    return (struct radeon_drm_bufmgr *)mgr;
    +}
    +
    +static void
    +radeon_drm_buffer_destroy(struct pb_buffer *_buf)
    +{
    +    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
    +
    +    if (buf->mapped) {
    +	remove_from_list(buf);
    +	radeon_bo_unmap(buf->bo);
    +	buf->mapped = false;
    +    }
    +    radeon_bo_unref(buf->bo);
    +
    +    FREE(buf);
    +}
    +
    +static void *
    +radeon_drm_buffer_map(struct pb_buffer *_buf,
    +		      unsigned flags)
    +{
    +    struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
    +    int write;
    +
    +    if (buf->mapped)
    +	return buf->bo->ptr;
    +    
    +    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
    +        uint32_t domain;
    +
    +        if (radeon_bo_is_busy(buf->bo, &domain))
    +            return NULL;
    +    }
    +
    +
    +    if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
    +        buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
    +    }
    +
    +    if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
    +        write = 1;
    +    }
    +
    +    if (radeon_bo_map(buf->bo, write)) {
    +        return NULL;
    +    }
    +    buf->mapped = true;
    +    insert_at_tail(&buf->mgr->buffer_map_list, buf);
    +    return buf->bo->ptr;
    +}
    +
    +static void
    +radeon_drm_buffer_unmap(struct pb_buffer *_buf)
    +{
    +    (void)_buf;
    +}
    +
    +static void
    +radeon_drm_buffer_get_base_buffer(struct pb_buffer *buf,
    +				  struct pb_buffer **base_buf,
    +				  unsigned *offset)
    +{
    +    *base_buf = buf;
    +    *offset = 0;
    +}
    +
    +
    +static enum pipe_error
    +radeon_drm_buffer_validate(struct pb_buffer *_buf, 
    +			   struct pb_validate *vl,
    +			   unsigned flags)
    +{
    +   /* Always pinned */
    +   return PIPE_OK;
    +}
    +
    +static void
    +radeon_drm_buffer_fence(struct pb_buffer *buf,
    +			struct pipe_fence_handle *fence)
    +{
    +}
    +
    +const struct pb_vtbl radeon_drm_buffer_vtbl = {
    +    radeon_drm_buffer_destroy,
    +    radeon_drm_buffer_map,
    +    radeon_drm_buffer_unmap,
    +    radeon_drm_buffer_validate,
    +    radeon_drm_buffer_fence,
    +    radeon_drm_buffer_get_base_buffer,
    +};
    +
    +
    +static uint32_t radeon_domain_from_usage(unsigned usage)
    +{
    +    uint32_t domain = 0;
    +
    +    if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
    +        domain |= RADEON_GEM_DOMAIN_VRAM;
    +    }
    +    if (usage & PIPE_BUFFER_USAGE_PIXEL) {
    +        domain |= RADEON_GEM_DOMAIN_VRAM;
    +    }
    +    if (usage & PIPE_BUFFER_USAGE_VERTEX) {
    +        domain |= RADEON_GEM_DOMAIN_GTT;
    +    }
    +    if (usage & PIPE_BUFFER_USAGE_INDEX) {
    +        domain |= RADEON_GEM_DOMAIN_GTT;
    +    }
    +
    +    return domain;
    +}
    +
    +struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager *_mgr,
    +							      uint32_t handle)
    +{
    +    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
    +    struct radeon_libdrm_winsys *rws = mgr->rws;
    +    struct radeon_drm_buffer *buf;
    +    struct radeon_bo *bo;
    +
    +    bo = radeon_bo_open(rws->bom, handle, 0,
    +			0, 0, 0);
    +    if (bo == NULL)
    +	return NULL;
    +
    +    buf = CALLOC_STRUCT(radeon_drm_buffer);
    +    if (!buf) {
    +	radeon_bo_unref(bo);
    +	return NULL;
    +    }
    +
    +    make_empty_list(buf);
    +
    +    pipe_reference_init(&buf->base.base.reference, 1);
    +    buf->base.base.alignment = 0;
    +    buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL;
    +    buf->base.base.size = 0;
    +    buf->base.vtbl = &radeon_drm_buffer_vtbl;
    +    buf->mgr = mgr;
    +
    +    buf->bo = bo;
    +
    +    return &buf->base;
    +}
    +
    +static struct pb_buffer *
    +radeon_drm_bufmgr_create_buffer(struct pb_manager *_mgr,
    +				pb_size size,
    +				const struct pb_desc *desc)
    +{
    +    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
    +    struct radeon_libdrm_winsys *rws = mgr->rws;
    +    struct radeon_drm_buffer *buf;
    +    uint32_t domain;
    +
    +    buf = CALLOC_STRUCT(radeon_drm_buffer);
    +    if (!buf)
    +	goto error1;
    +
    +    pipe_reference_init(&buf->base.base.reference, 1);
    +    buf->base.base.alignment = desc->alignment;
    +    buf->base.base.usage = desc->usage;
    +    buf->base.base.size = size;
    +    buf->base.vtbl = &radeon_drm_buffer_vtbl;
    +    buf->mgr = mgr;
    +
    +    make_empty_list(buf);
    +    domain = radeon_domain_from_usage(desc->usage);
    +    buf->bo = radeon_bo_open(rws->bom, 0, size,
    +			     desc->alignment, domain, 0);
    +    if (buf->bo == NULL)
    +	goto error2;
    +
    +    return &buf->base;
    +
    + error2:
    +    FREE(buf);
    + error1:
    +    return NULL; 
    +}
    +
    +static void
    +radeon_drm_bufmgr_flush(struct pb_manager *mgr)
    +{
    +    /* NOP */
    +}
    +
    +static void
    +radeon_drm_bufmgr_destroy(struct pb_manager *_mgr)
    +{
    +    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
    +    FREE(mgr);
    +}
    +
    +struct pb_manager *
    +radeon_drm_bufmgr_create(struct radeon_libdrm_winsys *rws)
    +{
    +    struct radeon_drm_bufmgr *mgr;
    +
    +    mgr = CALLOC_STRUCT(radeon_drm_bufmgr);
    +    if (!mgr)
    +	return NULL;
    +
    +    mgr->base.destroy = radeon_drm_bufmgr_destroy;
    +    mgr->base.create_buffer = radeon_drm_bufmgr_create_buffer;
    +    mgr->base.flush = radeon_drm_bufmgr_flush;
    +
    +    mgr->rws = rws;
    +    make_empty_list(&mgr->buffer_map_list);
    +    return &mgr->base;
    +}
    +
    +static struct radeon_drm_buffer *get_drm_buffer(struct pb_buffer *_buf)
    +{
    +    struct radeon_drm_buffer *buf;
    +    if (_buf->vtbl == &radeon_drm_buffer_vtbl) {
    +        buf = radeon_drm_buffer(_buf);
    +    } else {
    +	struct pb_buffer *base_buf;
    +	pb_size offset;
    +	pb_get_base_buffer(_buf, &base_buf, &offset);
    +
    +	buf = radeon_drm_buffer(base_buf);
    +    }
    +    return buf;
    +}
    +
    +boolean radeon_drm_bufmgr_get_handle(struct pb_buffer *_buf,
    +				     struct winsys_handle *whandle)
    +{
    +    int retval, fd;
    +    struct drm_gem_flink flink;
    +    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
    +    if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
    +	if (!buf->flinked) {
    +	    fd = buf->mgr->rws->fd;
    +	    flink.handle = buf->bo->handle;
    +
    +	    retval = ioctl(fd, DRM_IOCTL_GEM_FLINK, &flink);
    +	    if (retval) {
    +		return false;
    +	    }
    +
    +	    buf->flinked = TRUE;
    +	    buf->flink = flink.name;
    +	}
    +	whandle->handle = buf->flink;
    +    } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
    +	whandle->handle = buf->bo->handle;
    +    }
    +    return TRUE;
    +}
    +					   
    +
    +void radeon_drm_bufmgr_set_tiling(struct pb_buffer *_buf, boolean microtiled, boolean macrotiled, uint32_t pitch)
    +{
    +    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
    +    uint32_t flags = 0;
    +
    +    if (microtiled)
    +	flags |= RADEON_BO_FLAGS_MICRO_TILE;
    +    if (macrotiled)
    +	flags |= RADEON_BO_FLAGS_MACRO_TILE;
    +
    +    radeon_bo_set_tiling(buf->bo, flags, pitch);
    +
    +}
    +
    +boolean radeon_drm_bufmgr_add_buffer(struct pb_buffer *_buf,
    +				     uint32_t rd, uint32_t wd)
    +{
    +    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
    +    radeon_cs_space_add_persistent_bo(buf->mgr->rws->cs, buf->bo,
    +					  rd, wd);
    +    return true;
    +}
    +
    +void radeon_drm_bufmgr_write_reloc(struct pb_buffer *_buf,
    +				   uint32_t rd, uint32_t wd,
    +				   uint32_t flags)
    +{
    +    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
    +    int retval;
    +
    +    retval = radeon_cs_write_reloc(buf->mgr->rws->cs,
    +				   buf->bo, rd, wd, flags);
    +    if (retval) {
    +        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
    +		     buf, rd, wd, flags);
    +    }
    +}
    +
    +boolean radeon_drm_bufmgr_is_buffer_referenced(struct pb_buffer *_buf)
    +{
    +    struct radeon_drm_buffer *buf = get_drm_buffer(_buf);
    +    uint32_t domain;
    +
    +    return (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs) ||
    +	    radeon_bo_is_busy(buf->bo, &domain));
    +}
    +					    
    +
    +void radeon_drm_bufmgr_flush_maps(struct pb_manager *_mgr)
    +{
    +    struct radeon_drm_bufmgr *mgr = radeon_drm_bufmgr(_mgr);
    +    struct radeon_drm_buffer *rpb, *t_rpb;
    +
    +    foreach_s(rpb, t_rpb, &mgr->buffer_map_list) {
    +	rpb->mapped = 0;
    +	radeon_bo_unmap(rpb->bo);
    +	remove_from_list(rpb);
    +    }
    +
    +    make_empty_list(&mgr->buffer_map_list);
    +
    +    
    +}
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
    index 122bd21354..5b82a776a8 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c
    @@ -23,31 +23,139 @@
     #include "radeon_r300.h"
     #include "radeon_buffer.h"
     
    +#include "radeon_bo_gem.h"
     #include "radeon_cs_gem.h"
    +#include "state_tracker/drm_api.h"
     
    -static void radeon_set_flush_cb(struct radeon_winsys *winsys,
    +static struct r300_winsys_buffer *
    +radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
    +				 unsigned alignment,
    +				 unsigned usage,
    +				 unsigned size)
    +{
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    struct pb_desc desc;
    +    struct pb_manager *provider;
    +    struct pb_buffer *buffer;
    +
    +    memset(&desc, 0, sizeof(desc));
    +    desc.alignment = alignment;
    +    desc.usage = usage;
    +
    +    if (usage & PIPE_BUFFER_USAGE_CONSTANT)
    +        provider = ws->mman;
    +    else
    +        provider = ws->kman;
    +    buffer = provider->create_buffer(provider, size, &desc);
    +    if (!buffer)
    +	return NULL;
    +
    +    return radeon_libdrm_winsys_buffer(buffer);
    +}
    +
    +static void radeon_r300_winsys_buffer_destroy(struct r300_winsys_buffer *buf)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +
    +    pb_destroy(_buf);
    +}
    +static void radeon_r300_winsys_buffer_set_tiling(struct r300_winsys_screen *rws,
    +						  struct r300_winsys_buffer *buf,
    +						  uint32_t pitch,
    +						  boolean microtiled,
    +						  boolean macrotiled)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +    radeon_drm_bufmgr_set_tiling(_buf, microtiled, macrotiled, pitch);
    +}
    +
    +static void *radeon_r300_winsys_buffer_map(struct r300_winsys_screen *ws,
    +					   struct r300_winsys_buffer *buf,
    +					   unsigned usage)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +    
    +    return pb_map(_buf, usage);
    +}
    +
    +static void radeon_r300_winsys_buffer_unmap(struct r300_winsys_screen *ws,
    +					    struct r300_winsys_buffer *buf)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +
    +    pb_unmap(_buf);
    +}
    +
    +static void radeon_r300_winsys_buffer_reference(struct r300_winsys_screen *rws,
    +						struct r300_winsys_buffer **pdst,
    +						struct r300_winsys_buffer *src)
    +{
    +    struct pb_buffer *_src = radeon_pb_buffer(src);
    +    struct pb_buffer *_dst = radeon_pb_buffer(*pdst);
    +
    +    pb_reference(&_dst, _src);
    +
    +    *pdst = radeon_libdrm_winsys_buffer(_dst);
    +}
    +
    +static boolean radeon_r300_winsys_is_buffer_referenced(struct r300_winsys_screen *rws,
    +						       struct r300_winsys_buffer *buf)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +
    +    return radeon_drm_bufmgr_is_buffer_referenced(_buf);
    +}
    +
    +static struct r300_winsys_buffer *radeon_r300_winsys_buffer_from_handle(struct r300_winsys_screen *rws,
    +									struct pipe_screen *screen,
    +									struct winsys_handle *whandle,
    +									unsigned *stride)
    +{
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    struct pb_buffer *_buf;
    +
    +    _buf = radeon_drm_bufmgr_create_buffer_from_handle(ws->kman, whandle->handle);
    +    *stride = whandle->stride;
    +    return radeon_libdrm_winsys_buffer(_buf);
    +}
    +
    +static boolean radeon_r300_winsys_buffer_get_handle(struct r300_winsys_screen *rws,
    +						    struct r300_winsys_buffer *buffer,
    +						    unsigned stride,
    +						    struct winsys_handle *whandle)
    +{
    +    struct pb_buffer *_buf = radeon_pb_buffer(buffer);
    +    boolean ret;
    +    ret = radeon_drm_bufmgr_get_handle(_buf, whandle);
    +    if (ret)
    +	whandle->stride = stride;
    +    return ret;
    +}
    +
    +static void radeon_set_flush_cb(struct r300_winsys_screen *rws,
                                     void (*flush_cb)(void *),
                                     void *data)
     {
    -    winsys->priv->flush_cb = flush_cb;
    -    winsys->priv->flush_data = data;
    -    radeon_cs_space_set_flush(winsys->priv->cs, flush_cb, data);
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    ws->flush_cb = flush_cb;
    +    ws->flush_data = data;
    +    radeon_cs_space_set_flush(ws->cs, flush_cb, data);
     }
     
    -static boolean radeon_add_buffer(struct radeon_winsys* winsys,
    -                                 struct pipe_buffer* pbuffer,
    +static boolean radeon_add_buffer(struct r300_winsys_screen *rws,
    +                                 struct r300_winsys_buffer *buf,
                                      uint32_t rd,
                                      uint32_t wd)
     {
    -    struct radeon_bo* bo = ((struct radeon_pipe_buffer*)pbuffer)->bo;
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
     
    -    radeon_cs_space_add_persistent_bo(winsys->priv->cs, bo, rd, wd);
    -    return TRUE;
    +    return radeon_drm_bufmgr_add_buffer(_buf, rd, wd);
     }
     
    -static boolean radeon_validate(struct radeon_winsys* winsys)
    +static boolean radeon_validate(struct r300_winsys_screen *rws)
     {
    -    if (radeon_cs_space_check(winsys->priv->cs) < 0) {
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    if (radeon_cs_space_check(ws->cs) < 0) {
             return FALSE;
         }
     
    @@ -55,108 +163,175 @@ static boolean radeon_validate(struct radeon_winsys* winsys)
         return TRUE;
     }
     
    -static boolean radeon_check_cs(struct radeon_winsys* winsys, int size)
    +static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size)
     {
    -    struct radeon_cs* cs = winsys->priv->cs;
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    struct radeon_cs *cs = ws->cs;
     
    -    return radeon_validate(winsys) && cs->cdw + size <= cs->ndw;
    +    return radeon_validate(rws) && cs->cdw + size <= cs->ndw;
     }
     
    -static void radeon_begin_cs(struct radeon_winsys* winsys,
    +static void radeon_begin_cs(struct r300_winsys_screen *rws,
                                 int size,
                                 const char* file,
                                 const char* function,
                                 int line)
     {
    -    radeon_cs_begin(winsys->priv->cs, size, file, function, line);
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    radeon_cs_begin(ws->cs, size, file, function, line);
     }
     
    -static void radeon_write_cs_dword(struct radeon_winsys* winsys,
    +static void radeon_write_cs_dword(struct r300_winsys_screen *rws,
                                       uint32_t dword)
     {
    -    radeon_cs_write_dword(winsys->priv->cs, dword);
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    radeon_cs_write_dword(ws->cs, dword);
     }
     
    -static void radeon_write_cs_reloc(struct radeon_winsys* winsys,
    -                                  struct pipe_buffer* pbuffer,
    +static void radeon_write_cs_reloc(struct r300_winsys_screen *rws,
    +                                  struct r300_winsys_buffer *buf,
                                       uint32_t rd,
                                       uint32_t wd,
                                       uint32_t flags)
     {
    -    int retval = 0;
    -    struct radeon_pipe_buffer* radeon_buffer =
    -        (struct radeon_pipe_buffer*)pbuffer;
    -
    -    assert(!radeon_buffer->pb);
    -
    -    retval = radeon_cs_write_reloc(winsys->priv->cs, radeon_buffer->bo,
    -                                   rd, wd, flags);
    -
    -    if (retval) {
    -        debug_printf("radeon: Relocation of %p (%d, %d, %d) failed!\n",
    -                pbuffer, rd, wd, flags);
    -    }
    +    struct pb_buffer *_buf = radeon_pb_buffer(buf);
    +    radeon_drm_bufmgr_write_reloc(_buf, rd, wd, flags);
     }
     
    -static void radeon_reset_bos(struct radeon_winsys *winsys)
    +static void radeon_reset_bos(struct r300_winsys_screen *rws)
     {
    -    radeon_cs_space_reset_bos(winsys->priv->cs);
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    radeon_cs_space_reset_bos(ws->cs);
     }
     
    -static void radeon_end_cs(struct radeon_winsys* winsys,
    +static void radeon_end_cs(struct r300_winsys_screen *rws,
                               const char* file,
                               const char* function,
                               int line)
     {
    -    radeon_cs_end(winsys->priv->cs, file, function, line);
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
    +    radeon_cs_end(ws->cs, file, function, line);
     }
     
    -static void radeon_flush_cs(struct radeon_winsys* winsys)
    +static void radeon_flush_cs(struct r300_winsys_screen *rws)
     {
    +    struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
         int retval;
     
         /* Don't flush a zero-sized CS. */
    -    if (!winsys->priv->cs->cdw) {
    +    if (!ws->cs->cdw) {
             return;
         }
     
    +    radeon_drm_bufmgr_flush_maps(ws->kman);
         /* Emit the CS. */
    -    retval = radeon_cs_emit(winsys->priv->cs);
    +    retval = radeon_cs_emit(ws->cs);
         if (retval) {
             debug_printf("radeon: Bad CS, dumping...\n");
    -        radeon_cs_print(winsys->priv->cs, stderr);
    +        radeon_cs_print(ws->cs, stderr);
         }
     
         /* Reset CS.
          * Someday, when we care about performance, we should really find a way
          * to rotate between two or three CS objects so that the GPU can be
          * spinning through one CS while another one is being filled. */
    -    radeon_cs_erase(winsys->priv->cs);
    +    radeon_cs_erase(ws->cs);
     }
     
    -void
    -radeon_setup_winsys(int fd, struct radeon_winsys* winsys)
    +static uint32_t radeon_get_value(struct r300_winsys_screen *rws,
    +			     enum r300_value_id id)
     {
    -    struct radeon_winsys_priv* priv = winsys->priv;
    +    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
     
    -    priv->csm = radeon_cs_manager_gem_ctor(fd);
    +    switch(id) {
    +    case R300_VID_PCI_ID:
    +	return ws->pci_id;
    +    case R300_VID_GB_PIPES:
    +	return ws->gb_pipes;
    +    case R300_VID_Z_PIPES:
    +	return ws->z_pipes;
    +    }
    +    return 0;
    +}
    +
    +static void
    +radeon_winsys_destroy(struct r300_winsys_screen *rws)
    +{
    +    struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
    +    radeon_cs_destroy(ws->cs);
    +
    +    ws->kman->destroy(ws->kman);
    +    ws->mman->destroy(ws->mman);
    +
    +    radeon_bo_manager_gem_dtor(ws->bom);
    +    radeon_cs_manager_gem_dtor(ws->csm);
    +}
    +
    +boolean
    +radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
    +{
    +    
    +    ws->csm = radeon_cs_manager_gem_ctor(fd);
    +    if (!ws->csm)
    +	goto fail;
    +    ws->bom = radeon_bo_manager_gem_ctor(fd);
    +    if (!ws->bom)
    +	goto fail;
    +    ws->kman = radeon_drm_bufmgr_create(ws);
    +    if (!ws->kman)
    +	goto fail;
    +
    +    ws->mman = pb_malloc_bufmgr_create();
    +    if (!ws->mman)
    +	goto fail;
     
         /* Size limit on IBs is 64 kibibytes. */
    -    priv->cs = radeon_cs_create(priv->csm, 1024 * 64 / 4);
    -    radeon_cs_set_limit(priv->cs,
    -            RADEON_GEM_DOMAIN_GTT, winsys->gart_size);
    -    radeon_cs_set_limit(priv->cs,
    -            RADEON_GEM_DOMAIN_VRAM, winsys->vram_size);
    -
    -    winsys->add_buffer = radeon_add_buffer;
    -    winsys->validate = radeon_validate;
    -
    -    winsys->check_cs = radeon_check_cs;
    -    winsys->begin_cs = radeon_begin_cs;
    -    winsys->write_cs_dword = radeon_write_cs_dword;
    -    winsys->write_cs_reloc = radeon_write_cs_reloc;
    -    winsys->end_cs = radeon_end_cs;
    -    winsys->flush_cs = radeon_flush_cs;
    -    winsys->reset_bos = radeon_reset_bos;
    -    winsys->set_flush_cb = radeon_set_flush_cb;
    +    ws->cs = radeon_cs_create(ws->csm, 1024 * 64 / 4);
    +    if (!ws->cs)
    +	goto fail;
    +    radeon_cs_set_limit(ws->cs,
    +            RADEON_GEM_DOMAIN_GTT, ws->gart_size);
    +    radeon_cs_set_limit(ws->cs,
    +            RADEON_GEM_DOMAIN_VRAM, ws->vram_size);
    +
    +    ws->base.add_buffer = radeon_add_buffer;
    +    ws->base.validate = radeon_validate;
    +    ws->base.destroy = radeon_winsys_destroy;
    +    ws->base.check_cs = radeon_check_cs;
    +    ws->base.begin_cs = radeon_begin_cs;
    +    ws->base.write_cs_dword = radeon_write_cs_dword;
    +    ws->base.write_cs_reloc = radeon_write_cs_reloc;
    +    ws->base.end_cs = radeon_end_cs;
    +    ws->base.flush_cs = radeon_flush_cs;
    +    ws->base.reset_bos = radeon_reset_bos;
    +    ws->base.set_flush_cb = radeon_set_flush_cb;
    +    ws->base.get_value = radeon_get_value;
    +
    +    ws->base.buffer_create = radeon_r300_winsys_buffer_create;
    +    ws->base.buffer_destroy = radeon_r300_winsys_buffer_destroy;
    +    ws->base.buffer_set_tiling = radeon_r300_winsys_buffer_set_tiling;
    +    ws->base.buffer_map = radeon_r300_winsys_buffer_map;
    +    ws->base.buffer_unmap = radeon_r300_winsys_buffer_unmap;
    +    ws->base.buffer_reference = radeon_r300_winsys_buffer_reference;
    +    ws->base.buffer_from_handle = radeon_r300_winsys_buffer_from_handle;
    +    ws->base.buffer_get_handle = radeon_r300_winsys_buffer_get_handle;
    +    ws->base.is_buffer_referenced = radeon_r300_winsys_is_buffer_referenced;
    +    return TRUE;
    +
    +fail:
    +    if (ws->csm)
    +	radeon_cs_manager_gem_dtor(ws->csm);
    +
    +    if (ws->bom)
    +	radeon_bo_manager_gem_dtor(ws->bom);
    +
    +
    +    if (ws->kman)
    +	ws->kman->destroy(ws->kman);
    +    if (ws->mman)
    +	ws->mman->destroy(ws->mman);
    +
    +    if (ws->cs)
    +	radeon_cs_destroy(ws->cs);
    +    return FALSE;
     }
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.h b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
    index e655dc32c8..2703464ad8 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.h
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.h
    @@ -25,6 +25,6 @@
     
     #include "radeon_winsys.h"
     
    -void radeon_setup_winsys(int fd, struct radeon_winsys* winsys);
    +boolean radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* winsys);
     
     #endif /* RADEON_R300_H */
    diff --git a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    index 887a381cc4..16cc701ad6 100644
    --- a/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    +++ b/src/gallium/winsys/drm/radeon/core/radeon_winsys.h
    @@ -30,16 +30,15 @@
     #ifndef RADEON_WINSYS_H
     #define RADEON_WINSYS_H
     
    -#include "util/u_simple_screen.h"
    +#include "r300_winsys.h"
     
    -struct radeon_winsys_priv;
    -
    -struct radeon_winsys {
    +struct radeon_libdrm_winsys {
         /* Parent class. */
    -    struct pipe_winsys base;
    +    struct r300_winsys_screen base;
    +
    +    struct pb_manager *kman;
     
    -    /* Winsys private */
    -    struct radeon_winsys_priv* priv;
    +    struct pb_manager *mman;
     
         /* PCI ID */
         uint32_t pci_id;
    @@ -56,71 +55,27 @@ struct radeon_winsys {
         /* VRAM size. */
         uint32_t vram_size;
     
    -    /* Create a buffer from a winsys handle. */
    -    struct pipe_buffer *(*buffer_from_handle)(struct radeon_winsys *winsys,
    -                                              struct pipe_screen *screen,
    -                                              struct winsys_handle *whandle,
    -                                              unsigned *stride);
    -
    -    /* Get the handle from a buffer. */
    -    boolean (*buffer_get_handle)(struct radeon_winsys *winsys,
    -                                 struct pipe_buffer *buffer,
    -                                 unsigned stride,
    -                                 struct winsys_handle *whandle);
    -
    -    /* Add a pipe_buffer to the list of buffer objects to validate. */
    -    boolean (*add_buffer)(struct radeon_winsys* winsys,
    -                          struct pipe_buffer* pbuffer,
    -                          uint32_t rd,
    -                          uint32_t wd);
    -
    -    /* Revalidate all currently setup pipe_buffers.
    -     * Returns TRUE if a flush is required. */
    -    boolean (*validate)(struct radeon_winsys* winsys);
    -
    -    /* Check to see if there's room for commands. */
    -    boolean (*check_cs)(struct radeon_winsys* winsys, int size);
    -
    -    /* Start a command emit. */
    -    void (*begin_cs)(struct radeon_winsys* winsys,
    -                     int size,
    -                     const char* file,
    -                     const char* function,
    -                     int line);
    -
    -    /* Write a dword to the command buffer. */
    -    void (*write_cs_dword)(struct radeon_winsys* winsys, uint32_t dword);
    -
    -    /* Write a relocated dword to the command buffer. */
    -    void (*write_cs_reloc)(struct radeon_winsys* winsys,
    -                           struct pipe_buffer* bo,
    -                           uint32_t rd,
    -                           uint32_t wd,
    -                           uint32_t flags);
    -
    -    /* Finish a command emit. */
    -    void (*end_cs)(struct radeon_winsys* winsys,
    -                   const char* file,
    -                   const char* function,
    -                   int line);
    -
    -    /* Flush the CS. */
    -    void (*flush_cs)(struct radeon_winsys* winsys);
    -
    -    /* winsys flush - callback from winsys when flush required */
    -    void (*set_flush_cb)(struct radeon_winsys *winsys,
    -			 void (*flush_cb)(void *), void *data);
    -
    -    void (*reset_bos)(struct radeon_winsys *winsys);
    -
    -    void (*buffer_set_tiling)(struct radeon_winsys* winsys,
    -                              struct pipe_buffer* buffer,
    -                              uint32_t pitch,
    -                              boolean microtiled,
    -                              boolean macrotiled);
    -
    -    boolean (*is_buffer_referenced)(struct radeon_winsys *winsys,
    -                                    struct pipe_buffer *buffer);
    +    /* DRM FD */
    +    int fd;
    +
    +    /* Radeon BO manager. */
    +    struct radeon_bo_manager *bom;
    +
    +    /* Radeon CS manager. */
    +    struct radeon_cs_manager *csm;
    +
    +    /* Current CS. */
    +    struct radeon_cs *cs;
    +
    +    /* Flush CB */
    +    void (*flush_cb)(void *);
    +    void *flush_data;
     };
     
    +static INLINE struct radeon_libdrm_winsys *
    +radeon_winsys_screen(struct r300_winsys_screen *base)
    +{
    +  return (struct radeon_libdrm_winsys *)base;
    +}
    +
     #endif
    -- 
    cgit v1.2.3
    
    
    From 50d96f741e59678a19dd3308d532add1350ad441 Mon Sep 17 00:00:00 2001
    From: Luca Barbieri 
    Date: Mon, 15 Mar 2010 14:35:41 +0100
    Subject: nv40: remove leftover nv40_transfer.c from unification into nvfx
    
    ---
     src/gallium/drivers/nv40/nv40_transfer.c | 181 -------------------------------
     1 file changed, 181 deletions(-)
     delete mode 100644 src/gallium/drivers/nv40/nv40_transfer.c
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
    deleted file mode 100644
    index 3d8c8e8c78..0000000000
    --- a/src/gallium/drivers/nv40/nv40_transfer.c
    +++ /dev/null
    @@ -1,181 +0,0 @@
    -#include "pipe/p_state.h"
    -#include "pipe/p_defines.h"
    -#include "util/u_inlines.h"
    -#include "util/u_format.h"
    -#include "util/u_memory.h"
    -#include "util/u_math.h"
    -#include "nouveau/nouveau_winsys.h"
    -#include "nv40_context.h"
    -#include "nvfx_screen.h"
    -#include "nvfx_state.h"
    -
    -struct nv40_transfer {
    -	struct pipe_transfer base;
    -	struct pipe_surface *surface;
    -	boolean direct;
    -};
    -
    -static void
    -nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
    -                             struct pipe_texture *template)
    -{
    -	memset(template, 0, sizeof(struct pipe_texture));
    -	template->target = pt->target;
    -	template->format = pt->format;
    -	template->width0 = width;
    -	template->height0 = height;
    -	template->depth0 = 1;
    -	template->last_level = 0;
    -	template->nr_samples = pt->nr_samples;
    -
    -	template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
    -	                      NOUVEAU_TEXTURE_USAGE_LINEAR;
    -}
    -
    -static struct pipe_transfer *
    -nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
    -		  unsigned face, unsigned level, unsigned zslice,
    -		  enum pipe_transfer_usage usage,
    -		  unsigned x, unsigned y, unsigned w, unsigned h)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
    -	struct nv40_transfer *tx;
    -	struct pipe_texture tx_tex_template, *tx_tex;
    -
    -	tx = CALLOC_STRUCT(nv40_transfer);
    -	if (!tx)
    -		return NULL;
    -
    -	pipe_texture_reference(&tx->base.texture, pt);
    -	tx->base.x = x;
    -	tx->base.y = y;
    -	tx->base.width = w;
    -	tx->base.height = h;
    -	tx->base.stride = mt->level[level].pitch;
    -	tx->base.usage = usage;
    -	tx->base.face = face;
    -	tx->base.level = level;
    -	tx->base.zslice = zslice;
    -
    -	/* Direct access to texture */
    -	if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC ||
    -	     debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/)) &&
    -	    pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
    -	{
    -		tx->direct = true;
    -		tx->surface = pscreen->get_tex_surface(pscreen, pt,
    -	                                               face, level, zslice,
    -	                                               pipe_transfer_buffer_flags(&tx->base));
    -		return &tx->base;
    -	}
    -
    -	tx->direct = false;
    -
    -	nv40_compatible_transfer_tex(pt, w, h, &tx_tex_template);
    -
    -	tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
    -	if (!tx_tex)
    -	{
    -		FREE(tx);
    -		return NULL;
    -	}
    -
    -	tx->base.stride = ((struct nvfx_miptree*)tx_tex)->level[0].pitch;
    -
    -	tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
    -	                                       0, 0, 0,
    -	                                       pipe_transfer_buffer_flags(&tx->base));
    -
    -	pipe_texture_reference(&tx_tex, NULL);
    -
    -	if (!tx->surface)
    -	{
    -		pipe_surface_reference(&tx->surface, NULL);
    -		FREE(tx);
    -		return NULL;
    -	}
    -
    -	if (usage & PIPE_TRANSFER_READ) {
    -		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    -		struct pipe_surface *src;
    -
    -		src = pscreen->get_tex_surface(pscreen, pt,
    -	                                       face, level, zslice,
    -	                                       PIPE_BUFFER_USAGE_GPU_READ);
    -
    -		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    -		/* TODO: Check if SIFM can un-swizzle */
    -		nvscreen->eng2d->copy(nvscreen->eng2d,
    -		                      tx->surface, 0, 0,
    -		                      src, x, y,
    -		                      w, h);
    -
    -		pipe_surface_reference(&src, NULL);
    -	}
    -
    -	return &tx->base;
    -}
    -
    -static void
    -nv40_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    -{
    -	struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
    -
    -	if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
    -		struct pipe_screen *pscreen = pcontext->screen;
    -		struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
    -		struct pipe_surface *dst;
    -
    -		dst = pscreen->get_tex_surface(pscreen, ptx->texture,
    -	                                       ptx->face, ptx->level, ptx->zslice,
    -	                                       PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
    -
    -		/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
    -		nvscreen->eng2d->copy(nvscreen->eng2d,
    -		                      dst, tx->base.x, tx->base.y,
    -		                      tx->surface, 0, 0,
    -		                      tx->base.width, tx->base.height);
    -
    -		pipe_surface_reference(&dst, NULL);
    -	}
    -
    -	pipe_surface_reference(&tx->surface, NULL);
    -	pipe_texture_reference(&ptx->texture, NULL);
    -	FREE(ptx);
    -}
    -
    -static void *
    -nv40_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
    -	struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    -	void *map = pipe_buffer_map(pscreen, mt->buffer,
    -	                            pipe_transfer_buffer_flags(ptx));
    -
    -	if(!tx->direct)
    -		return map + ns->base.offset;
    -	else
    -		return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
    -}
    -
    -static void
    -nv40_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
    -{
    -        struct pipe_screen *pscreen = pcontext->screen;
    -	struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
    -	struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
    -
    -	pipe_buffer_unmap(pscreen, mt->buffer);
    -}
    -
    -void
    -nv40_init_transfer_functions(struct nvfx_context *nvfx)
    -{
    -	nvfx->pipe.get_tex_transfer = nv40_transfer_new;
    -	nvfx->pipe.tex_transfer_destroy = nv40_transfer_del;
    -	nvfx->pipe.transfer_map = nv40_transfer_map;
    -	nvfx->pipe.transfer_unmap = nv40_transfer_unmap;
    -}
    -- 
    cgit v1.2.3
    
    
    From f9d753787e6c566d3481cca07dee939239eb7071 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 10:29:04 -0600
    Subject: gallivm: fix incorrect floor(), itrunc()
    
    LLVMBuildFPTrunc() should be used for double->float conversion, not
    float->int conversion.
    
    There should be a better way to compute floor(), ceil(), etc that doesn't
    involve float->int->float conversion.
    ---
     src/gallium/auxiliary/gallivm/lp_bld_arit.c | 7 +++++--
     1 file changed, 5 insertions(+), 2 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    index aa47338b32..c39b062d10 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    @@ -930,7 +930,10 @@ lp_build_floor(struct lp_build_context *bld,
        assert(type.floating);
     
        if (type.length == 1) {
    -      return LLVMBuildFPTrunc(bld->builder, a, LLVMFloatType(), "");
    +      LLVMValueRef res;
    +      res = lp_build_ifloor(bld, a);
    +      res = LLVMBuildSIToFP(bld->builder, res, LLVMFloatType(), "");
    +      return res;
        }
     
        if(util_cpu_caps.has_sse4_1)
    @@ -993,7 +996,7 @@ lp_build_itrunc(struct lp_build_context *bld,
     
        if (type.length == 1) {
           LLVMTypeRef int_type = LLVMIntType(type.width);
    -      return LLVMBuildFPTrunc(bld->builder, a, int_type, "");
    +      return LLVMBuildFPToSI(bld->builder, a, int_type, "");
        }
        else {
           LLVMTypeRef int_vec_type = lp_build_int_vec_type(type);
    -- 
    cgit v1.2.3
    
    
    From e0f7c3cbf09c4425852d805a91991ca6ce8a0ad6 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 10:31:20 -0600
    Subject: gallivm: fix incorrect clamp in lp_build_linear_mip_levels()
    
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    index 72018737a8..19d78424bc 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    @@ -986,7 +986,7 @@ lp_build_linear_mip_levels(struct lp_build_sample_context *bld,
                                     last_level);
        /* compute level 1 and clamp to legal range of levels */
        *level1_out = lp_build_add(int_bld, *level0_out, int_bld->one);
    -   *level1_out = lp_build_min(int_bld, *level1_out, int_bld->zero);
    +   *level1_out = lp_build_min(int_bld, *level1_out, last_level);
     
        *weight_out = lp_build_fract(float_bld, lod);
     }
    -- 
    cgit v1.2.3
    
    
    From eecf9c85b071973cc54d8e8bb7e9982a1f5714a5 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 10:36:56 -0600
    Subject: gallivm: implement minification/magnification selection
    
    Use the LOD value to determine whether to use the minification vs.
    magnification filter.
    
    All mipmap sampling modes work now.
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 188 ++++++++++++++++------
     1 file changed, 137 insertions(+), 51 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    index 19d78424bc..ba62d7a013 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    @@ -1413,6 +1413,85 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
     
     
     
    +/**
    + * Sample the texture/mipmap using given image filter and mip filter.
    + * data0_ptr and data1_ptr point to the two mipmap levels to sample
    + * from.  width0/1_vec, height0/1_vec, depth0/1_vec indicate their sizes.
    + * If we're using nearest miplevel sampling the '1' values will be null/unused.
    + */
    +static void
    +lp_sample_mipmap(struct lp_build_sample_context *bld,
    +                 unsigned img_filter,
    +                 unsigned mip_filter,
    +                 LLVMValueRef s,
    +                 LLVMValueRef t,
    +                 LLVMValueRef r,
    +                 LLVMValueRef lod_fpart,
    +                 LLVMValueRef width0_vec,
    +                 LLVMValueRef width1_vec,
    +                 LLVMValueRef height0_vec,
    +                 LLVMValueRef height1_vec,
    +                 LLVMValueRef depth0_vec,
    +                 LLVMValueRef depth1_vec,
    +                 LLVMValueRef row_stride0_vec,
    +                 LLVMValueRef row_stride1_vec,
    +                 LLVMValueRef img_stride0_vec,
    +                 LLVMValueRef img_stride1_vec,
    +                 LLVMValueRef data_ptr0,
    +                 LLVMValueRef data_ptr1,
    +                 LLVMValueRef *colors_out)
    +{
    +   LLVMValueRef colors0[4], colors1[4];
    +   int chan;
    +
    +   if (img_filter == PIPE_TEX_FILTER_NEAREST) {
    +      lp_build_sample_image_nearest(bld,
    +                                    width0_vec, height0_vec, depth0_vec,
    +                                    row_stride0_vec, img_stride0_vec,
    +                                    data_ptr0, s, t, r, colors0);
    +
    +      if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    +         /* sample the second mipmap level, and interp */
    +         lp_build_sample_image_nearest(bld,
    +                                       width1_vec, height1_vec, depth1_vec,
    +                                       row_stride1_vec, img_stride1_vec,
    +                                       data_ptr1, s, t, r, colors1);
    +      }
    +   }
    +   else {
    +      assert(img_filter == PIPE_TEX_FILTER_LINEAR);
    +
    +      lp_build_sample_image_linear(bld,
    +                                   width0_vec, height0_vec, depth0_vec,
    +                                   row_stride0_vec, img_stride0_vec,
    +                                   data_ptr0, s, t, r, colors0);
    +
    +      if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    +         /* sample the second mipmap level, and interp */
    +         lp_build_sample_image_linear(bld,
    +                                      width1_vec, height1_vec, depth1_vec,
    +                                      row_stride1_vec, img_stride1_vec,
    +                                      data_ptr1, s, t, r, colors1);
    +      }
    +   }
    +
    +   if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    +      /* interpolate samples from the two mipmap levels */
    +      for (chan = 0; chan < 4; chan++) {
    +         colors_out[chan] = lp_build_lerp(&bld->texel_bld, lod_fpart,
    +                                          colors0[chan], colors1[chan]);
    +      }
    +   }
    +   else {
    +      /* use first/only level's colors */
    +      for (chan = 0; chan < 4; chan++) {
    +         colors_out[chan] = colors0[chan];
    +      }
    +   }
    +}
    +
    +
    +
     /**
      * General texture sampling codegen.
      * This function handles texture sampling for all texture targets (1D,
    @@ -1435,6 +1514,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
                             LLVMValueRef data_array,
                             LLVMValueRef *colors_out)
     {
    +   struct lp_build_context *float_bld = &bld->float_bld;
        const unsigned mip_filter = bld->static_state->min_mip_filter;
        const unsigned min_filter = bld->static_state->min_img_filter;
        const unsigned mag_filter = bld->static_state->mag_img_filter;
    @@ -1446,7 +1526,6 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        LLVMValueRef row_stride0_vec = NULL, row_stride1_vec = NULL;
        LLVMValueRef img_stride0_vec = NULL, img_stride1_vec = NULL;
        LLVMValueRef data_ptr0, data_ptr1;
    -   int chan;
     
        /*
        printf("%s mip %d  min %d  mag %d\n", __FUNCTION__,
    @@ -1459,6 +1538,10 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        if (mip_filter == PIPE_TEX_MIPFILTER_NONE) {
           /* always use mip level 0 */
           ilevel0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
    +
    +      /* XXX temporary here */
    +      lod = lp_build_lod_selector(bld, s, t, r, width, height, depth);
    +
        }
        else {
           /* compute float LOD */
    @@ -1538,62 +1621,65 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        /*
         * Get/interpolate texture colors.
         */
    -   /* XXX temporarily force this path: */
    -   if (1 /*min_filter == mag_filter*/) {
    -      /* same filter for minification or magnification */
    -      LLVMValueRef colors0[4], colors1[4];
    -
    -      if (min_filter == PIPE_TEX_FILTER_NEAREST) {
    -         lp_build_sample_image_nearest(bld,
    -                                       width0_vec, height0_vec, depth0_vec,
    -                                       row_stride0_vec, img_stride0_vec,
    -                                       data_ptr0, s, t, r, colors0);
    -
    -         if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    -            /* sample the second mipmap level, and interp */
    -            lp_build_sample_image_nearest(bld,
    -                                          width1_vec, height1_vec, depth1_vec,
    -                                          row_stride1_vec, img_stride1_vec,
    -                                          data_ptr1, s, t, r, colors1);
    -         }
    -      }
    -      else {
    -         assert(min_filter == PIPE_TEX_FILTER_LINEAR);
    +   if (min_filter == mag_filter) {
    +      /* no need to distinquish between minification and magnification */
    +      lp_sample_mipmap(bld, min_filter, mip_filter, s, t, r, lod_fpart,
    +                       width0_vec, width1_vec,
    +                       height0_vec, height1_vec,
    +                       depth0_vec, depth1_vec,
    +                       row_stride0_vec, row_stride1_vec,
    +                       img_stride0_vec, img_stride1_vec,
    +                       data_ptr0, data_ptr1,
    +                       colors_out);
    +   }
    +   else {
    +      /* Emit conditional to choose min image filter or mag image filter
    +       * depending on the lod being >0 or <= 0, respectively.
    +       */
    +      struct lp_build_flow_context *flow_ctx;
    +      struct lp_build_if_state if_ctx;
    +      LLVMValueRef minify;
     
    -         lp_build_sample_image_linear(bld,
    -                                      width0_vec, height0_vec, depth0_vec,
    -                                      row_stride0_vec, img_stride0_vec,
    -                                      data_ptr0, s, t, r, colors0);
    +      flow_ctx = lp_build_flow_create(bld->builder);
    +      lp_build_flow_scope_begin(flow_ctx);
     
    +      lp_build_flow_scope_declare(flow_ctx, &colors_out[0]);
    +      lp_build_flow_scope_declare(flow_ctx, &colors_out[1]);
    +      lp_build_flow_scope_declare(flow_ctx, &colors_out[2]);
    +      lp_build_flow_scope_declare(flow_ctx, &colors_out[3]);
     
    -         if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    -            /* sample the second mipmap level, and interp */
    -            lp_build_sample_image_linear(bld,
    -                                         width1_vec, height1_vec, depth1_vec,
    -                                         row_stride1_vec, img_stride1_vec,
    -                                         data_ptr1, s, t, r, colors1);
    -         }
    -      }
    +      /* minify = lod > 0.0 */
    +      minify = LLVMBuildFCmp(bld->builder, LLVMRealUGE,
    +                             lod, float_bld->zero, "");
     
    -      if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    -         /* interpolate samples from the two mipmap levels */
    -         for (chan = 0; chan < 4; chan++) {
    -            colors_out[chan] = lp_build_lerp(&bld->texel_bld, lod_fpart,
    -                                             colors0[chan], colors1[chan]);
    -         }
    +      lp_build_if(&if_ctx, flow_ctx, bld->builder, minify);
    +      {
    +         /* Use the minification filter */
    +         lp_sample_mipmap(bld, min_filter, mip_filter, s, t, r, lod_fpart,
    +                          width0_vec, width1_vec,
    +                          height0_vec, height1_vec,
    +                          depth0_vec, depth1_vec,
    +                          row_stride0_vec, row_stride1_vec,
    +                          img_stride0_vec, img_stride1_vec,
    +                          data_ptr0, data_ptr1,
    +                          colors_out);
           }
    -      else {
    -         /* use first/only level's colors */
    -         for (chan = 0; chan < 4; chan++) {
    -            colors_out[chan] = colors0[chan];
    -         }
    +      lp_build_else(&if_ctx);
    +      {
    +         /* Use the magnification filter */
    +         lp_sample_mipmap(bld, mag_filter, mip_filter, s, t, r, lod_fpart,
    +                          width0_vec, width1_vec,
    +                          height0_vec, height1_vec,
    +                          depth0_vec, depth1_vec,
    +                          row_stride0_vec, row_stride1_vec,
    +                          img_stride0_vec, img_stride1_vec,
    +                          data_ptr0, data_ptr1,
    +                          colors_out);
           }
    -   }
    -   else {
    -      /* emit conditional to choose min image filter or mag image filter
    -       * depending on the lod being >0 or <= 0, respectively.
    -       */
    -      abort();
    +      lp_build_endif(&if_ctx);
    +
    +      lp_build_flow_scope_end(flow_ctx);
    +      lp_build_flow_destroy(flow_ctx);
        }
     }
     
    -- 
    cgit v1.2.3
    
    
    From b9a81b626a4659d6d611516c8afea012d39b0e4a Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 10:43:05 -0600
    Subject: gallivm: asst clean-ups, comments, etc.
    
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 114 ++++++++++++----------
     1 file changed, 60 insertions(+), 54 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    index ba62d7a013..29845c65d0 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    @@ -1420,26 +1420,26 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld,
      * If we're using nearest miplevel sampling the '1' values will be null/unused.
      */
     static void
    -lp_sample_mipmap(struct lp_build_sample_context *bld,
    -                 unsigned img_filter,
    -                 unsigned mip_filter,
    -                 LLVMValueRef s,
    -                 LLVMValueRef t,
    -                 LLVMValueRef r,
    -                 LLVMValueRef lod_fpart,
    -                 LLVMValueRef width0_vec,
    -                 LLVMValueRef width1_vec,
    -                 LLVMValueRef height0_vec,
    -                 LLVMValueRef height1_vec,
    -                 LLVMValueRef depth0_vec,
    -                 LLVMValueRef depth1_vec,
    -                 LLVMValueRef row_stride0_vec,
    -                 LLVMValueRef row_stride1_vec,
    -                 LLVMValueRef img_stride0_vec,
    -                 LLVMValueRef img_stride1_vec,
    -                 LLVMValueRef data_ptr0,
    -                 LLVMValueRef data_ptr1,
    -                 LLVMValueRef *colors_out)
    +lp_build_sample_mipmap(struct lp_build_sample_context *bld,
    +                       unsigned img_filter,
    +                       unsigned mip_filter,
    +                       LLVMValueRef s,
    +                       LLVMValueRef t,
    +                       LLVMValueRef r,
    +                       LLVMValueRef lod_fpart,
    +                       LLVMValueRef width0_vec,
    +                       LLVMValueRef width1_vec,
    +                       LLVMValueRef height0_vec,
    +                       LLVMValueRef height1_vec,
    +                       LLVMValueRef depth0_vec,
    +                       LLVMValueRef depth1_vec,
    +                       LLVMValueRef row_stride0_vec,
    +                       LLVMValueRef row_stride1_vec,
    +                       LLVMValueRef img_stride0_vec,
    +                       LLVMValueRef img_stride1_vec,
    +                       LLVMValueRef data_ptr0,
    +                       LLVMValueRef data_ptr1,
    +                       LLVMValueRef *colors_out)
     {
        LLVMValueRef colors0[4], colors1[4];
        int chan;
    @@ -1533,20 +1533,24 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        */
     
        /*
    -    * Compute the level of detail (mipmap level index(es)).
    +    * Compute the level of detail (float).
    +    */
    +   if (min_filter != mag_filter ||
    +       mip_filter != PIPE_TEX_MIPFILTER_NONE) {
    +      /* Need to compute lod either to choose mipmap levels or to
    +       * distinguish between minification/magnification with one mipmap level.
    +       */
    +      lod = lp_build_lod_selector(bld, s, t, r, width, height, depth);
    +   }
    +
    +   /*
    +    * Compute integer mipmap level(s) to fetch texels from.
         */
        if (mip_filter == PIPE_TEX_MIPFILTER_NONE) {
           /* always use mip level 0 */
           ilevel0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
    -
    -      /* XXX temporary here */
    -      lod = lp_build_lod_selector(bld, s, t, r, width, height, depth);
    -
        }
        else {
    -      /* compute float LOD */
    -      lod = lp_build_lod_selector(bld, s, t, r, width, height, depth);
    -
           if (mip_filter == PIPE_TEX_MIPFILTER_NEAREST) {
              lp_build_nearest_mip_level(bld, unit, lod, &ilevel0);
           }
    @@ -1582,7 +1586,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
           }
        }
        if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) {
    -      /* compute width, height, depth for second mipmap level at ilevel1 */
    +      /* compute width, height, depth for second mipmap level at 'ilevel1' */
           width1_vec = lp_build_minify(bld, width_vec, ilevel1_vec);
           if (dims >= 2) {
              height1_vec = lp_build_minify(bld, height_vec, ilevel1_vec);
    @@ -1599,7 +1603,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
        }
     
        /*
    -    * Choose cube face, recompute texcoords.
    +    * Choose cube face, recompute per-face texcoords.
         */
        if (bld->static_state->target == PIPE_TEXTURE_CUBE) {
           LLVMValueRef face, face_s, face_t;
    @@ -1623,14 +1627,14 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
         */
        if (min_filter == mag_filter) {
           /* no need to distinquish between minification and magnification */
    -      lp_sample_mipmap(bld, min_filter, mip_filter, s, t, r, lod_fpart,
    -                       width0_vec, width1_vec,
    -                       height0_vec, height1_vec,
    -                       depth0_vec, depth1_vec,
    -                       row_stride0_vec, row_stride1_vec,
    -                       img_stride0_vec, img_stride1_vec,
    -                       data_ptr0, data_ptr1,
    -                       colors_out);
    +      lp_build_sample_mipmap(bld, min_filter, mip_filter, s, t, r, lod_fpart,
    +                             width0_vec, width1_vec,
    +                             height0_vec, height1_vec,
    +                             depth0_vec, depth1_vec,
    +                             row_stride0_vec, row_stride1_vec,
    +                             img_stride0_vec, img_stride1_vec,
    +                             data_ptr0, data_ptr1,
    +                             colors_out);
        }
        else {
           /* Emit conditional to choose min image filter or mag image filter
    @@ -1655,26 +1659,28 @@ lp_build_sample_general(struct lp_build_sample_context *bld,
           lp_build_if(&if_ctx, flow_ctx, bld->builder, minify);
           {
              /* Use the minification filter */
    -         lp_sample_mipmap(bld, min_filter, mip_filter, s, t, r, lod_fpart,
    -                          width0_vec, width1_vec,
    -                          height0_vec, height1_vec,
    -                          depth0_vec, depth1_vec,
    -                          row_stride0_vec, row_stride1_vec,
    -                          img_stride0_vec, img_stride1_vec,
    -                          data_ptr0, data_ptr1,
    -                          colors_out);
    +         lp_build_sample_mipmap(bld, min_filter, mip_filter,
    +                                s, t, r, lod_fpart,
    +                                width0_vec, width1_vec,
    +                                height0_vec, height1_vec,
    +                                depth0_vec, depth1_vec,
    +                                row_stride0_vec, row_stride1_vec,
    +                                img_stride0_vec, img_stride1_vec,
    +                                data_ptr0, data_ptr1,
    +                                colors_out);
           }
           lp_build_else(&if_ctx);
           {
              /* Use the magnification filter */
    -         lp_sample_mipmap(bld, mag_filter, mip_filter, s, t, r, lod_fpart,
    -                          width0_vec, width1_vec,
    -                          height0_vec, height1_vec,
    -                          depth0_vec, depth1_vec,
    -                          row_stride0_vec, row_stride1_vec,
    -                          img_stride0_vec, img_stride1_vec,
    -                          data_ptr0, data_ptr1,
    -                          colors_out);
    +         lp_build_sample_mipmap(bld, mag_filter, mip_filter,
    +                                s, t, r, lod_fpart,
    +                                width0_vec, width1_vec,
    +                                height0_vec, height1_vec,
    +                                depth0_vec, depth1_vec,
    +                                row_stride0_vec, row_stride1_vec,
    +                                img_stride0_vec, img_stride1_vec,
    +                                data_ptr0, data_ptr1,
    +                                colors_out);
           }
           lp_build_endif(&if_ctx);
     
    -- 
    cgit v1.2.3
    
    
    From 1d6d51413e546299010666ef64ce7e6c4a92064d Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 10:51:56 -0600
    Subject: gallivm: add min_lod==max_lod special-case code in
     lp_build_lod_selector()
    
    When min_lod==max_lod we don't need to go through all the work of
    computing the lod from partial derivatives.  This is hit by the mipmap
    generation utility code.
    ---
     src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 155 ++++++++++++----------
     1 file changed, 83 insertions(+), 72 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    index 29845c65d0..9741dbb389 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
    @@ -843,87 +843,98 @@ lp_build_lod_selector(struct lp_build_sample_context *bld,
                           LLVMValueRef depth)
     
     {
    -   const int dims = texture_dims(bld->static_state->target);
    -   struct lp_build_context *float_bld = &bld->float_bld;
    -   LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(), bld->static_state->lod_bias);
    -   LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod);
    -   LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(), bld->static_state->max_lod);
    -
    -   LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
    -   LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0);
    -   LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0);
    -
    -   LLVMValueRef s0, s1, s2;
    -   LLVMValueRef t0, t1, t2;
    -   LLVMValueRef r0, r1, r2;
    -   LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy;
    -   LLVMValueRef rho, lod;
    -
    -   /*
    -    * dsdx = abs(s[1] - s[0]);
    -    * dsdy = abs(s[2] - s[0]);
    -    * dtdx = abs(t[1] - t[0]);
    -    * dtdy = abs(t[2] - t[0]);
    -    * drdx = abs(r[1] - r[0]);
    -    * drdy = abs(r[2] - r[0]);
    -    * XXX we're assuming a four-element quad in 2x2 layout here.
    -    */
    -   s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0");
    -   s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1");
    -   s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2");
    -   dsdx = LLVMBuildSub(bld->builder, s1, s0, "");
    -   dsdx = lp_build_abs(float_bld, dsdx);
    -   dsdy = LLVMBuildSub(bld->builder, s2, s0, "");
    -   dsdy = lp_build_abs(float_bld, dsdy);
    -   if (dims > 1) {
    -      t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0");
    -      t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1");
    -      t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2");
    -      dtdx = LLVMBuildSub(bld->builder, t1, t0, "");
    -      dtdx = lp_build_abs(float_bld, dtdx);
    -      dtdy = LLVMBuildSub(bld->builder, t2, t0, "");
    -      dtdy = lp_build_abs(float_bld, dtdy);
    -      if (dims > 2) {
    -         r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0");
    -         r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1");
    -         r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2");
    -         drdx = LLVMBuildSub(bld->builder, r1, r0, "");
    -         drdx = lp_build_abs(float_bld, drdx);
    -         drdy = LLVMBuildSub(bld->builder, r2, r0, "");
    -         drdy = lp_build_abs(float_bld, drdy);
    -      }
    +   if (bld->static_state->min_lod == bld->static_state->max_lod) {
    +      /* User is forcing sampling from a particular mipmap level.
    +       * This is hit during mipmap generation.
    +       */
    +      return LLVMConstReal(LLVMFloatType(), bld->static_state->min_lod);
        }
    +   else {
    +      const int dims = texture_dims(bld->static_state->target);
    +      struct lp_build_context *float_bld = &bld->float_bld;
    +      LLVMValueRef lod_bias = LLVMConstReal(LLVMFloatType(),
    +                                            bld->static_state->lod_bias);
    +      LLVMValueRef min_lod = LLVMConstReal(LLVMFloatType(),
    +                                           bld->static_state->min_lod);
    +      LLVMValueRef max_lod = LLVMConstReal(LLVMFloatType(),
    +                                           bld->static_state->max_lod);
    +
    +      LLVMValueRef index0 = LLVMConstInt(LLVMInt32Type(), 0, 0);
    +      LLVMValueRef index1 = LLVMConstInt(LLVMInt32Type(), 1, 0);
    +      LLVMValueRef index2 = LLVMConstInt(LLVMInt32Type(), 2, 0);
    +
    +      LLVMValueRef s0, s1, s2;
    +      LLVMValueRef t0, t1, t2;
    +      LLVMValueRef r0, r1, r2;
    +      LLVMValueRef dsdx, dsdy, dtdx, dtdy, drdx, drdy;
    +      LLVMValueRef rho, lod;
    +
    +      /*
    +       * dsdx = abs(s[1] - s[0]);
    +       * dsdy = abs(s[2] - s[0]);
    +       * dtdx = abs(t[1] - t[0]);
    +       * dtdy = abs(t[2] - t[0]);
    +       * drdx = abs(r[1] - r[0]);
    +       * drdy = abs(r[2] - r[0]);
    +       * XXX we're assuming a four-element quad in 2x2 layout here.
    +       */
    +      s0 = LLVMBuildExtractElement(bld->builder, s, index0, "s0");
    +      s1 = LLVMBuildExtractElement(bld->builder, s, index1, "s1");
    +      s2 = LLVMBuildExtractElement(bld->builder, s, index2, "s2");
    +      dsdx = LLVMBuildSub(bld->builder, s1, s0, "");
    +      dsdx = lp_build_abs(float_bld, dsdx);
    +      dsdy = LLVMBuildSub(bld->builder, s2, s0, "");
    +      dsdy = lp_build_abs(float_bld, dsdy);
    +      if (dims > 1) {
    +         t0 = LLVMBuildExtractElement(bld->builder, t, index0, "t0");
    +         t1 = LLVMBuildExtractElement(bld->builder, t, index1, "t1");
    +         t2 = LLVMBuildExtractElement(bld->builder, t, index2, "t2");
    +         dtdx = LLVMBuildSub(bld->builder, t1, t0, "");
    +         dtdx = lp_build_abs(float_bld, dtdx);
    +         dtdy = LLVMBuildSub(bld->builder, t2, t0, "");
    +         dtdy = lp_build_abs(float_bld, dtdy);
    +         if (dims > 2) {
    +            r0 = LLVMBuildExtractElement(bld->builder, r, index0, "r0");
    +            r1 = LLVMBuildExtractElement(bld->builder, r, index1, "r1");
    +            r2 = LLVMBuildExtractElement(bld->builder, r, index2, "r2");
    +            drdx = LLVMBuildSub(bld->builder, r1, r0, "");
    +            drdx = lp_build_abs(float_bld, drdx);
    +            drdy = LLVMBuildSub(bld->builder, r2, r0, "");
    +            drdy = lp_build_abs(float_bld, drdy);
    +         }
    +      }
     
    -   /* Compute rho = max of all partial derivatives scaled by texture size.
    -    * XXX this could be vectorized somewhat
    -    */
    -   rho = LLVMBuildMul(bld->builder,
    -                      lp_build_max(float_bld, dsdx, dsdy),
    -                      lp_build_int_to_float(float_bld, width), "");
    -   if (dims > 1) {
    -      LLVMValueRef max;
    -      max = LLVMBuildMul(bld->builder,
    -                         lp_build_max(float_bld, dtdx, dtdy),
    -                         lp_build_int_to_float(float_bld, height), "");
    -      rho = lp_build_max(float_bld, rho, max);
    -      if (dims > 2) {
    +      /* Compute rho = max of all partial derivatives scaled by texture size.
    +       * XXX this could be vectorized somewhat
    +       */
    +      rho = LLVMBuildMul(bld->builder,
    +                         lp_build_max(float_bld, dsdx, dsdy),
    +                         lp_build_int_to_float(float_bld, width), "");
    +      if (dims > 1) {
    +         LLVMValueRef max;
              max = LLVMBuildMul(bld->builder,
    -                            lp_build_max(float_bld, drdx, drdy),
    -                            lp_build_int_to_float(float_bld, depth), "");
    +                            lp_build_max(float_bld, dtdx, dtdy),
    +                            lp_build_int_to_float(float_bld, height), "");
              rho = lp_build_max(float_bld, rho, max);
    +         if (dims > 2) {
    +            max = LLVMBuildMul(bld->builder,
    +                               lp_build_max(float_bld, drdx, drdy),
    +                               lp_build_int_to_float(float_bld, depth), "");
    +            rho = lp_build_max(float_bld, rho, max);
    +         }
           }
    -   }
     
    -   /* compute lod = log2(rho) */
    -   lod = lp_build_log2(float_bld, rho);
    +      /* compute lod = log2(rho) */
    +      lod = lp_build_log2(float_bld, rho);
     
    -   /* add lod bias */
    -   lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "LOD bias");
    +      /* add lod bias */
    +      lod = LLVMBuildAdd(bld->builder, lod, lod_bias, "LOD bias");
     
    -   /* clamp lod */
    -   lod = lp_build_clamp(float_bld, lod, min_lod, max_lod);
    +      /* clamp lod */
    +      lod = lp_build_clamp(float_bld, lod, min_lod, max_lod);
     
    -   return lod;
    +      return lod;
    +   }
     }
     
     
    -- 
    cgit v1.2.3
    
    
    From d25d3cc0086a1a2a5b6c41ad37c035c33d56a487 Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 11:27:24 -0600
    Subject: gallivm: fix typo/bug in lp_build_sgn()
    
    We were never returning -1 as a result.  This fixes some inverted/flipped
    faces with cube mapping.
    ---
     src/gallium/auxiliary/gallivm/lp_bld_arit.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    index c39b062d10..233a36669d 100644
    --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
    @@ -770,7 +770,7 @@ lp_build_sgn(struct lp_build_context *bld,
     
        /* Handle zero */
        cond = lp_build_cmp(bld, PIPE_FUNC_EQUAL, a, bld->zero);
    -   res = lp_build_select(bld, cond, bld->zero, bld->one);
    +   res = lp_build_select(bld, cond, bld->zero, res);
     
        return res;
     }
    -- 
    cgit v1.2.3
    
    
    From d0b35352ed27b1e66785c45ee95a352ed06b47ce Mon Sep 17 00:00:00 2001
    From: Brian Paul 
    Date: Mon, 15 Mar 2010 11:46:41 -0600
    Subject: llvmpipe: updated status in README file
    
    ---
     src/gallium/drivers/llvmpipe/README | 19 +++++++++++++------
     1 file changed, 13 insertions(+), 6 deletions(-)
    
    (limited to 'src/gallium')
    
    diff --git a/src/gallium/drivers/llvmpipe/README b/src/gallium/drivers/llvmpipe/README
    index bf4c9a5727..3c3fd386b5 100644
    --- a/src/gallium/drivers/llvmpipe/README
    +++ b/src/gallium/drivers/llvmpipe/README
    @@ -12,7 +12,11 @@ Done so far is:
        
        - depth testing
      
    -   - texture sampling (not all state/formats are supported) 
    +   - texture sampling
    +     - 1D/2D/3D/cube maps supported
    +     - all texture wrap modes supported
    +     - all texture filtering modes supported
    +     - perhaps not all texture formats yet supported
        
        - fragment shader TGSI translation
          - same level of support as the TGSI SSE2 exec machine, with the exception
    @@ -37,8 +41,6 @@ To do (probably by this order):
     
      - code generate stipple and stencil testing
     
    - - translate the remaining bits of texture sampling state
    -
      - translate TGSI control flow instructions, and all other remaining opcodes
      
      - integrate with the draw module for VS code generation
    @@ -57,7 +59,7 @@ Requirements
        
        See /proc/cpuinfo to know what your CPU supports.
      
    - - LLVM 2.6.
    + - LLVM 2.6 (or later)
      
        For Linux, on a recent Debian based distribution do:
      
    @@ -67,6 +69,9 @@ Requirements
        http://people.freedesktop.org/~jrfonseca/llvm/ and set the LLVM environment
        variable to the extracted path.
     
    +   The version of LLVM from SVN ("2.7svn") from mid-March 2010 seems pretty
    +   stable and has some features not in version 2.6.
    +
      - scons (optional)
     
      - udis86, http://udis86.sourceforge.net/ (optional):
    @@ -140,11 +145,13 @@ Development Notes
       then skim through the lp_bld_* functions called in there, and the comments
       at the top of the lp_bld_*.c functions.  
     
    -- All lp_bld_*.[ch] are isolated from the rest of the driver, and could/may be 
    -  put in a stand-alone Gallium state -> LLVM IR translation module.
    +- The driver-independent parts of the LLVM / Gallium code are found in
    +  src/gallium/auxiliary/gallivm/.  The filenames and function prefixes
    +  need to be renamed from "lp_bld_" to something else though.
     
     - We use LLVM-C bindings for now. They are not documented, but follow the C++
       interfaces very closely, and appear to be complete enough for code
       generation. See 
       http://npcontemplation.blogspot.com/2008/06/secret-of-llvm-c-bindings.html
       for a stand-alone example.
    +  See the llvm-c/Core.h file for reference.
    -- 
    cgit v1.2.3