From a82da7fa263c7fb6b902285994136890e6dc3278 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 11 Oct 2009 11:04:09 -0700 Subject: i965: Fix the bounds emitted in the vertex buffer packets. It's the address of the last valid byte, not the address of the first invalid byte. This should also fix problems with rendering with the new sanity checks in the kernel. --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 4aa17fa02d..5c33246749 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -539,12 +539,12 @@ static void brw_emit_vertices(struct brw_context *brw) if (input->stride) { OUT_RELOC(input->bo, I915_GEM_DOMAIN_VERTEX, 0, - input->offset + input->stride * input->count); + input->offset + input->stride * input->count - 1); } else { assert(input->count == 1); OUT_RELOC(input->bo, I915_GEM_DOMAIN_VERTEX, 0, - input->offset + input->element_size); + input->offset + input->element_size - 1); } } else OUT_BATCH(input->stride ? input->count : 0); -- cgit v1.2.3 From f3be27c0cf8a4c47230f31d9d66bde7340ffb204 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sun, 11 Oct 2009 11:16:03 -0700 Subject: i965: Fix the last valid address setting for the index buffer. Again, last valid address, not first invalid address. Fixes regression in 255e5be265133280293bbfd8b2f9b74b2dec50bb that the kernel now catches and caused piglit draw_elements_base_vertex to fail. --- src/mesa/drivers/dri/i965/brw_draw_upload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 5c33246749..9d089e113e 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -726,7 +726,7 @@ static void brw_emit_index_buffer(struct brw_context *brw) brw->ib.offset); OUT_RELOC(brw->ib.bo, I915_GEM_DOMAIN_VERTEX, 0, - brw->ib.offset + brw->ib.size); + brw->ib.offset + brw->ib.size - 1); OUT_BATCH( 0 ); ADVANCE_BATCH(); } -- cgit v1.2.3 From dfefde38c7dfe70a3531cb85215e55eeb6407180 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 13 Oct 2009 16:18:06 -0600 Subject: mesa: don't print pointer in _mesa_fprint_parameter_list() --- src/mesa/shader/prog_print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index a2bed07900..ba4d39452f 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -906,7 +906,8 @@ _mesa_fprint_parameter_list(FILE *f, if (!list) return; - _mesa_fprintf(f, "param list %p\n", (void *) list); + if (0) + _mesa_fprintf(f, "param list %p\n", (void *) list); _mesa_fprintf(f, "dirty state flags: 0x%x\n", list->StateFlags); for (i = 0; i < list->NumParameters; i++){ struct gl_program_parameter *param = list->Parameters + i; -- cgit v1.2.3 From 435623b3f0b2d2db5b107ef177693ccafc591a29 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 13 Oct 2009 16:32:15 -0600 Subject: mesa: rework _mesa_read_shader() debug hook Look for shaders named "newshader_" to replace the incoming shader text. For debug purposes. --- src/mesa/main/shaders.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c index bc76b91291..96fd8695a5 100644 --- a/src/mesa/main/shaders.c +++ b/src/mesa/main/shaders.c @@ -388,7 +388,6 @@ _mesa_read_shader(const char *fname) int len; if (!f) { - _mesa_fprintf(stderr, "Unable to open shader file %s\n", fname); return NULL; } @@ -401,11 +400,6 @@ _mesa_read_shader(const char *fname) shader = _mesa_strdup(buffer); free(buffer); - if (0) { - _mesa_fprintf(stderr, "Read shader %s:\n", fname); - _mesa_fprintf(stderr, "%s\n", shader); - } - return shader; } @@ -475,19 +469,25 @@ _mesa_ShaderSourceARB(GLhandleARB shaderObj, GLsizei count, source[totalLength - 1] = '\0'; source[totalLength - 2] = '\0'; -#if 0 if (0) { + /* Compute the shader's source code checksum then try to open a file + * named newshader_. If it exists, use it in place of the + * original shader source code. For debugging. + */ + const GLuint checksum = _mesa_str_checksum(source); + char filename[100]; GLcharARB *newSource; - newSource = _mesa_read_shader("newshader.frag"); + sprintf(filename, "newshader_%d", checksum); + + newSource = _mesa_read_shader(filename); if (newSource) { + _mesa_fprintf(stderr, "Mesa: Replacing shader %u chksum=%d with %s\n", + shaderObj, checksum, filename); _mesa_free(source); source = newSource; } - } -#else - (void) _mesa_read_shader; -#endif + } ctx->Driver.ShaderSource(ctx, shaderObj, source); -- cgit v1.2.3 From 220f72a8d04728efbbc097d27be43590b0fe1ceb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 13 Oct 2009 16:33:17 -0600 Subject: mesa: minor tweak to printf string --- src/mesa/shader/shader_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index ce19649323..6de97984e6 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -1526,7 +1526,7 @@ _mesa_use_program(GLcontext *ctx, GLuint program) /* debug code */ if (0) { GLuint i; - _mesa_printf("Use Shader %u\n", shProg->Name); + _mesa_printf("Use Shader Program %u\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { _mesa_printf(" shader %u, type 0x%x, checksum %u\n", shProg->Shaders[i]->Name, -- cgit v1.2.3 From 23c0c820e2767324546d450d2a7aa7bf1f70c36f Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 11:42:05 +1000 Subject: r300g: fix case where texture unit 0 is disabled but unit 1 is enabled. to reproduce, start texrect, disable 0 texture in menu. Signed-off-by: Dave Airlie --- src/gallium/drivers/r300/r300_emit.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 570b4c5ef7..99deb50400 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -683,7 +683,8 @@ validate: /* ...textures... */ for (i = 0; i < r300->texture_count; i++) { tex = r300->textures[i]; - assert(tex && tex->buffer && "texture is marked, but NULL!"); + if (!tex) + continue; if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { r300->context.flush(&r300->context, 0, NULL); @@ -770,12 +771,13 @@ validate: if (r300->dirty_state & (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) { for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) { - if (r300->dirty_state & - ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) { - r300_emit_texture(r300, - r300->sampler_states[i], - r300->textures[i], - 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)); dirty_tex++; -- cgit v1.2.3 From 210481ae16e966865dcf9f1fd5f5dfabf4dc28bc Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 15:13:25 +1000 Subject: r300g: attempt to make bo space check sane. This attempts to make r300g do proper bo space checking as opposed to whatever it was doing now. Signed-off-by: Dave Airlie --- src/gallium/drivers/r300/r300_context.c | 9 +++++++++ src/gallium/drivers/r300/r300_emit.c | 3 +++ src/gallium/drivers/r300/r300_winsys.h | 6 ++++++ src/gallium/winsys/drm/radeon/core/radeon_r300.c | 23 ++++++++++++++++++++--- 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 9cc455135d..e6bc80e48f 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -136,6 +136,13 @@ r300_is_buffer_referenced( struct pipe_context *pipe, return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; } +static void r300_flush_cb(void *data) +{ + struct r300_context* const cs_context_copy = data; + + cs_context_copy->context.flush(&cs_context_copy->context, 0, NULL); +} + struct pipe_context* r300_create_context(struct pipe_screen* screen, struct r300_winsys* r300_winsys) { @@ -190,6 +197,8 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_init_state_functions(r300); r300_emit_invariant_state(r300); + + r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300); r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw++; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 99deb50400..64748ad8f8 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -658,6 +658,9 @@ void r300_emit_dirty_state(struct r300_context* r300) r300_update_derived_state(r300); + /* Clean out BOs. */ + r300->winsys->reset_bos(r300->winsys); + /* XXX check size */ validate: /* Color buffers... */ diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index f18ad75a47..540f8eca92 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -92,6 +92,12 @@ struct r300_winsys { /* Flush the CS. */ void (*flush_cs)(struct r300_winsys* winsys); + + /* winsys flush - callback from winsys when flush required */ + void (*set_flush_cb)(struct r300_winsys *winsys, + void (*flush_cb)(void *), void *data); + + void (*reset_bos)(struct r300_winsys *winsys); }; struct pipe_context* r300_create_context(struct pipe_screen* screen, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index d2d84f1a8f..3587892e00 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -22,6 +22,17 @@ #include "radeon_r300.h" +static void radeon_r300_set_flush_cb(struct r300_winsys *winsys, + void (*flush_cb)(void *), + void *data) +{ + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + + radeon_cs_space_set_flush(priv->cs, flush_cb, + data); +} + static boolean radeon_r300_add_buffer(struct r300_winsys* winsys, struct pipe_buffer* pbuffer, uint32_t rd, @@ -95,6 +106,13 @@ static void radeon_r300_write_cs_reloc(struct r300_winsys* winsys, } } +static void radeon_r300_reset_bos(struct r300_winsys *winsys) +{ + struct radeon_winsys_priv* priv = + (struct radeon_winsys_priv*)winsys->radeon_winsys; + radeon_cs_space_reset_bos(priv->cs); +} + static void radeon_r300_end_cs(struct r300_winsys* winsys, const char* file, const char* function, @@ -119,9 +137,6 @@ static void radeon_r300_flush_cs(struct r300_winsys* winsys) radeon_cs_print(priv->cs, stderr); } - /* Clean out BOs. */ - radeon_cs_space_reset_bos(priv->cs); - /* 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 @@ -203,6 +218,8 @@ radeon_create_r300_winsys(int fd, struct radeon_winsys* old_winsys) winsys->write_cs_reloc = radeon_r300_write_cs_reloc; winsys->end_cs = radeon_r300_end_cs; winsys->flush_cs = radeon_r300_flush_cs; + winsys->reset_bos = radeon_r300_reset_bos; + winsys->set_flush_cb = radeon_r300_set_flush_cb; memcpy(winsys, old_winsys, sizeof(struct radeon_winsys)); -- cgit v1.2.3 From c1bee7bdea470b6b5dcebef9aacc8fe4feca687c Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 16:53:12 +1000 Subject: r300g: fixup arb occulsion query support. 1: add rv530 support - num z pipes cap - add proper start/finish query options for rv530 2: convert to use linked list properly. 3: add flushing required check. 4: initial Z top disabling support. TODO: make it actually work on my rv530. --- src/gallium/drivers/r300/r300_chipset.h | 2 + src/gallium/drivers/r300/r300_context.c | 10 ++-- src/gallium/drivers/r300/r300_context.h | 4 +- src/gallium/drivers/r300/r300_emit.c | 69 ++++++++++++++++++++---- src/gallium/drivers/r300/r300_flush.c | 10 +++- src/gallium/drivers/r300/r300_query.c | 42 ++++++++------- src/gallium/drivers/r300/r300_reg.h | 15 ++++-- src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/r300/r300_state.c | 11 ++-- src/gallium/drivers/r300/r300_winsys.h | 3 ++ src/gallium/winsys/drm/radeon/core/radeon_r300.c | 10 ++++ 11 files changed, 134 insertions(+), 43 deletions(-) diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h index 322d4a57e4..f015a4243d 100644 --- a/src/gallium/drivers/r300/r300_chipset.h +++ b/src/gallium/drivers/r300/r300_chipset.h @@ -36,6 +36,8 @@ struct r300_capabilities { int num_vert_fpus; /* The number of fragment pipes */ int num_frag_pipes; + /* The number of z pipes */ + int num_z_pipes; /* Whether or not TCL is physically present */ boolean has_tcl; /* Whether or not this is an RV515 or newer; R500s have many differences diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index e6bc80e48f..7a9c098e30 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -99,11 +99,9 @@ static void r300_destroy_context(struct pipe_context* context) { context->screen->buffer_destroy(r300->oqbo); /* If there are any queries pending or not destroyed, remove them now. */ - if (r300->query_list) { - foreach_s(query, temp, r300->query_list) { - remove_from_list(query); - FREE(query); - } + foreach_s(query, temp, &r300->query_list) { + remove_from_list(query); + FREE(query); } FREE(r300->blend_color_state); @@ -201,6 +199,6 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->winsys->set_flush_cb(r300->winsys, r300_flush_cb, r300); r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw++; - + make_empty_list(&r300->query_list); return &r300->context; } diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 086633f732..9b0094b63c 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -172,6 +172,8 @@ struct r300_query { unsigned int count; /* The offset of this query into the query buffer, in bytes. */ unsigned offset; + /* if we've flushed the query */ + boolean flushed; /* Linked list members. */ struct r300_query* prev; struct r300_query* next; @@ -237,7 +239,7 @@ struct r300_context { /* Occlusion query buffer. */ struct pipe_buffer* oqbo; /* Query list. */ - struct r300_query* query_list; + struct r300_query query_list; /* Various CSO state objects. */ /* Blend state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 64748ad8f8..3d28249c16 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -323,28 +323,30 @@ void r300_emit_fb_state(struct r300_context* r300, void r300_emit_query_begin(struct r300_context* r300, struct r300_query* query) { + struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); /* XXX This will almost certainly not return good results * for overlapping queries. */ - BEGIN_CS(2); + BEGIN_CS(4); + if (caps->family == CHIP_FAMILY_RV530) { + OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); + } else { + OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL); + } OUT_CS_REG(R300_ZB_ZPASS_DATA, 0); END_CS; } -void r300_emit_query_end(struct r300_context* r300, - struct r300_query* query) + +static void r300_emit_query_finish(struct r300_context *r300, + struct r300_query *query) { struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); - if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo, - 0, RADEON_GEM_DOMAIN_GTT)) { - debug_printf("r300: There wasn't room for the OQ buffer!?" - " Oh noes!\n"); - } - assert(caps->num_frag_pipes); + BEGIN_CS(6 * caps->num_frag_pipes + 2); /* I'm not so sure I like this switch, but it's hard to be elegant * when there's so many special cases... @@ -394,6 +396,55 @@ void r300_emit_query_end(struct r300_context* r300, } +static void rv530_emit_query_single(struct r300_context *r300, + struct r300_query *query) +{ + CS_LOCALS(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_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); + END_CS; +} + +static void rv530_emit_query_double(struct r300_context *r300, + struct r300_query *query) +{ + CS_LOCALS(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_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_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); + END_CS; +} + +void r300_emit_query_end(struct r300_context* r300, + struct r300_query* query) +{ + struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps; + + if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo, + 0, RADEON_GEM_DOMAIN_GTT)) { + debug_printf("r300: There wasn't room for the OQ buffer!?" + " Oh noes!\n"); + } + + if (caps->family == CHIP_FAMILY_RV530) { + if (caps->num_z_pipes == 2) + rv530_emit_query_double(r300, query); + else + rv530_emit_query_single(r300, query); + } else + r300_emit_query_finish(r300, query); +} + void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs) { CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 0dff1c6f4f..a8ab0d7212 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -26,9 +26,10 @@ static void r300_flush(struct pipe_context* pipe, unsigned flags, struct pipe_fence_handle** fence) { - struct r300_context* r300 = r300_context(pipe); - CS_LOCALS(r300); + struct r300_context *r300 = r300_context(pipe); + struct r300_query *query; + CS_LOCALS(r300); /* We probably need to flush Draw, but we may have been called from * within Draw. This feels kludgy, but it might be the best thing. */ if (!r300->draw->flushing) { @@ -41,8 +42,13 @@ static void r300_flush(struct pipe_context* pipe, r300->dirty_state = R300_NEW_KITCHEN_SINK; r300->dirty_hw = 0; } + /* reset flushed query */ + foreach(query, &r300->query_list) { + query->flushed = TRUE; + } } + void r300_init_flush_functions(struct r300_context* r300) { r300->context.flush = r300_flush; diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 2880d34877..b01313648b 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -24,13 +24,13 @@ #include "r300_emit.h" -static struct pipe_query* r300_create_query(struct pipe_context* pipe, +static struct pipe_query *r300_create_query(struct pipe_context *pipe, unsigned query_type) { - struct r300_context* r300 = r300_context(pipe); - struct r300_screen* r300screen = r300_screen(r300->context.screen); - unsigned query_size = r300screen->caps->num_frag_pipes * 4; - struct r300_query* q, * qptr; + struct r300_context *r300 = r300_context(pipe); + struct r300_screen *r300screen = r300_screen(r300->context.screen); + unsigned query_size; + struct r300_query *q, *qptr; q = CALLOC_STRUCT(r300_query); @@ -39,13 +39,16 @@ static struct pipe_query* r300_create_query(struct pipe_context* pipe, q->active = FALSE; - if (!r300->query_list) { - r300->query_list = q; - } else if (!is_empty_list(r300->query_list)) { - qptr = last_elem(r300->query_list); + if (r300screen->caps->family == CHIP_FAMILY_RV530) + query_size = r300screen->caps->num_z_pipes * sizeof(uint32_t); + else + query_size = r300screen->caps->num_frag_pipes * sizeof(uint32_t); + + if (!is_empty_list(&r300->query_list)) { + qptr = last_elem(&r300->query_list); q->offset = qptr->offset + query_size; - insert_at_tail(r300->query_list, q); } + insert_at_tail(&r300->query_list, q); /* XXX */ if (q->offset >= 4096) { @@ -74,9 +77,10 @@ static void r300_begin_query(struct pipe_context* pipe, map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, PIPE_BUFFER_USAGE_CPU_WRITE); map += q->offset / 4; - *map = ~0; + *map = ~0U; pipe->screen->buffer_unmap(pipe->screen, r300->oqbo); + q->flushed = FALSE; r300_emit_dirty_state(r300); r300_emit_query_begin(r300, q); } @@ -98,28 +102,30 @@ static boolean r300_get_query_result(struct pipe_context* pipe, { struct r300_context* r300 = r300_context(pipe); struct r300_screen* r300screen = r300_screen(r300->context.screen); - struct r300_query* q = (struct r300_query*)query; + struct r300_query *q = (struct r300_query*)query; unsigned flags = PIPE_BUFFER_USAGE_CPU_READ; uint32_t* map; - uint32_t temp; + uint32_t temp = 0; unsigned i; - if (wait) { + if (q->flushed == FALSE) pipe->flush(pipe, 0, NULL); - } else { + if (!wait) { flags |= PIPE_BUFFER_USAGE_DONTBLOCK; } map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, flags); + if (!map) + return FALSE; map += q->offset / 4; for (i = 0; i < r300screen->caps->num_frag_pipes; i++) { - if (*map == ~0) { + if (*map == ~0U) { /* Looks like our results aren't ready yet. */ if (wait) { debug_printf("r300: Despite waiting, OQ results haven't" " come in yet.\n"); } - temp = ~0; + temp = ~0U; break; } temp += *map; @@ -127,7 +133,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe, } pipe->screen->buffer_unmap(pipe->screen, r300->oqbo); - if (temp == ~0) { + if (temp == ~0U) { /* Our results haven't been written yet... */ return FALSE; } diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 3abff5db62..ae94bb9b9f 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -1172,6 +1172,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* SU Depth Offset value */ #define R300_SU_DEPTH_OFFSET 0x42c4 +#define R300_SU_REG_DEST 0x42c8 +# define R300_RASTER_PIPE_SELECT_0 (1 << 0) +# define R300_RASTER_PIPE_SELECT_1 (1 << 1) +# define R300_RASTER_PIPE_SELECT_2 (1 << 2) +# define R300_RASTER_PIPE_SELECT_3 (1 << 3) +# define R300_RASTER_PIPE_SELECT_ALL 0xf + /* BEGIN: Rasterization / Interpolators - many guesses */ @@ -2095,6 +2102,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define R500_FG_ALPHA_VALUE 0x4be0 # define R500_FG_ALPHA_VALUE_MASK 0x0000ffff +#define RV530_FG_ZBREG_DEST 0x4be8 +# define RV530_FG_ZBREG_DEST_PIPE_SELECT_0 (1 << 0) +# define RV530_FG_ZBREG_DEST_PIPE_SELECT_1 (1 << 1) +# define RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL (3 << 0) /* gap */ /* Fragment program parameters in 7.16 floating point */ @@ -3313,10 +3324,6 @@ enum { #define R200_3D_DRAW_IMMD_2 0xC0003500 -/* XXX Oh look, stuff not brought over from docs yet */ - -#define R300_SU_REG_DEST 0x42C8 - #endif /* _R300_REG_H */ /* *INDENT-ON* */ diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 7d154576e0..5381651c77 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -395,6 +395,7 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys) caps->pci_id = r300_winsys->pci_id; caps->num_frag_pipes = r300_winsys->gb_pipes; + caps->num_z_pipes = r300_winsys->z_pipes; r300_parse_chipset(caps); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 3cef285dee..d8533ac168 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -190,6 +190,7 @@ static void* r300_create_dsa_state(struct pipe_context* pipe, const struct pipe_depth_stencil_alpha_state* state) { + struct r300_context* r300 = r300_context(pipe); struct r300_dsa_state* dsa = CALLOC_STRUCT(r300_dsa_state); /* Depth test setup. */ @@ -247,11 +248,15 @@ static void* R300_FG_ALPHA_FUNC_ENABLE; dsa->alpha_reference = CLAMP(state->alpha.ref_value * 1023.0f, 0, 1023); - } else { - /* XXX need to fix this to be dynamically set - dsa->z_buffer_top = R300_ZTOP_ENABLE; */ } + dsa->z_buffer_top = R300_ZTOP_ENABLE; + /* XXX TODO: add frag prog rules for ztop disable */ + if (state->alpha.enabled && state->alpha.func != PIPE_FUNC_ALWAYS) + dsa->z_buffer_top = R300_ZTOP_DISABLE; + if (!is_empty_list(&r300->query_list)) + dsa->z_buffer_top = R300_ZTOP_DISABLE; + return (void*)dsa; } diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h index 540f8eca92..864a6146b2 100644 --- a/src/gallium/drivers/r300/r300_winsys.h +++ b/src/gallium/drivers/r300/r300_winsys.h @@ -48,6 +48,9 @@ struct r300_winsys { /* GB pipe count */ uint32_t gb_pipes; + /* Z pipe count (rv530 only) */ + uint32_t z_pipes; + /* GART size. */ uint32_t gart_size; diff --git a/src/gallium/winsys/drm/radeon/core/radeon_r300.c b/src/gallium/winsys/drm/radeon/core/radeon_r300.c index 3587892e00..7ea5d1fb4e 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_r300.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_r300.c @@ -164,6 +164,16 @@ static void do_ioctls(struct r300_winsys* winsys, int fd) } winsys->gb_pipes = target; + /* get Z pipes */ + info.request = RADEON_INFO_NUM_Z_PIPES; + retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); + if (retval) { + fprintf(stderr, "%s: Failed to get GB pipe count, " + "error number %d\n", __FUNCTION__, retval); + exit(1); + } + winsys->z_pipes = target; + /* Then, get PCI ID */ info.request = RADEON_INFO_DEVICE_ID; retval = drmCommandWriteRead(fd, DRM_RADEON_INFO, &info, sizeof(info)); -- cgit v1.2.3 From 47791697ab6eb6965f0ba8ba3f20373b3753ca2a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 17:14:43 +1000 Subject: r300g: convert query to a state for emitting. This means we don't emit in the begin query but when we have to flush. Similiar to classic. TODO: make query object actually work. --- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 15 ++++++++++++--- src/gallium/drivers/r300/r300_query.c | 8 ++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 9b0094b63c..3a01869ba1 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -141,6 +141,7 @@ struct r300_viewport_state { #define R300_NEW_VERTEX_FORMAT 0x04000000 #define R300_NEW_VERTEX_SHADER 0x08000000 #define R300_NEW_VIEWPORT 0x10000000 +#define R300_NEW_QUERY 0x20000000 #define R300_NEW_KITCHEN_SINK 0x1fffffff /* The next several objects are not pure Radeon state; they inherit from @@ -239,6 +240,7 @@ struct r300_context { /* Occlusion query buffer. */ struct pipe_buffer* oqbo; /* Query list. */ + struct r300_query *query_current; struct r300_query query_list; /* Various CSO state objects. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 3d28249c16..babbe0dd74 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -320,12 +320,16 @@ void r300_emit_fb_state(struct r300_context* r300, END_CS; } -void r300_emit_query_begin(struct r300_context* r300, - struct r300_query* query) +void r300_emit_query_start(struct r300_context *r300) + { - struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; + struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps; + struct r300_query *query = r300->query_current; CS_LOCALS(r300); + if (!query) + return; + /* XXX This will almost certainly not return good results * for overlapping queries. */ BEGIN_CS(4); @@ -772,6 +776,11 @@ validate: goto validate; } + if (r300->dirty_state & R300_NEW_QUERY) { + r300_emit_query_start(r300); + r300->dirty_state &= ~R300_NEW_QUERY; + } + if (r300->dirty_state & R300_NEW_BLEND) { r300_emit_blend_state(r300, r300->blend_state); r300->dirty_state &= ~R300_NEW_BLEND; diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index b01313648b..fb4340ff3d 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -74,6 +74,8 @@ static void r300_begin_query(struct pipe_context* pipe, struct r300_context* r300 = r300_context(pipe); struct r300_query* q = (struct r300_query*)query; + assert(r300->query_current == NULL); + map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, PIPE_BUFFER_USAGE_CPU_WRITE); map += q->offset / 4; @@ -81,8 +83,8 @@ static void r300_begin_query(struct pipe_context* pipe, pipe->screen->buffer_unmap(pipe->screen, r300->oqbo); q->flushed = FALSE; - r300_emit_dirty_state(r300); - r300_emit_query_begin(r300, q); + r300->query_current = q; + r300->dirty_state |= R300_NEW_QUERY; } static void r300_end_query(struct pipe_context* pipe, @@ -93,6 +95,8 @@ static void r300_end_query(struct pipe_context* pipe, r300_emit_dirty_state(r300); r300_emit_query_end(r300, q); + + r300->query_current = NULL; } static boolean r300_get_query_result(struct pipe_context* pipe, -- cgit v1.2.3 From 51d1cf55da6f8b8a215814589a189b6e5e537fe5 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 17:44:19 +1000 Subject: r300g: port over last parts of oq support. Add support for begin/end in each CS so we don't get any other processes rendering in between. TODO: blame other parts of driver for this not working like Z. --- src/gallium/drivers/r300/r300_context.h | 2 ++ src/gallium/drivers/r300/r300_emit.c | 11 +++++++++-- src/gallium/drivers/r300/r300_emit.h | 3 +-- src/gallium/drivers/r300/r300_flush.c | 2 ++ src/gallium/drivers/r300/r300_query.c | 7 ++----- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 3a01869ba1..7826ed1452 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -175,6 +175,8 @@ struct r300_query { unsigned offset; /* if we've flushed the query */ boolean flushed; + /* if begin has been emitted */ + boolean begin_emitted; /* Linked list members. */ struct r300_query* prev; struct r300_query* next; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index babbe0dd74..6e616cd5b2 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -340,6 +340,7 @@ void r300_emit_query_start(struct r300_context *r300) } OUT_CS_REG(R300_ZB_ZPASS_DATA, 0); END_CS; + query->begin_emitted = TRUE; } @@ -429,10 +430,16 @@ static void rv530_emit_query_double(struct r300_context *r300, END_CS; } -void r300_emit_query_end(struct r300_context* r300, - struct r300_query* query) +void r300_emit_query_end(struct r300_context* r300) { struct r300_capabilities *caps = r300_screen(r300->context.screen)->caps; + struct r300_query *query = r300->query_current; + + if (!query) + return; + + if (query->begin_emitted == FALSE) + return; if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo, 0, RADEON_GEM_DOMAIN_GTT)) { diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index c4002b8e5d..b62aa9fec5 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -58,8 +58,7 @@ void r300_emit_fb_state(struct r300_context* r300, void r300_emit_query_begin(struct r300_context* r300, struct r300_query* query); -void r300_emit_query_end(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, struct r300_rs_state* rs); diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index a8ab0d7212..241ea71d6b 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -36,6 +36,8 @@ static void r300_flush(struct pipe_context* pipe, draw_flush(r300->draw); } + r300_emit_query_end(r300); + if (r300->dirty_hw) { FLUSH_CS; r300_emit_invariant_state(r300); diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index fb4340ff3d..2b0fbfb7d2 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -88,14 +88,11 @@ static void r300_begin_query(struct pipe_context* pipe, } static void r300_end_query(struct pipe_context* pipe, - struct pipe_query* query) + struct pipe_query* query) { struct r300_context* r300 = r300_context(pipe); - struct r300_query* q = (struct r300_query*)query; - - r300_emit_dirty_state(r300); - r300_emit_query_end(r300, q); + r300_emit_query_end(r300); r300->query_current = NULL; } -- cgit v1.2.3 From ce5cba040c34a1a70186c29a5055e9be3c85a54a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 18:05:14 +1000 Subject: r300g: add one more ZTOP disable bit. Still missing the frag uses kill support, hopefully nha can point that out. --- src/gallium/drivers/r300/r300_fs.h | 6 ++++++ src/gallium/drivers/r300/r300_state.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h index 967e9f697e..04453274aa 100644 --- a/src/gallium/drivers/r300/r300_fs.h +++ b/src/gallium/drivers/r300/r300_fs.h @@ -48,4 +48,10 @@ struct r300_fragment_shader { void r300_translate_fragment_shader(struct r300_context* r300, struct r300_fragment_shader* fs); +static inline boolean r300_fragment_shader_writes_depth(struct r300_fragment_shader *fs) +{ + if (!fs) + return FALSE; + return (fs->code.writes_depth) ? TRUE : FALSE; +} #endif /* R300_FS_H */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index d8533ac168..95e2943baa 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -252,9 +252,11 @@ static void* dsa->z_buffer_top = R300_ZTOP_ENABLE; /* XXX TODO: add frag prog rules for ztop disable */ + if (r300_fragment_shader_writes_depth(r300->fs)) + dsa->z_buffer_top = R300_ZTOP_DISABLE; if (state->alpha.enabled && state->alpha.func != PIPE_FUNC_ALWAYS) dsa->z_buffer_top = R300_ZTOP_DISABLE; - if (!is_empty_list(&r300->query_list)) + if (r300->query_current) dsa->z_buffer_top = R300_ZTOP_DISABLE; return (void*)dsa; -- cgit v1.2.3 From fa581580b18d530b849299c38604ab0804290e49 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 18:24:05 +1000 Subject: r300g: add QUERY to KITCHEN_SINK I missed this, thanks to Corbin for pointing it out. --- src/gallium/drivers/r300/r300_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 7826ed1452..d2e8875503 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -142,7 +142,7 @@ struct r300_viewport_state { #define R300_NEW_VERTEX_SHADER 0x08000000 #define R300_NEW_VIEWPORT 0x10000000 #define R300_NEW_QUERY 0x20000000 -#define R300_NEW_KITCHEN_SINK 0x1fffffff +#define R300_NEW_KITCHEN_SINK 0x3fffffff /* The next several objects are not pure Radeon state; they inherit from * various Gallium classes. */ -- cgit v1.2.3 From 88b697fb0aaaab8479716763510f56b1053ddb37 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Wed, 14 Oct 2009 18:24:34 +1000 Subject: r300g: remove buffer add that should be unnecessary. This should be handled in the emit fine --- src/gallium/drivers/r300/r300_emit.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 6e616cd5b2..feffadd0ee 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -441,12 +441,6 @@ void r300_emit_query_end(struct r300_context* r300) if (query->begin_emitted == FALSE) return; - if (!r300->winsys->add_buffer(r300->winsys, r300->oqbo, - 0, RADEON_GEM_DOMAIN_GTT)) { - debug_printf("r300: There wasn't room for the OQ buffer!?" - " Oh noes!\n"); - } - if (caps->family == CHIP_FAMILY_RV530) { if (caps->num_z_pipes == 2) rv530_emit_query_double(r300, query); -- cgit v1.2.3 From f13e507798cdbbe2fad5df33dcd581d49d6fa7ab Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 14 Oct 2009 01:58:18 -0700 Subject: r300g: Compiler warning cleanup. --- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/drivers/r300/r300_render.c | 7 ------- src/gallium/drivers/r300/r300_state_derived.c | 2 +- src/gallium/drivers/r300/r300_surface.c | 3 +-- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 7a9c098e30..b243f88bb5 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -152,7 +152,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->winsys = r300_winsys; r300->context.winsys = (struct pipe_winsys*)r300_winsys; - r300->context.screen = r300_screen(screen); + r300->context.screen = screen; r300_init_debug(r300); diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index ca44e0f661..b56f7a3d1e 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -127,7 +127,6 @@ static void r300_render_unmap_vertices(struct vbuf_render* render, static void r300_render_release_vertices(struct vbuf_render* render) { struct r300_render* r300render = r300_render(render); - struct r300_context* r300 = r300render->r300; r300render->vbo_offset += r300render->vbo_max_used; r300render->vbo_max_used = 0; @@ -182,8 +181,6 @@ static void r300_prepare_render(struct r300_render* render, unsigned count) { struct r300_context* r300 = render->r300; - CS_LOCALS(r300); - r300_emit_dirty_state(r300); } @@ -213,11 +210,7 @@ static void r300_render_draw(struct vbuf_render* render, { struct r300_render* r300render = r300_render(render); struct r300_context* r300 = r300render->r300; - struct pipe_screen* screen = r300->context.screen; - struct pipe_buffer* index_buffer; - void* index_map; int i; - uint32_t index; CS_LOCALS(r300); diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 02b7ab9107..335b54820a 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -193,7 +193,7 @@ static void r300_vertex_psc(struct r300_context* r300, struct vertex_info* vinfo = &vformat->vinfo; int* tab = vformat->vs_tab; uint32_t temp; - int i, attrib_count; + unsigned i, attrib_count; /* Vertex shaders have no semantics on their inputs, * so PSC should just route stuff based on their info, diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index d72e734ff0..5cf49d20aa 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -95,8 +95,7 @@ static void r300_surface_fill(struct pipe_context* pipe, unsigned w, unsigned h, unsigned color) { - int i; - float r, g, b, a, depth; + float r, g, b, a; struct r300_context* r300 = r300_context(pipe); struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* tex = (struct r300_texture*)dest->texture; -- cgit v1.2.3 From fd63f89e95342d7d5921d6369346e356b505b584 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 14 Oct 2009 03:09:41 -0700 Subject: r300g: Move ztop to derived state. Need to get it into its own atom instead of piggybacking on DSA. --- src/gallium/drivers/r300/r300_state.c | 10 -------- src/gallium/drivers/r300/r300_state_derived.c | 36 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 95e2943baa..8359850966 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -190,7 +190,6 @@ static void* r300_create_dsa_state(struct pipe_context* pipe, const struct pipe_depth_stencil_alpha_state* state) { - struct r300_context* r300 = r300_context(pipe); struct r300_dsa_state* dsa = CALLOC_STRUCT(r300_dsa_state); /* Depth test setup. */ @@ -250,15 +249,6 @@ static void* 0, 1023); } - dsa->z_buffer_top = R300_ZTOP_ENABLE; - /* XXX TODO: add frag prog rules for ztop disable */ - if (r300_fragment_shader_writes_depth(r300->fs)) - dsa->z_buffer_top = R300_ZTOP_DISABLE; - if (state->alpha.enabled && state->alpha.func != PIPE_FUNC_ALWAYS) - dsa->z_buffer_top = R300_ZTOP_DISABLE; - if (r300->query_current) - dsa->z_buffer_top = R300_ZTOP_DISABLE; - return (void*)dsa; } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 335b54820a..5d323a26b1 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -444,6 +444,37 @@ static void r300_update_rs_block(struct r300_context* r300) rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0); } +static void r300_update_ztop(struct r300_context* r300) +{ + r300->dsa_state->z_buffer_top = R300_ZTOP_ENABLE; + + /* This is important enough that I felt it warranted a comment. + * + * According to the docs, these are the conditions where ZTOP must be + * disabled: + * 1) Alpha testing enabled + * 2) Texture kill instructions in fragment shader + * 3) Chroma key culling enabled + * 4) W-buffering enabled + * + * The docs claim that for the first three cases, if no ZS writes happen, + * then ZTOP can be used. + * + * Additionally, the following conditions require disabled ZTOP: + * ~) Depth writes in fragment shader + * ~) Outstanding occlusion queries + * + * ~C. + */ + if (r300->dsa_state->alpha_function) { + r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + } else if (r300_fragment_shader_writes_depth(r300->fs)) { + r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + } else if (r300->query_current) { + r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + } +} + void r300_update_derived_state(struct r300_context* r300) { if (r300->dirty_state & @@ -455,4 +486,9 @@ void r300_update_derived_state(struct r300_context* r300) r300_update_fs_tab(r300); r300_update_rs_block(r300); } + + if (r300->dirty_state & + (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) { + r300_update_ztop(r300); + } } -- cgit v1.2.3 From ea862ec8ff4a52b30b822e737d93a49330be9e31 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 14 Oct 2009 07:43:18 -0600 Subject: prog/tests: Fix MSVC build. --- progs/tests/arraytexture.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c index 6c0484df0d..28252a354b 100644 --- a/progs/tests/arraytexture.c +++ b/progs/tests/arraytexture.c @@ -77,10 +77,6 @@ static GLfloat texZ = 0.0; static GLfloat texZ_dir = 0.01; static GLint num_layers; -static PFNGLBINDPROGRAMARBPROC bind_program; -static PFNGLPROGRAMSTRINGARBPROC program_string; -static PFNGLGENPROGRAMSARBPROC gen_programs; - static void PrintString(const char *s) @@ -125,13 +121,13 @@ static void Display(void) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); glColor3f(1,1,1); glRasterPos3f(-0.9, -0.9, 0.0); sprintf(str, "Texture Z coordinate = %4.1f", texZ); PrintString(str); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 1); GL_CHECK_ERROR(); glEnable(GL_TEXTURE_2D_ARRAY_EXT); GL_CHECK_ERROR(); @@ -159,7 +155,7 @@ static void Display(void) glDisable(GL_TEXTURE_2D_ARRAY_EXT); GL_CHECK_ERROR(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); GL_CHECK_ERROR(); glutSwapBuffers(); @@ -226,8 +222,8 @@ compile_fragment_program(GLuint id, const char *prog) int err; err = glGetError(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id); - (*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, id); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(prog), (const GLubyte *) prog); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); @@ -264,11 +260,6 @@ static void Init(void) require_extension("GL_MESA_texture_array"); require_extension("GL_SGIS_generate_mipmap"); - bind_program = glutGetProcAddress("glBindProgramARB"); - program_string = glutGetProcAddress("glProgramStringARB"); - gen_programs = glutGetProcAddress("glGenProgramsARB"); - - for (num_layers = 0; textures[num_layers] != NULL; num_layers++) /* empty */ ; -- cgit v1.2.3 From 98eb7a14a44f8e5c3c2d2f1418d7d4e4ed0fe5e8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 07:52:26 -0600 Subject: mesa: remove left-over debug printf --- src/mesa/drivers/common/meta.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 21458a7c73..ceb929f694 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -2118,7 +2118,6 @@ _mesa_meta_check_generate_mipmap_fallback(GLcontext *ctx, GLenum target, _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboSave); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { - printf("Can't render\n"); return GL_TRUE; } -- cgit v1.2.3 From 5ba645f0fbcb16ac97064c3d25d5966645410a44 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Oct 2009 16:16:40 +0100 Subject: scons: Disable SSE intrinsics on MinGW. -mstackrealign causes stack corruption on MinGW. And without it the ability to use SSE instrinsics goes down the drain. Even if we use __attribute__((force_align_arg_pointer)) for the functions we explicitly use SSE instrinsics, the SSE code automatically generated by gcc will cause assertion failures. What a nightmare. Thankfully LLVM gets this right, so all runtime generated SSE code just works. rtasm code doesn't assume 16byte alignment. Therefore the bulk of our performance sensitive code is not affected by this. Still, intrinsics can be convenient, and it would be nice to get this working again some day, sp will try to get a reduced test case. --- scons/gallium.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scons/gallium.py b/scons/gallium.py index 38782ac726..587294af71 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -343,10 +343,18 @@ def generate(env): ccflags += [ '-m32', #'-march=pentium4', - '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics - '-mstackrealign', # ensure stack is aligned -- do not enabled -msse without it! #'-mfpmath=sse', ] + if platform != 'windows': + # XXX: -mstackrealign causes stack corruption on MinGW. Ditto + # for -mincoming-stack-boundary=2. Still enable it on other + # platforms for now, but we can't rely on it for cross platform + # code. We have to use __attribute__((force_align_arg_pointer)) + # instead. + ccflags += [ + '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics + '-mstackrealign', # ensure stack is aligned + ] if env['machine'] == 'x86_64': ccflags += ['-m64'] # See also: -- cgit v1.2.3 From 68edb4eac55457796ed5c5e4f1c702af749fd543 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Oct 2009 17:11:08 +0100 Subject: gallium: New ALIGN_STACK macro to tell gcc to align stack pointer. --- src/gallium/include/pipe/p_compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index c13cffceb0..c36286f9be 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -167,11 +167,17 @@ typedef unsigned char boolean; #define ALIGN16_ASSIGN(NAME) NAME##___aligned #define ALIGN16_ATTRIB __attribute__(( aligned( 16 ) )) #define ALIGN8_ATTRIB __attribute__(( aligned( 8 ) )) +#if __GNUC__ > 4 || (__GNUC__ == 4 &&__GNUC_MINOR__>1) +#define ALIGN_STACK __attribute__((force_align_arg_pointer)) +#else +#define ALIGN_STACK +#endif #else #define ALIGN16_DECL(TYPE, NAME, SIZE) TYPE NAME##___unaligned[SIZE + 1] #define ALIGN16_ASSIGN(NAME) align16(NAME##___unaligned) #define ALIGN16_ATTRIB #define ALIGN8_ATTRIB +#define ALIGN_STACK #endif -- cgit v1.2.3 From 4046c3bab4dde95d4096f26637adaa6ce6d310a9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Oct 2009 17:11:30 +0100 Subject: llvmpipe: Use ALIGN_STACK. --- src/gallium/drivers/llvmpipe/lp_setup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index 60107214df..b14c265b7f 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -115,6 +115,7 @@ struct setup_context { /** * Execute fragment shader for the four fragments in the quad. */ +ALIGN_STACK static void shade_quads(struct llvmpipe_context *llvmpipe, struct quad_header *quads[], -- cgit v1.2.3 From 3ce3c03257bccc5f9e8a6caf0f39565a87856eaf Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 14 Oct 2009 17:27:06 +0100 Subject: util: Fix cpu detection on Windows. Cleanup. --- src/gallium/auxiliary/util/u_cpu_detect.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c index ded361ce70..b94390aef9 100644 --- a/src/gallium/auxiliary/util/u_cpu_detect.c +++ b/src/gallium/auxiliary/util/u_cpu_detect.c @@ -397,12 +397,17 @@ util_cpu_detect(void) #endif /* Count the number of CPUs in system */ -#if !defined(PIPE_OS_WINDOWS) && !defined(PIPE_OS_UNKNOWN) && defined(_SC_NPROCESSORS_ONLN) +#if defined(PIPE_OS_WINDOWS) + { + SYSTEM_INFO system_info; + GetSystemInfo(&system_info); + util_cpu_caps.nr_cpus = system_info.dwNumberOfProcessors; + } +#elif defined(PIPE_OS_UNIX) && defined(_SC_NPROCESSORS_ONLN) util_cpu_caps.nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); if (util_cpu_caps.nr_cpus == -1) util_cpu_caps.nr_cpus = 1; - -#elif defined(PIPE_OS_NETBSD) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_OPENBSD) +#elif defined(PIPE_OS_BSD) { int mib[2], ncpu; int len; @@ -469,7 +474,6 @@ util_cpu_detect(void) util_cpu_caps.cacheline = regs2[2] & 0xFF; } -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_FREEBSD) || defined(PIPE_OS_NETBSD) || defined(PIPE_OS_CYGWIN) || defined(PIPE_OS_OPENBSD) if (util_cpu_caps.has_sse) check_os_katmai_support(); @@ -477,13 +481,8 @@ util_cpu_detect(void) util_cpu_caps.has_sse2 = 0; util_cpu_caps.has_sse3 = 0; util_cpu_caps.has_ssse3 = 0; + util_cpu_caps.has_sse4_1 = 0; } -#else - util_cpu_caps.has_sse = 0; - util_cpu_caps.has_sse2 = 0; - util_cpu_caps.has_sse3 = 0; - util_cpu_caps.has_ssse3 = 0; -#endif } #endif /* PIPE_ARCH_X86 || PIPE_ARCH_X86_64 */ -- cgit v1.2.3 From f22c427bd685f55e6f7e29dcd72cdb1aa42f04d9 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 14 Oct 2009 14:18:36 -0400 Subject: r600: enable EXT_vertex_array_bgra extensions --- src/mesa/drivers/dri/r600/r600_context.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 969144ba12..ba0d450cbb 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -131,6 +131,7 @@ const struct dri_extension card_extensions[] = { {"GL_EXT_texture_lod_bias", NULL}, {"GL_EXT_texture_mirror_clamp", NULL}, {"GL_EXT_texture_rectangle", NULL}, + {"GL_EXT_vertex_array_bgra", NULL}, {"GL_EXT_texture_sRGB", NULL}, {"GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions}, {"GL_ATI_texture_env_combine3", NULL}, -- cgit v1.2.3 From 96c9b39a6a9553573fcbdb5fd6db0e9d59768442 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 13 Oct 2009 15:32:04 +0100 Subject: i915g: Fix warnings --- src/gallium/drivers/i915/i915_debug.c | 2 +- src/gallium/drivers/i915/i915_fpc_translate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/i915/i915_debug.c b/src/gallium/drivers/i915/i915_debug.c index ce92d1af9a..e6640e587b 100644 --- a/src/gallium/drivers/i915/i915_debug.c +++ b/src/gallium/drivers/i915/i915_debug.c @@ -880,7 +880,7 @@ i915_dump_batchbuffer( struct intel_batchbuffer *batch ) return; } - debug_printf( "\n\nBATCH: (%d)\n", bytes / 4); + debug_printf( "\n\nBATCH: (%d)\n", (int)bytes / 4); while (!done && stream.offset < bytes) diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c index 89504ced27..1fe5cda956 100644 --- a/src/gallium/drivers/i915/i915_fpc_translate.c +++ b/src/gallium/drivers/i915/i915_fpc_translate.c @@ -127,7 +127,7 @@ i915_program_error(struct i915_fp_compile *p, const char *msg, ...) va_start( args, msg ); util_vsnprintf( buffer, sizeof(buffer), msg, args ); va_end( args ); - debug_printf(buffer); + debug_printf("%s", buffer); debug_printf("\n"); p->error = 1; -- cgit v1.2.3 From 59cf40059a7c451b1d1bc0c90f674e8e4baa5ab8 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sun, 11 Oct 2009 01:07:26 -0400 Subject: st/xorg: get transparency on fills working (fixes Qt/KDE apps) --- src/gallium/state_trackers/xorg/xorg_composite.c | 19 ++++++++++++------- src/gallium/state_trackers/xorg/xorg_renderer.c | 3 +++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 6871625605..b39b39511e 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -40,6 +40,14 @@ static const struct xorg_composite_blend xorg_blends[] = { { PictOpOverReverse, PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpOutReverse, + PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpAdd, + PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, }; @@ -138,7 +146,9 @@ boolean xorg_composite_accelerated(int op, (!accelerated_ops[i].with_mask || (pMaskPicture->componentAlpha && !accelerated_ops[i].component_alpha)))) - XORG_FALLBACK("component alpha unsupported"); + XORG_FALLBACK("component alpha unsupported (PictOpOver=%s(%d)", + (accelerated_ops[i].op == PictOpOver) ? "yes" : "no", + accelerated_ops[i].op); return TRUE; } } @@ -156,10 +166,7 @@ bind_blend_state(struct exa_context *exa, int op, memset(&blend, 0, sizeof(struct pipe_blend_state)); blend.blend_enable = 1; - blend.colormask |= PIPE_MASK_R; - blend.colormask |= PIPE_MASK_G; - blend.colormask |= PIPE_MASK_B; - blend.colormask |= PIPE_MASK_A; + blend.colormask |= PIPE_MASK_RGBA; blend.rgb_src_factor = blend_opt.rgb_src_factor; blend.alpha_src_factor = blend_opt.alpha_src_factor; @@ -346,8 +353,6 @@ boolean xorg_solid_bind_state(struct exa_context *exa, pixel_to_float4(fg, exa->solid_color); exa->has_solid_color = TRUE; - exa->solid_color[3] = 1.f; - #if 0 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", (fg >> 24) & 0xff, (fg >> 16) & 0xff, diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 1eecf7d2b9..81b209cb59 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -681,6 +681,9 @@ void renderer_draw_solid_rect(struct xorg_renderer *r, struct pipe_context *pipe = r->pipe; struct pipe_buffer *buf = 0; + /* + debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n", + x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/ /* 1st vertex */ setup_vertex0(r->vertices2[0], x0, y0, color); /* 2nd vertex */ -- cgit v1.2.3 From 5c4bdbd825934fe01330890d360b61caa06fdc8d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 15 Oct 2009 01:24:53 +0100 Subject: autoconf: Fix case for not having package --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 085f419929..f8b9b53810 100644 --- a/configure.ac +++ b/configure.ac @@ -1152,9 +1152,9 @@ yes) fi if test "$tracker" = xorg; then PKG_CHECK_MODULES(XEXT, [xextproto >= 7.0.99.1], - HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71" + HAVE_XEXTPROTO_71="yes"; DEFINES="$DEFINES -DHAVE_XEXTPROTO_71", HAVE_XEXTPROTO_71="no") - fi + fi done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; -- cgit v1.2.3 From ef067b5f01eb7ea7a08a64d897e0e70e139c618d Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 13 Oct 2009 11:56:35 +0200 Subject: st/xorg: Fix dpms include problems --- src/gallium/state_trackers/xorg/Makefile | 1 - src/gallium/state_trackers/xorg/xorg_crtc.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile index 030bac5fff..27a1990724 100644 --- a/src/gallium/state_trackers/xorg/Makefile +++ b/src/gallium/state_trackers/xorg/Makefile @@ -5,7 +5,6 @@ LIBNAME = xorgtracker LIBRARY_INCLUDES = \ -DHAVE_CONFIG_H \ - -DHAVE_XEXTPROTO_71=1 \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 95973586da..67fe29a69d 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -43,10 +43,10 @@ #include "xf86Modes.h" #ifdef HAVE_XEXTPROTO_71 -#include "X11/extensions/dpmsconst.h" +#include #else #define DPMS_SERVER -#include "X11/extensions/dpmsconst.h" +#include #endif #include "pipe/p_inlines.h" -- cgit v1.2.3 From 9282edfaa0ad24be16f5e395f346ca477050cdf6 Mon Sep 17 00:00:00 2001 From: Tom Fogal Date: Tue, 13 Oct 2009 10:55:33 -0700 Subject: ac: Fix AIX shared library builds. AIX uses ".a" for both static and shared library extensions. --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 75189761ee..44fb77960c 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,8 @@ else LIB_EXTENSION='dylib' ;; cygwin* ) LIB_EXTENSION='dll' ;; + aix* ) + LIB_EXTENSION='a' ;; * ) LIB_EXTENSION='so' ;; esac -- cgit v1.2.3 From 115edf24a9128b79dfa5f30482c990e2cb898357 Mon Sep 17 00:00:00 2001 From: Tom Fogal Date: Tue, 13 Oct 2009 10:55:34 -0700 Subject: Fix build when PROGRAM_DIRS is empty. SUBDIRS just takes PROGRAM_DIRS value. If PROGRAM_DIRS gets set to the empty string (as can happen when building only OSMesa), a 'for' loop will lack anything to iterate over, causing a parse error. This fixes the issue by making sure SUBDIRS is the null string when PROGRAM_DIRS is, and wrapping the for loops in if's, causing them only to execute if there are directories to iterate over. --- progs/Makefile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/progs/Makefile b/progs/Makefile index c99f4eebcc..064e5a232e 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -4,7 +4,7 @@ TOP = .. include $(TOP)/configs/current -SUBDIRS = $(PROGRAM_DIRS) +SUBDIRS ="$(PROGRAM_DIRS)" default: message subdirs @@ -15,18 +15,22 @@ message: subdirs: - @for dir in $(SUBDIRS) ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE)) || exit 1 ; \ - fi \ - done + @if test -n "$(SUBDIRS)" ; then \ + for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1 ; \ + fi \ + done \ + fi # Dummy install target install: clean: - -@for dir in $(SUBDIRS) tests ; do \ - if [ -d $$dir ] ; then \ - (cd $$dir && $(MAKE) clean) ; \ - fi \ - done + -@if test -n "$(SUBDIRS)" ; then \ + for dir in $(SUBDIRS) tests ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE) clean) ; \ + fi \ + done \ + fi -- cgit v1.2.3 From 0187e042b681663938a1a12e9ae03c6f0ab48af5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 15:00:50 -0600 Subject: mesa: remove unused ctx->Driver.TextureMatrix() hook --- src/mesa/drivers/common/driverfuncs.c | 1 - src/mesa/main/dd.h | 1 - src/mesa/main/texstate.c | 7 ------- 3 files changed, 9 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 0f8447cb70..5934907cf0 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -183,7 +183,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->TexGen = NULL; driver->TexEnv = NULL; driver->TexParameter = NULL; - driver->TextureMatrix = NULL; driver->Viewport = NULL; /* vertex arrays */ diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index ce5e158626..a9632ec954 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -717,7 +717,6 @@ struct dd_function_table { void (*TexParameter)(GLcontext *ctx, GLenum target, struct gl_texture_object *texObj, GLenum pname, const GLfloat *params); - void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat); /** Set the viewport */ void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); /*@}*/ diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 43f26873e0..16492bd7bc 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -307,10 +307,6 @@ _mesa_ActiveTextureARB(GLenum texture) /* update current stack pointer */ ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit]; } - - if (ctx->Driver.ActiveTexture) { - (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit ); - } } @@ -360,9 +356,6 @@ update_texture_matrices( GLcontext *ctx ) if (ctx->Texture.Unit[u]._ReallyEnabled && ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY) ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u); - - if (ctx->Driver.TextureMatrix) - ctx->Driver.TextureMatrix( ctx, u, ctx->TextureMatrixStack[u].Top); } } } -- cgit v1.2.3 From 73fc0ca4c36f258c4d0d7707dd3313a685c211bf Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 15:11:12 -0600 Subject: mesa: remove unused ctx->Driver.PrioritizeTextures() hook --- src/mesa/drivers/common/driverfuncs.c | 1 - src/mesa/drivers/dri/mach64/mach64_tex.c | 1 - src/mesa/main/dd.h | 6 ------ src/mesa/main/texobj.c | 2 -- 4 files changed, 10 deletions(-) diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c index 5934907cf0..4d21b033f7 100644 --- a/src/mesa/drivers/common/driverfuncs.c +++ b/src/mesa/drivers/common/driverfuncs.c @@ -125,7 +125,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->UnmapTexture = NULL; driver->TextureMemCpy = _mesa_memcpy; driver->IsTextureResident = NULL; - driver->PrioritizeTexture = NULL; driver->ActiveTexture = NULL; driver->UpdateTexturePalette = NULL; diff --git a/src/mesa/drivers/dri/mach64/mach64_tex.c b/src/mesa/drivers/dri/mach64/mach64_tex.c index 225d23179e..5a22c93bd2 100644 --- a/src/mesa/drivers/dri/mach64/mach64_tex.c +++ b/src/mesa/drivers/dri/mach64/mach64_tex.c @@ -567,7 +567,6 @@ void mach64InitTextureFuncs( struct dd_function_table *functions ) functions->UpdateTexturePalette = NULL; functions->ActiveTexture = NULL; - functions->PrioritizeTexture = NULL; driInitTextureFormats(); } diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h index a9632ec954..25aaddea81 100644 --- a/src/mesa/main/dd.h +++ b/src/mesa/main/dd.h @@ -544,12 +544,6 @@ struct dd_function_table { GLboolean (*IsTextureResident)( GLcontext *ctx, struct gl_texture_object *t ); - /** - * Called by glPrioritizeTextures(). - */ - void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t, - GLclampf priority ); - /** * Called by glActiveTextureARB() to set current texture unit. */ diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 8fd5eaa266..31832184c0 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -1098,8 +1098,6 @@ _mesa_PrioritizeTextures( GLsizei n, const GLuint *texName, struct gl_texture_object *t = _mesa_lookup_texture(ctx, texName[i]); if (t) { t->Priority = CLAMP( priorities[i], 0.0F, 1.0F ); - if (ctx->Driver.PrioritizeTexture) - ctx->Driver.PrioritizeTexture( ctx, t, t->Priority ); } } } -- cgit v1.2.3 From d9099f8602eb6d15e9fc2e0b0987e7a58fb98b68 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 15:46:25 -0600 Subject: mesa: rename VERBOSE_IMMEDIATE->VERBOSE_MATERIAL to reflect what it does --- src/mesa/main/debug.c | 2 +- src/mesa/main/light.c | 2 +- src/mesa/main/mtypes.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 8492c8561d..530170b526 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -167,7 +167,7 @@ static void add_debug_flags( const char *debug ) static const struct debug_option debug_opt[] = { { "varray", VERBOSE_VARRAY }, { "tex", VERBOSE_TEXTURE }, - { "imm", VERBOSE_IMMEDIATE }, + { "mat", VERBOSE_MATERIAL }, { "pipe", VERBOSE_PIPELINE }, { "driver", VERBOSE_DRIVER }, { "state", VERBOSE_STATE }, diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 10c89f4368..1c8a081e9a 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -636,7 +636,7 @@ _mesa_update_material( GLcontext *ctx, GLuint bitmask ) struct gl_light *light, *list = &ctx->Light.EnabledList; GLfloat (*mat)[4] = ctx->Light.Material.Attrib; - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) + if (MESA_VERBOSE & VERBOSE_MATERIAL) _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask); if (!bitmask) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a1184df281..f0f21f633f 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3099,7 +3099,7 @@ enum _verbose { VERBOSE_VARRAY = 0x0001, VERBOSE_TEXTURE = 0x0002, - VERBOSE_IMMEDIATE = 0x0004, + VERBOSE_MATERIAL = 0x0004, VERBOSE_PIPELINE = 0x0008, VERBOSE_DRIVER = 0x0010, VERBOSE_STATE = 0x0020, -- cgit v1.2.3 From ade1cc992410c8696fdfe0f84fb613fd0dc8099f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 16:23:22 -0600 Subject: mesa: added MESA_VERBOSE option 'draw' to debug glDrawArrays/Elements, etc. --- src/mesa/main/debug.c | 3 ++- src/mesa/main/mtypes.h | 3 +++ src/mesa/vbo/vbo_exec_array.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 530170b526..07ed51f5ab 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -174,7 +174,8 @@ static void add_debug_flags( const char *debug ) { "api", VERBOSE_API }, { "list", VERBOSE_DISPLAY_LIST }, { "lighting", VERBOSE_LIGHTING }, - { "disassem", VERBOSE_DISASSEM } + { "disassem", VERBOSE_DISASSEM }, + { "draw", VERBOSE_DRAW } }; GLuint i; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index f0f21f633f..5699db5d4a 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3095,6 +3095,7 @@ extern int MESA_DEBUG_FLAGS; #endif +/** The MESA_VERBOSE var is a bitmask of these flags */ enum _verbose { VERBOSE_VARRAY = 0x0001, @@ -3109,9 +3110,11 @@ enum _verbose VERBOSE_PRIMS = 0x0400, VERBOSE_VERTS = 0x0800, VERBOSE_DISASSEM = 0x1000, + VERBOSE_DRAW = 0x2000 }; +/** The MESA_DEBUG_FLAGS var is a bitmask of these flags */ enum _debug { DEBUG_ALWAYS_FLUSH = 0x1 diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 774cffc451..0e1737c210 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -33,6 +33,7 @@ #include "main/api_noop.h" #include "main/varray.h" #include "main/bufferobj.h" +#include "main/enums.h" #include "main/macros.h" #include "glapi/dispatch.h" @@ -482,6 +483,10 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) struct vbo_exec_context *exec = &vbo->exec; struct _mesa_prim prim[1]; + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawArrays(%s, %d, %d)\n", + _mesa_lookup_enum_by_nr(mode), start, count); + if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) return; @@ -675,6 +680,12 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, static GLuint warnCount = 0; GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, + "glDrawRangeElementsBaseVertex(%s, %u, %u, %d, %s, %p, %d)\n", + _mesa_lookup_enum_by_nr(mode), start, end, count, + _mesa_lookup_enum_by_nr(type), indices, basevertex); + if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices, basevertex )) return; @@ -761,6 +772,14 @@ vbo_exec_DrawRangeElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) { + GET_CURRENT_CONTEXT(ctx); + + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, + "glDrawRangeElements(%s, %u, %u, %d, %s, %p)\n", + _mesa_lookup_enum_by_nr(mode), start, end, count, + _mesa_lookup_enum_by_nr(type), indices); + vbo_exec_DrawRangeElementsBaseVertex(mode, start, end, count, type, indices, 0); } @@ -772,6 +791,11 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, { GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawElements(%s, %u, %s, %p)\n", + _mesa_lookup_enum_by_nr(mode), count, + _mesa_lookup_enum_by_nr(type), indices); + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) return; @@ -785,6 +809,11 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, { GET_CURRENT_CONTEXT(ctx); + if (MESA_VERBOSE & VERBOSE_DRAW) + _mesa_debug(ctx, "glDrawElementsBaseVertex(%s, %d, %s, %p, %d)\n", + _mesa_lookup_enum_by_nr(mode), count, + _mesa_lookup_enum_by_nr(type), indices, basevertex); + if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, basevertex )) return; -- cgit v1.2.3 From f9784072fee016e14e0319c705420becb2490bf9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 16:23:52 -0600 Subject: vbo: clean-ups, reformatting --- src/mesa/vbo/vbo_exec_array.c | 49 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index 0e1737c210..fd70b57b72 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -54,10 +54,9 @@ vbo_get_minmax_index(GLcontext *ctx, const void *indices; if (_mesa_is_bufferobj(ib->obj)) { - const GLvoid *map = ctx->Driver.MapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - ib->obj); + const GLvoid *map = + ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, + GL_READ_ONLY, ib->obj); indices = ADD_POINTERS(map, ib->ptr); } else { indices = ib->ptr; @@ -106,9 +105,7 @@ vbo_get_minmax_index(GLcontext *ctx, } if (_mesa_is_bufferobj(ib->obj)) { - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, - ib->obj); + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ib->obj); } } @@ -126,10 +123,9 @@ check_array_data(GLcontext *ctx, struct gl_client_array *array, if (_mesa_is_bufferobj(array->BufferObj)) { if (!array->BufferObj->Pointer) { /* need to map now */ - array->BufferObj->Pointer = ctx->Driver.MapBuffer(ctx, - GL_ARRAY_BUFFER_ARB, - GL_READ_ONLY, - array->BufferObj); + array->BufferObj->Pointer = + ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER_ARB, + GL_READ_ONLY, array->BufferObj); } data = ADD_POINTERS(data, array->BufferObj->Pointer); } @@ -170,9 +166,7 @@ unmap_array_buffer(GLcontext *ctx, struct gl_client_array *array) if (array->Enabled && _mesa_is_bufferobj(array->BufferObj) && _mesa_bufferobj_mapped(array->BufferObj)) { - ctx->Driver.UnmapBuffer(ctx, - GL_ARRAY_BUFFER_ARB, - array->BufferObj); + ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB, array->BufferObj); } } @@ -223,13 +217,13 @@ check_draw_elements_data(GLcontext *ctx, GLsizei count, GLenum elemType, check_array_data(ctx, &arrayObj->TexCoord[k], VERT_ATTRIB_TEX0 + k, j); } for (k = 0; k < Elements(arrayObj->VertexAttrib); k++) { - check_array_data(ctx, &arrayObj->VertexAttrib[k], VERT_ATTRIB_GENERIC0 + k, j); + check_array_data(ctx, &arrayObj->VertexAttrib[k], + VERT_ATTRIB_GENERIC0 + k, j); } } if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) { - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ctx->Array.ElementArrayBufferObj); } @@ -460,7 +454,6 @@ bind_arrays(GLcontext *ctx) } else if (exec->array.program_mode != get_program_mode(ctx) || exec->array.enabled_flags != ctx->Array.ArrayObj->_Enabled) { - recalculate_input_bindings(ctx); } #else @@ -587,11 +580,11 @@ dump_element_buffer(GLcontext *ctx, GLenum type) ; } - ctx->Driver.UnmapBuffer(ctx, - GL_ELEMENT_ARRAY_BUFFER_ARB, + ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER_ARB, ctx->Array.ElementArrayBufferObj); } + /* Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */ static void vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode, @@ -766,11 +759,10 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, count, type, indices, basevertex); } + static void GLAPIENTRY -vbo_exec_DrawRangeElements(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices) +vbo_exec_DrawRangeElements(GLenum mode, GLuint start, GLuint end, + GLsizei count, GLenum type, const GLvoid *indices) { GET_CURRENT_CONTEXT(ctx); @@ -803,6 +795,7 @@ vbo_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, count, type, indices, 0); } + static void GLAPIENTRY vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex) @@ -822,7 +815,8 @@ vbo_exec_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, count, type, indices, basevertex); } -/* Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */ + +/** Inner support for both _mesa_DrawElements and _mesa_DrawRangeElements */ static void vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, const GLsizei *count, GLenum type, @@ -957,6 +951,7 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, _mesa_free(prim); } + static void GLAPIENTRY vbo_exec_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, @@ -978,6 +973,7 @@ vbo_exec_MultiDrawElements(GLenum mode, NULL); } + static void GLAPIENTRY vbo_exec_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, GLenum type, @@ -1067,6 +1063,7 @@ _mesa_DrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, vbo_exec_DrawRangeElements(mode, start, end, count, type, indices); } + void GLAPIENTRY _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, @@ -1076,6 +1073,7 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, indices, basevertex); } + /* GL_EXT_multi_draw_arrays */ void GLAPIENTRY _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, @@ -1084,6 +1082,7 @@ _mesa_MultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, vbo_exec_MultiDrawElements(mode, count, type, indices, primcount); } + void GLAPIENTRY _mesa_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, GLenum type, -- cgit v1.2.3 From 2fd5cb713338e91999a036399a4bea4406687ca0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 16:24:35 -0600 Subject: mesa: added VERBOSE_SWAPBUFFERS --- src/mesa/main/context.c | 2 ++ src/mesa/main/debug.c | 3 ++- src/mesa/main/mtypes.h | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 95ff3495ab..ea1ee22812 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -173,6 +173,8 @@ GLfloat _mesa_ubyte_to_float_color_tab[256]; void _mesa_notifySwapBuffers(__GLcontext *ctx) { + if (MESA_VERBOSE & VERBOSE_SWAPBUFFERS) + _mesa_debug(ctx, "SwapBuffers\n"); FLUSH_CURRENT( ctx, 0 ); if (ctx->Driver.Flush) { ctx->Driver.Flush(ctx); diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 07ed51f5ab..490cc9c26b 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -175,7 +175,8 @@ static void add_debug_flags( const char *debug ) { "list", VERBOSE_DISPLAY_LIST }, { "lighting", VERBOSE_LIGHTING }, { "disassem", VERBOSE_DISASSEM }, - { "draw", VERBOSE_DRAW } + { "draw", VERBOSE_DRAW }, + { "swap", VERBOSE_SWAPBUFFERS } }; GLuint i; diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5699db5d4a..988bfe1e22 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3110,7 +3110,8 @@ enum _verbose VERBOSE_PRIMS = 0x0400, VERBOSE_VERTS = 0x0800, VERBOSE_DISASSEM = 0x1000, - VERBOSE_DRAW = 0x2000 + VERBOSE_DRAW = 0x2000, + VERBOSE_SWAPBUFFERS = 0x4000 }; -- cgit v1.2.3 From 24e2f61469a4915ca4aba431cbe4634293cbe92e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 10:56:29 -0600 Subject: mesa: assorted top-level Makefile clean-ups --- Makefile | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 413a1b4372..7f073fd516 100644 --- a/Makefile +++ b/Makefile @@ -505,9 +505,11 @@ rm_depend: touch $$dep ; \ done -lib_gz: - rm -f configs/current ; \ - rm -f configs/autoconf ; \ +rm_config: + rm -f configs/current + rm -f configs/autoconf + +lib_gz: rm_config cd .. ; \ tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \ gzip $(LIB_NAME).tar ; \ @@ -525,9 +527,7 @@ glut_gz: gzip $(GLUT_NAME).tar ; \ mv $(GLUT_NAME).tar.gz $(DIRECTORY) -lib_bz2: - rm -f configs/current ; \ - rm -f configs/autoconf ; \ +lib_bz2: rm_config cd .. ; \ tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \ bzip2 $(LIB_NAME).tar ; \ @@ -545,9 +545,7 @@ glut_bz2: bzip2 $(GLUT_NAME).tar ; \ mv $(GLUT_NAME).tar.bz2 $(DIRECTORY) -lib_zip: - rm -f configs/current ; \ - rm -f configs/autoconf ; \ +lib_zip: rm_config rm -f $(LIB_NAME).zip ; \ cd .. ; \ zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \ @@ -576,5 +574,7 @@ md5: @-md5sum $(GLUT_NAME).tar.bz2 @-md5sum $(GLUT_NAME).zip -.PHONY: tarballs rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 \ - glut_bz2 lib_zip demo_zip glut_zip md5 +.PHONY: tarballs rm_depend rm_config md5 \ + lib_gz demo_gz glut_gz \ + lib_bz2 demo_bz2 glut_bz2 \ + lib_zip demo_zip glut_zip -- cgit v1.2.3 From 85fb3e402744bbfd67ca9c79c98f54dd8ad169f5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 11:28:28 -0600 Subject: docs: document more MESA_GLSL env var options --- docs/envvars.html | 1 + docs/shading.html | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/envvars.html b/docs/envvars.html index 6d7a321da9..b2c0e01ee3 100644 --- a/docs/envvars.html +++ b/docs/envvars.html @@ -28,6 +28,7 @@ Setting this variable automatically sets the MESA_TEX_PROG variable as well.
  • MESA_EXTENSION_OVERRIDE - can be used to enable/disable extensions. A value such as "GL_EXT_foo -GL_EXT_bar" will enable the GL_EXT_foo extension and disable the GL_EXT_bar extension. +
  • MESA_GLSL - shading language options

    diff --git a/docs/shading.html b/docs/shading.html index 77c86be3aa..96060f1a75 100644 --- a/docs/shading.html +++ b/docs/shading.html @@ -39,7 +39,8 @@ Contents

    The MESA_GLSL environment variable can be set to a comma-separated -list of keywords to control some aspects of the GLSL compiler: +list of keywords to control some aspects of the GLSL compiler and shader +execution. These are generally used for debugging.

    • dump - print GLSL shader code to stdout at link time @@ -49,6 +50,11 @@ list of keywords to control some aspects of the GLSL compiler:
    • nopt - disable compiler optimizations
    • opt - force compiler optimizations
    • uniform - print message to stdout when glUniform is called +
    • nopvert - force vertex shaders to be a simple shader that just transforms + the vertex position with ftransform() and passes through the color and + texcoord[0] attributes. +
    • nopfrag - force fragment shader to be a simple shader that passes + through the color attribute.

    Example: export MESA_GLSL=dump,nopt -- cgit v1.2.3 From 91bd87c06ee5427887e1284bd52424387e54397f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 19:13:32 -0600 Subject: progs/demos: try different depth formats in fbo_firecube.c --- progs/demos/fbo_firecube.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/progs/demos/fbo_firecube.c b/progs/demos/fbo_firecube.c index 4e42924a09..b3f7e00e5a 100644 --- a/progs/demos/fbo_firecube.c +++ b/progs/demos/fbo_firecube.c @@ -938,7 +938,14 @@ reshape(int width, int height) static void init_fbotexture() { + static const GLenum depthFormats[] = { + GL_DEPTH_COMPONENT, + GL_DEPTH_COMPONENT16, + GL_DEPTH_COMPONENT32 + }; + static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]); GLint i; + GLenum stat; /* gen framebuffer id, delete it, do some assertions, just for testing */ glGenFramebuffersEXT(1, &MyFB); @@ -969,18 +976,31 @@ init_fbotexture() /* make depth renderbuffer */ glGenRenderbuffersEXT(1, &DepthRB); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, - TexWidth, TexHeight); - CheckError(__LINE__); + /* we may have to try several formats */ + for (i = 0; i < numDepthFormats; i++) { + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i], + TexWidth, TexHeight); + CheckError(__LINE__); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, DepthRB); + CheckError(__LINE__); + stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) { + break; + } + } + + if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) { + fprintf(stderr, "Error: unable to get usable FBO combination!\n"); + exit(1); + } + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, - GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i); + GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i); CheckError(__LINE__); printf("Depth renderbuffer size = %d bits\n", i); - /* attach DepthRB to MyFB */ - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, - GL_RENDERBUFFER_EXT, DepthRB); - CheckError(__LINE__); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); /* -- cgit v1.2.3 From a82fc97c643c4309a10cfefb108c4c0f11a2e55a Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 14 Oct 2009 20:06:38 -0700 Subject: r300g: Move ZTOP to its own state atom. It may seem pointless, but this avoids a fair amount of predicted CSO pain. --- src/gallium/drivers/r300/r300_context.h | 8 +++++++- src/gallium/drivers/r300/r300_emit.c | 2 +- src/gallium/drivers/r300/r300_state_derived.c | 8 ++++---- src/gallium/drivers/r300/r300_surface.h | 1 - 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index d2e8875503..2acce0fd4a 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -62,7 +62,6 @@ struct r300_dsa_state { uint32_t z_buffer_control; /* R300_ZB_CNTL: 0x4f00 */ uint32_t z_stencil_control; /* R300_ZB_ZSTENCILCNTL: 0x4f04 */ uint32_t stencil_ref_mask; /* R300_ZB_STENCILREFMASK: 0x4f08 */ - uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */ uint32_t stencil_ref_bf; /* R500_ZB_STENCILREFMASK_BF: 0x4fd4 */ }; @@ -124,6 +123,10 @@ struct r300_viewport_state { uint32_t vte_control; /* R300_VAP_VTE_CNTL: 0x20b0 */ }; +struct r300_ztop_state { + uint32_t z_buffer_top; /* R300_ZB_ZTOP: 0x4f14 */ +}; + #define R300_NEW_BLEND 0x00000001 #define R300_NEW_BLEND_COLOR 0x00000002 #define R300_NEW_CLIP 0x00000004 @@ -281,6 +284,9 @@ struct r300_context { struct r300_vertex_shader* vs; /* Viewport state. */ struct r300_viewport_state* viewport_state; + /* ZTOP state. */ + struct r300_ztop_state ztop_state; + /* 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_emit.c b/src/gallium/drivers/r300/r300_emit.c index feffadd0ee..2c3bba952d 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -106,7 +106,7 @@ void r300_emit_dsa_state(struct r300_context* r300, OUT_CS(dsa->z_buffer_control); OUT_CS(dsa->z_stencil_control); OUT_CS(dsa->stencil_ref_mask); - OUT_CS_REG(R300_ZB_ZTOP, dsa->z_buffer_top); + OUT_CS_REG(R300_ZB_ZTOP, r300->ztop_state.z_buffer_top); if (r300screen->caps->is_r500) { /* OUT_CS_REG(R500_ZB_STENCILREFMASK_BF, dsa->stencil_ref_bf); */ } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 5d323a26b1..f0861a9cf1 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -446,7 +446,7 @@ static void r300_update_rs_block(struct r300_context* r300) static void r300_update_ztop(struct r300_context* r300) { - r300->dsa_state->z_buffer_top = R300_ZTOP_ENABLE; + r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE; /* This is important enough that I felt it warranted a comment. * @@ -467,11 +467,11 @@ static void r300_update_ztop(struct r300_context* r300) * ~C. */ if (r300->dsa_state->alpha_function) { - r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; } else if (r300_fragment_shader_writes_depth(r300->fs)) { - r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; } else if (r300->query_current) { - r300->dsa_state->z_buffer_top = R300_ZTOP_DISABLE; + r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; } } diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h index f9e98b2ec9..d5998e6e6d 100644 --- a/src/gallium/drivers/r300/r300_surface.h +++ b/src/gallium/drivers/r300/r300_surface.h @@ -54,7 +54,6 @@ static struct r300_dsa_state dsa_clear_state = { .z_buffer_control = 0x0, .z_stencil_control = 0x0, .stencil_ref_mask = R300_STENCILWRITEMASK_MASK, - .z_buffer_top = R300_ZTOP_ENABLE, .stencil_ref_bf = 0x0, }; -- cgit v1.2.3 From 074e069910c7082620be4211fe5496365f828886 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sun, 11 Oct 2009 06:08:42 -0400 Subject: st/xorg: fix most of the composition modes --- src/gallium/state_trackers/xorg/xorg_composite.c | 40 +++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index b39b39511e..b07192175e 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -22,7 +22,7 @@ struct xorg_composite_blend { #define BLEND_OP_OVER 3 static const struct xorg_composite_blend xorg_blends[] = { { PictOpClear, - PIPE_BLENDFACTOR_CONST_COLOR, PIPE_BLENDFACTOR_CONST_ALPHA, + PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO }, { PictOpSrc, @@ -34,20 +34,44 @@ static const struct xorg_composite_blend xorg_blends[] = { PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE }, { PictOpOver, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, { PictOpOverReverse, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpIn, + PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpInReverse, + PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE }, + + { PictOpOut, + PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, { PictOpOutReverse, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - { PictOpAdd, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, + { PictOpAtop, + PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpAtopReverse, + PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, + + { PictOpXor, + PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_ONE }, + + { PictOpAdd, + PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE }, }; @@ -164,7 +188,7 @@ bind_blend_state(struct exa_context *exa, int op, blend_opt = blend_for_op(op); - memset(&blend, 0, sizeof(struct pipe_blend_state)); + memset(&blend, 0, sizeof(struct pipe_blend_state)); blend.blend_enable = 1; blend.colormask |= PIPE_MASK_RGBA; -- cgit v1.2.3 From 72fd1cf292937565a182b400595816c6ad88836a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Wed, 14 Oct 2009 11:44:09 +0200 Subject: trace: Handle transfer returning null --- src/gallium/drivers/trace/tr_screen.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index ab605c7fc8..7da9bd3866 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -366,7 +366,8 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen, trace_dump_call_end(); - result = trace_transfer_create(tr_tex, result); + if (result) + result = trace_transfer_create(tr_tex, result); return result; } -- cgit v1.2.3 From 31f7e8efb25a77e3bdfb6e9850cf31e339060976 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 09:37:40 -0600 Subject: progs/Makefile: remove extra quoting This reverts part of commit 115edf24a9128b79dfa5f30482c990e2cb898357 and fixes the error: "/bin/sh: line 0: test: too many arguments". --- progs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/Makefile b/progs/Makefile index 064e5a232e..3700707dfb 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -4,7 +4,7 @@ TOP = .. include $(TOP)/configs/current -SUBDIRS ="$(PROGRAM_DIRS)" +SUBDIRS = $(PROGRAM_DIRS) default: message subdirs -- cgit v1.2.3 From 269f16cd96fdbee5d178130171b4ef40258f61cf Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 14 Oct 2009 23:25:04 +0100 Subject: mesa: Use _mesa_strtod in the lexer for assembly shaders See bug 24531. --- src/mesa/shader/program_lexer.l | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index d240217481..c2803ff707 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -22,6 +22,7 @@ * DEALINGS IN THE SOFTWARE. */ #include "main/glheader.h" +#include "main/imports.h" #include "prog_instruction.h" #include "prog_statevars.h" @@ -318,19 +319,19 @@ ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require return INTEGER; } {num}?{frac}{exp}? { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } {num}"."/[^.] { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } {num}{exp} { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } {num}"."{exp} { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } -- cgit v1.2.3 From 6f8b4d9e3625c7de83247596fd6822227da04336 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 15 Oct 2009 08:59:13 -0600 Subject: mesa: regenerated lex.yy.c w/ _mesa_strtod() --- src/mesa/shader/lex.yy.c | 385 ++++++++++++++++++++++++----------------------- 1 file changed, 193 insertions(+), 192 deletions(-) diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index 709426f3a6..fefef573ee 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -900,6 +900,7 @@ static yyconst flex_int16_t yy_chk[1023] = * DEALINGS IN THE SOFTWARE. */ #include "main/glheader.h" +#include "main/imports.h" #include "prog_instruction.h" #include "prog_statevars.h" @@ -1003,7 +1004,7 @@ swiz_from_char(char c) } while(0); #define YY_EXTRA_TYPE struct asm_parser_state * -#line 1007 "lex.yy.c" +#line 1008 "lex.yy.c" #define INITIAL 0 @@ -1244,10 +1245,10 @@ YY_DECL register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 136 "program_lexer.l" +#line 137 "program_lexer.l" -#line 1251 "lex.yy.c" +#line 1252 "lex.yy.c" yylval = yylval_param; @@ -1336,17 +1337,17 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 138 "program_lexer.l" +#line 139 "program_lexer.l" { return ARBvp_10; } YY_BREAK case 2: YY_RULE_SETUP -#line 139 "program_lexer.l" +#line 140 "program_lexer.l" { return ARBfp_10; } YY_BREAK case 3: YY_RULE_SETUP -#line 140 "program_lexer.l" +#line 141 "program_lexer.l" { yylval->integer = at_address; return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); @@ -1354,747 +1355,747 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 144 "program_lexer.l" +#line 145 "program_lexer.l" { return ALIAS; } YY_BREAK case 5: YY_RULE_SETUP -#line 145 "program_lexer.l" +#line 146 "program_lexer.l" { return ATTRIB; } YY_BREAK case 6: YY_RULE_SETUP -#line 146 "program_lexer.l" +#line 147 "program_lexer.l" { return END; } YY_BREAK case 7: YY_RULE_SETUP -#line 147 "program_lexer.l" +#line 148 "program_lexer.l" { return OPTION; } YY_BREAK case 8: YY_RULE_SETUP -#line 148 "program_lexer.l" +#line 149 "program_lexer.l" { return OUTPUT; } YY_BREAK case 9: YY_RULE_SETUP -#line 149 "program_lexer.l" +#line 150 "program_lexer.l" { return PARAM; } YY_BREAK case 10: YY_RULE_SETUP -#line 150 "program_lexer.l" +#line 151 "program_lexer.l" { yylval->integer = at_temp; return TEMP; } YY_BREAK case 11: YY_RULE_SETUP -#line 152 "program_lexer.l" +#line 153 "program_lexer.l" { return_opcode( 1, VECTOR_OP, ABS, OFF); } YY_BREAK case 12: YY_RULE_SETUP -#line 153 "program_lexer.l" +#line 154 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, ABS, ZERO_ONE); } YY_BREAK case 13: YY_RULE_SETUP -#line 154 "program_lexer.l" +#line 155 "program_lexer.l" { return_opcode( 1, BIN_OP, ADD, OFF); } YY_BREAK case 14: YY_RULE_SETUP -#line 155 "program_lexer.l" +#line 156 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, ADD, ZERO_ONE); } YY_BREAK case 15: YY_RULE_SETUP -#line 156 "program_lexer.l" +#line 157 "program_lexer.l" { return_opcode(require_ARB_vp, ARL, ARL, OFF); } YY_BREAK case 16: YY_RULE_SETUP -#line 158 "program_lexer.l" +#line 159 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, OFF); } YY_BREAK case 17: YY_RULE_SETUP -#line 159 "program_lexer.l" +#line 160 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, CMP, ZERO_ONE); } YY_BREAK case 18: YY_RULE_SETUP -#line 160 "program_lexer.l" +#line 161 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, OFF); } YY_BREAK case 19: YY_RULE_SETUP -#line 161 "program_lexer.l" +#line 162 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, COS, ZERO_ONE); } YY_BREAK case 20: YY_RULE_SETUP -#line 163 "program_lexer.l" +#line 164 "program_lexer.l" { return_opcode( 1, BIN_OP, DP3, OFF); } YY_BREAK case 21: YY_RULE_SETUP -#line 164 "program_lexer.l" +#line 165 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP3, ZERO_ONE); } YY_BREAK case 22: YY_RULE_SETUP -#line 165 "program_lexer.l" +#line 166 "program_lexer.l" { return_opcode( 1, BIN_OP, DP4, OFF); } YY_BREAK case 23: YY_RULE_SETUP -#line 166 "program_lexer.l" +#line 167 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DP4, ZERO_ONE); } YY_BREAK case 24: YY_RULE_SETUP -#line 167 "program_lexer.l" +#line 168 "program_lexer.l" { return_opcode( 1, BIN_OP, DPH, OFF); } YY_BREAK case 25: YY_RULE_SETUP -#line 168 "program_lexer.l" +#line 169 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DPH, ZERO_ONE); } YY_BREAK case 26: YY_RULE_SETUP -#line 169 "program_lexer.l" +#line 170 "program_lexer.l" { return_opcode( 1, BIN_OP, DST, OFF); } YY_BREAK case 27: YY_RULE_SETUP -#line 170 "program_lexer.l" +#line 171 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, DST, ZERO_ONE); } YY_BREAK case 28: YY_RULE_SETUP -#line 172 "program_lexer.l" +#line 173 "program_lexer.l" { return_opcode( 1, SCALAR_OP, EX2, OFF); } YY_BREAK case 29: YY_RULE_SETUP -#line 173 "program_lexer.l" +#line 174 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, EX2, ZERO_ONE); } YY_BREAK case 30: YY_RULE_SETUP -#line 174 "program_lexer.l" +#line 175 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, EXP, OFF); } YY_BREAK case 31: YY_RULE_SETUP -#line 176 "program_lexer.l" +#line 177 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FLR, OFF); } YY_BREAK case 32: YY_RULE_SETUP -#line 177 "program_lexer.l" +#line 178 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FLR, ZERO_ONE); } YY_BREAK case 33: YY_RULE_SETUP -#line 178 "program_lexer.l" +#line 179 "program_lexer.l" { return_opcode( 1, VECTOR_OP, FRC, OFF); } YY_BREAK case 34: YY_RULE_SETUP -#line 179 "program_lexer.l" +#line 180 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, FRC, ZERO_ONE); } YY_BREAK case 35: YY_RULE_SETUP -#line 181 "program_lexer.l" +#line 182 "program_lexer.l" { return_opcode(require_ARB_fp, KIL, KIL, OFF); } YY_BREAK case 36: YY_RULE_SETUP -#line 183 "program_lexer.l" +#line 184 "program_lexer.l" { return_opcode( 1, VECTOR_OP, LIT, OFF); } YY_BREAK case 37: YY_RULE_SETUP -#line 184 "program_lexer.l" +#line 185 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, LIT, ZERO_ONE); } YY_BREAK case 38: YY_RULE_SETUP -#line 185 "program_lexer.l" +#line 186 "program_lexer.l" { return_opcode( 1, SCALAR_OP, LG2, OFF); } YY_BREAK case 39: YY_RULE_SETUP -#line 186 "program_lexer.l" +#line 187 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, LG2, ZERO_ONE); } YY_BREAK case 40: YY_RULE_SETUP -#line 187 "program_lexer.l" +#line 188 "program_lexer.l" { return_opcode(require_ARB_vp, SCALAR_OP, LOG, OFF); } YY_BREAK case 41: YY_RULE_SETUP -#line 188 "program_lexer.l" +#line 189 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, OFF); } YY_BREAK case 42: YY_RULE_SETUP -#line 189 "program_lexer.l" +#line 190 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, LRP, ZERO_ONE); } YY_BREAK case 43: YY_RULE_SETUP -#line 191 "program_lexer.l" +#line 192 "program_lexer.l" { return_opcode( 1, TRI_OP, MAD, OFF); } YY_BREAK case 44: YY_RULE_SETUP -#line 192 "program_lexer.l" +#line 193 "program_lexer.l" { return_opcode(require_ARB_fp, TRI_OP, MAD, ZERO_ONE); } YY_BREAK case 45: YY_RULE_SETUP -#line 193 "program_lexer.l" +#line 194 "program_lexer.l" { return_opcode( 1, BIN_OP, MAX, OFF); } YY_BREAK case 46: YY_RULE_SETUP -#line 194 "program_lexer.l" +#line 195 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MAX, ZERO_ONE); } YY_BREAK case 47: YY_RULE_SETUP -#line 195 "program_lexer.l" +#line 196 "program_lexer.l" { return_opcode( 1, BIN_OP, MIN, OFF); } YY_BREAK case 48: YY_RULE_SETUP -#line 196 "program_lexer.l" +#line 197 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MIN, ZERO_ONE); } YY_BREAK case 49: YY_RULE_SETUP -#line 197 "program_lexer.l" +#line 198 "program_lexer.l" { return_opcode( 1, VECTOR_OP, MOV, OFF); } YY_BREAK case 50: YY_RULE_SETUP -#line 198 "program_lexer.l" +#line 199 "program_lexer.l" { return_opcode(require_ARB_fp, VECTOR_OP, MOV, ZERO_ONE); } YY_BREAK case 51: YY_RULE_SETUP -#line 199 "program_lexer.l" +#line 200 "program_lexer.l" { return_opcode( 1, BIN_OP, MUL, OFF); } YY_BREAK case 52: YY_RULE_SETUP -#line 200 "program_lexer.l" +#line 201 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, MUL, ZERO_ONE); } YY_BREAK case 53: YY_RULE_SETUP -#line 202 "program_lexer.l" +#line 203 "program_lexer.l" { return_opcode( 1, BINSC_OP, POW, OFF); } YY_BREAK case 54: YY_RULE_SETUP -#line 203 "program_lexer.l" +#line 204 "program_lexer.l" { return_opcode(require_ARB_fp, BINSC_OP, POW, ZERO_ONE); } YY_BREAK case 55: YY_RULE_SETUP -#line 205 "program_lexer.l" +#line 206 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RCP, OFF); } YY_BREAK case 56: YY_RULE_SETUP -#line 206 "program_lexer.l" +#line 207 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RCP, ZERO_ONE); } YY_BREAK case 57: YY_RULE_SETUP -#line 207 "program_lexer.l" +#line 208 "program_lexer.l" { return_opcode( 1, SCALAR_OP, RSQ, OFF); } YY_BREAK case 58: YY_RULE_SETUP -#line 208 "program_lexer.l" +#line 209 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, RSQ, ZERO_ONE); } YY_BREAK case 59: YY_RULE_SETUP -#line 210 "program_lexer.l" +#line 211 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, OFF); } YY_BREAK case 60: YY_RULE_SETUP -#line 211 "program_lexer.l" +#line 212 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SCS, ZERO_ONE); } YY_BREAK case 61: YY_RULE_SETUP -#line 212 "program_lexer.l" +#line 213 "program_lexer.l" { return_opcode( 1, BIN_OP, SGE, OFF); } YY_BREAK case 62: YY_RULE_SETUP -#line 213 "program_lexer.l" +#line 214 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SGE, ZERO_ONE); } YY_BREAK case 63: YY_RULE_SETUP -#line 214 "program_lexer.l" +#line 215 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, OFF); } YY_BREAK case 64: YY_RULE_SETUP -#line 215 "program_lexer.l" +#line 216 "program_lexer.l" { return_opcode(require_ARB_fp, SCALAR_OP, SIN, ZERO_ONE); } YY_BREAK case 65: YY_RULE_SETUP -#line 216 "program_lexer.l" +#line 217 "program_lexer.l" { return_opcode( 1, BIN_OP, SLT, OFF); } YY_BREAK case 66: YY_RULE_SETUP -#line 217 "program_lexer.l" +#line 218 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SLT, ZERO_ONE); } YY_BREAK case 67: YY_RULE_SETUP -#line 218 "program_lexer.l" +#line 219 "program_lexer.l" { return_opcode( 1, BIN_OP, SUB, OFF); } YY_BREAK case 68: YY_RULE_SETUP -#line 219 "program_lexer.l" +#line 220 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, SUB, ZERO_ONE); } YY_BREAK case 69: YY_RULE_SETUP -#line 220 "program_lexer.l" +#line 221 "program_lexer.l" { return_opcode( 1, SWZ, SWZ, OFF); } YY_BREAK case 70: YY_RULE_SETUP -#line 221 "program_lexer.l" +#line 222 "program_lexer.l" { return_opcode(require_ARB_fp, SWZ, SWZ, ZERO_ONE); } YY_BREAK case 71: YY_RULE_SETUP -#line 223 "program_lexer.l" +#line 224 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, OFF); } YY_BREAK case 72: YY_RULE_SETUP -#line 224 "program_lexer.l" +#line 225 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, ZERO_ONE); } YY_BREAK case 73: YY_RULE_SETUP -#line 225 "program_lexer.l" +#line 226 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, OFF); } YY_BREAK case 74: YY_RULE_SETUP -#line 226 "program_lexer.l" +#line 227 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, ZERO_ONE); } YY_BREAK case 75: YY_RULE_SETUP -#line 227 "program_lexer.l" +#line 228 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, OFF); } YY_BREAK case 76: YY_RULE_SETUP -#line 228 "program_lexer.l" +#line 229 "program_lexer.l" { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, ZERO_ONE); } YY_BREAK case 77: YY_RULE_SETUP -#line 230 "program_lexer.l" +#line 231 "program_lexer.l" { return_opcode( 1, BIN_OP, XPD, OFF); } YY_BREAK case 78: YY_RULE_SETUP -#line 231 "program_lexer.l" +#line 232 "program_lexer.l" { return_opcode(require_ARB_fp, BIN_OP, XPD, ZERO_ONE); } YY_BREAK case 79: YY_RULE_SETUP -#line 233 "program_lexer.l" +#line 234 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } YY_BREAK case 80: YY_RULE_SETUP -#line 234 "program_lexer.l" +#line 235 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } YY_BREAK case 81: YY_RULE_SETUP -#line 235 "program_lexer.l" +#line 236 "program_lexer.l" { return PROGRAM; } YY_BREAK case 82: YY_RULE_SETUP -#line 236 "program_lexer.l" +#line 237 "program_lexer.l" { return STATE; } YY_BREAK case 83: YY_RULE_SETUP -#line 237 "program_lexer.l" +#line 238 "program_lexer.l" { return RESULT; } YY_BREAK case 84: YY_RULE_SETUP -#line 239 "program_lexer.l" +#line 240 "program_lexer.l" { return AMBIENT; } YY_BREAK case 85: YY_RULE_SETUP -#line 240 "program_lexer.l" +#line 241 "program_lexer.l" { return ATTENUATION; } YY_BREAK case 86: YY_RULE_SETUP -#line 241 "program_lexer.l" +#line 242 "program_lexer.l" { return BACK; } YY_BREAK case 87: YY_RULE_SETUP -#line 242 "program_lexer.l" +#line 243 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, CLIP); } YY_BREAK case 88: YY_RULE_SETUP -#line 243 "program_lexer.l" +#line 244 "program_lexer.l" { return COLOR; } YY_BREAK case 89: YY_RULE_SETUP -#line 244 "program_lexer.l" +#line 245 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, DEPTH); } YY_BREAK case 90: YY_RULE_SETUP -#line 245 "program_lexer.l" +#line 246 "program_lexer.l" { return DIFFUSE; } YY_BREAK case 91: YY_RULE_SETUP -#line 246 "program_lexer.l" +#line 247 "program_lexer.l" { return DIRECTION; } YY_BREAK case 92: YY_RULE_SETUP -#line 247 "program_lexer.l" +#line 248 "program_lexer.l" { return EMISSION; } YY_BREAK case 93: YY_RULE_SETUP -#line 248 "program_lexer.l" +#line 249 "program_lexer.l" { return ENV; } YY_BREAK case 94: YY_RULE_SETUP -#line 249 "program_lexer.l" +#line 250 "program_lexer.l" { return EYE; } YY_BREAK case 95: YY_RULE_SETUP -#line 250 "program_lexer.l" +#line 251 "program_lexer.l" { return FOGCOORD; } YY_BREAK case 96: YY_RULE_SETUP -#line 251 "program_lexer.l" +#line 252 "program_lexer.l" { return FOG; } YY_BREAK case 97: YY_RULE_SETUP -#line 252 "program_lexer.l" +#line 253 "program_lexer.l" { return FRONT; } YY_BREAK case 98: YY_RULE_SETUP -#line 253 "program_lexer.l" +#line 254 "program_lexer.l" { return HALF; } YY_BREAK case 99: YY_RULE_SETUP -#line 254 "program_lexer.l" +#line 255 "program_lexer.l" { return INVERSE; } YY_BREAK case 100: YY_RULE_SETUP -#line 255 "program_lexer.l" +#line 256 "program_lexer.l" { return INVTRANS; } YY_BREAK case 101: YY_RULE_SETUP -#line 256 "program_lexer.l" +#line 257 "program_lexer.l" { return LIGHT; } YY_BREAK case 102: YY_RULE_SETUP -#line 257 "program_lexer.l" +#line 258 "program_lexer.l" { return LIGHTMODEL; } YY_BREAK case 103: YY_RULE_SETUP -#line 258 "program_lexer.l" +#line 259 "program_lexer.l" { return LIGHTPROD; } YY_BREAK case 104: YY_RULE_SETUP -#line 259 "program_lexer.l" +#line 260 "program_lexer.l" { return LOCAL; } YY_BREAK case 105: YY_RULE_SETUP -#line 260 "program_lexer.l" +#line 261 "program_lexer.l" { return MATERIAL; } YY_BREAK case 106: YY_RULE_SETUP -#line 261 "program_lexer.l" +#line 262 "program_lexer.l" { return MAT_PROGRAM; } YY_BREAK case 107: YY_RULE_SETUP -#line 262 "program_lexer.l" +#line 263 "program_lexer.l" { return MATRIX; } YY_BREAK case 108: YY_RULE_SETUP -#line 263 "program_lexer.l" +#line 264 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } YY_BREAK case 109: YY_RULE_SETUP -#line 264 "program_lexer.l" +#line 265 "program_lexer.l" { return MODELVIEW; } YY_BREAK case 110: YY_RULE_SETUP -#line 265 "program_lexer.l" +#line 266 "program_lexer.l" { return MVP; } YY_BREAK case 111: YY_RULE_SETUP -#line 266 "program_lexer.l" +#line 267 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, NORMAL); } YY_BREAK case 112: YY_RULE_SETUP -#line 267 "program_lexer.l" +#line 268 "program_lexer.l" { return OBJECT; } YY_BREAK case 113: YY_RULE_SETUP -#line 268 "program_lexer.l" +#line 269 "program_lexer.l" { return PALETTE; } YY_BREAK case 114: YY_RULE_SETUP -#line 269 "program_lexer.l" +#line 270 "program_lexer.l" { return PARAMS; } YY_BREAK case 115: YY_RULE_SETUP -#line 270 "program_lexer.l" +#line 271 "program_lexer.l" { return PLANE; } YY_BREAK case 116: YY_RULE_SETUP -#line 271 "program_lexer.l" +#line 272 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINT_TOK); } YY_BREAK case 117: YY_RULE_SETUP -#line 272 "program_lexer.l" +#line 273 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, POINTSIZE); } YY_BREAK case 118: YY_RULE_SETUP -#line 273 "program_lexer.l" +#line 274 "program_lexer.l" { return POSITION; } YY_BREAK case 119: YY_RULE_SETUP -#line 274 "program_lexer.l" +#line 275 "program_lexer.l" { return PRIMARY; } YY_BREAK case 120: YY_RULE_SETUP -#line 275 "program_lexer.l" +#line 276 "program_lexer.l" { return PROJECTION; } YY_BREAK case 121: YY_RULE_SETUP -#line 276 "program_lexer.l" +#line 277 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, RANGE); } YY_BREAK case 122: YY_RULE_SETUP -#line 277 "program_lexer.l" +#line 278 "program_lexer.l" { return ROW; } YY_BREAK case 123: YY_RULE_SETUP -#line 278 "program_lexer.l" +#line 279 "program_lexer.l" { return SCENECOLOR; } YY_BREAK case 124: YY_RULE_SETUP -#line 279 "program_lexer.l" +#line 280 "program_lexer.l" { return SECONDARY; } YY_BREAK case 125: YY_RULE_SETUP -#line 280 "program_lexer.l" +#line 281 "program_lexer.l" { return SHININESS; } YY_BREAK case 126: YY_RULE_SETUP -#line 281 "program_lexer.l" +#line 282 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } YY_BREAK case 127: YY_RULE_SETUP -#line 282 "program_lexer.l" +#line 283 "program_lexer.l" { return SPECULAR; } YY_BREAK case 128: YY_RULE_SETUP -#line 283 "program_lexer.l" +#line 284 "program_lexer.l" { return SPOT; } YY_BREAK case 129: YY_RULE_SETUP -#line 284 "program_lexer.l" +#line 285 "program_lexer.l" { return TEXCOORD; } YY_BREAK case 130: YY_RULE_SETUP -#line 285 "program_lexer.l" +#line 286 "program_lexer.l" { return_token_or_DOT(require_ARB_fp, TEXENV); } YY_BREAK case 131: YY_RULE_SETUP -#line 286 "program_lexer.l" +#line 287 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN); } YY_BREAK case 132: YY_RULE_SETUP -#line 287 "program_lexer.l" +#line 288 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } YY_BREAK case 133: YY_RULE_SETUP -#line 288 "program_lexer.l" +#line 289 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } YY_BREAK case 134: YY_RULE_SETUP -#line 289 "program_lexer.l" +#line 290 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } YY_BREAK case 135: YY_RULE_SETUP -#line 290 "program_lexer.l" +#line 291 "program_lexer.l" { return TEXTURE; } YY_BREAK case 136: YY_RULE_SETUP -#line 291 "program_lexer.l" +#line 292 "program_lexer.l" { return TRANSPOSE; } YY_BREAK case 137: YY_RULE_SETUP -#line 292 "program_lexer.l" +#line 293 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } YY_BREAK case 138: YY_RULE_SETUP -#line 293 "program_lexer.l" +#line 294 "program_lexer.l" { return_token_or_DOT(require_ARB_vp, WEIGHT); } YY_BREAK case 139: YY_RULE_SETUP -#line 295 "program_lexer.l" +#line 296 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } YY_BREAK case 140: YY_RULE_SETUP -#line 296 "program_lexer.l" +#line 297 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } YY_BREAK case 141: YY_RULE_SETUP -#line 297 "program_lexer.l" +#line 298 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } YY_BREAK case 142: YY_RULE_SETUP -#line 298 "program_lexer.l" +#line 299 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } YY_BREAK case 143: YY_RULE_SETUP -#line 299 "program_lexer.l" +#line 300 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } YY_BREAK case 144: YY_RULE_SETUP -#line 300 "program_lexer.l" +#line 301 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } YY_BREAK case 145: YY_RULE_SETUP -#line 301 "program_lexer.l" +#line 302 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } YY_BREAK case 146: YY_RULE_SETUP -#line 302 "program_lexer.l" +#line 303 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } YY_BREAK case 147: YY_RULE_SETUP -#line 303 "program_lexer.l" +#line 304 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } YY_BREAK case 148: YY_RULE_SETUP -#line 304 "program_lexer.l" +#line 305 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } YY_BREAK case 149: YY_RULE_SETUP -#line 305 "program_lexer.l" +#line 306 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } YY_BREAK case 150: YY_RULE_SETUP -#line 306 "program_lexer.l" +#line 307 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } YY_BREAK case 151: YY_RULE_SETUP -#line 307 "program_lexer.l" +#line 308 "program_lexer.l" { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } YY_BREAK case 152: YY_RULE_SETUP -#line 309 "program_lexer.l" +#line 310 "program_lexer.l" { yylval->string = strdup(yytext); return IDENTIFIER; @@ -2102,12 +2103,12 @@ YY_RULE_SETUP YY_BREAK case 153: YY_RULE_SETUP -#line 314 "program_lexer.l" +#line 315 "program_lexer.l" { return DOT_DOT; } YY_BREAK case 154: YY_RULE_SETUP -#line 316 "program_lexer.l" +#line 317 "program_lexer.l" { yylval->integer = strtol(yytext, NULL, 10); return INTEGER; @@ -2115,9 +2116,9 @@ YY_RULE_SETUP YY_BREAK case 155: YY_RULE_SETUP -#line 320 "program_lexer.l" +#line 321 "program_lexer.l" { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } YY_BREAK @@ -2127,31 +2128,31 @@ case 156: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 324 "program_lexer.l" +#line 325 "program_lexer.l" { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } YY_BREAK case 157: YY_RULE_SETUP -#line 328 "program_lexer.l" +#line 329 "program_lexer.l" { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } YY_BREAK case 158: YY_RULE_SETUP -#line 332 "program_lexer.l" +#line 333 "program_lexer.l" { - yylval->real = strtod(yytext, NULL); + yylval->real = _mesa_strtod(yytext, NULL); return REAL; } YY_BREAK case 159: YY_RULE_SETUP -#line 337 "program_lexer.l" +#line 338 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2160,7 +2161,7 @@ YY_RULE_SETUP YY_BREAK case 160: YY_RULE_SETUP -#line 343 "program_lexer.l" +#line 344 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2170,7 +2171,7 @@ YY_RULE_SETUP YY_BREAK case 161: YY_RULE_SETUP -#line 349 "program_lexer.l" +#line 350 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2179,7 +2180,7 @@ YY_RULE_SETUP YY_BREAK case 162: YY_RULE_SETUP -#line 354 "program_lexer.l" +#line 355 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2188,7 +2189,7 @@ YY_RULE_SETUP YY_BREAK case 163: YY_RULE_SETUP -#line 360 "program_lexer.l" +#line 361 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2198,7 +2199,7 @@ YY_RULE_SETUP YY_BREAK case 164: YY_RULE_SETUP -#line 366 "program_lexer.l" +#line 367 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2208,7 +2209,7 @@ YY_RULE_SETUP YY_BREAK case 165: YY_RULE_SETUP -#line 372 "program_lexer.l" +#line 373 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2217,7 +2218,7 @@ YY_RULE_SETUP YY_BREAK case 166: YY_RULE_SETUP -#line 378 "program_lexer.l" +#line 379 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2227,7 +2228,7 @@ YY_RULE_SETUP YY_BREAK case 167: YY_RULE_SETUP -#line 385 "program_lexer.l" +#line 386 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2239,7 +2240,7 @@ YY_RULE_SETUP YY_BREAK case 168: YY_RULE_SETUP -#line 394 "program_lexer.l" +#line 395 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_NOOP; yylval->swiz_mask.mask = WRITEMASK_XYZW; @@ -2248,7 +2249,7 @@ YY_RULE_SETUP YY_BREAK case 169: YY_RULE_SETUP -#line 400 "program_lexer.l" +#line 401 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XY @@ -2258,7 +2259,7 @@ YY_RULE_SETUP YY_BREAK case 170: YY_RULE_SETUP -#line 406 "program_lexer.l" +#line 407 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_XZW; @@ -2267,7 +2268,7 @@ YY_RULE_SETUP YY_BREAK case 171: YY_RULE_SETUP -#line 411 "program_lexer.l" +#line 412 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_YZW; @@ -2276,7 +2277,7 @@ YY_RULE_SETUP YY_BREAK case 172: YY_RULE_SETUP -#line 417 "program_lexer.l" +#line 418 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_X @@ -2286,7 +2287,7 @@ YY_RULE_SETUP YY_BREAK case 173: YY_RULE_SETUP -#line 423 "program_lexer.l" +#line 424 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_Y @@ -2296,7 +2297,7 @@ YY_RULE_SETUP YY_BREAK case 174: YY_RULE_SETUP -#line 429 "program_lexer.l" +#line 430 "program_lexer.l" { yylval->swiz_mask.swizzle = SWIZZLE_INVAL; yylval->swiz_mask.mask = WRITEMASK_ZW; @@ -2305,7 +2306,7 @@ YY_RULE_SETUP YY_BREAK case 175: YY_RULE_SETUP -#line 435 "program_lexer.l" +#line 436 "program_lexer.l" { const unsigned s = swiz_from_char(yytext[1]); yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); @@ -2315,7 +2316,7 @@ YY_RULE_SETUP YY_BREAK case 176: YY_RULE_SETUP -#line 443 "program_lexer.l" +#line 444 "program_lexer.l" { if (require_ARB_vp) { return TEXGEN_R; @@ -2329,7 +2330,7 @@ YY_RULE_SETUP YY_BREAK case 177: YY_RULE_SETUP -#line 454 "program_lexer.l" +#line 455 "program_lexer.l" { yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), swiz_from_char(yytext[2]), @@ -2341,13 +2342,13 @@ YY_RULE_SETUP YY_BREAK case 178: YY_RULE_SETUP -#line 463 "program_lexer.l" +#line 464 "program_lexer.l" { return DOT; } YY_BREAK case 179: /* rule 179 can match eol */ YY_RULE_SETUP -#line 465 "program_lexer.l" +#line 466 "program_lexer.l" { yylloc->first_line++; yylloc->first_column = 1; @@ -2358,7 +2359,7 @@ YY_RULE_SETUP YY_BREAK case 180: YY_RULE_SETUP -#line 472 "program_lexer.l" +#line 473 "program_lexer.l" /* eat whitespace */ ; YY_BREAK case 181: @@ -2366,20 +2367,20 @@ case 181: yyg->yy_c_buf_p = yy_cp -= 1; YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP -#line 473 "program_lexer.l" +#line 474 "program_lexer.l" /* eat comments */ ; YY_BREAK case 182: YY_RULE_SETUP -#line 474 "program_lexer.l" +#line 475 "program_lexer.l" { return yytext[0]; } YY_BREAK case 183: YY_RULE_SETUP -#line 475 "program_lexer.l" +#line 476 "program_lexer.l" ECHO; YY_BREAK -#line 2383 "lex.yy.c" +#line 2384 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -3554,7 +3555,7 @@ void yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 475 "program_lexer.l" +#line 476 "program_lexer.l" -- cgit v1.2.3 From f7285bdffcd8cca1c7d3066d38907a5987e844ea Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Tue, 29 Sep 2009 09:46:29 +0300 Subject: r600: clear position enable bit when when wpos is not used by FP Makes doom3 alot nicer.. --- src/mesa/drivers/dri/r600/r700_fragprog.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c index 78ce3ae436..62a1ea1a22 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.c +++ b/src/mesa/drivers/dri/r600/r700_fragprog.c @@ -341,6 +341,11 @@ GLboolean r700SetupFragmentProgram(GLcontext * ctx) SETbit(r700->SPI_PS_IN_CONTROL_0.u32All, POSITION_ENA_bit); SETbit(r700->SPI_INPUT_Z.u32All, PROVIDE_Z_TO_SPI_bit); } + else + { + CLEARbit(r700->SPI_PS_IN_CONTROL_0.u32All, POSITION_ENA_bit); + CLEARbit(r700->SPI_INPUT_Z.u32All, PROVIDE_Z_TO_SPI_bit); + } ui = (unNumOfReg < ui) ? ui : unNumOfReg; -- cgit v1.2.3 From 5101215a64a69a212241eadba7f097cef33a0b5c Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 28 Sep 2009 10:42:35 +0300 Subject: r600: user correct alpha blend factor Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/r600/r700_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 98f116d0a6..0d1f906d84 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -467,10 +467,10 @@ static void r700SetBlendState(GLcontext * ctx) eqn, COLOR_COMB_FCN_shift, COLOR_COMB_FCN_mask); SETfield(blend_reg, - blend_factor(ctx->Color.BlendSrcRGB, GL_TRUE), + blend_factor(ctx->Color.BlendSrcA, GL_TRUE), ALPHA_SRCBLEND_shift, ALPHA_SRCBLEND_mask); SETfield(blend_reg, - blend_factor(ctx->Color.BlendDstRGB, GL_FALSE), + blend_factor(ctx->Color.BlendDstA, GL_FALSE), ALPHA_DESTBLEND_shift, ALPHA_DESTBLEND_mask); switch (ctx->Color.BlendEquationA) { -- cgit v1.2.3 From bf68e54a4d69bdd9a01656919d3cd752c96157b3 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 28 Sep 2009 11:23:49 +0300 Subject: r600: use CB_TARGET_MASK instead of CB_SHADER_MASK for setting color mask makes blend functions work better Signed-off-by: Dave Airlie --- src/mesa/drivers/dri/r600/r700_state.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 0d1f906d84..244a016e07 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -745,9 +745,9 @@ static void r700ColorMask(GLcontext * ctx, (b ? 4 : 0) | (a ? 8 : 0)); - if (mask != r700->CB_SHADER_MASK.u32All) { + if (mask != r700->CB_TARGET_MASK.u32All) { R600_STATECHANGE(context, cb); - SETfield(r700->CB_SHADER_MASK.u32All, mask, OUTPUT0_ENABLE_shift, OUTPUT0_ENABLE_mask); + SETfield(r700->CB_TARGET_MASK.u32All, mask, TARGET0_ENABLE_shift, TARGET0_ENABLE_mask); } } @@ -1758,7 +1758,7 @@ void r700InitState(GLcontext * ctx) //------------------- r700->CB_CLRCMP_MSK.u32All = 0xFFFFFFFF; /* screen/window/view */ - SETfield(r700->CB_TARGET_MASK.u32All, 0xF, (4 * id), TARGET0_ENABLE_mask); + SETfield(r700->CB_SHADER_MASK.u32All, 0xF, (4 * id), OUTPUT0_ENABLE_mask); context->radeon.hw.all_dirty = GL_TRUE; -- cgit v1.2.3 From 95851d8cb232cbd1312d2b8de471ba2aeb276911 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Fri, 9 Oct 2009 10:46:12 +0300 Subject: r600: fixup KIL instruction a bit - KILLGT takes 2 arguments - arb KIL has no dst register - add TODO about clause ending but currently piglit fp-kil passes and does not hang the card --- src/mesa/drivers/dri/r600/r700_assembler.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 00eda544d4..e79c256c6b 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -336,7 +336,8 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm) switch (pAsm->D.dst.opcode) { - case SQ_OP2_INST_ADD: + case SQ_OP2_INST_ADD: + case SQ_OP2_INST_KILLGT: case SQ_OP2_INST_MUL: case SQ_OP2_INST_MAX: case SQ_OP2_INST_MIN: @@ -356,7 +357,6 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm) case SQ_OP2_INST_MOV: case SQ_OP2_INST_FRACT: case SQ_OP2_INST_FLOOR: - case SQ_OP2_INST_KILLGT: case SQ_OP2_INST_EXP_IEEE: case SQ_OP2_INST_LOG_CLAMPED: case SQ_OP2_INST_LOG_IEEE: @@ -2617,15 +2617,15 @@ GLboolean assemble_FRC(r700_AssemblerBase *pAsm) GLboolean assemble_KIL(r700_AssemblerBase *pAsm) { + /* TODO: doc says KILL has to be last(end) ALU clause */ + checkop1(pAsm); pAsm->D.dst.opcode = SQ_OP2_INST_KILLGT; - - if ( GL_FALSE == assemble_dst(pAsm) ) - { - return GL_FALSE; - } + setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); + pAsm->D.dst.rtype = DST_REG_TEMPORARY; + pAsm->D.dst.reg = 0; pAsm->D.dst.writex = 0; pAsm->D.dst.writey = 0; pAsm->D.dst.writez = 0; @@ -2638,20 +2638,11 @@ GLboolean assemble_KIL(r700_AssemblerBase *pAsm) setswizzle_PVSSRC(&(pAsm->S[0].src), SQ_SEL_0); noneg_PVSSRC(&(pAsm->S[0].src)); - pAsm->S[1].src.rtype = SRC_REG_TEMPORARY; - - if(PROGRAM_TEMPORARY == pAsm->pILInst[pAsm->uiCurInst].DstReg.File) + if ( GL_FALSE == assemble_src(pAsm, 0, 1) ) { - pAsm->S[1].src.reg = pAsm->pILInst[pAsm->uiCurInst].DstReg.Index + pAsm->starting_temp_register_number; - } - else - { //PROGRAM_OUTPUT - pAsm->S[1].src.reg = pAsm->uiFP_OutputMap[pAsm->pILInst[pAsm->uiCurInst].DstReg.Index]; + return GL_FALSE; } - setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE); - noswizzle_PVSSRC(&(pAsm->S[1].src)); - if ( GL_FALSE == next_ins(pAsm) ) { return GL_FALSE; -- cgit v1.2.3 From 74c31e5d05f7ed342fb143cb6f637b54e8961973 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 12 Oct 2009 12:20:26 +0300 Subject: r600: DPH adds w comp of second operand, so set first one to 1 instead --- src/mesa/drivers/dri/r600/r700_assembler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index e79c256c6b..1837712883 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -2508,7 +2508,7 @@ GLboolean assemble_DOT(r700_AssemblerBase *pAsm) } else if(pAsm->pILInst[pAsm->uiCurInst].Opcode == OPCODE_DPH) { - onecomp_PVSSRC(&(pAsm->S[1].src), 3); + onecomp_PVSSRC(&(pAsm->S[0].src), 3); } if ( GL_FALSE == next_ins(pAsm) ) -- cgit v1.2.3 From 606becc7f3513354548f587d84db731046616401 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 12 Oct 2009 12:58:40 +0300 Subject: r600: LIT dst.y gets value from src.x seems I overlooked this when removing hardcoded swizzles for this one previously --- src/mesa/drivers/dri/r600/r700_assembler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 1837712883..25b27cd829 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -2899,6 +2899,7 @@ GLboolean assemble_LIT(r700_AssemblerBase *pAsm) pAsm->S[0].src.rtype = srcType; pAsm->S[0].src.reg = srcReg; setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE); + swizzleagain_PVSSRC(&(pAsm->S[0].src), SQ_SEL_X, SQ_SEL_X, SQ_SEL_X, SQ_SEL_X); pAsm->S[1].src.rtype = SRC_REG_TEMPORARY; pAsm->S[1].src.reg = tmp; setaddrmode_PVSSRC(&(pAsm->S[1].src), ADDR_ABSOLUTE); -- cgit v1.2.3 From a3fec141017a39916d07000a3aa00eef3c9ac8a7 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Mon, 12 Oct 2009 14:57:45 +0300 Subject: r600: implement ProgramStringNotify need this to properly test with piglit/glean vert/fragprog tests copied mostly from r300, many thanks to osiris, nha, airlied, others... --- src/mesa/drivers/dri/r600/r700_oglprog.c | 55 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_oglprog.c b/src/mesa/drivers/dri/r600/r700_oglprog.c index 5290ef31be..0d476fcd86 100644 --- a/src/mesa/drivers/dri/r600/r700_oglprog.c +++ b/src/mesa/drivers/dri/r600/r700_oglprog.c @@ -40,6 +40,24 @@ #include "r700_vertprog.h" +static void freeVertProgCache(GLcontext *ctx, struct r700_vertex_program_cont *cache) +{ + struct r700_vertex_program *tmp, *vp = cache->progs; + + while (vp) { + tmp = vp->next; + /* Release DMA region */ + r600DeleteShader(ctx, vp->shaderbo); + /* Clean up */ + Clean_Up_Assembler(&(vp->r700AsmCode)); + Clean_Up_Shader(&(vp->r700Shader)); + + _mesa_reference_vertprog(ctx, &vp->mesa_program, NULL); + _mesa_free(vp); + vp = tmp; + } +} + static struct gl_program *r700NewProgram(GLcontext * ctx, GLenum target, GLuint id) @@ -84,8 +102,7 @@ static struct gl_program *r700NewProgram(GLcontext * ctx, static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog) { - struct r700_vertex_program_cont * vpc; - struct r700_vertex_program *vp, *tmp; + struct r700_vertex_program_cont *vpc = (struct r700_vertex_program_cont *)prog; struct r700_fragment_program * fp; radeon_print(RADEON_SHADER, RADEON_VERBOSE, @@ -95,20 +112,7 @@ static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog) { case GL_VERTEX_STATE_PROGRAM_NV: case GL_VERTEX_PROGRAM_ARB: - vpc = (struct r700_vertex_program_cont*)prog; - vp = vpc->progs; - while (vp) { - tmp = vp->next; - /* Release DMA region */ - - r600DeleteShader(ctx, vp->shaderbo); - - /* Clean up */ - Clean_Up_Assembler(&(vp->r700AsmCode)); - Clean_Up_Shader(&(vp->r700Shader)); - _mesa_free(vp); - vp = tmp; - } + freeVertProgCache(ctx, vpc); break; case GL_FRAGMENT_PROGRAM_NV: case GL_FRAGMENT_PROGRAM_ARB: @@ -131,7 +135,24 @@ static void r700DeleteProgram(GLcontext * ctx, struct gl_program *prog) static void r700ProgramStringNotify(GLcontext * ctx, GLenum target, struct gl_program *prog) { - + struct r700_vertex_program_cont *vpc = (struct r700_vertex_program_cont *)prog; + struct r700_fragment_program * fp = (struct r700_fragment_program*)prog; + + switch (target) { + case GL_VERTEX_PROGRAM_ARB: + freeVertProgCache(ctx, vpc); + vpc->progs = NULL; + break; + case GL_FRAGMENT_PROGRAM_ARB: + r600DeleteShader(ctx, fp->shaderbo); + Clean_Up_Assembler(&(fp->r700AsmCode)); + Clean_Up_Shader(&(fp->r700Shader)); + fp->translated = GL_FALSE; + fp->loaded = GL_FALSE; + fp->shaderbo = NULL; + break; + } + } static GLboolean r700IsProgramNative(GLcontext * ctx, GLenum target, struct gl_program *prog) -- cgit v1.2.3 From 22a0029a68cf6a17e5d799c7d8eb8a699ccdeabb Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Thu, 15 Oct 2009 11:24:49 -0400 Subject: r600: fix tfp1 bo size Setting the wrong bo size resulting in an incomplete read cache flush when reading the texture. This fixes the compiz text corruption. [agd5f: take hw pitch alignment into account] --- src/mesa/drivers/dri/r600/r600_texstate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index bcb8d7c73d..61ff7e8158 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -721,7 +721,9 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname, struct gl_texture_object *tObj = _mesa_lookup_texture(rmesa->radeon.glCtx, texname); radeonTexObjPtr t = radeon_tex_obj(tObj); - uint32_t pitch_val, size; + int firstlevel = t->mt ? t->mt->firstLevel : 0; + const struct gl_texture_image *firstImage; + uint32_t pitch_val, size, row_align; if (!tObj) return; @@ -731,7 +733,9 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname, if (!offset) return; - size = pitch;//h * w * (depth / 8); + firstImage = t->base.Image[0][firstlevel]; + row_align = rmesa->radeon.texture_row_align - 1; + size = ((firstImage->Width * (depth / 8) + row_align) & ~row_align) * firstImage->Height; if (t->bo) { radeon_bo_unref(t->bo); t->bo = NULL; -- cgit v1.2.3 From e5d6450c2c85cc7d645cb0736194f41e5393802d Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 14 Oct 2009 13:58:56 -0500 Subject: radeon: return EINVAL for 0 length buffers. Signed-off-by: Robert Noland --- src/mesa/drivers/dri/radeon/radeon_bo_legacy.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c index 3e7547d2f9..ce60a2f7ea 100644 --- a/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c +++ b/src/mesa/drivers/dri/radeon/radeon_bo_legacy.c @@ -710,6 +710,10 @@ int radeon_bo_legacy_validate(struct radeon_bo *bo, bo, bo->size, bo_legacy->map_count); return -EINVAL; } + if(bo->size == 0) { + fprintf(stderr, "bo(%p) has size 0.\n", bo); + return -EINVAL; + } if (bo_legacy->static_bo || bo_legacy->validated) { *soffset = bo_legacy->offset; *eoffset = bo_legacy->offset + bo->size; -- cgit v1.2.3 From a176b1c5d8b14601ec7e6ca9599c55fcc4797a7d Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 14 Oct 2009 14:02:12 -0500 Subject: r600: cleanup in r600_cs_process_relocs(). Signed-off-by: Robert Noland --- src/mesa/drivers/dri/r600/r600_cmdbuf.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_cmdbuf.c b/src/mesa/drivers/dri/r600/r600_cmdbuf.c index 3cfe03a45f..d27a3245a3 100644 --- a/src/mesa/drivers/dri/r600/r600_cmdbuf.c +++ b/src/mesa/drivers/dri/r600/r600_cmdbuf.c @@ -254,7 +254,7 @@ static int r600_cs_process_relocs(struct radeon_cs *cs, relocs = (struct r600_cs_reloc_legacy *)cs->relocs; restart: for (i = 0; i < cs->crelocs; i++) { - uint32_t soffset, eoffset, asicoffset; + uint32_t soffset, eoffset; r = radeon_bo_legacy_validate(relocs[i].base.bo, &soffset, &eoffset); @@ -262,24 +262,12 @@ restart: goto restart; } if (r) { - fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n", + fprintf(stderr, "invalid bo(%p) [0x%08X, 0x%08X]\n", relocs[i].base.bo, soffset, eoffset); return r; } - asicoffset = soffset; for (j = 0; j < relocs[i].cindices; j++) { - if (asicoffset >= eoffset) { - /* radeon_bo_debug(relocs[i].base.bo, 12); */ - fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n", - relocs[i].base.bo, soffset, eoffset); - fprintf(stderr, "above end: %p 0x%08X 0x%08X\n", - relocs[i].base.bo, - cs->packets[relocs[i].indices[j]], - eoffset); - exit(0); - return -EINVAL; - } /* pkt3 nop header in ib chunk */ cs->packets[relocs[i].reloc_indices[j]] = 0xC0001000; /* reloc index in ib chunk */ @@ -287,7 +275,7 @@ restart: } /* asic offset in reloc chunk */ /* see alex drm r600_nomm_relocate */ - reloc_chunk[offset_dw] = asicoffset; + reloc_chunk[offset_dw] = soffset; reloc_chunk[offset_dw + 3] = 0; offset_dw += 4; -- cgit v1.2.3 From 16c6a3b71e6be04b6bb3d08fcb658194c5251fc7 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Wed, 14 Oct 2009 14:04:24 -0500 Subject: r600: FRAG_ATTRIB_WPOS and FRAG_ATTRIB_FOGC appear to be supported. Report unsupported attributes while I'm here. Signed-off-by: Robert Noland --- src/mesa/drivers/dri/r600/r700_assembler.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 25b27cd829..a683008746 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -1180,8 +1180,10 @@ GLboolean tex_src(r700_AssemblerBase *pAsm) case PROGRAM_INPUT: switch (pILInst->SrcReg[0].Index) { + case FRAG_ATTRIB_WPOS: case FRAG_ATTRIB_COL0: case FRAG_ATTRIB_COL1: + case FRAG_ATTRIB_FOGC: case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: case FRAG_ATTRIB_TEX2: @@ -1194,7 +1196,16 @@ GLboolean tex_src(r700_AssemblerBase *pAsm) pAsm->S[0].src.reg = pAsm->uiFP_AttributeMap[pILInst->SrcReg[0].Index]; pAsm->S[0].src.rtype = SRC_REG_INPUT; - break; + break; + case FRAG_ATTRIB_FACE: + fprintf(stderr, "FRAG_ATTRIB_FACE unsupported\n"); + break; + case FRAG_ATTRIB_PNTC: + fprintf(stderr, "FRAG_ATTRIB_PNTC unsupported\n"); + break; + case FRAG_ATTRIB_VAR0: + fprintf(stderr, "FRAG_ATTRIB_VAR0 unsupported\n"); + break; } break; } -- cgit v1.2.3 From 3f30b0709b5a71915df336194f9f805e4c306cef Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 14 Oct 2009 16:20:07 -0400 Subject: Use the right pitch when rendering to a texture We need to get the pitch from the texture level we are rendering to, rather than just using the base texel width. --- src/mesa/drivers/dri/radeon/radeon_fbo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c index d83b166742..2012cbcf83 100644 --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c @@ -445,7 +445,6 @@ restart: goto restart; } - rrb->pitch = texImage->Width * rrb->cpp; rrb->base.InternalFormat = rrb->base._ActualFormat; rrb->base.Width = texImage->Width; rrb->base.Height = texImage->Height; @@ -555,8 +554,10 @@ radeon_render_texture(GLcontext * ctx, imageOffset += offsets[att->Zoffset]; } - /* store that offset in the region */ + /* store that offset in the region, along with the correct pitch for + * the image we are rendering to */ rrb->draw_offset = imageOffset; + rrb->pitch = radeon_image->mt->levels[att->TextureLevel].rowstride; /* update drawing region, etc */ radeon_draw_buffer(ctx, fb); -- cgit v1.2.3 From 2fc1614e7a56ab16df1b6ebbc159c58e8212d96d Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 16:40:09 +0800 Subject: egl: Fix eglCheckConfigHandle. A stupid bug by me made the check void. Signed-off-by: Chia-I Wu --- src/egl/main/eglconfig.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c index 2c8d1c4055..31d69a7708 100644 --- a/src/egl/main/eglconfig.c +++ b/src/egl/main/eglconfig.c @@ -82,18 +82,17 @@ _eglAddConfig(_EGLDisplay *dpy, _EGLConfig *conf) EGLBoolean _eglCheckConfigHandle(EGLConfig config, _EGLDisplay *dpy) { - _EGLConfig *conf = NULL; + EGLint num_configs = (dpy) ? dpy->NumConfigs : 0; EGLint i; - for (i = 0; dpy && i < dpy->NumConfigs; i++) { - conf = dpy->Configs[i]; + for (i = 0; i < num_configs; i++) { + _EGLConfig *conf = dpy->Configs[i]; if (conf == (_EGLConfig *) config) { assert(conf->Display == dpy); break; } } - - return (conf != NULL); + return (i < num_configs); } -- cgit v1.2.3 From 29d115092e7b9e1436df3ce1fb7ffe183f8a9302 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 10 Oct 2009 14:39:43 +0800 Subject: egl: Fix GLX_USE_TLS build. Remove an extraneous semicolon. Signed-off-by: Chia-I Wu --- src/egl/main/eglcurrent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c index ca7a077168..df506151b5 100644 --- a/src/egl/main/eglcurrent.c +++ b/src/egl/main/eglcurrent.c @@ -16,7 +16,7 @@ static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER; #ifdef GLX_USE_TLS -static __thread const _EGLThreadInfo *_egl_TSD; +static __thread const _EGLThreadInfo *_egl_TSD __attribute__ ((tls_model("initial-exec"))); static INLINE void _eglSetTSD(const _EGLThreadInfo *t) -- cgit v1.2.3 From 8bb2485ed0e4764b8ad1f1a7f0bfe1c3f66d71bc Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 18:32:19 +0800 Subject: egl: Include GL header in eglconfigutil.h. This is just a cosmetic change. Signed-off-by: Chia-I Wu --- src/egl/main/eglconfigutil.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/egl/main/eglconfigutil.h b/src/egl/main/eglconfigutil.h index ad85079890..8c923ee206 100644 --- a/src/egl/main/eglconfigutil.h +++ b/src/egl/main/eglconfigutil.h @@ -2,7 +2,7 @@ #define EGLCONFIGUTIL_INCLUDED -#include "GLES/gl.h" +#include "GL/gl.h" #include "GL/internal/glcore.h" #include "eglconfig.h" -- cgit v1.2.3 From 61906631202af855d0742586956ff9f34522a525 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 30 Sep 2009 15:34:45 +0800 Subject: egl: Rework error checking in eglGetCurrentSurface. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index d86ef9ce56..1512c0a14e 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -568,8 +568,26 @@ eglGetCurrentContext(void) EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { - _EGLSurface *s = _eglGetCurrentSurface(readdraw); - return _eglGetSurfaceHandle(s); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLSurface *surf; + + if (!ctx) + return EGL_NO_SURFACE; + + switch (readdraw) { + case EGL_DRAW: + surf = ctx->DrawSurface; + break; + case EGL_READ: + surf = ctx->ReadSurface; + break; + default: + _eglError(EGL_BAD_PARAMETER, __FUNCTION__); + surf = NULL; + break; + } + + return _eglGetSurfaceHandle(surf); } -- cgit v1.2.3 From aaa1253b09a6a38e7fcd695aa36e89b9d4bd8dfe Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 30 Sep 2009 15:08:34 +0800 Subject: egl: Update comments about eglapi.c. Mention that opaque handles are looked up and checked. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 1512c0a14e..1d370db471 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -9,12 +9,27 @@ * heterogeneous hardware devices in the future. * * The EGLDisplay, EGLConfig, EGLContext and EGLSurface types are - * opaque handles implemented with 32-bit unsigned integers. - * It's up to the driver function or fallback function to look up the - * handle and get an object. - * By using opaque handles, we leave open the possibility of having - * indirect rendering in the future, like GLX. + * opaque handles. Internal objects are linked to a display to + * create the handles. * + * For each public API entry point, the opaque handles are looked up + * before being dispatched to the drivers. When it fails to look up + * a handle, one of + * + * EGL_BAD_DISPLAY + * EGL_BAD_CONFIG + * EGL_BAD_CONTEXT + * EGL_BAD_SURFACE + * EGL_BAD_SCREEN_MESA + * EGL_BAD_MODE_MESA + * + * is generated and the driver function is not called. An + * uninitialized EGLDisplay has no driver associated with it. When + * such display is detected, + * + * EGL_NOT_INITIALIZED + * + * is generated. * * Notes on naming conventions: * -- cgit v1.2.3 From bbfd0e26151bef567c152c8018ecc15f04c70914 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 15 Oct 2009 11:08:33 +0800 Subject: egl: Rework error checking in eglSwapBuffers. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 1d370db471..366901889f 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -31,6 +31,15 @@ * * is generated. * + * Some of the entry points use current display, context, or surface + * implicitly. For such entry points, the implicit objects are also + * checked before calling the driver function. Other than the + * errors listed above, + * + * EGL_BAD_CURRENT_SURFACE + * + * may also be generated. + * * Notes on naming conventions: * * eglFooBar - public EGL function @@ -519,7 +528,13 @@ eglSwapInterval(EGLDisplay dpy, EGLint interval) EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { + _EGLContext *ctx = _eglGetCurrentContext(); _EGL_DECLARE_DD_AND_SURFACE(dpy, surface); + + /* surface must be bound to current context in EGL 1.4 */ + if (!ctx || !_eglIsContextLinked(ctx) || surf != ctx->DrawSurface) + return _eglError(EGL_BAD_SURFACE, __FUNCTION__); + return drv->API.SwapBuffers(drv, disp, surf); } -- cgit v1.2.3 From 57da499d7ba074128e8c97b8076805e403a2b9c4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 15 Oct 2009 11:08:48 +0800 Subject: egl: Rework eglSwapInterval. This adds error checking to eglSwapInterval and clamps the swap interval. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 12 +++++++++++- src/egl/main/eglapi.h | 2 +- src/egl/main/eglsurface.c | 27 ++++++++++++++++++++++----- src/egl/main/eglsurface.h | 2 +- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 366901889f..5ce0469351 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -520,8 +520,18 @@ eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer) EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLSurface *surf; _EGL_DECLARE_DD(dpy); - return drv->API.SwapInterval(drv, disp, interval); + + if (!ctx || !_eglIsContextLinked(ctx) || ctx->Display != disp) + return _eglError(EGL_BAD_CONTEXT, __FUNCTION__); + + surf = ctx->DrawSurface; + if (!_eglIsSurfaceLinked(surf)) + return _eglError(EGL_BAD_SURFACE, __FUNCTION__); + + return drv->API.SwapInterval(drv, disp, surf, interval); } diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index 6081e58892..feb35c863c 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -35,7 +35,7 @@ typedef EGLBoolean (*QuerySurface_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurf typedef EGLBoolean (*SurfaceAttrib_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint attribute, EGLint value); typedef EGLBoolean (*BindTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer); typedef EGLBoolean (*ReleaseTexImage_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLint buffer); -typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval); +typedef EGLBoolean (*SwapInterval_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); typedef EGLBoolean (*SwapBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw); typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, NativePixmapType target); diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c index e7a1a8329e..940a1b760c 100644 --- a/src/egl/main/eglsurface.c +++ b/src/egl/main/eglsurface.c @@ -15,6 +15,22 @@ #include "eglsurface.h" +static void +_eglClampSwapInterval(_EGLSurface *surf, EGLint interval) +{ + EGLint bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MAX_SWAP_INTERVAL); + if (interval >= bound) { + interval = bound; + } + else { + bound = GET_CONFIG_ATTRIB(surf->Config, EGL_MIN_SWAP_INTERVAL); + if (interval < bound) + interval = bound; + } + surf->SwapInterval = interval; +} + + /** * Do error check on parameters and initialize the given _EGLSurface object. * \return EGL_TRUE if no errors, EGL_FALSE otherwise. @@ -194,7 +210,9 @@ _eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type, surf->TextureTarget = texTarget; surf->MipmapTexture = mipmapTex; surf->MipmapLevel = 0; - surf->SwapInterval = 0; + /* the default swap interval is 1 */ + _eglClampSwapInterval(surf, 1); + #ifdef EGL_VERSION_1_2 surf->SwapBehavior = EGL_BUFFER_DESTROYED; /* XXX ok? */ surf->HorizontalResolution = EGL_UNKNOWN; /* set by caller */ @@ -466,11 +484,10 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface, EGLBoolean -_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval) +_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, + EGLint interval) { - _EGLSurface *surf = _eglGetCurrentSurface(EGL_DRAW); - if (surf) - surf->SwapInterval = interval; + _eglClampSwapInterval(surf, interval); return EGL_TRUE; } diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h index f6d44b5922..b75fa9c368 100644 --- a/src/egl/main/eglsurface.h +++ b/src/egl/main/eglsurface.h @@ -86,7 +86,7 @@ _eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint extern EGLBoolean -_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, EGLint interval); +_eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval); #ifdef EGL_VERSION_1_2 -- cgit v1.2.3 From 6c21c8862bc6edc9cddf3b6eb6f276961099a7a8 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Mon, 28 Sep 2009 14:12:39 +0800 Subject: egl: Rework the synchronization primitives. This adds error checking to the synchronization primitives. And eglWaitGL is now implemented by eglWaitClient. Signed-off-by: Chia-I Wu --- src/egl/main/eglapi.c | 66 ++++++++++++++++++++++++++++++------------------ src/egl/main/eglapi.h | 6 ++--- src/egl/main/egldriver.c | 2 +- src/egl/main/eglmisc.c | 3 ++- src/egl/main/eglmisc.h | 2 +- 5 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c index 5ce0469351..14cc5fa613 100644 --- a/src/egl/main/eglapi.c +++ b/src/egl/main/eglapi.c @@ -558,32 +558,66 @@ eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, NativePixmapType target) EGLBoolean EGLAPIENTRY -eglWaitGL(void) +eglWaitClient(void) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); + + return drv->API.WaitClient(drv, disp, ctx); +} + - return drv->API.WaitGL(drv, disp); +EGLBoolean EGLAPIENTRY +eglWaitGL(void) +{ +#ifdef EGL_VERSION_1_2 + _EGLThreadInfo *t = _eglGetCurrentThread(); + EGLint api_index = t->CurrentAPIIndex; + EGLint es_index = _eglConvertApiToIndex(EGL_OPENGL_ES_API); + EGLBoolean ret; + + if (api_index != es_index && _eglIsCurrentThreadDummy()) + return _eglError(EGL_BAD_ALLOC, "eglWaitGL"); + + t->CurrentAPIIndex = es_index; + ret = eglWaitClient(); + t->CurrentAPIIndex = api_index; + return ret; +#else + return eglWaitClient(); +#endif } EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { - _EGLDisplay *disp = _eglGetCurrentDisplay(); + _EGLContext *ctx = _eglGetCurrentContext(); + _EGLDisplay *disp; _EGLDriver *drv; - if (!disp) + if (!ctx) return EGL_TRUE; + /* let bad current context imply bad current surface */ + if (!_eglIsContextLinked(ctx) || !_eglIsSurfaceLinked(ctx->DrawSurface)) + return _eglError(EGL_BAD_CURRENT_SURFACE, __FUNCTION__); - /* a current display is always initialized */ + /* a valid current context implies an initialized current display */ + disp = ctx->Display; drv = disp->Driver; + assert(drv); return drv->API.WaitNative(drv, disp, engine); } @@ -958,20 +992,4 @@ eglReleaseThread(void) } -EGLBoolean -eglWaitClient(void) -{ - _EGLDisplay *disp = _eglGetCurrentDisplay(); - _EGLDriver *drv; - - if (!disp) - return EGL_TRUE; - - /* a current display is always initialized */ - drv = disp->Driver; - - return drv->API.WaitClient(drv, disp); -} - - #endif /* EGL_VERSION_1_2 */ diff --git a/src/egl/main/eglapi.h b/src/egl/main/eglapi.h index feb35c863c..aa0abe3eb6 100644 --- a/src/egl/main/eglapi.h +++ b/src/egl/main/eglapi.h @@ -41,7 +41,7 @@ typedef EGLBoolean (*CopyBuffers_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurfa /* misc funcs */ typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); -typedef EGLBoolean (*WaitGL_t)(_EGLDriver *drv, _EGLDisplay *dpy); +typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine); typedef _EGLProc (*GetProcAddress_t)(const char *procname); @@ -65,7 +65,6 @@ typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, _EGLDisplay *dpy, #ifdef EGL_VERSION_1_2 -typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy); typedef _EGLSurface *(*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLenum buftype, EGLClientBuffer buffer, _EGLConfig *config, const EGLint *attrib_list); #endif /* EGL_VERSION_1_2 */ @@ -101,7 +100,7 @@ struct _egl_api CopyBuffers_t CopyBuffers; QueryString_t QueryString; - WaitGL_t WaitGL; + WaitClient_t WaitClient; WaitNative_t WaitNative; GetProcAddress_t GetProcAddress; @@ -120,7 +119,6 @@ struct _egl_api QueryModeStringMESA_t QueryModeStringMESA; #ifdef EGL_VERSION_1_2 - WaitClient_t WaitClient; CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer; #endif }; diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c index 0c76c79973..018b06d3be 100644 --- a/src/egl/main/egldriver.c +++ b/src/egl/main/egldriver.c @@ -408,7 +408,7 @@ _eglInitDriverFallbacks(_EGLDriver *drv) drv->API.CopyBuffers = _eglCopyBuffers; drv->API.QueryString = _eglQueryString; - drv->API.WaitGL = _eglWaitGL; + drv->API.WaitClient = _eglWaitClient; drv->API.WaitNative = _eglWaitNative; #ifdef EGL_MESA_screen_surface diff --git a/src/egl/main/eglmisc.c b/src/egl/main/eglmisc.c index b37213faf1..e66913320b 100644 --- a/src/egl/main/eglmisc.c +++ b/src/egl/main/eglmisc.c @@ -108,11 +108,12 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name) EGLBoolean -_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy) +_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) { /* just a placeholder */ (void) drv; (void) dpy; + (void) ctx; return EGL_TRUE; } diff --git a/src/egl/main/eglmisc.h b/src/egl/main/eglmisc.h index a15c839be2..829d4cde79 100644 --- a/src/egl/main/eglmisc.h +++ b/src/egl/main/eglmisc.h @@ -37,7 +37,7 @@ _eglQueryString(_EGLDriver *drv, _EGLDisplay *dpy, EGLint name); extern EGLBoolean -_eglWaitGL(_EGLDriver *drv, _EGLDisplay *dpy); +_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx); extern EGLBoolean -- cgit v1.2.3 From 5b7d9053a08d5042206781a664ecd74efac0eb86 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 15 Oct 2009 13:00:03 -0600 Subject: progs/egl: put declarations before code --- progs/egl/eglgears.c | 10 ++++++---- progs/egl/egltri.c | 5 +++-- progs/egl/peglgears.c | 10 ++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c index 0eee9ecf4d..052d0f9e25 100644 --- a/progs/egl/eglgears.c +++ b/progs/egl/eglgears.c @@ -274,10 +274,10 @@ draw(void) static void reshape(int width, int height) { - glViewport(0, 0, (GLint) width, (GLint) height); - GLfloat h = (GLfloat) height / (GLfloat) width; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); @@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; + while (ct - st < ttr) { double tt = current_time(); @@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c index 79f6702007..9bbc3cddaf 100644 --- a/progs/egl/egltri.c +++ b/progs/egl/egltri.c @@ -127,6 +127,7 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; while (ct - st < ttr) { @@ -139,8 +140,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } diff --git a/progs/egl/peglgears.c b/progs/egl/peglgears.c index 1ddb691677..212d1acf69 100644 --- a/progs/egl/peglgears.c +++ b/progs/egl/peglgears.c @@ -274,10 +274,10 @@ draw(void) static void reshape(int width, int height) { - glViewport(0, 0, (GLint) width, (GLint) height); - GLfloat h = (GLfloat) height / (GLfloat) width; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); @@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; + while (ct - st < ttr) { double tt = current_time(); @@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } -- cgit v1.2.3 From 108273c5ed43b2c54a58900b7bb4528f912e2b1f Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Sun, 11 Oct 2009 12:54:11 -0400 Subject: st/xorg: refix source over --- src/gallium/state_trackers/xorg/xorg_composite.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index b07192175e..d6483fb72c 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -34,7 +34,7 @@ static const struct xorg_composite_blend xorg_blends[] = { PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE }, { PictOpOver, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE, + PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, { PictOpOverReverse, -- cgit v1.2.3 From 13580aa3d142b17f936e517daf949ae228f9f14e Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 15 Oct 2009 21:58:44 +0200 Subject: nouveau: nv30: refuse binding a colour buffer with a zeta buffer with different bits, till the backend can tell Mesa not to do that. --- src/gallium/drivers/nv30/nv30_state_fb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 2729dcec7c..9b0266fba5 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -15,6 +15,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) unsigned w = fb->width; unsigned h = fb->height; struct nv30_miptree *nv30mt; + int colour_bits = 32, zeta_bits = 32; rt_enable = 0; for (i = 0; i < fb->nr_cbufs; i++) { @@ -54,6 +55,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) break; case PIPE_FORMAT_R5G6B5_UNORM: rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5; + colour_bits = 16; break; default: assert(0); @@ -62,6 +64,7 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) switch (zeta_format) { case PIPE_FORMAT_Z16_UNORM: rt_format |= NV34TCL_RT_FORMAT_ZETA_Z16; + zeta_bits = 16; break; case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: @@ -72,6 +75,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) assert(0); } + if (colour_bits != zeta_bits) { + return FALSE; + } + if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) { uint32_t pitch = rt[0]->pitch; if (zeta) { -- cgit v1.2.3 From a5a05fd782bf7bc3843e475df7b12fe6784c1b9e Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 15 Oct 2009 22:41:09 +0200 Subject: nouveau: nv30: Hack to enforce same number of bits as front buffer, for render targets --- src/gallium/drivers/nv30/nv30_screen.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 41af38450b..5b1e5cab2d 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -10,6 +10,22 @@ #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; + + unsigned nr_pctx; + struct pipe_context **pctx; + + struct pipe_surface *front; +}; + static int nv30_screen_get_param(struct pipe_screen *pscreen, int param) { @@ -83,21 +99,19 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen, 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_A8R8G8B8_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: - return TRUE; - default: - break; - } + return (format == front->format); } else if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { switch (format) { case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: + return (front->format == PIPE_FORMAT_A8R8G8B8_UNORM) + || (front->format == PIPE_FORMAT_A8R8G8B8_UNORM); case PIPE_FORMAT_Z16_UNORM: - return TRUE; + return (front->format == PIPE_FORMAT_R5G6B5_UNORM); default: break; } -- cgit v1.2.3 From e4f21be13ac14edd89e865138a9e36b266425b39 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 15 Oct 2009 16:58:26 -0700 Subject: r300g: Set logical ID for each emitted texture/sampler. multitexarray works on my r300, but texrect doesn't. --- src/gallium/drivers/r300/r300_emit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 2c3bba952d..f3adc0968e 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -531,7 +531,8 @@ void r300_emit_texture(struct r300_context* r300, CS_LOCALS(r300); BEGIN_CS(16); - OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0); + OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->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); -- cgit v1.2.3 From 60b6c7458319ff01ecdd9d1650d526ac8f75e194 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Fri, 16 Oct 2009 11:36:09 +0100 Subject: prog/tests: Fix MSVC build. --- progs/tests/invert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/tests/invert.c b/progs/tests/invert.c index 63099fbd22..3bc97a460b 100644 --- a/progs/tests/invert.c +++ b/progs/tests/invert.c @@ -128,7 +128,7 @@ static void Init( void ) { const char * const ver_string = (const char * const) glGetString( GL_VERSION ); - const float ver = strtof( ver_string, NULL ); + const float ver = strtod( ver_string, NULL ); printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); -- cgit v1.2.3 From 699260b19535abaa3af0a5d33eb039e3d6a30ce9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 16 Oct 2009 11:39:29 +0100 Subject: progs/tests: Use rand() instead of random(). More portable. Same implementation on Linux. --- progs/tests/prog_parameter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c index 6dd956c402..6123ef7c16 100644 --- a/progs/tests/prog_parameter.c +++ b/progs/tests/prog_parameter.c @@ -116,7 +116,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param, for ( i = 0 ; i < (4 * count) ; i++ ) { - param[i] = (GLfloat) random() / (GLfloat) random(); + param[i] = (GLfloat) rand() / (GLfloat) rand(); } /* Try using the "classic" interface. -- cgit v1.2.3 From 166957abebea6aa203eba7e6348e89d53cf0e13e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 16 Oct 2009 11:39:29 +0100 Subject: progs/tests: Use rand() instead of random(). Forgot these on previous commit. --- progs/tests/prog_parameter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c index 6123ef7c16..28e3b537ac 100644 --- a/progs/tests/prog_parameter.c +++ b/progs/tests/prog_parameter.c @@ -153,7 +153,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param, for ( i = 0 ; i < (4 * count) ; i++ ) { - param[i] = (GLfloat) random() / (GLfloat) random(); + param[i] = (GLfloat) rand() / (GLfloat) rand(); } printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count); -- cgit v1.2.3 From 89b31c9619449d5c9b8ebe4e245c2a926e3583e6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 Oct 2009 14:19:03 -0600 Subject: mesa: use C locale for _mesa_strtod() _mesa_strtod() is used for shader/program parsing where the decimal point character is always '.' Use strtod_l() with a "C" locale to ensure correct string->double conversion when the actual locale uses another character such as ',' for the decimal point. Fixes bug 24531. --- src/mesa/main/imports.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 6ffaddcde9..87cb5ce0fb 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -48,6 +48,10 @@ #include "context.h" #include "version.h" +#ifdef _GNU_SOURCE +#include +#endif + #define MAXSTRING 4000 /* for vsnprintf() */ @@ -908,7 +912,15 @@ _mesa_atoi(const char *s) double _mesa_strtod( const char *s, char **end ) { +#ifdef _GNU_SOURCE + static locale_t loc = NULL; + if (!loc) { + loc = newlocale(LC_CTYPE_MASK, "C", NULL); + } + return strtod_l(s, end, loc); +#else return strtod(s, end); +#endif } /** Compute simple checksum/hash for a string */ -- cgit v1.2.3 From 946bc9aa42600caa400eb6926dcc5cbd558f2280 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 07:38:39 -0600 Subject: docs: document GLSL float parsing bug fix --- docs/relnotes-7.6.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes-7.6.1.html b/docs/relnotes-7.6.1.html index 47a906f1f4..9d28a5b2b5 100644 --- a/docs/relnotes-7.6.1.html +++ b/docs/relnotes-7.6.1.html @@ -44,6 +44,7 @@ tbd

  • r300: Work around an issue with very large fragment programs on R500.
  • Fake glXQueryDrawable() didn't return good values (bug 24320)
  • Fixed AUX buffer breakage (bug 24426). +
  • Fixed locale-dependent float parsing bug in GLSL compiler (bug 24531) -- cgit v1.2.3 From 3924d8611513eea74446d655b554596ab66381ff Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 16 Oct 2009 08:27:56 -0700 Subject: util: Change function names to begin with u_. Avoids link-time clashes with Mesa's internal hash table. --- src/gallium/auxiliary/util/u_hash_table.c | 41 ++++++++++++++++--------------- src/gallium/auxiliary/util/u_hash_table.h | 33 +++++++++++++------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index 8c2a8f454c..de711f9c1d 100644 --- a/src/gallium/auxiliary/util/u_hash_table.c +++ b/src/gallium/auxiliary/util/u_hash_table.c @@ -47,7 +47,7 @@ #include "util/u_hash_table.h" -struct hash_table +struct u_hash_table { struct cso_hash *cso; @@ -75,13 +75,13 @@ hash_table_item(struct cso_hash_iter iter) } -struct hash_table * -hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)) +struct u_hash_table * +u_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2)) { - struct hash_table *ht; + struct u_hash_table *ht; - ht = MALLOC_STRUCT(hash_table); + ht = MALLOC_STRUCT(u_hash_table); if(!ht) return NULL; @@ -99,7 +99,7 @@ hash_table_create(unsigned (*hash)(void *key), static INLINE struct cso_hash_iter -hash_table_find_iter(struct hash_table *ht, +hash_table_find_iter(struct u_hash_table *ht, void *key, unsigned key_hash) { @@ -119,7 +119,7 @@ hash_table_find_iter(struct hash_table *ht, static INLINE struct hash_table_item * -hash_table_find_item(struct hash_table *ht, +hash_table_find_item(struct u_hash_table *ht, void *key, unsigned key_hash) { @@ -139,9 +139,9 @@ hash_table_find_item(struct hash_table *ht, enum pipe_error -hash_table_set(struct hash_table *ht, - void *key, - void *value) +u_hash_table_set(struct u_hash_table *ht, + void *key, + void *value) { unsigned key_hash; struct hash_table_item *item; @@ -178,8 +178,8 @@ hash_table_set(struct hash_table *ht, void * -hash_table_get(struct hash_table *ht, - void *key) +u_hash_table_get(struct u_hash_table *ht, + void *key) { unsigned key_hash; struct hash_table_item *item; @@ -199,8 +199,8 @@ hash_table_get(struct hash_table *ht, void -hash_table_remove(struct hash_table *ht, - void *key) +u_hash_table_remove(struct u_hash_table *ht, + void *key) { unsigned key_hash; struct cso_hash_iter iter; @@ -225,7 +225,7 @@ hash_table_remove(struct hash_table *ht, void -hash_table_clear(struct hash_table *ht) +u_hash_table_clear(struct u_hash_table *ht) { struct cso_hash_iter iter; struct hash_table_item *item; @@ -244,9 +244,10 @@ hash_table_clear(struct hash_table *ht) enum pipe_error -hash_table_foreach(struct hash_table *ht, - enum pipe_error (*callback)(void *key, void *value, void *data), - void *data) +u_hash_table_foreach(struct u_hash_table *ht, + enum pipe_error (*callback) + (void *key, void *value, void *data), + void *data) { struct cso_hash_iter iter; struct hash_table_item *item; @@ -270,7 +271,7 @@ hash_table_foreach(struct hash_table *ht, void -hash_table_destroy(struct hash_table *ht) +u_hash_table_destroy(struct u_hash_table *ht) { struct cso_hash_iter iter; struct hash_table_item *item; diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h index feee881582..feb47365f0 100644 --- a/src/gallium/auxiliary/util/u_hash_table.h +++ b/src/gallium/auxiliary/util/u_hash_table.h @@ -46,7 +46,7 @@ extern "C" { /** * Generic purpose hash table. */ -struct hash_table; +struct u_hash_table; /** @@ -55,37 +55,38 @@ struct hash_table; * @param hash hash function * @param compare should return 0 for two equal keys. */ -struct hash_table * -hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)); +struct u_hash_table * +u_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2)); enum pipe_error -hash_table_set(struct hash_table *ht, - void *key, - void *value); +u_hash_table_set(struct u_hash_table *ht, + void *key, + void *value); void * -hash_table_get(struct hash_table *ht, - void *key); +u_hash_table_get(struct u_hash_table *ht, + void *key); void -hash_table_remove(struct hash_table *ht, - void *key); +u_hash_table_remove(struct u_hash_table *ht, + void *key); void -hash_table_clear(struct hash_table *ht); +u_hash_table_clear(struct u_hash_table *ht); enum pipe_error -hash_table_foreach(struct hash_table *ht, - enum pipe_error (*callback)(void *key, void *value, void *data), - void *data); +u_hash_table_foreach(struct u_hash_table *ht, + enum pipe_error (*callback) + (void *key, void *value, void *data), + void *data); void -hash_table_destroy(struct hash_table *ht); +u_hash_table_destroy(struct u_hash_table *ht); #ifdef __cplusplus -- cgit v1.2.3 From fc8a156cfc539b9c04dc3527e4fc61cb4b0b688e Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 16 Oct 2009 08:39:59 -0700 Subject: r300g: Use a hash table to look up vertex info. Need to move rs_block to this, too. Also, I'm getting massive amounts of flicker for some reason; I bet we've gotta re-re-examine PSC and friends. :C --- src/gallium/drivers/r300/r300_context.c | 18 ++++++- src/gallium/drivers/r300/r300_context.h | 10 +++- src/gallium/drivers/r300/r300_emit.c | 26 +++++----- src/gallium/drivers/r300/r300_render.c | 2 +- src/gallium/drivers/r300/r300_state_derived.c | 72 ++++++++++++++++++++------- src/gallium/drivers/r300/r300_state_derived.h | 4 ++ 6 files changed, 97 insertions(+), 35 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index b243f88bb5..a1156d2de6 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -89,10 +89,23 @@ static boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode, return r300_draw_elements(pipe, NULL, 0, mode, start, count); } -static void r300_destroy_context(struct pipe_context* context) { +static enum pipe_error r300_clear_hash_table(void* key, void* value, + void* data) +{ + FREE(key); + FREE(value); + return PIPE_OK; +} + +static void r300_destroy_context(struct pipe_context* context) +{ struct r300_context* r300 = r300_context(context); struct r300_query* query, * temp; + u_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table, + NULL); + u_hash_table_destroy(r300->shader_hash_table); + draw_destroy(r300->draw); /* Free the OQ BO. */ @@ -167,6 +180,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.is_texture_referenced = r300_is_texture_referenced; r300->context.is_buffer_referenced = r300_is_buffer_referenced; + r300->shader_hash_table = u_hash_table_create(r300_shader_key_hash, + r300_shader_key_compare); + r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state); r300->rs_block = CALLOC_STRUCT(r300_rs_block); r300->scissor_state = CALLOC_STRUCT(r300_scissor_state); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2acce0fd4a..2a62c67fc7 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -30,12 +30,14 @@ #include "tgsi/tgsi_scan.h" +#include "util/u_hash_table.h" #include "util/u_memory.h" #include "util/u_simple_list.h" #include "r300_clear.h" #include "r300_query.h" #include "r300_screen.h" +#include "r300_state_derived.h" #include "r300_winsys.h" struct r300_fragment_shader; @@ -248,6 +250,12 @@ struct r300_context { struct r300_query *query_current; struct r300_query query_list; + /* Shader hash table. Used to store vertex formatting information, which + * depends on the combination of both currently loaded shaders. */ + struct u_hash_table* shader_hash_table; + /* Vertex formatting information. */ + struct r300_vertex_format* vertex_info; + /* Various CSO state objects. */ /* Blend state. */ struct r300_blend_state* blend_state; @@ -278,8 +286,6 @@ struct r300_context { /* Vertex buffers for Gallium. */ struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; - /* Vertex information. */ - struct r300_vertex_format vertex_info; /* Vertex shader. */ struct r300_vertex_shader* vs; /* Viewport state. */ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index f3adc0968e..e6092cda9b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -551,7 +551,7 @@ void r300_emit_vertex_buffer(struct r300_context* r300) DBG(r300, DBG_DRAW, "r300: Preparing vertex buffer %p for render, " "vertex size %d\n", r300->vbo, - r300->vertex_info.vinfo.size); + r300->vertex_info->vinfo.size); /* Set the pointer to our vertex buffer. The emitted values are this: * PACKET3 [3D_LOAD_VBPNTR] * COUNT [1] @@ -562,8 +562,8 @@ void r300_emit_vertex_buffer(struct r300_context* r300) BEGIN_CS(7); OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, 3); OUT_CS(1); - OUT_CS(r300->vertex_info.vinfo.size | - (r300->vertex_info.vinfo.size << 8)); + OUT_CS(r300->vertex_info->vinfo.size | + (r300->vertex_info->vinfo.size << 8)); OUT_CS(r300->vbo_offset); OUT_CS_RELOC(r300->vbo, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); END_CS; @@ -575,30 +575,30 @@ void r300_emit_vertex_format_state(struct r300_context* r300) CS_LOCALS(r300); BEGIN_CS(26); - OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info.vinfo.size); + OUT_CS_REG(R300_VAP_VTX_SIZE, r300->vertex_info->vinfo.size); OUT_CS_REG_SEQ(R300_VAP_VTX_STATE_CNTL, 2); - OUT_CS(r300->vertex_info.vinfo.hwfmt[0]); - OUT_CS(r300->vertex_info.vinfo.hwfmt[1]); + OUT_CS(r300->vertex_info->vinfo.hwfmt[0]); + OUT_CS(r300->vertex_info->vinfo.hwfmt[1]); OUT_CS_REG_SEQ(R300_VAP_OUTPUT_VTX_FMT_0, 2); - OUT_CS(r300->vertex_info.vinfo.hwfmt[2]); - OUT_CS(r300->vertex_info.vinfo.hwfmt[3]); + OUT_CS(r300->vertex_info->vinfo.hwfmt[2]); + OUT_CS(r300->vertex_info->vinfo.hwfmt[3]); /* for (i = 0; i < 4; i++) { * debug_printf("hwfmt%d: 0x%08x\n", i, - * r300->vertex_info.vinfo.hwfmt[i]); + * r300->vertex_info->vinfo.hwfmt[i]); * } */ OUT_CS_REG_SEQ(R300_VAP_PROG_STREAM_CNTL_0, 8); for (i = 0; i < 8; i++) { - OUT_CS(r300->vertex_info.vap_prog_stream_cntl[i]); + OUT_CS(r300->vertex_info->vap_prog_stream_cntl[i]); /* debug_printf("prog_stream_cntl%d: 0x%08x\n", i, - * r300->vertex_info.vap_prog_stream_cntl[i]); */ + * r300->vertex_info->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(r300->vertex_info.vap_prog_stream_cntl_ext[i]); + OUT_CS(r300->vertex_info->vap_prog_stream_cntl_ext[i]); /* debug_printf("prog_stream_cntl_ext%d: 0x%08x\n", i, - * r300->vertex_info.vap_prog_stream_cntl_ext[i]); */ + * r300->vertex_info->vap_prog_stream_cntl_ext[i]); */ } END_CS; } diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index b56f7a3d1e..4e778e1e57 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -67,7 +67,7 @@ r300_render_get_vertex_info(struct vbuf_render* render) r300_update_derived_state(r300); - return &r300->vertex_info.vinfo; + return &r300->vertex_info->vinfo; } static boolean r300_render_allocate_vertices(struct vbuf_render* render, diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index f0861a9cf1..53027777d6 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -29,6 +29,27 @@ /* r300_state_derived: Various bits of state which are dependent upon * currently bound CSO data. */ +struct r300_shader_key { + struct r300_vertex_shader* vs; + struct r300_fragment_shader* fs; +}; + +unsigned r300_shader_key_hash(void* key) { + struct r300_shader_key* shader_key = (struct r300_shader_key*)key; + unsigned vs = (unsigned)shader_key->vs; + unsigned fs = (unsigned)shader_key->fs; + + return (vs << 16) | (fs & 0xffff); +} + +int r300_shader_key_compare(void* key1, void* key2) { + struct r300_shader_key* shader_key1 = (struct r300_shader_key*)key1; + struct r300_shader_key* shader_key2 = (struct r300_shader_key*)key2; + + return (shader_key1->vs == shader_key2->vs) && + (shader_key1->fs == shader_key2->fs); +} + /* Set up the vs_tab and routes. */ static void r300_vs_tab_routes(struct r300_context* r300, struct r300_vertex_format* vformat) @@ -247,23 +268,41 @@ static void r300_vertex_psc(struct r300_context* r300, /* Update the vertex format. */ static void r300_update_vertex_format(struct r300_context* r300) { - struct r300_vertex_format vformat; + struct r300_shader_key* key; + struct r300_vertex_format* vformat; + void* value; int i; - memset(&vformat, 0, sizeof(struct r300_vertex_format)); - for (i = 0; i < 16; i++) { - vformat.vs_tab[i] = -1; - vformat.fs_tab[i] = -1; - } + key = CALLOC_STRUCT(r300_shader_key); + key->vs = r300->vs; + key->fs = r300->fs; - r300_vs_tab_routes(r300, &vformat); + value = u_hash_table_get(r300->shader_hash_table, (void*)key); + if (value) { + debug_printf("r300: Hash table hit! vs: %p fs: %p\n", key->vs, + key->fs); + vformat = (struct r300_vertex_format*)value; + } else { + debug_printf("r300: Hash table miss... vs: %p fs: %p\n", key->vs, + key->fs); + vformat = CALLOC_STRUCT(r300_vertex_format); + + for (i = 0; i < 16; i++) { + vformat->vs_tab[i] = -1; + vformat->fs_tab[i] = -1; + } + + r300_vs_tab_routes(r300, vformat); + r300_vertex_psc(r300, vformat); - r300_vertex_psc(r300, &vformat); + if (u_hash_table_set(r300->shader_hash_table, (void*)key, + (void*)vformat) != PIPE_OK) { + debug_printf("r300: Hash table insertion error!\n"); + } + } - if (memcmp(&r300->vertex_info, &vformat, - sizeof(struct r300_vertex_format))) { - memcpy(&r300->vertex_info, &vformat, - sizeof(struct r300_vertex_format)); + if (r300->vertex_info != vformat) { + r300->vertex_info = vformat; r300->dirty_state |= R300_NEW_VERTEX_FORMAT; } } @@ -271,7 +310,7 @@ static void r300_update_vertex_format(struct r300_context* r300) /* Set up the mappings from GB to US, for RS block. */ static void r300_update_fs_tab(struct r300_context* r300) { - struct r300_vertex_format* vformat = &r300->vertex_info; + struct r300_vertex_format* vformat = r300->vertex_info; struct tgsi_shader_info* info = &r300->fs->info; int i, cols = 0, texs = 0, cols_emitted = 0; int* tab = vformat->fs_tab; @@ -337,7 +376,7 @@ static void r300_update_rs_block(struct r300_context* r300) { struct r300_rs_block* rs = r300->rs_block; struct tgsi_shader_info* info = &r300->fs->info; - int* tab = r300->vertex_info.fs_tab; + int* tab = r300->vertex_info->fs_tab; int col_count = 0, fp_offset = 0, i, tex_count = 0; int rs_tex_comp = 0; memset(rs, 0, sizeof(struct r300_rs_block)); @@ -477,10 +516,7 @@ static void r300_update_ztop(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { - if (r300->dirty_state & - (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) { - r300_update_vertex_format(r300); - } + r300_update_vertex_format(r300); if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) { r300_update_fs_tab(r300); diff --git a/src/gallium/drivers/r300/r300_state_derived.h b/src/gallium/drivers/r300/r300_state_derived.h index 71a4a47b00..05ad535e2d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.h +++ b/src/gallium/drivers/r300/r300_state_derived.h @@ -25,6 +25,10 @@ struct r300_context; +unsigned r300_shader_key_hash(void* key); + +int r300_shader_key_compare(void* key1, void* key2); + void r300_update_derived_state(struct r300_context* r300); #endif /* R300_STATE_DERIVED_H */ -- cgit v1.2.3 From 3e56bef5a5f56feb65ae94a51e5db9cf943ce0ce Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Fri, 16 Oct 2009 09:45:07 -0700 Subject: radeon-gallium: Use debug_get_bool_option instead of getenv. --- src/gallium/winsys/drm/radeon/core/radeon_drm.c | 4 ++-- src/gallium/winsys/drm/radeon/core/radeon_drm.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.c b/src/gallium/winsys/drm/radeon/core/radeon_drm.c index caab33de1c..69f14e54f2 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.c +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.c @@ -38,7 +38,7 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api, { struct radeon_winsys* winsys = radeon_pipe_winsys(drmFB); - if (getenv("RADEON_SOFTPIPE")) { + if (debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) { return softpipe_create_screen((struct pipe_winsys*)winsys); } else { struct r300_winsys* r300 = radeon_create_r300_winsys(drmFB, winsys); @@ -51,7 +51,7 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api, struct pipe_context* radeon_create_context(struct drm_api* api, struct pipe_screen* screen) { - if (getenv("RADEON_SOFTPIPE")) { + if (debug_get_bool_option("RADEON_SOFTPIPE", FALSE)) { return radeon_create_softpipe(screen->winsys); } else { return r300_create_context(screen, diff --git a/src/gallium/winsys/drm/radeon/core/radeon_drm.h b/src/gallium/winsys/drm/radeon/core/radeon_drm.h index 88a5c82b28..9a789ec1a4 100644 --- a/src/gallium/winsys/drm/radeon/core/radeon_drm.h +++ b/src/gallium/winsys/drm/radeon/core/radeon_drm.h @@ -37,6 +37,7 @@ #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" -- cgit v1.2.3 From 3594b53c0173ac810106f667604bf94b5cfc4a1e Mon Sep 17 00:00:00 2001 From: Maciej Cencora Date: Fri, 16 Oct 2009 20:21:17 +0200 Subject: r300: fix vertex program parameters limits --- src/mesa/drivers/dri/r300/r300_vertprog.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_vertprog.c b/src/mesa/drivers/dri/r300/r300_vertprog.c index 2f7b67c143..ed8b788108 100644 --- a/src/mesa/drivers/dri/r300/r300_vertprog.c +++ b/src/mesa/drivers/dri/r300/r300_vertprog.c @@ -62,12 +62,6 @@ static int r300VertexProgUpdateParams(GLcontext * ctx, struct r300_vertex_progra } } - if (vp->code.constants.Count * 4 > VSF_MAX_FRAGMENT_LENGTH) { - /* Should have checked this earlier... */ - fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__); - _mesa_exit(-1); - } - for(i = 0; i < vp->code.constants.Count; ++i) { const float * src = 0; const struct rc_constant * constant = &vp->code.constants.Constants[i]; @@ -281,6 +275,11 @@ static struct r300_vertex_program *build_program(GLcontext *ctx, } r3xx_compile_vertex_program(&compiler); + + if (vp->code.constants.Count > ctx->Const.VertexProgram.MaxParameters) { + rc_error(&compiler.Base, "Program exceeds constant buffer size limit\n"); + } + vp->error = compiler.Base.Error; vp->Base->Base.InputsRead = vp->code.InputsRead; @@ -334,7 +333,6 @@ struct r300_vertex_program * r300SelectAndTranslateVertexShader(GLcontext *ctx) #define bump_vpu_count(ptr, new_count) do { \ drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr)); \ int _nc=(new_count)/4; \ - assert(_nc < 256); \ if(_nc>_p->vpu.count)_p->vpu.count=_nc; \ } while(0) -- cgit v1.2.3 From 2ee7fd8d584abf051c552f455aeb588e2936b0ea Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 15 Oct 2009 15:25:52 -0600 Subject: mesa: added MESA_GLSL=useprog debug flag This logs glUseProgram() calls to stderr. --- src/mesa/main/mtypes.h | 1 + src/mesa/shader/shader_api.c | 27 +++++++++++++++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 988bfe1e22..b77dcdb730 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2046,6 +2046,7 @@ struct gl_shader_program #define GLSL_UNIFORMS 0x10 /**< Print glUniform calls */ #define GLSL_NOP_VERT 0x20 /**< Force no-op vertex shaders */ #define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */ +#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */ /** diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c index 6de97984e6..f473bd1173 100644 --- a/src/mesa/shader/shader_api.c +++ b/src/mesa/shader/shader_api.c @@ -390,6 +390,8 @@ get_shader_flags(void) flags |= GLSL_OPT; if (_mesa_strstr(env, "uniform")) flags |= GLSL_UNIFORMS; + if (_mesa_strstr(env, "useprog")) + flags |= GLSL_USE_PROG; } return flags; @@ -1524,19 +1526,32 @@ _mesa_use_program(GLcontext *ctx, GLuint program) } /* debug code */ - if (0) { + if (ctx->Shader.Flags & GLSL_USE_PROG) { GLuint i; - _mesa_printf("Use Shader Program %u\n", shProg->Name); + _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name); for (i = 0; i < shProg->NumShaders; i++) { - _mesa_printf(" shader %u, type 0x%x, checksum %u\n", + const char *s; + switch (shProg->Shaders[i]->Type) { + case GL_VERTEX_SHADER: + s = "vertex"; + break; + case GL_FRAGMENT_SHADER: + s = "fragment"; + break; + case GL_GEOMETRY_SHADER: + s = "geometry"; + break; + default: + s = ""; + } + _mesa_printf(" %s shader %u, checksum %u\n", s, shProg->Shaders[i]->Name, - shProg->Shaders[i]->Type, shProg->Shaders[i]->SourceChecksum); } if (shProg->VertexProgram) - printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); + _mesa_printf(" vert prog %u\n", shProg->VertexProgram->Base.Id); if (shProg->FragmentProgram) - printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); + _mesa_printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id); } } else { -- cgit v1.2.3 From f0503726bf8113919e4b00fbca504d7cbdcd0151 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 08:12:47 -0600 Subject: mesa: move a comma --- src/mesa/main/mtypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index b77dcdb730..ea3b552b9d 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -208,7 +208,7 @@ typedef enum VERT_RESULT_BFC0 = 13, VERT_RESULT_BFC1 = 14, VERT_RESULT_EDGE = 15, - VERT_RESULT_VAR0 = 16 /**< shader varying */, + VERT_RESULT_VAR0 = 16, /**< shader varying */ VERT_RESULT_MAX = (VERT_RESULT_VAR0 + MAX_VARYING) } gl_vert_result; -- cgit v1.2.3 From d9fd207133ba2ff8cd0bbcab6963c70d71628b1b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 09:21:45 -0600 Subject: mesa: added SUBDIRS support in dri/Makefile.template --- src/mesa/drivers/dri/Makefile.template | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 18dbeba24a..defead6c6b 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -60,7 +60,7 @@ SHARED_INCLUDES = \ ##### TARGETS ##### -default: symlinks depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) +default: symlinks subdirs depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template @@ -72,6 +72,18 @@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) $(INSTALL) $(LIBNAME) $(TOP)/$(LIB_DIR) +# If the Makefile defined SUBDIRS, run make in each +.PHONY: subdirs +subdirs: + @if test -n "$(SUBDIRS)" ; then \ + for dir in $(SUBDIRS) ; do \ + if [ -d $$dir ] ; then \ + (cd $$dir && $(MAKE)) || exit 1; \ + fi \ + done \ + fi + + depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) @ echo "running $(MKDEP)" @ rm -f depend -- cgit v1.2.3 From db2046580f3b5be0e9fe30337f3bf412c4556ed9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 09:25:05 -0600 Subject: mesa: use EXTRA_MODULES and SUBDIRS to build r300 compiler This is a bit cleaner and avoids rebuilding the r300_dri.so library all the time. --- src/mesa/drivers/dri/Makefile.template | 6 ++++-- src/mesa/drivers/dri/r300/Makefile | 10 ++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index defead6c6b..d2731aebae 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -63,9 +63,11 @@ SHARED_INCLUDES = \ default: symlinks subdirs depend $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) -$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template +$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) Makefile \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ - $(OBJECTS) $(PIPE_DRIVERS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS) + $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(WINOBJ) \ + $(DRI_LIB_DEPS) $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index c64f940623..0e5b29b685 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -69,7 +69,10 @@ DRIVER_DEFINES = -DRADEON_R300 DRI_LIB_DEPS += $(RADEON_LDFLAGS) -PIPE_DRIVERS = compiler/libr300compiler.a +SUBDIRS = compiler + +EXTRA_MODULES = compiler/libr300compiler.a + ##### TARGETS ##### @@ -77,8 +80,3 @@ include ../Makefile.template symlinks: -# Mark the archive phony so that we always check for recompilation -.PHONY : compiler/libr300compiler.a - -compiler/libr300compiler.a: - cd compiler && $(MAKE) -- cgit v1.2.3 From f094b86bb5ab93aedc03df5cf5bdf51ab9d37045 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 09:33:11 -0600 Subject: mesa: lift default symlinks target into Makefile.template Driver Makefiles can still add symlink dependencies/rules if needed. --- src/mesa/drivers/dri/Makefile.template | 4 ++++ src/mesa/drivers/dri/fb/Makefile | 2 -- src/mesa/drivers/dri/ffb/Makefile | 1 - src/mesa/drivers/dri/gamma/Makefile | 1 - src/mesa/drivers/dri/i810/Makefile | 1 - src/mesa/drivers/dri/i915/Makefile | 1 - src/mesa/drivers/dri/i965/Makefile | 1 - src/mesa/drivers/dri/mach64/Makefile | 1 - src/mesa/drivers/dri/mga/Makefile | 1 - src/mesa/drivers/dri/r128/Makefile | 1 - src/mesa/drivers/dri/r200/Makefile | 1 - src/mesa/drivers/dri/r300/Makefile | 2 -- src/mesa/drivers/dri/r600/Makefile | 1 - src/mesa/drivers/dri/radeon/Makefile | 1 - src/mesa/drivers/dri/s3v/Makefile | 1 - src/mesa/drivers/dri/savage/Makefile | 1 - src/mesa/drivers/dri/sis/Makefile | 1 - src/mesa/drivers/dri/swrast/Makefile | 1 - src/mesa/drivers/dri/tdfx/Makefile | 2 -- src/mesa/drivers/dri/trident/Makefile | 1 - src/mesa/drivers/dri/unichrome/Makefile | 1 - 21 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index d2731aebae..1ce9315530 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -86,6 +86,10 @@ subdirs: fi +.PHONY: symlinks +symlinks: + + depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS) @ echo "running $(MKDEP)" @ rm -f depend diff --git a/src/mesa/drivers/dri/fb/Makefile b/src/mesa/drivers/dri/fb/Makefile index 309f50b95f..cf9b3a8556 100644 --- a/src/mesa/drivers/dri/fb/Makefile +++ b/src/mesa/drivers/dri/fb/Makefile @@ -25,5 +25,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: - diff --git a/src/mesa/drivers/dri/ffb/Makefile b/src/mesa/drivers/dri/ffb/Makefile index cb73238c03..e9da8f9066 100644 --- a/src/mesa/drivers/dri/ffb/Makefile +++ b/src/mesa/drivers/dri/ffb/Makefile @@ -33,4 +33,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/gamma/Makefile b/src/mesa/drivers/dri/gamma/Makefile index 250d3ac089..09df1578fc 100644 --- a/src/mesa/drivers/dri/gamma/Makefile +++ b/src/mesa/drivers/dri/gamma/Makefile @@ -32,4 +32,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/i810/Makefile b/src/mesa/drivers/dri/i810/Makefile index a7825b49b4..3874faee51 100644 --- a/src/mesa/drivers/dri/i810/Makefile +++ b/src/mesa/drivers/dri/i810/Makefile @@ -29,4 +29,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/i915/Makefile b/src/mesa/drivers/dri/i915/Makefile index 393312e732..37f15aa767 100644 --- a/src/mesa/drivers/dri/i915/Makefile +++ b/src/mesa/drivers/dri/i915/Makefile @@ -72,4 +72,3 @@ intel_decode.o: ../intel/intel_decode.c intel_tex_layout.o: ../intel/intel_tex_layout.c -symlinks: diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile index 57dcc91586..7a55333e89 100644 --- a/src/mesa/drivers/dri/i965/Makefile +++ b/src/mesa/drivers/dri/i965/Makefile @@ -100,6 +100,5 @@ DRI_LIB_DEPS += -ldrm_intel include ../Makefile.template -symlinks: intel_decode.o: ../intel/intel_decode.c intel_tex_layout.o: ../intel/intel_tex_layout.c diff --git a/src/mesa/drivers/dri/mach64/Makefile b/src/mesa/drivers/dri/mach64/Makefile index 7246d51f5d..a8f463e9fd 100644 --- a/src/mesa/drivers/dri/mach64/Makefile +++ b/src/mesa/drivers/dri/mach64/Makefile @@ -30,4 +30,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/mga/Makefile b/src/mesa/drivers/dri/mga/Makefile index a871064c62..0cc329fb22 100644 --- a/src/mesa/drivers/dri/mga/Makefile +++ b/src/mesa/drivers/dri/mga/Makefile @@ -31,4 +31,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/r128/Makefile b/src/mesa/drivers/dri/r128/Makefile index 796dfbc516..52c5a38a70 100644 --- a/src/mesa/drivers/dri/r128/Makefile +++ b/src/mesa/drivers/dri/r128/Makefile @@ -29,4 +29,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/r200/Makefile b/src/mesa/drivers/dri/r200/Makefile index fbce70c37b..776f1e3f3f 100644 --- a/src/mesa/drivers/dri/r200/Makefile +++ b/src/mesa/drivers/dri/r200/Makefile @@ -66,4 +66,3 @@ include ../Makefile.template #INCLUDES += -I../radeon/server -symlinks: diff --git a/src/mesa/drivers/dri/r300/Makefile b/src/mesa/drivers/dri/r300/Makefile index 0e5b29b685..cb0f715fa0 100644 --- a/src/mesa/drivers/dri/r300/Makefile +++ b/src/mesa/drivers/dri/r300/Makefile @@ -78,5 +78,3 @@ EXTRA_MODULES = compiler/libr300compiler.a include ../Makefile.template -symlinks: - diff --git a/src/mesa/drivers/dri/r600/Makefile b/src/mesa/drivers/dri/r600/Makefile index 7d5a7b1ab6..9b7c42042e 100644 --- a/src/mesa/drivers/dri/r600/Makefile +++ b/src/mesa/drivers/dri/r600/Makefile @@ -76,4 +76,3 @@ DRI_LIB_DEPS += $(RADEON_LDFLAGS) include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/radeon/Makefile b/src/mesa/drivers/dri/radeon/Makefile index b1efc72872..ae2e695bfc 100644 --- a/src/mesa/drivers/dri/radeon/Makefile +++ b/src/mesa/drivers/dri/radeon/Makefile @@ -55,4 +55,3 @@ X86_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/s3v/Makefile b/src/mesa/drivers/dri/s3v/Makefile index 9bd7973154..da7e6cdc20 100644 --- a/src/mesa/drivers/dri/s3v/Makefile +++ b/src/mesa/drivers/dri/s3v/Makefile @@ -33,4 +33,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/savage/Makefile b/src/mesa/drivers/dri/savage/Makefile index 018482f66b..2e5c40802c 100644 --- a/src/mesa/drivers/dri/savage/Makefile +++ b/src/mesa/drivers/dri/savage/Makefile @@ -27,4 +27,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/sis/Makefile b/src/mesa/drivers/dri/sis/Makefile index d2354e6776..ad009fc239 100644 --- a/src/mesa/drivers/dri/sis/Makefile +++ b/src/mesa/drivers/dri/sis/Makefile @@ -34,4 +34,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index 5f3a4f2191..771169c1ff 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -21,4 +21,3 @@ SWRAST_COMMON_SOURCES = \ include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/tdfx/Makefile b/src/mesa/drivers/dri/tdfx/Makefile index 092c580fea..b9f25db4fe 100644 --- a/src/mesa/drivers/dri/tdfx/Makefile +++ b/src/mesa/drivers/dri/tdfx/Makefile @@ -32,6 +32,4 @@ ASM_SOURCES = include ../Makefile.template -symlinks: - diff --git a/src/mesa/drivers/dri/trident/Makefile b/src/mesa/drivers/dri/trident/Makefile index 9ee24c504c..bd9b7f35a2 100644 --- a/src/mesa/drivers/dri/trident/Makefile +++ b/src/mesa/drivers/dri/trident/Makefile @@ -23,4 +23,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: diff --git a/src/mesa/drivers/dri/unichrome/Makefile b/src/mesa/drivers/dri/unichrome/Makefile index 5fe00c1bd1..344d34fce3 100644 --- a/src/mesa/drivers/dri/unichrome/Makefile +++ b/src/mesa/drivers/dri/unichrome/Makefile @@ -29,4 +29,3 @@ ASM_SOURCES = include ../Makefile.template -symlinks: -- cgit v1.2.3 From a335d334d45701a42c283257fa44f2f7148e186d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 16 Oct 2009 09:42:30 -0600 Subject: mesa: fix/update some comments --- src/mesa/main/mtypes.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index ea3b552b9d..052fbaaaea 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 7.5 + * Version: 7.7 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. All Rights Reserved. @@ -1917,10 +1917,10 @@ struct ati_fragment_shader struct atifs_instruction *Instructions[2]; struct atifs_setupinst *SetupInst[2]; GLfloat Constants[8][4]; - GLbitfield LocalConstDef; /** Indicates which constants have been set */ + GLbitfield LocalConstDef; /**< Indicates which constants have been set */ GLubyte numArithInstr[2]; GLubyte regsAssigned[2]; - GLubyte NumPasses; /** 1 or 2 */ + GLubyte NumPasses; /**< 1 or 2 */ GLubyte cur_pass; GLubyte last_optype; GLboolean interpinp1; @@ -1934,7 +1934,7 @@ struct ati_fragment_shader struct gl_ati_fragment_shader_state { GLboolean Enabled; - GLboolean _Enabled; /** enabled and valid shader? */ + GLboolean _Enabled; /**< enabled and valid shader? */ GLboolean Compiling; GLfloat GlobalConstants[8][4]; struct ati_fragment_shader *Current; -- cgit v1.2.3 From 60a39b6799c72430851d92f93758e2f25487a0f4 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 17 Oct 2009 08:25:48 +0100 Subject: intel: Disallow relocations to the byte beyond the end of the buffer --- src/mesa/drivers/dri/intel/intel_batchbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h index 9a619fbd5c..d4899aab7f 100644 --- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h +++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h @@ -157,7 +157,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch, #define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d) #define OUT_RELOC(buf, read_domains, write_domain, delta) do { \ - assert((unsigned) (delta) <= buf->size); \ + assert((unsigned) (delta) < buf->size); \ intel_batchbuffer_emit_reloc(intel->batch, buf, \ read_domains, write_domain, delta); \ } while (0) -- cgit v1.2.3 From 5d42e3988de8b3e1b37d8c21d18db240bc8b4096 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 17 Oct 2009 11:45:04 +0100 Subject: util: Rename from u_* to util_* while we're at it. To be consistent with the rest. --- src/gallium/auxiliary/util/u_hash_table.c | 90 +++++++++++++++---------------- src/gallium/auxiliary/util/u_hash_table.h | 32 +++++------ src/gallium/auxiliary/util/u_keymap.c | 2 +- 3 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/gallium/auxiliary/util/u_hash_table.c b/src/gallium/auxiliary/util/u_hash_table.c index de711f9c1d..5604e3ac37 100644 --- a/src/gallium/auxiliary/util/u_hash_table.c +++ b/src/gallium/auxiliary/util/u_hash_table.c @@ -47,7 +47,7 @@ #include "util/u_hash_table.h" -struct u_hash_table +struct util_hash_table { struct cso_hash *cso; @@ -61,27 +61,27 @@ struct u_hash_table }; -struct hash_table_item +struct util_hash_table_item { void *key; void *value; }; -static INLINE struct hash_table_item * -hash_table_item(struct cso_hash_iter iter) +static INLINE struct util_hash_table_item * +util_hash_table_item(struct cso_hash_iter iter) { - return (struct hash_table_item *)cso_hash_iter_data(iter); + return (struct util_hash_table_item *)cso_hash_iter_data(iter); } -struct u_hash_table * -u_hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)) +struct util_hash_table * +util_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2)) { - struct u_hash_table *ht; + struct util_hash_table *ht; - ht = MALLOC_STRUCT(u_hash_table); + ht = MALLOC_STRUCT(util_hash_table); if(!ht) return NULL; @@ -99,16 +99,16 @@ u_hash_table_create(unsigned (*hash)(void *key), static INLINE struct cso_hash_iter -hash_table_find_iter(struct u_hash_table *ht, - void *key, - unsigned key_hash) +util_hash_table_find_iter(struct util_hash_table *ht, + void *key, + unsigned key_hash) { struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; iter = cso_hash_find(ht->cso, key_hash); while (!cso_hash_iter_is_null(iter)) { - item = (struct hash_table_item *)cso_hash_iter_data(iter); + item = (struct util_hash_table_item *)cso_hash_iter_data(iter); if (!ht->compare(item->key, key)) break; iter = cso_hash_iter_next(iter); @@ -118,17 +118,17 @@ hash_table_find_iter(struct u_hash_table *ht, } -static INLINE struct hash_table_item * -hash_table_find_item(struct u_hash_table *ht, - void *key, - unsigned key_hash) +static INLINE struct util_hash_table_item * +util_hash_table_find_item(struct util_hash_table *ht, + void *key, + unsigned key_hash) { struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; iter = cso_hash_find(ht->cso, key_hash); while (!cso_hash_iter_is_null(iter)) { - item = (struct hash_table_item *)cso_hash_iter_data(iter); + item = (struct util_hash_table_item *)cso_hash_iter_data(iter); if (!ht->compare(item->key, key)) return item; iter = cso_hash_iter_next(iter); @@ -139,12 +139,12 @@ hash_table_find_item(struct u_hash_table *ht, enum pipe_error -u_hash_table_set(struct u_hash_table *ht, - void *key, - void *value) +util_hash_table_set(struct util_hash_table *ht, + void *key, + void *value) { unsigned key_hash; - struct hash_table_item *item; + struct util_hash_table_item *item; struct cso_hash_iter iter; assert(ht); @@ -153,14 +153,14 @@ u_hash_table_set(struct u_hash_table *ht, key_hash = ht->hash(key); - item = hash_table_find_item(ht, key, key_hash); + item = util_hash_table_find_item(ht, key, key_hash); if(item) { /* TODO: key/value destruction? */ item->value = value; return PIPE_OK; } - item = MALLOC_STRUCT(hash_table_item); + item = MALLOC_STRUCT(util_hash_table_item); if(!item) return PIPE_ERROR_OUT_OF_MEMORY; @@ -178,11 +178,11 @@ u_hash_table_set(struct u_hash_table *ht, void * -u_hash_table_get(struct u_hash_table *ht, - void *key) +util_hash_table_get(struct util_hash_table *ht, + void *key) { unsigned key_hash; - struct hash_table_item *item; + struct util_hash_table_item *item; assert(ht); if (!ht) @@ -190,7 +190,7 @@ u_hash_table_get(struct u_hash_table *ht, key_hash = ht->hash(key); - item = hash_table_find_item(ht, key, key_hash); + item = util_hash_table_find_item(ht, key, key_hash); if(!item) return NULL; @@ -199,12 +199,12 @@ u_hash_table_get(struct u_hash_table *ht, void -u_hash_table_remove(struct u_hash_table *ht, - void *key) +util_hash_table_remove(struct util_hash_table *ht, + void *key) { unsigned key_hash; struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; assert(ht); if (!ht) @@ -212,11 +212,11 @@ u_hash_table_remove(struct u_hash_table *ht, key_hash = ht->hash(key); - iter = hash_table_find_iter(ht, key, key_hash); + iter = util_hash_table_find_iter(ht, key, key_hash); if(cso_hash_iter_is_null(iter)) return; - item = hash_table_item(iter); + item = util_hash_table_item(iter); assert(item); FREE(item); @@ -225,10 +225,10 @@ u_hash_table_remove(struct u_hash_table *ht, void -u_hash_table_clear(struct u_hash_table *ht) +util_hash_table_clear(struct util_hash_table *ht) { struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; assert(ht); if (!ht) @@ -236,7 +236,7 @@ u_hash_table_clear(struct u_hash_table *ht) iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { - item = (struct hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter)); + item = (struct util_hash_table_item *)cso_hash_take(ht->cso, cso_hash_iter_key(iter)); FREE(item); iter = cso_hash_first_node(ht->cso); } @@ -244,13 +244,13 @@ u_hash_table_clear(struct u_hash_table *ht) enum pipe_error -u_hash_table_foreach(struct u_hash_table *ht, +util_hash_table_foreach(struct util_hash_table *ht, enum pipe_error (*callback) (void *key, void *value, void *data), void *data) { struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; enum pipe_error result; assert(ht); @@ -259,7 +259,7 @@ u_hash_table_foreach(struct u_hash_table *ht, iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { - item = (struct hash_table_item *)cso_hash_iter_data(iter); + item = (struct util_hash_table_item *)cso_hash_iter_data(iter); result = callback(item->key, item->value, data); if(result != PIPE_OK) return result; @@ -271,10 +271,10 @@ u_hash_table_foreach(struct u_hash_table *ht, void -u_hash_table_destroy(struct u_hash_table *ht) +util_hash_table_destroy(struct util_hash_table *ht) { struct cso_hash_iter iter; - struct hash_table_item *item; + struct util_hash_table_item *item; assert(ht); if (!ht) @@ -282,7 +282,7 @@ u_hash_table_destroy(struct u_hash_table *ht) iter = cso_hash_first_node(ht->cso); while (!cso_hash_iter_is_null(iter)) { - item = (struct hash_table_item *)cso_hash_iter_data(iter); + item = (struct util_hash_table_item *)cso_hash_iter_data(iter); FREE(item); iter = cso_hash_iter_next(iter); } diff --git a/src/gallium/auxiliary/util/u_hash_table.h b/src/gallium/auxiliary/util/u_hash_table.h index feb47365f0..258a31aec8 100644 --- a/src/gallium/auxiliary/util/u_hash_table.h +++ b/src/gallium/auxiliary/util/u_hash_table.h @@ -46,7 +46,7 @@ extern "C" { /** * Generic purpose hash table. */ -struct u_hash_table; +struct util_hash_table; /** @@ -55,38 +55,38 @@ struct u_hash_table; * @param hash hash function * @param compare should return 0 for two equal keys. */ -struct u_hash_table * -u_hash_table_create(unsigned (*hash)(void *key), - int (*compare)(void *key1, void *key2)); +struct util_hash_table * +util_hash_table_create(unsigned (*hash)(void *key), + int (*compare)(void *key1, void *key2)); enum pipe_error -u_hash_table_set(struct u_hash_table *ht, - void *key, - void *value); +util_hash_table_set(struct util_hash_table *ht, + void *key, + void *value); void * -u_hash_table_get(struct u_hash_table *ht, - void *key); +util_hash_table_get(struct util_hash_table *ht, + void *key); void -u_hash_table_remove(struct u_hash_table *ht, - void *key); +util_hash_table_remove(struct util_hash_table *ht, + void *key); void -u_hash_table_clear(struct u_hash_table *ht); +util_hash_table_clear(struct util_hash_table *ht); enum pipe_error -u_hash_table_foreach(struct u_hash_table *ht, - enum pipe_error (*callback) +util_hash_table_foreach(struct util_hash_table *ht, + enum pipe_error (*callback) (void *key, void *value, void *data), - void *data); + void *data); void -u_hash_table_destroy(struct u_hash_table *ht); +util_hash_table_destroy(struct util_hash_table *ht); #ifdef __cplusplus diff --git a/src/gallium/auxiliary/util/u_keymap.c b/src/gallium/auxiliary/util/u_keymap.c index 508a2ee063..f856395ca9 100644 --- a/src/gallium/auxiliary/util/u_keymap.c +++ b/src/gallium/auxiliary/util/u_keymap.c @@ -28,7 +28,7 @@ /** * Key lookup/associative container. * - * Like Jose's u_hash_table, based on CSO cache code for now. + * Like Jose's util_hash_table, based on CSO cache code for now. * * Author: Brian Paul */ -- cgit v1.2.3 From 67356ae04743da3137e950503ffd4a1f8fa36400 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 17 Oct 2009 20:27:24 +0200 Subject: nouveau: nv30: Use same workaround as i915 for segfault related to vbo --- src/gallium/drivers/nv30/nv30_context.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c index f827bdc78b..a3e65b96f7 100644 --- a/src/gallium/drivers/nv30/nv30_context.c +++ b/src/gallium/drivers/nv30/nv30_context.c @@ -10,7 +10,7 @@ nv30_flush(struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence) { struct nv30_context *nv30 = nv30_context(pipe); - + if (flags & PIPE_FLUSH_TEXTURE_CACHE) { BEGIN_RING(rankine, 0x1fd8, 1); OUT_RING (2); @@ -37,10 +37,14 @@ nv30_is_texture_referenced( struct pipe_context *pipe, unsigned face, unsigned level) { /** - * FIXME: Optimize. + * FIXME: Return the corrent result. We can't alays return referenced + * since it causes a double flush within the vbo module. */ - +#if 0 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; +#else + return 0; +#endif } static unsigned int @@ -48,10 +52,14 @@ nv30_is_buffer_referenced( struct pipe_context *pipe, struct pipe_buffer *buf) { /** - * FIXME: Optimize. + * FIXME: Return the corrent result. We can't alays return referenced + * since it causes a double flush within the vbo module. */ - +#if 0 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; +#else + return 0; +#endif } struct pipe_context * @@ -95,4 +103,3 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id) return &nv30->pipe; } - -- cgit v1.2.3 From 66aab9a1f6de241687a14f7aed45226061c1b84b Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 17 Oct 2009 20:46:19 +0200 Subject: nouveau: nv30: Remove duplicate case. Was a typo for X8R8G8B8, but that will never be use for front buffer. --- src/gallium/drivers/nv30/nv30_screen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c index 5b1e5cab2d..bb40e1803d 100644 --- a/src/gallium/drivers/nv30/nv30_screen.c +++ b/src/gallium/drivers/nv30/nv30_screen.c @@ -108,8 +108,7 @@ nv30_screen_surface_format_supported(struct pipe_screen *pscreen, switch (format) { case PIPE_FORMAT_Z24S8_UNORM: case PIPE_FORMAT_Z24X8_UNORM: - return (front->format == PIPE_FORMAT_A8R8G8B8_UNORM) - || (front->format == PIPE_FORMAT_A8R8G8B8_UNORM); + return (front->format == PIPE_FORMAT_A8R8G8B8_UNORM); case PIPE_FORMAT_Z16_UNORM: return (front->format == PIPE_FORMAT_R5G6B5_UNORM); default: -- cgit v1.2.3 From 114417a2f52ab463f37fcabb5e9b0636574623dc Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Sat, 17 Oct 2009 20:49:18 +0200 Subject: nouveau: nv40: Use same workaround as i915 for segfault related to vbo --- src/gallium/drivers/nv40/nv40_context.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c index 8eba6a43ef..4e23671202 100644 --- a/src/gallium/drivers/nv40/nv40_context.c +++ b/src/gallium/drivers/nv40/nv40_context.c @@ -10,7 +10,7 @@ nv40_flush(struct pipe_context *pipe, unsigned flags, struct pipe_fence_handle **fence) { struct nv40_context *nv40 = nv40_context(pipe); - + if (flags & PIPE_FLUSH_TEXTURE_CACHE) { BEGIN_RING(curie, 0x1fd8, 1); OUT_RING (2); @@ -37,10 +37,14 @@ nv40_is_texture_referenced( struct pipe_context *pipe, unsigned face, unsigned level) { /** - * FIXME: Optimize. + * FIXME: Return the correct result. We can't always return referenced + * since it causes a double flush within the vbo module. */ - +#if 0 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; +#else + return 0; +#endif } static unsigned int @@ -48,10 +52,14 @@ nv40_is_buffer_referenced( struct pipe_context *pipe, struct pipe_buffer *buf) { /** - * FIXME: Optimize. + * FIXME: Return the correct result. We can't always return referenced + * since it causes a double flush within the vbo module. */ - +#if 0 return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; +#else + return 0; +#endif } struct pipe_context * @@ -95,4 +103,3 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id) return &nv40->pipe; } - -- cgit v1.2.3 From ce9ae4a483e7c85a9046a87005232aa09de782aa Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 17 Oct 2009 20:05:23 -0700 Subject: r300g: Fix u_hash_table rename. --- src/gallium/drivers/r300/r300_context.c | 6 +++--- src/gallium/drivers/r300/r300_context.h | 2 +- src/gallium/drivers/r300/r300_state_derived.c | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index a1156d2de6..0518685200 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -102,9 +102,9 @@ static void r300_destroy_context(struct pipe_context* context) struct r300_context* r300 = r300_context(context); struct r300_query* query, * temp; - u_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table, + util_hash_table_foreach(r300->shader_hash_table, r300_clear_hash_table, NULL); - u_hash_table_destroy(r300->shader_hash_table); + util_hash_table_destroy(r300->shader_hash_table); draw_destroy(r300->draw); @@ -180,7 +180,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.is_texture_referenced = r300_is_texture_referenced; r300->context.is_buffer_referenced = r300_is_buffer_referenced; - r300->shader_hash_table = u_hash_table_create(r300_shader_key_hash, + r300->shader_hash_table = util_hash_table_create(r300_shader_key_hash, r300_shader_key_compare); r300->blend_color_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 2a62c67fc7..2d608d6afc 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -252,7 +252,7 @@ struct r300_context { /* Shader hash table. Used to store vertex formatting information, which * depends on the combination of both currently loaded shaders. */ - struct u_hash_table* shader_hash_table; + struct util_hash_table* shader_hash_table; /* Vertex formatting information. */ struct r300_vertex_format* vertex_info; diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 53027777d6..0210d97914 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -277,7 +277,7 @@ static void r300_update_vertex_format(struct r300_context* r300) key->vs = r300->vs; key->fs = r300->fs; - value = u_hash_table_get(r300->shader_hash_table, (void*)key); + value = util_hash_table_get(r300->shader_hash_table, (void*)key); if (value) { debug_printf("r300: Hash table hit! vs: %p fs: %p\n", key->vs, key->fs); @@ -295,10 +295,8 @@ static void r300_update_vertex_format(struct r300_context* r300) r300_vs_tab_routes(r300, vformat); r300_vertex_psc(r300, vformat); - if (u_hash_table_set(r300->shader_hash_table, (void*)key, - (void*)vformat) != PIPE_OK) { - debug_printf("r300: Hash table insertion error!\n"); - } + util_hash_table_set(r300->shader_hash_table, + (void*)key, (void*)vformat); } if (r300->vertex_info != vformat) { -- cgit v1.2.3 From 51173e4e53a64465d1498ffd6454687b7629eb59 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 17 Oct 2009 20:29:27 -0700 Subject: r300g: Also have rs_block keyed to the current shader combo. Eliminates part of the glxgears corruption here. Need to clean up PSC more, to get rid of the rest of it. --- src/gallium/drivers/r300/r300_state_derived.c | 109 ++++++++++++++------------ 1 file changed, 58 insertions(+), 51 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 0210d97914..da8c366f30 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -34,6 +34,11 @@ struct r300_shader_key { struct r300_fragment_shader* fs; }; +struct r300_shader_derived_value { + struct r300_vertex_format* vformat; + struct r300_rs_block* rs_block; +}; + unsigned r300_shader_key_hash(void* key) { struct r300_shader_key* shader_key = (struct r300_shader_key*)key; unsigned vs = (unsigned)shader_key->vs; @@ -265,50 +270,10 @@ static void r300_vertex_psc(struct r300_context* r300, (R300_LAST_VEC << (i & 1 ? 16 : 0)); } -/* Update the vertex format. */ -static void r300_update_vertex_format(struct r300_context* r300) -{ - struct r300_shader_key* key; - struct r300_vertex_format* vformat; - void* value; - int i; - - key = CALLOC_STRUCT(r300_shader_key); - key->vs = r300->vs; - key->fs = r300->fs; - - value = util_hash_table_get(r300->shader_hash_table, (void*)key); - if (value) { - debug_printf("r300: Hash table hit! vs: %p fs: %p\n", key->vs, - key->fs); - vformat = (struct r300_vertex_format*)value; - } else { - debug_printf("r300: Hash table miss... vs: %p fs: %p\n", key->vs, - key->fs); - vformat = CALLOC_STRUCT(r300_vertex_format); - - for (i = 0; i < 16; i++) { - vformat->vs_tab[i] = -1; - vformat->fs_tab[i] = -1; - } - - r300_vs_tab_routes(r300, vformat); - r300_vertex_psc(r300, vformat); - - util_hash_table_set(r300->shader_hash_table, - (void*)key, (void*)vformat); - } - - if (r300->vertex_info != vformat) { - r300->vertex_info = vformat; - r300->dirty_state |= R300_NEW_VERTEX_FORMAT; - } -} - /* Set up the mappings from GB to US, for RS block. */ -static void r300_update_fs_tab(struct r300_context* r300) +static void r300_update_fs_tab(struct r300_context* r300, + struct r300_vertex_format* vformat) { - struct r300_vertex_format* vformat = r300->vertex_info; struct tgsi_shader_info* info = &r300->fs->info; int i, cols = 0, texs = 0, cols_emitted = 0; int* tab = vformat->fs_tab; @@ -370,14 +335,14 @@ static void r300_update_fs_tab(struct r300_context* r300) /* Set up the RS block. This is the part of the chipset that actually does * the rasterization of vertices into fragments. This is also the part of the * chipset that locks up if any part of it is even slightly wrong. */ -static void r300_update_rs_block(struct r300_context* r300) +static void r300_update_rs_block(struct r300_context* r300, + struct r300_vertex_format* vformat, + struct r300_rs_block* rs) { - struct r300_rs_block* rs = r300->rs_block; struct tgsi_shader_info* info = &r300->fs->info; - int* tab = r300->vertex_info->fs_tab; + int* tab = vformat->fs_tab; int col_count = 0, fp_offset = 0, i, tex_count = 0; int rs_tex_comp = 0; - memset(rs, 0, sizeof(struct r300_rs_block)); if (r300_screen(r300->context.screen)->caps->is_r500) { for (i = 0; i < info->num_inputs; i++) { @@ -481,6 +446,53 @@ static void r300_update_rs_block(struct r300_context* r300) rs->inst_count = MAX2(MAX2(col_count - 1, tex_count - 1), 0); } +/* Update the vertex format. */ +static void r300_update_vertex_format(struct r300_context* r300) +{ + struct r300_shader_key* key; + struct r300_vertex_format* vformat; + struct r300_rs_block* rs_block; + struct r300_shader_derived_value* value; + int i; + + key = CALLOC_STRUCT(r300_shader_key); + key->vs = r300->vs; + key->fs = r300->fs; + + value = (struct r300_shader_derived_value*) + util_hash_table_get(r300->shader_hash_table, (void*)key); + if (value) { + vformat = value->vformat; + rs_block = value->rs_block; + + FREE(key); + } else { + vformat = CALLOC_STRUCT(r300_vertex_format); + rs_block = CALLOC_STRUCT(r300_rs_block); + value = CALLOC_STRUCT(r300_shader_derived_value); + + for (i = 0; i < 16; i++) { + vformat->vs_tab[i] = -1; + vformat->fs_tab[i] = -1; + } + + r300_vs_tab_routes(r300, vformat); + r300_vertex_psc(r300, vformat); + r300_update_fs_tab(r300, vformat); + + r300_update_rs_block(r300, vformat, rs_block); + + value->vformat = vformat; + value->rs_block = rs_block; + util_hash_table_set(r300->shader_hash_table, + (void*)key, (void*)value); + } + + r300->vertex_info = vformat; + r300->rs_block = rs_block; + r300->dirty_state |= (R300_NEW_VERTEX_FORMAT | R300_NEW_RS_BLOCK); +} + static void r300_update_ztop(struct r300_context* r300) { r300->ztop_state.z_buffer_top = R300_ZTOP_ENABLE; @@ -516,11 +528,6 @@ void r300_update_derived_state(struct r300_context* r300) { r300_update_vertex_format(r300); - if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) { - r300_update_fs_tab(r300); - r300_update_rs_block(r300); - } - if (r300->dirty_state & (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) { r300_update_ztop(r300); -- cgit v1.2.3 From 11056ca86fce64209b7d21c87070c419a1968d28 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 17 Oct 2009 20:47:45 -0700 Subject: r300g: Use a dirty test to bring framerate back up. This is just split out from the next commit, that's all. --- src/gallium/drivers/r300/r300_state_derived.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index da8c366f30..c59d446e93 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -447,7 +447,7 @@ static void r300_update_rs_block(struct r300_context* r300, } /* Update the vertex format. */ -static void r300_update_vertex_format(struct r300_context* r300) +static void r300_update_derived_shader_state(struct r300_context* r300) { struct r300_shader_key* key; struct r300_vertex_format* vformat; @@ -526,7 +526,10 @@ static void r300_update_ztop(struct r300_context* r300) void r300_update_derived_state(struct r300_context* r300) { - r300_update_vertex_format(r300); + if (r300->dirty_state & + (R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) { + r300_update_derived_shader_state(r300); + } if (r300->dirty_state & (R300_NEW_DSA | R300_NEW_FRAGMENT_SHADER | R300_NEW_QUERY)) { -- cgit v1.2.3 From bfd877e4705002d97ee8dba6fe0c1f8676582ab3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 17 Oct 2009 20:53:19 -0700 Subject: r300g: Squash format warning. Won't ever be supported. --- src/gallium/drivers/r300/r300_screen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 5381651c77..44770d1aca 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -231,6 +231,7 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage, /* Definitely unsupported formats. */ /* Non-usable Z buffer/stencil formats. */ + case PIPE_FORMAT_Z32_UNORM: case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: -- cgit v1.2.3 From bb567357bc1366df7115e0daa68c2470e3bf6ba6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sat, 17 Oct 2009 21:32:56 -0700 Subject: gallium: Permit surface_copy and surface_fill to be NULL. Uf. Lots of files touched. Would people with working vega, xorg, dri1, etc. please make sure you are not broken, and fix yourself up if you are. There were only two or three places where the code did not have painful fallbacks, so I would advise st maintainers to find less painful workarounds, or consider overhauling util_surface_copy and util_surface_fill. Per ymanton, darktama, and Dr_Jakob's suggestions, clear has been left as-is. I will not add PIPE_CAP_BLITTER unless it is deemed necessary. --- src/gallium/auxiliary/util/u_blit.c | 19 ++++++++++++++----- src/gallium/auxiliary/util/u_clear.h | 16 +++++++++++++--- src/gallium/drivers/r300/r300_context.c | 2 +- src/gallium/include/pipe/p_context.h | 3 +++ src/gallium/state_trackers/dri/dri_drawable.c | 22 ++++++++++++++++------ src/gallium/state_trackers/egl/egl_surface.c | 23 +++++++++++++++++------ src/gallium/state_trackers/vega/renderer.c | 16 ++++++++++++---- src/gallium/state_trackers/vega/vg_tracker.c | 24 +++++++++++++++++------- src/gallium/state_trackers/xorg/xorg_exa.c | 12 +++++++++--- src/gallium/state_trackers/xorg/xorg_renderer.c | 19 ++++++++++++++----- src/mesa/state_tracker/st_atom_framebuffer.c | 16 ++++++++++++---- src/mesa/state_tracker/st_cb_drawpixels.c | 19 ++++++++++++++----- src/mesa/state_tracker/st_cb_fbo.c | 16 ++++++++++++---- src/mesa/state_tracker/st_cb_texture.c | 3 ++- 14 files changed, 156 insertions(+), 54 deletions(-) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index fb00c3abe8..5038642599 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -46,6 +46,7 @@ #include "util/u_memory.h" #include "util/u_simple_shaders.h" #include "util/u_surface.h" +#include "util/u_rect.h" #include "cso_cache/cso_context.h" @@ -301,7 +302,8 @@ util_blit_pixels_writemask(struct blit_state *ctx, * no overlapping. * Filter mode should not matter since there's no stretching. */ - if (dst->format == src->format && + if (pipe->surface_copy && + dst->format == src->format && srcX0 < srcX1 && dstX0 < dstX1 && srcY0 < srcY1 && @@ -365,10 +367,17 @@ util_blit_pixels_writemask(struct blit_state *ctx, PIPE_BUFFER_USAGE_GPU_WRITE); /* load temp texture */ - pipe->surface_copy(pipe, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ + if (pipe->surface_copy) { + pipe->surface_copy(pipe, + texSurf, 0, 0, /* dest */ + src, srcLeft, srcTop, /* src */ + srcW, srcH); /* size */ + } else { + util_surface_copy(pipe, FALSE, + texSurf, 0, 0, /* dest */ + src, srcLeft, srcTop, /* src */ + srcW, srcH); /* size */ + } /* free the surface, update the texture if necessary. */ diff --git a/src/gallium/auxiliary/util/u_clear.h b/src/gallium/auxiliary/util/u_clear.h index 7c16b32cf9..1e65a035ae 100644 --- a/src/gallium/auxiliary/util/u_clear.h +++ b/src/gallium/auxiliary/util/u_clear.h @@ -32,6 +32,7 @@ #include "pipe/p_context.h" #include "pipe/p_state.h" #include "util/u_pack_color.h" +#include "util/u_rect.h" /** @@ -48,13 +49,22 @@ util_clear(struct pipe_context *pipe, unsigned color; util_pack_color(rgba, ps->format, &color); - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); + if (pipe->surface_fill) { + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); + } else { + util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, color); + } } if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { struct pipe_surface *ps = framebuffer->zsbuf; - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, - util_pack_z_stencil(ps->format, depth, stencil)); + if (pipe->surface_fill) { + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, + util_pack_z_stencil(ps->format, depth, stencil)); + } else { + util_surface_fill(pipe, ps, 0, 0, ps->width, ps->height, + util_pack_z_stencil(ps->format, depth, stencil)); + } } } diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 0518685200..7b370b3e95 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -206,7 +206,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300_init_query_functions(r300); - r300_init_surface_functions(r300); + /* r300_init_surface_functions(r300); */ r300_init_state_functions(r300); diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index 39620a7198..5569001e60 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -189,6 +189,9 @@ struct pipe_context { /** * Surface functions + * + * The pipe driver is allowed to set these functions to NULL, and in that + * case, they will not be available. */ /*@{*/ diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index c67cc8dacb..5625ff53cf 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -45,6 +45,7 @@ #include "state_tracker/st_cb_fbo.h" #include "util/u_memory.h" +#include "util/u_rect.h" static struct pipe_surface * dri_surface_from_handle(struct drm_api *api, @@ -541,12 +542,21 @@ dri1_swap_copy(struct dri_context *ctx, cur = dPriv->pClipRects; for (i = 0; i < dPriv->numClipRects; ++i) { - if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) - pipe->surface_copy(pipe, dst, clip.x1, clip.y1, - src, - (int)clip.x1 - dPriv->x, - (int)clip.y1 - dPriv->y, - clip.x2 - clip.x1, clip.y2 - clip.y1); + if (dri1_intersect_src_bbox(&clip, dPriv->x, dPriv->y, cur++, bbox)) { + if (pipe->surface_copy) { + pipe->surface_copy(pipe, dst, clip.x1, clip.y1, + src, + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, + clip.x2 - clip.x1, clip.y2 - clip.y1); + } else { + util_surface_copy(pipe, FALSE, dst, clip.x1, clip.y1, + src, + (int)clip.x1 - dPriv->x, + (int)clip.y1 - dPriv->y, + clip.x2 - clip.x1, clip.y2 - clip.y1); + } + } } } diff --git a/src/gallium/state_trackers/egl/egl_surface.c b/src/gallium/state_trackers/egl/egl_surface.c index 7911a8834e..71c013756d 100644 --- a/src/gallium/state_trackers/egl/egl_surface.c +++ b/src/gallium/state_trackers/egl/egl_surface.c @@ -12,6 +12,8 @@ #include "state_tracker/drm_api.h" +#include "util/u_rect.h" + /* * Util functions */ @@ -360,12 +362,21 @@ drm_swap_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw) st_notify_swapbuffers(surf->stfb); if (ctx && surf->screen) { - ctx->pipe->surface_copy(ctx->pipe, - surf->screen->surface, - 0, 0, - back_surf, - 0, 0, - surf->w, surf->h); + if (ctx->pipe->surface_copy) { + ctx->pipe->surface_copy(ctx->pipe, + surf->screen->surface, + 0, 0, + back_surf, + 0, 0, + surf->w, surf->h); + } else { + util_surface_copy(ctx->pipe, FALSE, + surf->screen->surface, + 0, 0, + back_surf, + 0, 0, + surf->w, surf->h); + } ctx->pipe->flush(ctx->pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_TEXTURE_CACHE, NULL); #ifdef DRM_MODE_FEATURE_DIRTYFB diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c index f7c5f2f0cd..396c88aa3d 100644 --- a/src/gallium/state_trackers/vega/renderer.c +++ b/src/gallium/state_trackers/vega/renderer.c @@ -37,6 +37,7 @@ #include "util/u_draw_quad.h" #include "util/u_simple_shaders.h" #include "util/u_memory.h" +#include "util/u_rect.h" #include "cso_cache/cso_context.h" @@ -457,10 +458,17 @@ void renderer_copy_surface(struct renderer *ctx, PIPE_BUFFER_USAGE_GPU_WRITE); /* load temp texture */ - pipe->surface_copy(pipe, - texSurf, 0, 0, /* dest */ - src, srcLeft, srcTop, /* src */ - srcW, srcH); /* size */ + if (pipe->surface_copy) { + pipe->surface_copy(pipe, + texSurf, 0, 0, /* dest */ + src, srcLeft, srcTop, /* src */ + srcW, srcH); /* size */ + } else { + util_surface_copy(pipe, FALSE, + texSurf, 0, 0, /* dest */ + src, srcLeft, srcTop, /* src */ + srcW, srcH); /* size */ + } /* free the surface, update the texture if necessary.*/ screen->tex_surface_destroy(texSurf); diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c index 56cc60aebe..c4da01e52c 100644 --- a/src/gallium/state_trackers/vega/vg_tracker.c +++ b/src/gallium/state_trackers/vega/vg_tracker.c @@ -235,13 +235,23 @@ static void setup_new_alpha_mask(struct vg_context *ctx, old_texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); - pipe->surface_copy(pipe, - surface, - 0, 0, - old_surface, - 0, 0, - MIN2(old_surface->width, width), - MIN2(old_surface->height, height)); + if (pipe->surface_copy) { + pipe->surface_copy(pipe, + surface, + 0, 0, + old_surface, + 0, 0, + MIN2(old_surface->width, width), + MIN2(old_surface->height, height)); + } else { + util_surface_copy(pipe, FALSE, + surface, + 0, 0, + old_surface, + 0, 0, + MIN2(old_surface->width, width), + MIN2(old_surface->height, height)); + } if (surface) pipe_surface_reference(&surface, NULL); if (old_surface) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index af76d6690f..4988af4864 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -693,9 +693,15 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, dst_surf = exa->scrn->get_tex_surface( exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE); src_surf = xorg_gpu_surface(exa->pipe->screen, priv); - exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, - 0, 0, min(width, texture->width[0]), - min(height, texture->height[0])); + if (exa->pipe->surface_copy) { + exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf, + 0, 0, min(width, texture->width[0]), + min(height, texture->height[0])); + } else { + util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf, + 0, 0, min(width, texture->width[0]), + min(height, texture->height[0])); + } exa->scrn->tex_surface_destroy(dst_surf); exa->scrn->tex_surface_destroy(src_surf); } diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 81b209cb59..ca69e1e0e9 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -7,6 +7,7 @@ #include "util/u_draw_quad.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "util/u_rect.h" #include "pipe/p_inlines.h" @@ -586,11 +587,19 @@ create_sampler_texture(struct xorg_renderer *r, screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ); struct pipe_surface *ps_tex = screen->get_tex_surface( screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); - pipe->surface_copy(pipe, - ps_tex, /* dest */ - 0, 0, /* destx/y */ - ps_read, - 0, 0, src->width[0], src->height[0]); + if (pipe->surface_copy) { + pipe->surface_copy(pipe, + ps_tex, /* dest */ + 0, 0, /* destx/y */ + ps_read, + 0, 0, src->width[0], src->height[0]); + } else { + util_surface_copy(pipe, FALSE, + ps_tex, /* dest */ + 0, 0, /* destx/y */ + ps_read, + 0, 0, src->width[0], src->height[0]); + } pipe_surface_reference(&ps_read, NULL); pipe_surface_reference(&ps_tex, NULL); } diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 5209a6a0c9..e18c0f6e0a 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -39,6 +39,7 @@ #include "pipe/p_context.h" #include "pipe/p_inlines.h" #include "cso_cache/cso_context.h" +#include "util/u_rect.h" @@ -162,10 +163,17 @@ update_framebuffer_state( struct st_context *st ) (void) st_get_framebuffer_surface(stfb, ST_SURFACE_FRONT_LEFT, &surf_front); (void) st_get_framebuffer_surface(stfb, ST_SURFACE_BACK_LEFT, &surf_back); - st->pipe->surface_copy(st->pipe, - surf_front, 0, 0, /* dest */ - surf_back, 0, 0, /* src */ - fb->Width, fb->Height); + if (st->pipe->surface_copy) { + st->pipe->surface_copy(st->pipe, + surf_front, 0, 0, /* dest */ + surf_back, 0, 0, /* src */ + fb->Width, fb->Height); + } else { + util_surface_copy(st->pipe, FALSE, + surf_front, 0, 0, + surf_back, 0, 0, + fb->Width, fb->Height); + } } /* we're assuming we'll really draw to the front buffer */ st->frontbuffer_status = FRONT_STATUS_DIRTY; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 5c3413f905..be44577117 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -62,6 +62,7 @@ #include "util/u_tile.h" #include "util/u_draw_quad.h" #include "util/u_math.h" +#include "util/u_rect.h" #include "shader/prog_instruction.h" #include "cso_cache/cso_context.h" @@ -1075,11 +1076,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, PIPE_BUFFER_USAGE_GPU_READ); struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE ); - pipe->surface_copy(pipe, - psTex, /* dest */ - 0, 0, /* destx/y */ - psRead, - srcx, srcy, width, height); + if (pipe->surface_copy) { + pipe->surface_copy(pipe, + psTex, /* dest */ + 0, 0, /* destx/y */ + psRead, + srcx, srcy, width, height); + } else { + util_surface_copy(pipe, FALSE, + psTex, + 0, 0, + psRead, + srcx, srcy, width, height); + } pipe_surface_reference(&psRead, NULL); pipe_surface_reference(&psTex, NULL); } diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 864f5d3ca3..73aa65955b 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -49,6 +49,7 @@ #include "st_public.h" #include "st_texture.h" +#include "util/u_rect.h" /** @@ -538,10 +539,17 @@ copy_back_to_front(struct st_context *st, (void) st_get_framebuffer_surface(stfb, backIndex, &surf_back); if (surf_front && surf_back) { - st->pipe->surface_copy(st->pipe, - surf_front, 0, 0, /* dest */ - surf_back, 0, 0, /* src */ - fb->Width, fb->Height); + if (st->pipe->surface_copy) { + st->pipe->surface_copy(st->pipe, + surf_front, 0, 0, /* dest */ + surf_back, 0, 0, /* src */ + fb->Width, fb->Height); + } else { + util_surface_copy(st->pipe, FALSE, + surf_front, 0, 0, + surf_back, 0, 0, + fb->Width, fb->Height); + } } } diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index b943787106..a1953342b4 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1546,7 +1546,8 @@ st_copy_texsubimage(GLcontext *ctx, if (ctx->_ImageTransferState == 0x0) { - if (matching_base_formats && + if (pipe->surface_copy && + matching_base_formats && src_format == dest_format && !do_flip) { -- cgit v1.2.3 From 838da1d4ae11aa8b5eab4f35713709714e337cbe Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 18 Oct 2009 14:31:58 +0100 Subject: llvmpipe: Allocate texture storage for whole quads. --- src/gallium/drivers/llvmpipe/lp_texture.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c index 08f0950d47..a00f2495df 100644 --- a/src/gallium/drivers/llvmpipe/lp_texture.c +++ b/src/gallium/drivers/llvmpipe/lp_texture.c @@ -66,16 +66,24 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen, pf_get_block(lpt->base.format, &lpt->base.block); for (level = 0; level <= pt->last_level; level++) { + unsigned nblocksx, nblocksy; + pt->width[level] = width; pt->height[level] = height; pt->depth[level] = depth; pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width); - pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height); - lpt->stride[level] = align(pt->nblocksx[level]*pt->block.size, 16); + pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height); + + /* Allocate storage for whole quads. This is particularly important + * for depth surfaces, which are currently stored in a swizzled format. */ + nblocksx = pf_get_nblocksx(&pt->block, align(width, 2)); + nblocksy = pf_get_nblocksy(&pt->block, align(height, 2)); + + lpt->stride[level] = align(nblocksx*pt->block.size, 16); lpt->level_offset[level] = buffer_size; - buffer_size += (pt->nblocksy[level] * + buffer_size += (nblocksy * ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) * lpt->stride[level]); -- cgit v1.2.3 From d2e29b502e5f777551ff057f08e54d82542863cf Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 18 Oct 2009 10:30:18 -0700 Subject: r300g: Add another ZTOP condition. I don't even know if texkill works right now. --- src/gallium/drivers/r300/r300_state_derived.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index c59d446e93..2c624766bb 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -517,6 +517,8 @@ static void r300_update_ztop(struct r300_context* r300) */ if (r300->dsa_state->alpha_function) { r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; + } else if (r300->fs->info.uses_kill) { + r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; } else if (r300_fragment_shader_writes_depth(r300->fs)) { r300->ztop_state.z_buffer_top = R300_ZTOP_DISABLE; } else if (r300->query_current) { -- cgit v1.2.3 From 16a06fea73b1e6e8857f7568762bfc56dcfe2940 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Sun, 18 Oct 2009 15:54:39 -0700 Subject: r300g: Fix up a bunch of warnings. --- src/gallium/drivers/r300/r300_emit.c | 24 +++++++++++------------- src/gallium/drivers/r300/r300_emit.h | 1 + src/gallium/drivers/r300/r300_flush.c | 2 ++ src/gallium/drivers/r300/r300_screen.c | 2 +- src/gallium/drivers/r300/r300_state.c | 4 ++-- src/gallium/drivers/r300/r300_state_derived.c | 10 ++++------ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index e6092cda9b..df2046bd0c 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -320,8 +320,7 @@ void r300_emit_fb_state(struct r300_context* r300, END_CS; } -void r300_emit_query_start(struct r300_context *r300) - +static 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; @@ -334,9 +333,9 @@ void r300_emit_query_start(struct r300_context *r300) * for overlapping queries. */ BEGIN_CS(4); if (caps->family == CHIP_FAMILY_RV530) { - OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); + OUT_CS_REG(RV530_FG_ZBREG_DEST, RV530_FG_ZBREG_DEST_PIPE_SELECT_ALL); } else { - OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL); + OUT_CS_REG(R300_SU_REG_DEST, R300_RASTER_PIPE_SELECT_ALL); } OUT_CS_REG(R300_ZB_ZPASS_DATA, 0); END_CS; @@ -345,7 +344,7 @@ void r300_emit_query_start(struct r300_context *r300) static void r300_emit_query_finish(struct r300_context *r300, - struct r300_query *query) + struct r300_query *query) { struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; CS_LOCALS(r300); @@ -388,7 +387,7 @@ static void r300_emit_query_finish(struct r300_context *r300, OUT_CS_REG_SEQ(R300_ZB_ZPASS_ADDR, 1); OUT_CS_RELOC(r300->oqbo, query->offset + (sizeof(uint32_t) * 0), 0, RADEON_GEM_DOMAIN_GTT, 0); - break; + break; default: debug_printf("r300: Implementation error: Chipset reports %d" " pixel pipes!\n", caps->num_frag_pipes); @@ -398,11 +397,10 @@ static void r300_emit_query_finish(struct r300_context *r300, /* And, finally, reset it to normal... */ OUT_CS_REG(R300_SU_REG_DEST, 0xF); END_CS; - } static void rv530_emit_query_single(struct r300_context *r300, - struct r300_query *query) + struct r300_query *query) { CS_LOCALS(r300); @@ -415,7 +413,7 @@ static void rv530_emit_query_single(struct r300_context *r300, } static void rv530_emit_query_double(struct r300_context *r300, - struct r300_query *query) + struct r300_query *query) { CS_LOCALS(r300); @@ -442,10 +440,10 @@ void r300_emit_query_end(struct r300_context* r300) return; if (caps->family == CHIP_FAMILY_RV530) { - if (caps->num_z_pipes == 2) - rv530_emit_query_double(r300, query); - else - rv530_emit_query_single(r300, query); + if (caps->num_z_pipes == 2) + rv530_emit_query_double(r300, query); + else + rv530_emit_query_single(r300, query); } else r300_emit_query_finish(r300, query); } diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index b62aa9fec5..7e469ea0c7 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -58,6 +58,7 @@ void r300_emit_fb_state(struct r300_context* r300, 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, struct r300_rs_state* rs); diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index 241ea71d6b..d60652a021 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -20,7 +20,9 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "r300_emit.h" #include "r300_flush.h" +#include "r300_state_invariant.h" static void r300_flush(struct pipe_context* pipe, unsigned flags, diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 44770d1aca..cc499d400a 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -311,7 +311,7 @@ r300_get_tex_transfer(struct pipe_screen *screen, { struct r300_texture *tex = (struct r300_texture *)texture; struct r300_transfer *trans; - unsigned offset; /* in bytes */ + unsigned offset = 0; /* in bytes */ /* XXX Add support for these things */ if (texture->target == PIPE_TEXTURE_CUBE) { diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 8359850966..0a982a9d5d 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -329,7 +329,7 @@ static void r300_delete_fs_state(struct pipe_context* pipe, void* shader) { struct r300_fragment_shader* fs = (struct r300_fragment_shader*)shader; rc_constants_destroy(&fs->code.constants); - FREE(fs->state.tokens); + FREE((void*)fs->state.tokens); FREE(shader); } @@ -697,7 +697,7 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader) rc_constants_destroy(&vs->code.constants); draw_delete_vertex_shader(r300->draw, vs->draw); - FREE(vs->state.tokens); + FREE((void*)vs->state.tokens); FREE(shader); } else { draw_delete_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 2c624766bb..1468b9d36e 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -265,7 +265,9 @@ static void r300_vertex_psc(struct r300_context* r300, } /* Set the last vector in the PSC. */ - i--; + if (i) { + i -= 1; + } vformat->vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC << (i & 1 ? 16 : 0)); } @@ -336,17 +338,14 @@ static void r300_update_fs_tab(struct r300_context* r300, * the rasterization of vertices into fragments. This is also the part of the * chipset that locks up if any part of it is even slightly wrong. */ static void r300_update_rs_block(struct r300_context* r300, - struct r300_vertex_format* vformat, struct r300_rs_block* rs) { struct tgsi_shader_info* info = &r300->fs->info; - int* tab = vformat->fs_tab; int col_count = 0, fp_offset = 0, i, tex_count = 0; int rs_tex_comp = 0; if (r300_screen(r300->context.screen)->caps->is_r500) { for (i = 0; i < info->num_inputs; i++) { - assert(tab[i] != -1); switch (info->input_semantic_name[i]) { case TGSI_SEMANTIC_COLOR: rs->ip[col_count] |= @@ -387,7 +386,6 @@ static void r300_update_rs_block(struct r300_context* r300, } } else { for (i = 0; i < info->num_inputs; i++) { - assert(tab[i] != -1); switch (info->input_semantic_name[i]) { case TGSI_SEMANTIC_COLOR: rs->ip[col_count] |= @@ -480,7 +478,7 @@ static void r300_update_derived_shader_state(struct r300_context* r300) r300_vertex_psc(r300, vformat); r300_update_fs_tab(r300, vformat); - r300_update_rs_block(r300, vformat, rs_block); + r300_update_rs_block(r300, rs_block); value->vformat = vformat; value->rs_block = rs_block; -- cgit v1.2.3 From 869d3eea37ee060d62cd5b7f6031ef5a93e328a1 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Wed, 7 Oct 2009 16:07:34 +1000 Subject: drm/nv50: write tic/tsc setup to correct slots when skipping units --- src/gallium/drivers/nv50/nv50_state_validate.c | 7 ++++--- src/gallium/drivers/nv50/nv50_tex.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index fd27620371..9079de918d 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -356,13 +356,14 @@ viewport_uptodate: if (nv50->dirty & NV50_NEW_SAMPLER) { int i; - so = so_new(nv50->sampler_nr * 9 + 2, 0); - so_method(so, tesla, NV50TCL_CB_ADDR, 1); - so_data (so, NV50_CB_TSC); + so = so_new(nv50->sampler_nr * 11, 0); for (i = 0; i < nv50->sampler_nr; i++) { if (!nv50->sampler[i]) continue; + so_method(so, tesla, NV50TCL_CB_ADDR, 1); + so_data (so, ((i * 8) << NV50TCL_CB_ADDR_ID_SHIFT) | + NV50_CB_TSC); so_method(so, tesla, NV50TCL_CB_DATA(0) | (2<<29), 8); so_datap (so, nv50->sampler[i]->tsc, 8); } diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 72d33150af..ca2b883e9b 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -148,18 +148,19 @@ nv50_tex_validate(struct nv50_context *nv50) struct nouveau_stateobj *so; int unit, push; - push = nv50->miptree_nr * 9 + 2; + push = nv50->miptree_nr * 11; push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2; so = so_new(push, nv50->miptree_nr * 2); - so_method(so, tesla, NV50TCL_CB_ADDR, 1); - so_data (so, NV50_CB_TIC); for (unit = 0; unit < nv50->miptree_nr; unit++) { struct nv50_miptree *mt = nv50->miptree[unit]; if (!mt) continue; + so_method(so, tesla, NV50TCL_CB_ADDR, 1); + so_data (so, ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT) | + NV50_CB_TIC); so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8); if (nv50_tex_construct(nv50, so, mt, unit)) { NOUVEAU_ERR("failed tex validate\n"); -- cgit v1.2.3 From 35b98e2884bd7c76c43fa08d5bb0a8f1396d3298 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Mon, 19 Oct 2009 09:28:59 +1000 Subject: nouveau: implement is_{texture,buffer}_referenced properly --- src/gallium/drivers/nouveau/Makefile | 3 +- src/gallium/drivers/nouveau/nouveau_context.c | 41 +++++++++++++++++++++++++++ src/gallium/drivers/nouveau/nouveau_context.h | 11 +++++++ src/gallium/drivers/nv04/nv04_context.c | 28 ++---------------- src/gallium/drivers/nv04/nv04_context.h | 1 + src/gallium/drivers/nv10/nv10_context.c | 27 ++---------------- src/gallium/drivers/nv10/nv10_context.h | 1 + src/gallium/drivers/nv20/nv20_context.c | 28 ++---------------- src/gallium/drivers/nv20/nv20_context.h | 1 + src/gallium/drivers/nv30/nv30_context.c | 35 ++--------------------- src/gallium/drivers/nv30/nv30_context.h | 1 + src/gallium/drivers/nv40/nv40_context.c | 35 ++--------------------- src/gallium/drivers/nv40/nv40_context.h | 1 + src/gallium/drivers/nv50/nv50_context.c | 27 ++---------------- src/gallium/drivers/nv50/nv50_context.h | 1 + 15 files changed, 72 insertions(+), 169 deletions(-) create mode 100644 src/gallium/drivers/nouveau/nouveau_context.c create mode 100644 src/gallium/drivers/nouveau/nouveau_context.h diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile index dbe8a6e7bf..0cb66041d5 100644 --- a/src/gallium/drivers/nouveau/Makefile +++ b/src/gallium/drivers/nouveau/Makefile @@ -3,6 +3,7 @@ include $(TOP)/configs/current LIBNAME = nouveau -C_SOURCES = nouveau_screen.c +C_SOURCES = nouveau_screen.c \ + nouveau_context.c include ../../Makefile.template diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c new file mode 100644 index 0000000000..23443869e6 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_context.c @@ -0,0 +1,41 @@ +#include +#include + +#include "nouveau/nouveau_screen.h" +#include "nouveau/nouveau_context.h" + +#include "nouveau/nouveau_bo.h" + +static unsigned int +nouveau_reference_flags(struct nouveau_bo *bo) +{ + uint32_t bo_flags; + int flags = 0; + + bo_flags = nouveau_bo_pending(bo); + if (bo_flags & NOUVEAU_BO_RD) + flags |= PIPE_REFERENCED_FOR_READ; + if (bo_flags & NOUVEAU_BO_WR) + flags |= PIPE_REFERENCED_FOR_WRITE; + + return flags; +} + +unsigned int +nouveau_is_texture_referenced(struct pipe_context *pipe, + struct pipe_texture *pt, + unsigned face, unsigned level) +{ + struct nouveau_miptree *mt = nouveau_miptree(pt); + + return nouveau_reference_flags(mt->bo); +} + +unsigned int +nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + return nouveau_reference_flags(bo); +} + diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h new file mode 100644 index 0000000000..6a28d40da7 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_context.h @@ -0,0 +1,11 @@ +#ifndef __NOUVEAU_CONTEXT_H__ +#define __NOUVEAU_CONTEXT_H__ + +unsigned int +nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *, + unsigned face, unsigned level); + +unsigned int +nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *); + +#endif diff --git a/src/gallium/drivers/nv04/nv04_context.c b/src/gallium/drivers/nv04/nv04_context.c index 17166c9f51..10d984ace9 100644 --- a/src/gallium/drivers/nv04/nv04_context.c +++ b/src/gallium/drivers/nv04/nv04_context.c @@ -64,30 +64,6 @@ nv04_init_hwctx(struct nv04_context *nv04) return TRUE; } -static unsigned int -nv04_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - -static unsigned int -nv04_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - - struct pipe_context * nv04_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -113,8 +89,8 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id) nv04->pipe.clear = nv04_clear; nv04->pipe.flush = nv04_flush; - nv04->pipe.is_texture_referenced = nv04_is_texture_referenced; - nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced; + nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; nv04_init_surface_functions(nv04); nv04_init_state_functions(nv04); diff --git a/src/gallium/drivers/nv04/nv04_context.h b/src/gallium/drivers/nv04/nv04_context.h index 2842b2c90d..55326c787a 100644 --- a/src/gallium/drivers/nv04/nv04_context.h +++ b/src/gallium/drivers/nv04/nv04_context.h @@ -13,6 +13,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" +#include "nouveau/nouveau_context.h" #define NOUVEAU_PUSH_CONTEXT(ctx) \ struct nv04_screen *ctx = nv04->screen diff --git a/src/gallium/drivers/nv10/nv10_context.c b/src/gallium/drivers/nv10/nv10_context.c index a127b134ec..933176fc32 100644 --- a/src/gallium/drivers/nv10/nv10_context.c +++ b/src/gallium/drivers/nv10/nv10_context.c @@ -257,29 +257,6 @@ nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield) { } -static unsigned int -nv10_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - -static unsigned int -nv10_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - struct pipe_context * nv10_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -305,8 +282,8 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id) nv10->pipe.clear = nv10_clear; nv10->pipe.flush = nv10_flush; - nv10->pipe.is_texture_referenced = nv10_is_texture_referenced; - nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced; + nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; nv10_init_surface_functions(nv10); nv10_init_state_functions(nv10); diff --git a/src/gallium/drivers/nv10/nv10_context.h b/src/gallium/drivers/nv10/nv10_context.h index f1e003c953..36a6aa7a74 100644 --- a/src/gallium/drivers/nv10/nv10_context.h +++ b/src/gallium/drivers/nv10/nv10_context.h @@ -13,6 +13,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" +#include "nouveau/nouveau_context.h" #define NOUVEAU_PUSH_CONTEXT(ctx) \ struct nv10_screen *ctx = nv10->screen diff --git a/src/gallium/drivers/nv20/nv20_context.c b/src/gallium/drivers/nv20/nv20_context.c index b32d0d83ba..9a48739661 100644 --- a/src/gallium/drivers/nv20/nv20_context.c +++ b/src/gallium/drivers/nv20/nv20_context.c @@ -380,30 +380,6 @@ nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield) { } - -static unsigned int -nv20_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - -static unsigned int -nv20_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - struct pipe_context * nv20_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -429,8 +405,8 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id) nv20->pipe.clear = nv20_clear; nv20->pipe.flush = nv20_flush; - nv20->pipe.is_texture_referenced = nv20_is_texture_referenced; - nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced; + nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; nv20_init_surface_functions(nv20); nv20_init_state_functions(nv20); diff --git a/src/gallium/drivers/nv20/nv20_context.h b/src/gallium/drivers/nv20/nv20_context.h index fc932f1f90..a4eaa95660 100644 --- a/src/gallium/drivers/nv20/nv20_context.h +++ b/src/gallium/drivers/nv20/nv20_context.h @@ -13,6 +13,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" +#include "nouveau/nouveau_context.h" #define NOUVEAU_PUSH_CONTEXT(ctx) \ struct nv20_screen *ctx = nv20->screen diff --git a/src/gallium/drivers/nv30/nv30_context.c b/src/gallium/drivers/nv30/nv30_context.c index a3e65b96f7..d8300fd69f 100644 --- a/src/gallium/drivers/nv30/nv30_context.c +++ b/src/gallium/drivers/nv30/nv30_context.c @@ -31,37 +31,6 @@ nv30_destroy(struct pipe_context *pipe) FREE(nv30); } -static unsigned int -nv30_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Return the corrent result. We can't alays return referenced - * since it causes a double flush within the vbo module. - */ -#if 0 - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -#else - return 0; -#endif -} - -static unsigned int -nv30_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Return the corrent result. We can't alays return referenced - * since it causes a double flush within the vbo module. - */ -#if 0 - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -#else - return 0; -#endif -} - struct pipe_context * nv30_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -86,8 +55,8 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id) nv30->pipe.clear = nv30_clear; nv30->pipe.flush = nv30_flush; - nv30->pipe.is_texture_referenced = nv30_is_texture_referenced; - nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced; + nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; nv30_init_query_functions(nv30); nv30_init_surface_functions(nv30); diff --git a/src/gallium/drivers/nv30/nv30_context.h b/src/gallium/drivers/nv30/nv30_context.h index 4229c0a0e1..8d49366dfc 100644 --- a/src/gallium/drivers/nv30/nv30_context.h +++ b/src/gallium/drivers/nv30/nv30_context.h @@ -13,6 +13,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" +#include "nouveau/nouveau_context.h" #define NOUVEAU_PUSH_CONTEXT(ctx) \ struct nv30_screen *ctx = nv30->screen diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c index 4e23671202..7f008274a4 100644 --- a/src/gallium/drivers/nv40/nv40_context.c +++ b/src/gallium/drivers/nv40/nv40_context.c @@ -31,37 +31,6 @@ nv40_destroy(struct pipe_context *pipe) FREE(nv40); } -static unsigned int -nv40_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Return the correct result. We can't always return referenced - * since it causes a double flush within the vbo module. - */ -#if 0 - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -#else - return 0; -#endif -} - -static unsigned int -nv40_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Return the correct result. We can't always return referenced - * since it causes a double flush within the vbo module. - */ -#if 0 - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -#else - return 0; -#endif -} - struct pipe_context * nv40_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -86,8 +55,8 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id) nv40->pipe.clear = nv40_clear; nv40->pipe.flush = nv40_flush; - nv40->pipe.is_texture_referenced = nv40_is_texture_referenced; - nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced; + nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; nv40_init_query_functions(nv40); nv40_init_surface_functions(nv40); diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h index 97bc83292d..a3d594167a 100644 --- a/src/gallium/drivers/nv40/nv40_context.h +++ b/src/gallium/drivers/nv40/nv40_context.h @@ -13,6 +13,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" +#include "nouveau/nouveau_context.h" #define NOUVEAU_PUSH_CONTEXT(ctx) \ struct nv40_screen *ctx = nv40->screen diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index fca078b174..7ef27bb671 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -60,29 +60,6 @@ nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield) { } -static unsigned int -nv50_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - -static unsigned int -nv50_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) -{ - /** - * FIXME: Optimize. - */ - - return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE; -} - struct pipe_context * nv50_create(struct pipe_screen *pscreen, unsigned pctx_id) { @@ -108,8 +85,8 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id) nv50->pipe.flush = nv50_flush; - nv50->pipe.is_texture_referenced = nv50_is_texture_referenced; - nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced; + nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced; + nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced; screen->base.channel->user_private = nv50; screen->base.channel->flush_notify = nv50_state_flush_notify; diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 4608854d71..fd2dab856d 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -14,6 +14,7 @@ #include "nouveau/nouveau_winsys.h" #include "nouveau/nouveau_gldefs.h" #include "nouveau/nouveau_stateobj.h" +#include "nouveau/nouveau_context.h" #include "nv50_screen.h" #include "nv50_program.h" -- cgit v1.2.3 From 6ab2fcca9d40ed65ab8d88c0253969c5311b7320 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 10 Oct 2009 13:18:07 +0200 Subject: nv50: nicer texture format switch Similar to nv40. --- src/gallium/drivers/nv50/nv50_tex.c | 144 ++++++++++++------------------------ 1 file changed, 49 insertions(+), 95 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index ca2b883e9b..81e04327e8 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -25,106 +25,60 @@ #include "nouveau/nouveau_stateobj.h" +#define _(pf, tt, r, g, b, a, tf) \ +{ \ + PIPE_FORMAT_##pf, \ + NV50TIC_0_0_MAPR_##r | NV50TIC_0_0_TYPER_##tt | \ + NV50TIC_0_0_MAPG_##g | NV50TIC_0_0_TYPEG_##tt | \ + NV50TIC_0_0_MAPB_##b | NV50TIC_0_0_TYPEB_##tt | \ + NV50TIC_0_0_MAPA_##a | NV50TIC_0_0_TYPEA_##tt | \ + NV50TIC_0_0_FMT_##tf \ +} + +struct nv50_texture_format { + enum pipe_format pf; + uint32_t hw; +}; + +#define NV50_TEX_FORMAT_LIST_SIZE \ + (sizeof(nv50_tex_format_list) / sizeof(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), + _(X8R8G8B8_UNORM, 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), + + _(R5G6B5_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), + + _(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) +}; + +#undef _ + static int nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, struct nv50_miptree *mt, int unit) { - switch (mt->base.base.format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8_8_8_8); - break; - case PIPE_FORMAT_X8R8G8B8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8_8_8_8); - break; - case PIPE_FORMAT_A1R5G5B5_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_1_5_5_5); - break; - case PIPE_FORMAT_A4R4G4B4_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_4_4_4_4); - break; - case PIPE_FORMAT_R5G6B5_UNORM: - so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C2 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_5_6_5); - break; - case PIPE_FORMAT_L8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8); - break; - case PIPE_FORMAT_A8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_ZERO | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_ZERO | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_ZERO | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8); - break; - case PIPE_FORMAT_I8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C0 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8); - break; - case PIPE_FORMAT_A8L8_UNORM: - so_data(so, NV50TIC_0_0_MAPA_C1 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C0 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C0 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_8_8); - break; - case PIPE_FORMAT_DXT1_RGB: - so_data(so, NV50TIC_0_0_MAPA_ONE | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_DXT1); - break; - case PIPE_FORMAT_DXT1_RGBA: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_DXT1); - break; - case PIPE_FORMAT_DXT3_RGBA: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_DXT3); - break; - case PIPE_FORMAT_DXT5_RGBA: - so_data(so, NV50TIC_0_0_MAPA_C3 | NV50TIC_0_0_TYPEA_UNORM | - NV50TIC_0_0_MAPR_C0 | NV50TIC_0_0_TYPER_UNORM | - NV50TIC_0_0_MAPG_C1 | NV50TIC_0_0_TYPEG_UNORM | - NV50TIC_0_0_MAPB_C2 | NV50TIC_0_0_TYPEB_UNORM | - NV50TIC_0_0_FMT_DXT5); - break; - default: - return 1; - } + unsigned i; + + for (i = 0; i < NV50_TEX_FORMAT_LIST_SIZE; i++) + if (nv50_tex_format_list[i].pf == mt->base.base.format) + break; + if (i == NV50_TEX_FORMAT_LIST_SIZE) + return 1; + so_data (so, nv50_tex_format_list[i].hw); so_reloc(so, mt->base.bo, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_LOW | NOUVEAU_BO_RD, 0, 0); if (nv50->sampler[unit]->normalized) -- cgit v1.2.3 From fba2eabe13b8a3f8c1396c5949db3daab0192156 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sat, 10 Oct 2009 13:13:16 +0200 Subject: nv50: use SIFC for TIC, TSC upload Add proper flushes for TIC and TSC and remove the costly 2D.0110 flush in nv50_flush. Correct TIC and TSC bo sizes. --- src/gallium/drivers/nv50/nv50_context.c | 7 ---- src/gallium/drivers/nv50/nv50_context.h | 5 +++ src/gallium/drivers/nv50/nv50_screen.c | 25 ++---------- src/gallium/drivers/nv50/nv50_state_validate.c | 54 ++++++++++++++++++++++---- src/gallium/drivers/nv50/nv50_tex.c | 34 +++++++++------- src/gallium/drivers/nv50/nv50_vbo.c | 4 -- 6 files changed, 77 insertions(+), 52 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index 7ef27bb671..219e7a7862 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -33,13 +33,6 @@ nv50_flush(struct pipe_context *pipe, unsigned flags, { struct nv50_context *nv50 = nv50_context(pipe); struct nouveau_channel *chan = nv50->screen->base.channel; - struct nouveau_grobj *eng2d = nv50->screen->eng2d; - - /* We need this in the ddx for reliable composite, not sure what we're - * actually flushing. We generate all our own flushes with flags = 0. */ - WAIT_RING(chan, 2); - BEGIN_RING(chan, eng2d, 0x0110, 1); - OUT_RING (chan, 0); if (flags & PIPE_FLUSH_FRAME) FIRE_RING(chan); diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index fd2dab856d..75cb65d9a2 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -199,6 +199,11 @@ extern void nv50_program_destroy(struct nv50_context *nv50, struct nv50_program extern boolean nv50_state_validate(struct nv50_context *nv50); extern void nv50_state_flush_notify(struct nouveau_channel *chan); +extern void nv50_so_init_sifc(struct nv50_context *nv50, + struct nouveau_stateobj *so, + struct nouveau_bo *bo, unsigned reloc, + unsigned size); + /* nv50_tex.c */ extern void nv50_tex_validate(struct nv50_context *); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index dd7baecba7..66361dc3ba 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -364,48 +364,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); so_data (so, 0x00000131 | (NV50_CB_PFP << 12)); - /* Texture sampler/image unit setup - we abuse the constant buffer - * upload mechanism for the moment to upload data to the tex config - * blocks. At some point we *may* want to go the NVIDIA way of doing - * things? - */ - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic); + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 64*8*4, &screen->tic); if (ret) { nv50_screen_destroy(pscreen); return NULL; } - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_TIC << 16) | 0x0800); so_method(so, screen->tesla, NV50TCL_TIC_ADDRESS_HIGH, 3); so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, 0x00000800); + so_data (so, 0x000007ff); - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc); + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 64*8*4, &screen->tsc); if (ret) { nv50_screen_destroy(pscreen); return NULL; } - so_method(so, screen->tesla, NV50TCL_CB_DEF_ADDRESS_HIGH, 3); - so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); - so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | - NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_TSC << 16) | 0x0800); so_method(so, screen->tesla, NV50TCL_TSC_ADDRESS_HIGH, 3); so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, 0x00000800); + so_data (so, 0x00000000); /* Vertex array limits - max them out */ diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c index 9079de918d..012911f41b 100644 --- a/src/gallium/drivers/nv50/nv50_state_validate.c +++ b/src/gallium/drivers/nv50/nv50_state_validate.c @@ -222,6 +222,9 @@ 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); + so_emit_reloc_markers(chan, nv50->state.fb); so_emit_reloc_markers(chan, nv50->state.vertprog); so_emit_reloc_markers(chan, nv50->state.fragprog); @@ -233,6 +236,7 @@ boolean nv50_state_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; + struct nouveau_grobj *eng2d = nv50->screen->eng2d; struct nouveau_stateobj *so; unsigned i; @@ -354,19 +358,25 @@ scissor_uptodate: viewport_uptodate: if (nv50->dirty & NV50_NEW_SAMPLER) { - int i; + unsigned i; + + so = so_new(nv50->sampler_nr * 9 + 23 + 4, 2); + + nv50_so_init_sifc(nv50, so, nv50->screen->tsc, NOUVEAU_BO_VRAM, + nv50->sampler_nr * 8 * 4); - so = so_new(nv50->sampler_nr * 11, 0); for (i = 0; i < nv50->sampler_nr; i++) { if (!nv50->sampler[i]) continue; - - so_method(so, tesla, NV50TCL_CB_ADDR, 1); - so_data (so, ((i * 8) << NV50TCL_CB_ADDR_ID_SHIFT) | - NV50_CB_TSC); - so_method(so, tesla, NV50TCL_CB_DATA(0) | (2<<29), 8); + so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8); so_datap (so, nv50->sampler[i]->tsc, 8); } + + so_method(so, tesla, 0x1440, 1); /* sync SIFC */ + so_data (so, 0); + so_method(so, tesla, 0x1334, 1); /* flush TSC */ + so_data (so, 0); + so_ref(so, &nv50->state.tsc_upload); so_ref(NULL, &so); } @@ -384,3 +394,33 @@ viewport_uptodate: return TRUE; } +void nv50_so_init_sifc(struct nv50_context *nv50, + struct nouveau_stateobj *so, + struct nouveau_bo *bo, unsigned reloc, unsigned size) +{ + struct nouveau_grobj *eng2d = nv50->screen->eng2d; + + so_method(so, eng2d, NV50_2D_DST_FORMAT, 2); + so_data (so, NV50_2D_DST_FORMAT_R8_UNORM); + so_data (so, 1); + so_method(so, eng2d, NV50_2D_DST_PITCH, 5); + so_data (so, 262144); + so_data (so, 65536); + so_data (so, 1); + so_reloc (so, bo, 0, reloc | NOUVEAU_BO_WR | NOUVEAU_BO_HIGH, 0, 0); + so_reloc (so, bo, 0, reloc | NOUVEAU_BO_WR | NOUVEAU_BO_LOW, 0, 0); + so_method(so, eng2d, NV50_2D_SIFC_UNK0800, 2); + so_data (so, 0); + so_data (so, NV50_2D_SIFC_FORMAT_R8_UNORM); + so_method(so, eng2d, NV50_2D_SIFC_WIDTH, 10); + so_data (so, size); + so_data (so, 1); + so_data (so, 0); + so_data (so, 1); + so_data (so, 0); + so_data (so, 1); + so_data (so, 0); + so_data (so, 0); + so_data (so, 0); + so_data (so, 0); +} diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c index 81e04327e8..e12a6ad648 100644 --- a/src/gallium/drivers/nv50/nv50_tex.c +++ b/src/gallium/drivers/nv50/nv50_tex.c @@ -98,24 +98,24 @@ nv50_tex_construct(struct nv50_context *nv50, struct nouveau_stateobj *so, void nv50_tex_validate(struct nv50_context *nv50) { + struct nouveau_grobj *eng2d = nv50->screen->eng2d; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *so; - int unit, push; + unsigned i, unit, push; - push = nv50->miptree_nr * 11; - push += MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2; + push = MAX2(nv50->miptree_nr, nv50->state.miptree_nr) * 2 + 23 + 6; + so = so_new(nv50->miptree_nr * 9 + push, nv50->miptree_nr + 2); - so = so_new(push, nv50->miptree_nr * 2); - for (unit = 0; unit < nv50->miptree_nr; unit++) { + nv50_so_init_sifc(nv50, so, nv50->screen->tic, NOUVEAU_BO_VRAM, + nv50->miptree_nr * 8 * 4); + + for (i = 0, unit = 0; unit < nv50->miptree_nr; ++unit) { struct nv50_miptree *mt = nv50->miptree[unit]; if (!mt) continue; - so_method(so, tesla, NV50TCL_CB_ADDR, 1); - so_data (so, ((unit * 8) << NV50TCL_CB_ADDR_ID_SHIFT) | - NV50_CB_TIC); - so_method(so, tesla, NV50TCL_CB_DATA(0) | 0x40000000, 8); + so_method(so, eng2d, NV50_2D_SIFC_DATA | (2 << 29), 8); if (nv50_tex_construct(nv50, so, mt, unit)) { NOUVEAU_ERR("failed tex validate\n"); so_ref(NULL, &so); @@ -123,17 +123,25 @@ nv50_tex_validate(struct nv50_context *nv50) } so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1); - so_data (so, (unit << NV50TCL_SET_SAMPLER_TEX_TIC_SHIFT) | - (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | - NV50TCL_SET_SAMPLER_TEX_VALID); + so_data (so, (i++ << NV50TCL_SET_SAMPLER_TEX_TIC_SHIFT) | + (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | + NV50TCL_SET_SAMPLER_TEX_VALID); } for (; unit < nv50->state.miptree_nr; unit++) { so_method(so, tesla, NV50TCL_SET_SAMPLER_TEX, 1); so_data (so, - (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | 0); + (unit << NV50TCL_SET_SAMPLER_TEX_SAMPLER_SHIFT) | 0); } + /* not sure if the following really do what I think: */ + so_method(so, tesla, 0x1440, 1); /* sync SIFC */ + so_data (so, 0); + so_method(so, tesla, 0x1330, 1); /* flush TIC */ + so_data (so, 0); + so_method(so, tesla, 0x1338, 1); /* flush texture caches */ + so_data (so, 0x20); + so_ref(so, &nv50->state.tic_upload); so_ref(NULL, &so); nv50->state.miptree_nr = nv50->miptree_nr; diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c index eeed148c7b..8b0fbf0e76 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -139,10 +139,6 @@ nv50_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start, OUT_RING (chan, 0); BEGIN_RING(chan, tesla, 0x142c, 1); OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, 0x1440, 1); - OUT_RING (chan, 0); - BEGIN_RING(chan, tesla, 0x1334, 1); - OUT_RING (chan, 0); BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BEGIN, 1); OUT_RING (chan, nv50_prim(mode)); -- cgit v1.2.3 From c0e80cf0e97cec526bb2ff0f94d9142e33374c20 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Wed, 14 Oct 2009 21:23:29 +0200 Subject: nv50: submit user vbo data through the fifo Requesting a new real buffer from the kernel and copying all the data is wasteful e.g. if only a few (but widely spread) vertices are accessed. --- src/gallium/drivers/nv50/nv50_context.h | 3 + src/gallium/drivers/nv50/nv50_vbo.c | 409 ++++++++++++++++++++++++++++++-- 2 files changed, 394 insertions(+), 18 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index 75cb65d9a2..33667e8765 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -121,6 +121,7 @@ struct nv50_state { struct nouveau_stateobj *vtxfmt; struct nouveau_stateobj *vtxbuf; struct nouveau_stateobj *vtxattr; + unsigned vtxelt_nr; }; struct nv50_context { @@ -153,6 +154,8 @@ struct nv50_context { unsigned sampler_nr; struct nv50_miptree *miptree[PIPE_MAX_SAMPLERS]; unsigned miptree_nr; + + 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 8b0fbf0e76..db54380241 100644 --- a/src/gallium/drivers/nv50/nv50_vbo.c +++ b/src/gallium/drivers/nv50/nv50_vbo.c @@ -26,6 +26,18 @@ #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); + static INLINE unsigned nv50_prim(unsigned mode) { @@ -132,6 +144,7 @@ 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; nv50_state_validate(nv50); @@ -142,17 +155,22 @@ 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)); - BEGIN_RING(chan, tesla, NV50TCL_VERTEX_BUFFER_FIRST, 2); - OUT_RING (chan, start); - OUT_RING (chan, count); + + 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_END, 1); OUT_RING (chan, 0); - pipe->flush(pipe, 0, NULL); - return TRUE; + return ret; } -static INLINE void +static INLINE boolean nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, unsigned start, unsigned count) { @@ -161,6 +179,9 @@ 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, 0x15e8, 1); OUT_RING (chan, map[0]); @@ -179,9 +200,10 @@ nv50_draw_elements_inline_u08(struct nv50_context *nv50, uint8_t *map, count -= nr; map += nr; } + return TRUE; } -static INLINE void +static INLINE boolean nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, unsigned start, unsigned count) { @@ -190,6 +212,9 @@ 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, 0x15e8, 1); OUT_RING (chan, map[0]); @@ -208,9 +233,10 @@ nv50_draw_elements_inline_u16(struct nv50_context *nv50, uint16_t *map, count -= nr; map += nr; } + return TRUE; } -static INLINE void +static INLINE boolean nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, unsigned start, unsigned count) { @@ -219,6 +245,9 @@ 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; @@ -228,6 +257,7 @@ nv50_draw_elements_inline_u32(struct nv50_context *nv50, uint32_t *map, count -= nr; map += nr; } + return TRUE; } boolean @@ -240,6 +270,7 @@ nv50_draw_elements(struct pipe_context *pipe, struct nouveau_grobj *tesla = nv50->screen->tesla; struct pipe_screen *pscreen = pipe->screen; void *map; + boolean ret; map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ); @@ -254,23 +285,25 @@ nv50_draw_elements(struct pipe_context *pipe, OUT_RING (chan, nv50_prim(mode)); switch (indexSize) { case 1: - nv50_draw_elements_inline_u08(nv50, map, start, count); + ret = nv50_draw_elements_inline_u08(nv50, map, start, count); break; case 2: - nv50_draw_elements_inline_u16(nv50, map, start, count); + ret = nv50_draw_elements_inline_u16(nv50, map, start, count); break; case 4: - nv50_draw_elements_inline_u32(nv50, map, start, count); + ret = nv50_draw_elements_inline_u32(nv50, map, start, count); break; default: assert(0); + ret = FALSE; + break; } BEGIN_RING(chan, tesla, NV50TCL_VERTEX_END, 1); OUT_RING (chan, 0); pipe_buffer_unmap(pscreen, indexBuffer); - pipe->flush(pipe, 0, NULL); - return TRUE; + + return ret; } static INLINE boolean @@ -337,17 +370,24 @@ nv50_vbo_validate(struct nv50_context *nv50) { struct nouveau_grobj *tesla = nv50->screen->tesla; struct nouveau_stateobj *vtxbuf, *vtxfmt, *vtxattr; - unsigned i; + unsigned i, n_ve; /* don't validate if Gallium took away our buffers */ if (nv50->vtxbuf_nr == 0) return; + 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; + + n_ve = MAX2(nv50->vtxelt_nr, nv50->state.vtxelt_nr); vtxattr = NULL; - vtxbuf = so_new(nv50->vtxelt_nr * 7, nv50->vtxelt_nr * 4); - vtxfmt = so_new(nv50->vtxelt_nr + 1, 0); - so_method(vtxfmt, tesla, NV50TCL_VERTEX_ARRAY_ATTRIB(0), - nv50->vtxelt_nr); + vtxbuf = so_new(n_ve * 7, nv50->vtxelt_nr * 4); + vtxfmt = so_new(n_ve + 1, 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]; @@ -363,10 +403,19 @@ 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; } so_data(vtxfmt, hw | i); + if (nv50->vbo_fifo) { + so_method(vtxbuf, tesla, + NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); + so_data (vtxbuf, 0); + continue; + } + so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 3); so_data (vtxbuf, 0x20000000 | vb->stride); so_reloc (vtxbuf, bo, vb->buffer_offset + @@ -385,6 +434,13 @@ nv50_vbo_validate(struct nv50_context *nv50) NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); } + for (; i < n_ve; ++i) { + so_data (vtxfmt, 0x7e080010); + + so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_FORMAT(i), 1); + so_data (vtxbuf, 0); + } + nv50->state.vtxelt_nr = nv50->vtxelt_nr; so_ref (vtxfmt, &nv50->state.vtxfmt); so_ref (vtxbuf, &nv50->state.vtxbuf); @@ -394,3 +450,320 @@ nv50_vbo_validate(struct nv50_context *nv50) so_ref (NULL, &vtxattr); } +typedef void (*pfn_push)(struct nouveau_channel *, void *); + +struct nv50_vbo_emitctx +{ + pfn_push push[16]; + void *map[16]; + unsigned stride[16]; + unsigned nr_ve; + unsigned vtx_dwords; + unsigned vtx_max; +}; + +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, delta; + + if (nouveau_bo(vb->buffer)->map) + continue; + + size = vb->stride * (vb->max_index + 1); + delta = vb->buffer_offset; + + if (!size) + size = vb->buffer->size - vb->buffer_offset; + + if (nouveau_bo_map_range(nouveau_bo(vb->buffer), + delta, 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 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)); +} + +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->nr_ve = 0; + emit->vtx_dwords = 0; + + for (i = 0; i < nv50->vtxelt_nr; ++i) { + struct pipe_vertex_element *ve; + struct pipe_vertex_buffer *vb; + unsigned n, type, size; + + ve = &nv50->vtxelt[i]; + vb = &nv50->vtxbuf[ve->vertex_buffer_index]; + if (!(nv50->vbo_fifo & (1 << i))) + continue; + n = emit->nr_ve++; + + emit->stride[n] = vb->stride; + emit->map[n] = nouveau_bo(vb->buffer)->map + + (start * vb->stride + ve->src_offset); + + type = pf_type(ve->src_format); + size = pf_size_x(ve->src_format) << pf_exp2(ve->src_format); + + assert(ve->nr_components > 0 && ve->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 (ve->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; + break; + case 16: + switch (ve->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; + break; + case 8: + switch (ve->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; + + return TRUE; +} + +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; + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + for (i = 0; i < nr; ++i) + emit_vtx_next(chan, &emit); + + count -= nr; + } + nv50_unmap_vbufs(nv50); + + 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; + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + for (i = 0; i < nr; ++i) + emit_vtx(chan, &emit, *map++); + + count -= nr; + } + nv50_unmap_vbufs(nv50); + + 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; + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + for (i = 0; i < nr; ++i) + emit_vtx(chan, &emit, *map++); + + count -= nr; + } + nv50_unmap_vbufs(nv50); + + 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; + + BEGIN_RING(chan, tesla, NV50TCL_VERTEX_DATA | 0x40000000, dw); + for (i = 0; i < nr; ++i) + emit_vtx(chan, &emit, *map++); + + count -= nr; + } + nv50_unmap_vbufs(nv50); + + return TRUE; +} -- cgit v1.2.3 From 1635e8d6f4b96e691746e8c8c5a273089bae6843 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Wed, 14 Oct 2009 21:27:35 +0200 Subject: nv50: add support for DDX and DDY opcodes --- src/gallium/drivers/nv50/nv50_program.c | 70 ++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 576d075318..89e0ac8db9 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -837,7 +837,7 @@ emit_precossin(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) #define CVTOP_SAT 0x08 #define CVTOP_ABS 0x10 -/* 0x04 == 32 bit */ +/* 0x04 == 32 bit dst */ /* 0x40 == dst is float */ /* 0x80 == src is float */ #define CVT_F32_F32 0xc4 @@ -858,7 +858,7 @@ emit_cvt(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src, set_long(pc, e); e->inst[0] |= 0xa0000000; - e->inst[1] |= 0x00004000; + e->inst[1] |= 0x00004000; /* 32 bit src */ e->inst[1] |= (cvn << 16); e->inst[1] |= (fmt << 24); set_src_0(pc, src, e); @@ -1037,20 +1037,10 @@ emit_lit(struct nv50_pc *pc, struct nv50_reg **dst, unsigned mask, FREE(one); } -static void +static INLINE void emit_neg(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) { - struct nv50_program_exec *e = exec(pc); - - set_long(pc, e); - e->inst[0] |= 0xa0000000; /* delta */ - e->inst[1] |= (7 << 29); /* delta */ - e->inst[1] |= 0x04000000; /* negate arg0? probably not */ - e->inst[1] |= (1 << 14); /* src .f32 */ - set_dst(pc, dst, e); - set_src_0(pc, src, e); - - emit(pc, e); + emit_cvt(pc, dst, src, -1, CVTOP_RN, CVT_F32_F32 | CVT_NEG); } static void @@ -1218,6 +1208,43 @@ emit_nop(struct nv50_pc *pc) emit(pc, e); } +static void +emit_ddx(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) +{ + struct nv50_program_exec *e = exec(pc); + + assert(src->type == P_TEMP); + + e->inst[0] = 0xc0140000; + e->inst[1] = 0x89800000; + set_long(pc, e); + set_dst(pc, dst, e); + set_src_0(pc, src, e); + set_src_2(pc, src, e); + + emit(pc, e); +} + +static void +emit_ddy(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) +{ + struct nv50_program_exec *e = exec(pc); + + assert(src->type == P_TEMP); + + if (!src->neg) /* ! double negation */ + emit_neg(pc, src, src); + + e->inst[0] = 0xc0150000; + e->inst[1] = 0x8a400000; + set_long(pc, e); + set_dst(pc, dst, e); + set_src_0(pc, src, e); + set_src_2(pc, src, e); + + emit(pc, e); +} + static void convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e) { @@ -1270,6 +1297,7 @@ static boolean negate_supported(const struct tgsi_full_instruction *insn, int i) { switch (insn->Instruction.Opcode) { + case TGSI_OPCODE_DDY: case TGSI_OPCODE_DP3: case TGSI_OPCODE_DP4: case TGSI_OPCODE_MUL: @@ -1660,6 +1688,20 @@ nv50_program_tx_insn(struct nv50_pc *pc, emit_precossin(pc, temp, src[0][0]); emit_flop(pc, 5, brdc, temp); break; + case TGSI_OPCODE_DDX: + for (c = 0; c < 4; c++) { + if (!(mask & (1 << c))) + continue; + emit_ddx(pc, dst[c], src[0][c]); + } + break; + case TGSI_OPCODE_DDY: + for (c = 0; c < 4; c++) { + if (!(mask & (1 << c))) + continue; + emit_ddy(pc, dst[c], src[0][c]); + } + break; case TGSI_OPCODE_DP3: emit_mul(pc, temp, src[0][0], src[1][0]); emit_mad(pc, temp, src[0][1], src[1][1], temp); -- cgit v1.2.3 From f204eb184237b387432413212a3a20d83c87594b Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Tue, 13 Oct 2009 15:09:13 +0200 Subject: nv50: quick fix for insn src negation We only have a per nv50_reg negation flag, if an nv50_reg is used more than once in a TGSI op with different sign modes, we'd generate wrong code. We probably can't do much better without more invasive changes. --- src/gallium/drivers/nv50/nv50_program.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 89e0ac8db9..1bd6f717d1 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -1293,9 +1293,12 @@ convert_to_long(struct nv50_pc *pc, struct nv50_program_exec *e) e->inst[1] |= q; } +/* Some operations support an optional negation flag. */ static boolean negate_supported(const struct tgsi_full_instruction *insn, int i) { + int s; + switch (insn->Instruction.Opcode) { case TGSI_OPCODE_DDY: case TGSI_OPCODE_DP3: @@ -1305,12 +1308,29 @@ negate_supported(const struct tgsi_full_instruction *insn, int i) case TGSI_OPCODE_ADD: case TGSI_OPCODE_SUB: case TGSI_OPCODE_MAD: - return TRUE; + break; case TGSI_OPCODE_POW: - return (i == 1) ? TRUE : FALSE; + if (i == 1) + break; + return FALSE; default: return FALSE; } + + /* Watch out for possible multiple uses of an nv50_reg, we + * can't use nv50_reg::neg in these cases. + */ + for (s = 0; s < insn->Instruction.NumSrcRegs; ++s) { + if (s == i) + continue; + if ((insn->FullSrcRegisters[s].SrcRegister.Index == + insn->FullSrcRegisters[i].SrcRegister.Index) && + (insn->FullSrcRegisters[s].SrcRegister.File == + insn->FullSrcRegisters[i].SrcRegister.File)) + return FALSE; + } + + return TRUE; } /* Return a read mask for source registers deduced from opcode & write mask. */ @@ -1956,6 +1976,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, for (c = 0; c < 4; c++) { if (!src[i][c]) continue; + src[i][c]->neg = 0; if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD) FREE(src[i][c]); } -- cgit v1.2.3 From 2eef2017acbbb617c559555648c7745141f3aedb Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 19 Oct 2009 17:47:29 +0200 Subject: nv50: implement TGSI_OPCODE_CMP --- src/gallium/drivers/nv50/nv50_program.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 1bd6f717d1..3b7033b518 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -506,11 +506,13 @@ emit_mov(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src) { struct nv50_program_exec *e = exec(pc); - e->inst[0] |= 0x10000000; + e->inst[0] = 0x10000000; + if (!pc->allow32) + set_long(pc, e); set_dst(pc, dst, e); - if (pc->allow32 && dst->type != P_RESULT && src->type == P_IMMD) { + if (!is_long(e) && src->type == P_IMMD) { set_immd(pc, src, e); /*XXX: 32-bit, but steals part of "half" reg space - need to * catch and handle this case if/when we do half-regs @@ -1696,6 +1698,18 @@ nv50_program_tx_insn(struct nv50_pc *pc, CVTOP_CEIL, CVT_F32_F32 | CVT_RI); } break; + case TGSI_OPCODE_CMP: + pc->allow32 = FALSE; + for (c = 0; c < 4; c++) { + if (!(mask & (1 << c))) + continue; + emit_cvt(pc, NULL, src[0][c], 1, CVTOP_RN, CVT_F32_F32); + emit_mov(pc, dst[c], src[1][c]); + set_pred(pc, 0x1, 1, pc->p->exec_tail); /* @SF */ + emit_mov(pc, dst[c], src[2][c]); + set_pred(pc, 0x6, 1, pc->p->exec_tail); /* @NSF */ + } + break; case TGSI_OPCODE_COS: if (mask & 8) { emit_precossin(pc, temp, src[0][3]); -- cgit v1.2.3 From eb7ea97e7fff1ee39921ad81294c4963b5b3ded8 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 19 Oct 2009 17:53:31 +0200 Subject: nv50: cleanup emit_kil --- src/gallium/drivers/nv50/nv50_program.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index 3b7033b518..bfd979ce0f 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -1050,22 +1050,18 @@ emit_kil(struct nv50_pc *pc, struct nv50_reg *src) { struct nv50_program_exec *e; const int r_pred = 1; + unsigned cvn = CVT_F32_F32; - /* Sets predicate reg ? */ - e = exec(pc); - e->inst[0] = 0xa00001fd; - e->inst[1] = 0xc4014788; - set_src_0(pc, src, e); - set_pred_wr(pc, 1, r_pred, e); if (src->neg) - e->inst[1] |= 0x20000000; - emit(pc, e); + cvn |= CVT_NEG; + /* write predicate reg */ + emit_cvt(pc, NULL, src, r_pred, CVTOP_RN, cvn); - /* This is probably KILP */ + /* conditional discard */ e = exec(pc); - e->inst[0] = 0x000001fe; + e->inst[0] = 0x00000002; set_long(pc, e); - set_pred(pc, 1 /* LT? */, r_pred, e); + set_pred(pc, 0x1 /* LT */, r_pred, e); emit(pc, e); } -- cgit v1.2.3 From ec5c23551cdb4c369d8f8f392208f4d4bf29911b Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Mon, 19 Oct 2009 18:17:45 +0200 Subject: nv50: add support for address regs Allow indirect uniform access and increase the limit on parameters from 128 to 512. --- src/gallium/drivers/nv50/nv50_program.c | 178 ++++++++++++++++++++++++++++++-- src/gallium/drivers/nv50/nv50_screen.c | 10 +- 2 files changed, 175 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c index bfd979ce0f..c7145bb9be 100644 --- a/src/gallium/drivers/nv50/nv50_program.c +++ b/src/gallium/drivers/nv50/nv50_program.c @@ -32,6 +32,7 @@ #include "nv50_context.h" #define NV50_SU_MAX_TEMP 64 +#define NV50_SU_MAX_ADDR 7 //#define NV50_PROGRAM_DUMP /* ARL - gallium craps itself on progs/vp/arl.txt @@ -79,7 +80,8 @@ struct nv50_reg { P_ATTR, P_RESULT, P_CONST, - P_IMMD + P_IMMD, + P_ADDR } type; int index; @@ -99,6 +101,7 @@ struct nv50_pc { /* hw resources */ struct nv50_reg *r_temp[NV50_SU_MAX_TEMP]; + struct nv50_reg r_addr[NV50_SU_MAX_ADDR]; /* tgsi resources */ struct nv50_reg *temp; @@ -112,6 +115,8 @@ struct nv50_pc { struct nv50_reg *immd; float *immd_buf; int immd_nr; + struct nv50_reg **addr; + int addr_nr; struct nv50_reg *temp_temp[16]; unsigned temp_temp_nr; @@ -158,6 +163,17 @@ popcnt4(uint32_t val) return cnt[val & 0xf]; } +static void +terminate_mbb(struct nv50_pc *pc) +{ + int i; + + /* remove records of temporary address register values */ + for (i = 0; i < NV50_SU_MAX_ADDR; ++i) + if (pc->r_addr[i].index < 0) + pc->r_addr[i].rhw = -1; +} + static void alloc_reg(struct nv50_pc *pc, struct nv50_reg *reg) { @@ -454,9 +470,68 @@ set_immd(struct nv50_pc *pc, struct nv50_reg *imm, struct nv50_program_exec *e) e->inst[1] |= (val >> 6) << 2; } +static void +emit_set_addr(struct nv50_pc *pc, struct nv50_reg *dst, unsigned val) +{ + struct nv50_program_exec *e = exec(pc); + + assert(val <= 0xffff); + e->inst[0] = 0xd0000000 | ((val & 0xffff) << 9); + e->inst[1] = 0x20000000; + e->inst[0] |= dst->hw << 2; + set_long(pc, e); + + emit(pc, e); +} + +static struct nv50_reg * +alloc_addr(struct nv50_pc *pc, struct nv50_reg *ref) +{ + int i; + struct nv50_reg *a = NULL; + + if (!ref) { + for (i = 0; i < NV50_SU_MAX_ADDR; ++i) { + if (pc->r_addr[i].index >= 0) + continue; + if (pc->r_addr[i].rhw >= 0 && + pc->r_addr[i].acc == pc->insn_cur) + continue; + + pc->r_addr[i].rhw = -1; + pc->r_addr[i].index = i; + return &pc->r_addr[i]; + } + assert(0); + return NULL; + } + + for (i = NV50_SU_MAX_ADDR - 1; i >= 0; --i) { + if (pc->r_addr[i].index >= 0) /* occupied for TGSI */ + continue; + if (pc->r_addr[i].rhw < 0) { /* unused */ + a = &pc->r_addr[i]; + continue; + } + if (!a && pc->r_addr[i].acc != pc->insn_cur) + a = &pc->r_addr[i]; + + if (ref->hw - pc->r_addr[i].rhw < 128) { + /* alloc'd & suitable */ + pc->r_addr[i].acc = pc->insn_cur; + return &pc->r_addr[i]; + } + } + assert(a); + emit_set_addr(pc, a, ref->hw * 4); + + a->rhw = ref->hw % 128; + a->acc = pc->insn_cur; + return a; +} #define INTERP_LINEAR 0 -#define INTERP_FLAT 1 +#define INTERP_FLAT 1 #define INTERP_PERSPECTIVE 2 #define INTERP_CENTROID 4 @@ -488,6 +563,16 @@ emit_interp(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *iv, emit(pc, e); } +static INLINE void +set_addr(struct nv50_program_exec *e, struct nv50_reg *a) +{ + assert(!(e->inst[0] & 0x0c000000)); + assert(!(e->inst[1] & 0x00000004)); + + e->inst[0] |= (a->hw & 3) << 26; + e->inst[1] |= (a->hw >> 2) << 2; +} + static void set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s, struct nv50_program_exec *e) @@ -498,6 +583,14 @@ set_data(struct nv50_pc *pc, struct nv50_reg *src, unsigned m, unsigned s, e->param.shift = s; e->param.mask = m << (s % 32); + if (src->hw > 127) + set_addr(e, alloc_addr(pc, src)); + else + if (src->acc < 0) { + assert(src->type == P_CONST); + set_addr(e, pc->addr[src->index]); + } + e->inst[1] |= (((src->type == P_IMMD) ? 0 : 1) << 22); } @@ -632,7 +725,7 @@ set_src_1(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e) } alloc_reg(pc, src); - e->inst[0] |= (src->hw << 16); + e->inst[0] |= ((src->hw & 127) << 16); } static void @@ -660,7 +753,7 @@ set_src_2(struct nv50_pc *pc, struct nv50_reg *src, struct nv50_program_exec *e) } alloc_reg(pc, src); - e->inst[1] |= (src->hw << 14); + e->inst[1] |= ((src->hw & 127) << 14); } static void @@ -722,6 +815,22 @@ emit_add(struct nv50_pc *pc, struct nv50_reg *dst, emit(pc, e); } +static void +emit_arl(struct nv50_pc *pc, struct nv50_reg *dst, struct nv50_reg *src, + uint8_t s) +{ + struct nv50_program_exec *e = exec(pc); + + set_long(pc, e); + e->inst[1] |= 0xc0000000; + + e->inst[0] |= dst->hw << 2; + e->inst[0] |= s << 16; /* shift left */ + set_src_0_restricted(pc, src, e); + + emit(pc, e); +} + static void emit_minmax(struct nv50_pc *pc, unsigned sub, struct nv50_reg *dst, struct nv50_reg *src0, struct nv50_reg *src1) @@ -1403,6 +1512,16 @@ tgsi_dst(struct nv50_pc *pc, int c, const struct tgsi_full_dst_register *dst) return &pc->temp[dst->DstRegister.Index * 4 + c]; case TGSI_FILE_OUTPUT: return &pc->result[dst->DstRegister.Index * 4 + c]; + case TGSI_FILE_ADDRESS: + { + struct nv50_reg *r = pc->addr[dst->DstRegister.Index * 4 + c]; + if (!r) { + r = alloc_addr(pc, NULL); + pc->addr[dst->DstRegister.Index * 4 + c] = r; + } + assert(r); + return r; + } case TGSI_FILE_NULL: return NULL; default: @@ -1418,7 +1537,10 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src, { struct nv50_reg *r = NULL; struct nv50_reg *temp; - unsigned sgn, c; + unsigned sgn, c, swz; + + if (src->SrcRegister.File != TGSI_FILE_CONSTANT) + assert(!src->SrcRegister.Indirect); sgn = tgsi_util_get_full_src_register_sign_mode(src, chan); @@ -1436,13 +1558,29 @@ tgsi_src(struct nv50_pc *pc, int chan, const struct tgsi_full_src_register *src, r = &pc->temp[src->SrcRegister.Index * 4 + c]; break; case TGSI_FILE_CONSTANT: - r = &pc->param[src->SrcRegister.Index * 4 + c]; + if (!src->SrcRegister.Indirect) { + r = &pc->param[src->SrcRegister.Index * 4 + c]; + break; + } + /* Indicate indirection by setting r->acc < 0 and + * use the index field to select the address reg. + */ + r = MALLOC_STRUCT(nv50_reg); + swz = tgsi_util_get_src_register_swizzle( + &src->SrcRegisterInd, 0); + ctor_reg(r, P_CONST, + src->SrcRegisterInd.Index * 4 + swz, c); + r->acc = -1; break; case TGSI_FILE_IMMEDIATE: r = &pc->immd[src->SrcRegister.Index * 4 + c]; break; case TGSI_FILE_SAMPLER: break; + case TGSI_FILE_ADDRESS: + r = pc->addr[src->SrcRegister.Index * 4 + c]; + assert(r); + break; default: assert(0); break; @@ -1678,8 +1816,15 @@ nv50_program_tx_insn(struct nv50_pc *pc, emit_add(pc, dst[c], src[0][c], src[1][c]); } break; + case TGSI_OPCODE_ARL: + assert(src[0][0]); + temp = temp_temp(pc); + emit_cvt(pc, temp, src[0][0], -1, CVTOP_FLOOR, CVT_S32_F32); + emit_arl(pc, dst[0], temp, 4); + break; case TGSI_OPCODE_BGNLOOP: pc->loop_pos[pc->loop_lvl++] = pc->p->exec_size; + terminate_mbb(pc); break; case TGSI_OPCODE_BRK: emit_branch(pc, -1, 0, NULL); @@ -1763,6 +1908,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, emit_branch(pc, -1, 0, NULL); pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size; pc->if_insn[pc->if_lvl++] = pc->p->exec_tail; + terminate_mbb(pc); break; case TGSI_OPCODE_ENDIF: pc->if_insn[--pc->if_lvl]->param.index = pc->p->exec_size; @@ -1775,6 +1921,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, pc->br_join[pc->if_lvl]->param.index = pc->p->exec_size; pc->br_join[pc->if_lvl] = NULL; } + terminate_mbb(pc); /* emit a NOP as join point, we could set it on the next * one, but would have to make sure it is long and !immd */ @@ -1785,6 +1932,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, emit_branch(pc, -1, 0, NULL); pc->p->exec_tail->param.index = pc->loop_pos[--pc->loop_lvl]; pc->br_loop[pc->loop_lvl]->param.index = pc->p->exec_size; + terminate_mbb(pc); break; case TGSI_OPCODE_EX2: emit_preex2(pc, temp, src[0][0]); @@ -1812,6 +1960,7 @@ nv50_program_tx_insn(struct nv50_pc *pc, set_pred_wr(pc, 1, 0, pc->if_cond); emit_branch(pc, 0, 2, &pc->br_join[pc->if_lvl]); pc->if_insn[pc->if_lvl++] = pc->p->exec_tail; + terminate_mbb(pc); break; case TGSI_OPCODE_KIL: emit_kil(pc, src[0][0]); @@ -1989,6 +2138,9 @@ nv50_program_tx_insn(struct nv50_pc *pc, src[i][c]->neg = 0; if (src[i][c]->index == -1 && src[i][c]->type == P_IMMD) FREE(src[i][c]); + else + if (src[i][c]->acc < 0 && src[i][c]->type == P_CONST) + FREE(src[i][c]); /* indirect constant */ } } @@ -2332,8 +2484,8 @@ nv50_program_tx_prep(struct nv50_pc *pc) pc->interp_mode[i] = mode; } break; + case TGSI_FILE_ADDRESS: case TGSI_FILE_CONSTANT: - break; case TGSI_FILE_SAMPLER: break; default: @@ -2527,6 +2679,8 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p) pc->attr_nr = p->info.file_max[TGSI_FILE_INPUT] + 1; pc->result_nr = p->info.file_max[TGSI_FILE_OUTPUT] + 1; pc->param_nr = p->info.file_max[TGSI_FILE_CONSTANT] + 1; + pc->addr_nr = p->info.file_max[TGSI_FILE_ADDRESS] + 1; + assert(pc->addr_nr <= 2); p->cfg.high_temp = 4; @@ -2595,6 +2749,14 @@ ctor_nv50_pc(struct nv50_pc *pc, struct nv50_program *p) ctor_reg(&pc->param[rid], P_CONST, i, rid); } + if (pc->addr_nr) { + pc->addr = CALLOC(pc->addr_nr * 4, sizeof(struct nv50_reg *)); + if (!pc->addr) + return FALSE; + } + for (i = 0; i < NV50_SU_MAX_ADDR; ++i) + ctor_reg(&pc->r_addr[i], P_ADDR, -1, i + 1); + return TRUE; } @@ -2774,7 +2936,7 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p) p->immd_nr, NV50_CB_PMISC); } - assert(p->param_nr <= 128); + assert(p->param_nr <= 512); if (p->param_nr) { unsigned cb; diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 66361dc3ba..0bd5487695 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -301,7 +301,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) so_data (so, 8); /* constant buffers for immediates and VP/FP parameters */ - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (32 * 4) * 4, &screen->constbuf_misc[0]); if (ret) { nv50_screen_destroy(pscreen); @@ -309,7 +309,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } for (i = 0; i < 2; i++) { - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, + ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, (128 * 4) * 4, &screen->constbuf_parm[i]); if (ret) { nv50_screen_destroy(pscreen); @@ -318,8 +318,8 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) } if (nouveau_resource_init(&screen->immd_heap[0], 0, 128) || - nouveau_resource_init(&screen->parm_heap[0], 0, 128) || - nouveau_resource_init(&screen->parm_heap[1], 0, 128)) + nouveau_resource_init(&screen->parm_heap[0], 0, 512) || + nouveau_resource_init(&screen->parm_heap[1], 0, 512)) { NOUVEAU_ERR("Error initialising constant buffers.\n"); nv50_screen_destroy(pscreen); @@ -340,7 +340,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0); so_reloc (so, screen->constbuf_misc[0], 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0); - so_data (so, (NV50_CB_PMISC << 16) | 0x00000800); + so_data (so, (NV50_CB_PMISC << 16) | 0x00000200); so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); so_data (so, 0x00000001 | (NV50_CB_PMISC << 12)); so_method(so, screen->tesla, NV50TCL_SET_PROGRAM_CB, 1); -- cgit v1.2.3 From 68b5dc9634a39b5aa84fe963676b4fd0249363cf Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 18 Oct 2009 07:50:14 +0200 Subject: st/xorg: Change how disable accel is handled --- src/gallium/state_trackers/xorg/xorg_exa.c | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 4988af4864..a1c07218cb 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -47,7 +47,7 @@ #define DEBUG_PRINT 0 #define DEBUG_SOLID 0 -#define DISABLE_ACCEL 0 +#define ACCEL_ENABLED TRUE /* * Helper functions @@ -307,11 +307,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) fg = 0xffff0000; #endif -#if DISABLE_ACCEL - return FALSE; -#else - return xorg_solid_bind_state(exa, priv, fg); -#endif + return ACCEL_ENABLED && xorg_solid_bind_state(exa, priv, fg); } static void @@ -409,11 +405,7 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, exa->copy.src = src_priv; exa->copy.dst = priv; -#if DISABLE_ACCEL - return FALSE; -#else - return TRUE; -#endif + return ACCEL_ENABLED; } static void @@ -484,16 +476,12 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, XORG_FALLBACK("pMask format: %s", pf_name(priv->tex->format)); } -#if DISABLE_ACCEL - (void) exa; - return FALSE; -#else - return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture, + return ACCEL_ENABLED && + xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc ? exaGetPixmapDriverPrivate(pSrc) : NULL, pMask ? exaGetPixmapDriverPrivate(pMask) : NULL, exaGetPixmapDriverPrivate(pDst)); -#endif } static void @@ -526,10 +514,7 @@ ExaCheckComposite(int op, debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n", op, pSrcPicture, pMaskPicture, pDstPicture, accelerated); #endif -#if DISABLE_ACCEL - accelerated = FALSE; -#endif - return accelerated; + return ACCEL_ENABLED && accelerated; } static void * -- cgit v1.2.3 From b8843c60565094be311e3b31c0826a3035627a3e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 18 Oct 2009 15:25:30 +0200 Subject: st/xorg: Support more then one output of a given type --- src/gallium/state_trackers/xorg/xorg_output.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 26f45f8d64..964d9595a9 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -56,17 +56,17 @@ static char *connector_enum_list[] = { "Unknown", "VGA", - "DVI-I", - "DVI-D", - "DVI-A", + "DVI", + "DVI", + "DVI", "Composite", "SVIDEO", "LVDS", - "Component", - "9-pin DIN", - "DisplayPort", - "HDMI Type A", - "HDMI Type B", + "CTV", + "DIN", + "DP", + "HDMI", + "HDMI", }; static void @@ -240,7 +240,7 @@ output_init(ScrnInfoPtr pScrn) drmModeResPtr res; drmModeConnectorPtr drm_connector = NULL; drmModeEncoderPtr drm_encoder = NULL; - char *name; + char name[32]; int c, v, p; res = drmModeGetResources(ms->fd); @@ -273,7 +273,10 @@ output_init(ScrnInfoPtr pScrn) (void)v; #endif - name = connector_enum_list[drm_connector->connector_type]; + snprintf(name, 32, "%s%d", + connector_enum_list[drm_connector->connector_type], + drm_connector->connector_type_id); + output = xf86OutputCreate(pScrn, &output_funcs, name); if (!output) -- cgit v1.2.3 From e9e6152cb38ca5f1ea6d65cf9bf32150bf9d2b7b Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 18 Oct 2009 11:46:19 +0200 Subject: st/xorg: Clean up cursor functions a bit --- src/gallium/state_trackers/xorg/xorg_crtc.c | 81 +++++++++++++++++------------ 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 67fe29a69d..6c6b6b5d1c 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -173,18 +173,23 @@ crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) //ScrnInfoPtr pScrn = crtc->scrn; } +/* + * Cursor functions + */ + static void -crtc_destroy(xf86CrtcPtr crtc) +crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg) { - struct crtc_private *crtcp = crtc->driver_private; +} - if (crtcp->cursor_tex) - pipe_texture_reference(&crtcp->cursor_tex, NULL); +static void +crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) +{ + modesettingPtr ms = modesettingPTR(crtc->scrn); + struct crtc_private *crtcp = crtc->driver_private; - drmModeFreeCrtc(crtcp->drm_crtc); - xfree(crtcp); + drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); } - static void crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) { @@ -229,15 +234,6 @@ crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) ms->screen->tex_transfer_destroy(transfer); } -static void -crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) -{ - modesettingPtr ms = modesettingPTR(crtc->scrn); - struct crtc_private *crtcp = crtc->driver_private; - - drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); -} - static void crtc_show_cursor(xf86CrtcPtr crtc) { @@ -258,38 +254,55 @@ crtc_hide_cursor(xf86CrtcPtr crtc) drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0); } +void +crtc_cursor_destroy(xf86CrtcPtr crtc) +{ + struct crtc_private *crtcp = crtc->driver_private; + + if (crtcp->cursor_tex) { + pipe_texture_reference(&crtcp->cursor_tex, NULL); + } +} + +/* + * Misc functions + */ + +static void +crtc_destroy(xf86CrtcPtr crtc) +{ + struct crtc_private *crtcp = crtc->driver_private; + + if (crtcp->cursor_tex) + pipe_texture_reference(&crtcp->cursor_tex, NULL); + + drmModeFreeCrtc(crtcp->drm_crtc); + xfree(crtcp); +} + static const xf86CrtcFuncsRec crtc_funcs = { .dpms = crtc_dpms, - .save = NULL, - .restore = NULL, + .lock = crtc_lock, .unlock = crtc_unlock, .mode_fixup = crtc_mode_fixup, .prepare = crtc_prepare, .mode_set = crtc_mode_set, .commit = crtc_commit, - .gamma_set = crtc_gamma_set, - .shadow_create = crtc_shadow_create, - .shadow_allocate = crtc_shadow_allocate, - .shadow_destroy = crtc_shadow_destroy, + + .set_cursor_colors = crtc_set_cursor_colors, .set_cursor_position = crtc_set_cursor_position, .show_cursor = crtc_show_cursor, .hide_cursor = crtc_hide_cursor, - .load_cursor_image = NULL, /* lets convert to argb only */ - .set_cursor_colors = NULL, /* using argb only */ .load_cursor_argb = crtc_load_cursor_argb, - .destroy = crtc_destroy, -}; -void -crtc_cursor_destroy(xf86CrtcPtr crtc) -{ - struct crtc_private *crtcp = crtc->driver_private; + .shadow_create = crtc_shadow_create, + .shadow_allocate = crtc_shadow_allocate, + .shadow_destroy = crtc_shadow_destroy, - if (crtcp->cursor_tex) { - pipe_texture_reference(&crtcp->cursor_tex, NULL); - } -} + .gamma_set = crtc_gamma_set, + .destroy = crtc_destroy, +}; void crtc_init(ScrnInfoPtr pScrn) -- cgit v1.2.3 From 846da0bfdae971cba84cd2ad9217c74c62e6bce9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 18 Oct 2009 15:42:25 +0200 Subject: st/xorg: Massivly redo root pixmap creation --- src/gallium/state_trackers/xorg/xorg_driver.c | 122 +++++++++++++++++-------- src/gallium/state_trackers/xorg/xorg_exa.c | 44 +++++++++ src/gallium/state_trackers/xorg/xorg_tracker.h | 9 ++ 3 files changed, 137 insertions(+), 38 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index ab6c3d7558..24d3c23fa6 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -144,20 +144,22 @@ static Bool CreateFrontBuffer(ScrnInfoPtr pScrn) { modesettingPtr ms = modesettingPTR(pScrn); - ScreenPtr pScreen = pScrn->pScreen; - PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); unsigned handle, stride; + struct pipe_texture *tex; ms->noEvict = TRUE; - xorg_exa_set_displayed_usage(rootPixmap); - pScreen->ModifyPixmapHeader(rootPixmap, - pScrn->virtualX, pScrn->virtualY, - pScrn->depth, pScrn->bitsPerPixel, - pScrn->displayWidth * pScrn->bitsPerPixel / 8, - NULL); - ms->noEvict = FALSE; - handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride); + tex = xorg_exa_create_root_texture(pScrn, pScrn->virtualX, pScrn->virtualY, + pScrn->depth, pScrn->bitsPerPixel); + + if (!tex) + return FALSE; + + if (!ms->api->local_handle_from_texture(ms->api, ms->screen, + tex, + &stride, + &handle)) + return FALSE; drmModeAddFB(ms->fd, pScrn->virtualX, @@ -166,12 +168,39 @@ CreateFrontBuffer(ScrnInfoPtr pScrn) pScrn->bitsPerPixel, stride, handle, - &ms->fb_id); + &ms->fb_id); pScrn->frameX0 = 0; pScrn->frameY0 = 0; AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + pipe_texture_reference(&ms->root_texture, tex); + pipe_texture_reference(&tex, NULL); + return TRUE; +} + +static Bool +BindTextureToRoot(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + ScreenPtr pScreen = pScrn->pScreen; + struct pipe_texture *check; + PixmapPtr rootPixmap; + + rootPixmap = pScreen->GetScreenPixmap(pScreen); + + xorg_exa_set_displayed_usage(rootPixmap); + xorg_exa_set_shared_usage(rootPixmap); + xorg_exa_set_texture(rootPixmap, ms->root_texture); + if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) + FatalError("Couldn't adjust screen pixmap\n"); + + check = xorg_exa_get_texture(rootPixmap); + if (ms->root_texture != check) + FatalError("Created new root texture\n"); + + pipe_texture_reference(&check, NULL); + return TRUE; } @@ -179,10 +208,9 @@ static Bool crtc_resize(ScrnInfoPtr pScrn, int width, int height) { modesettingPtr ms = modesettingPTR(pScrn); - //ScreenPtr pScreen = pScrn->pScreen; - //PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); - //Bool fbAccessDisabled; - //CARD8 *fbstart; + unsigned handle, stride; + PixmapPtr rootPixmap; + ScreenPtr pScreen = pScrn->pScreen; if (width == pScrn->virtualX && height == pScrn->virtualY) return TRUE; @@ -192,13 +220,40 @@ crtc_resize(ScrnInfoPtr pScrn, int width, int height) pScrn->virtualX = width; pScrn->virtualY = height; + /* + * Remove the old framebuffer & texture. + */ + drmModeRmFB(ms->fd, ms->fb_id); + pipe_texture_reference(&ms->root_texture, NULL); + + + rootPixmap = pScreen->GetScreenPixmap(pScreen); + if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, -1, -1, -1, NULL)) + return FALSE; + + /* takes one ref */ + ms->root_texture = xorg_exa_get_texture(rootPixmap); + + if (!ms->api->local_handle_from_texture(ms->api, ms->screen, + ms->root_texture, + &stride, + &handle)) + FatalError("Could not get handle and stride from texture\n"); + + drmModeAddFB(ms->fd, + pScrn->virtualX, + pScrn->virtualY, + pScrn->depth, + pScrn->bitsPerPixel, + stride, + handle, + &ms->fb_id); + /* HW dependent - FIXME */ pScrn->displayWidth = pScrn->virtualX; - drmModeRmFB(ms->fd, ms->fb_id); - /* now create new frontbuffer */ - return CreateFrontBuffer(pScrn); + return CreateFrontBuffer(pScrn) && BindTextureToRoot(pScrn); } static const xf86CrtcConfigFuncsRec crtc_config_funcs = { @@ -429,7 +484,6 @@ CreateScreenResources(ScreenPtr pScreen) modesettingPtr ms = modesettingPTR(pScrn); PixmapPtr rootPixmap; Bool ret; - unsigned handle, stride; ms->noEvict = TRUE; @@ -437,29 +491,14 @@ CreateScreenResources(ScreenPtr pScreen) ret = pScreen->CreateScreenResources(pScreen); pScreen->CreateScreenResources = CreateScreenResources; - rootPixmap = pScreen->GetScreenPixmap(pScreen); - - xorg_exa_set_displayed_usage(rootPixmap); - xorg_exa_set_shared_usage(rootPixmap); - if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) - FatalError("Couldn't adjust screen pixmap\n"); + BindTextureToRoot(pScrn); ms->noEvict = FALSE; - handle = xorg_exa_get_pixmap_handle(rootPixmap, &stride); - - drmModeAddFB(ms->fd, - pScrn->virtualX, - pScrn->virtualY, - pScrn->depth, - pScrn->bitsPerPixel, - stride, - handle, - &ms->fb_id); - AdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); #ifdef DRM_MODE_FEATURE_DIRTYFB + rootPixmap = pScreen->GetScreenPixmap(pScreen); ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, pScreen, rootPixmap); @@ -472,6 +511,8 @@ CreateScreenResources(ScreenPtr pScreen) "Failed to create screen damage record\n"); return FALSE; } +#else + (void)rootPixmap; #endif return ret; @@ -684,8 +725,11 @@ EnterVT(int scrnIndex, int flags) SaveHWState(pScrn); } - if (!flags) /* signals startup as we'll do this in CreateScreenResources */ - CreateFrontBuffer(pScrn); + if (!CreateFrontBuffer(pScrn)) + return FALSE; + + if (!flags && !BindTextureToRoot(pScrn)) + return FALSE; if (!xf86SetDesiredModes(pScrn)) return FALSE; @@ -725,6 +769,8 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) } #endif + pipe_texture_reference(&ms->root_texture, NULL); + if (ms->exa) xorg_exa_close(pScrn); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index a1c07218cb..ca25d90557 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -708,6 +708,50 @@ xorg_exa_get_texture(PixmapPtr pPixmap) return tex; } +Bool +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; + + if (!priv) + return FALSE; + + if (pPixmap->drawable.width != tex->width[0] || + pPixmap->drawable.height != tex->height[0]) + return FALSE; + + pipe_texture_reference(&priv->tex, tex); + priv->tex_flags = tex->tex_usage & mask; + + return TRUE; +} + +struct pipe_texture * +xorg_exa_create_root_texture(ScrnInfoPtr pScrn, + int width, int height, + int depth, int bitsPerPixel) +{ + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_context *exa = ms->exa; + struct pipe_texture template; + + memset(&template, 0, sizeof(template)); + template.target = PIPE_TEXTURE_2D; + exa_get_pipe_format(depth, &template.format, &bitsPerPixel); + pf_get_block(template.format, &template.block); + template.width[0] = width; + template.height[0] = height; + template.depth[0] = 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; + + return exa->scrn->texture_create(exa->scrn, &template); +} + void xorg_exa_close(ScrnInfoPtr pScrn) { diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h index 24e1a4928e..6130cf6621 100644 --- a/src/gallium/state_trackers/xorg/xorg_tracker.h +++ b/src/gallium/state_trackers/xorg/xorg_tracker.h @@ -92,6 +92,7 @@ typedef struct _modesettingRec struct pipe_context *ctx; boolean d_depth_bits_last; boolean ds_depth_bits_last; + struct pipe_texture *root_texture; /* exa */ struct exa_context *exa; @@ -121,6 +122,14 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap); int xorg_exa_set_shared_usage(PixmapPtr pPixmap); +Bool +xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex); + +struct pipe_texture * +xorg_exa_create_root_texture(ScrnInfoPtr pScrn, + int width, int height, + int depth, int bpp); + void * xorg_exa_init(ScrnInfoPtr pScrn); -- cgit v1.2.3 From e1b39c673d885e3dc990a29445360830b0a603aa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 18 Oct 2009 11:49:44 +0200 Subject: st/xorg: Switch to set_mode_major --- src/gallium/state_trackers/xorg/xorg_crtc.c | 86 ++++++++++----------------- src/gallium/state_trackers/xorg/xorg_driver.c | 4 +- 2 files changed, 32 insertions(+), 58 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 6c6b6b5d1c..85b9162d4c 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -64,8 +64,6 @@ struct crtc_private static void crtc_dpms(xf86CrtcPtr crtc, int mode) { - //ScrnInfoPtr pScrn = crtc->scrn; - switch (mode) { case DPMSModeOn: case DPMSModeStandby: @@ -77,44 +75,29 @@ crtc_dpms(xf86CrtcPtr crtc, int mode) } static Bool -crtc_lock(xf86CrtcPtr crtc) -{ - return FALSE; -} - -static void -crtc_unlock(xf86CrtcPtr crtc) -{ -} - -static void -crtc_prepare(xf86CrtcPtr crtc) -{ -} - -static void -crtc_commit(xf86CrtcPtr crtc) -{ -} - -static Bool -crtc_mode_fixup(xf86CrtcPtr crtc, DisplayModePtr mode, - DisplayModePtr adjusted_mode) -{ - return TRUE; -} - -static void -crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, - DisplayModePtr adjusted_mode, int x, int y) +crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, + Rotation rotation, int x, int y) { xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); modesettingPtr ms = modesettingPTR(crtc->scrn); - xf86OutputPtr output = config->output[config->compat_output]; - drmModeConnectorPtr drm_connector = output->driver_private; + xf86OutputPtr output = NULL; + drmModeConnectorPtr drm_connector; struct crtc_private *crtcp = crtc->driver_private; drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; drmModeModeInfo drm_mode; + int i, ret; + + for (i = 0; i < config->num_output; output = NULL, i++) { + output = config->output[i]; + + if (output->crtc == crtc) + break; + } + + if (!output) + return FALSE; + + drm_connector = output->driver_private; drm_mode.clock = mode->Clock; drm_mode.hdisplay = mode->HDisplay; @@ -133,17 +116,19 @@ crtc_mode_set(xf86CrtcPtr crtc, DisplayModePtr mode, xf86SetModeDefaultName(mode); strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN); - drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, - &drm_connector->connector_id, 1, &drm_mode); -} + ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, + &drm_connector->connector_id, 1, &drm_mode); -#if 0 -static void -crtc_load_lut(xf86CrtcPtr crtc) -{ - //ScrnInfoPtr pScrn = crtc->scrn; + if (ret) + return FALSE; + + crtc->x = x; + crtc->y = y; + crtc->mode = *mode; + crtc->rotation = rotation; + + return TRUE; } -#endif static void crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, @@ -154,23 +139,18 @@ crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, static void * crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) { - //ScrnInfoPtr pScrn = crtc->scrn; - return NULL; } static PixmapPtr crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) { - //ScrnInfoPtr pScrn = crtc->scrn; - return NULL; } static void crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) { - //ScrnInfoPtr pScrn = crtc->scrn; } /* @@ -282,13 +262,7 @@ crtc_destroy(xf86CrtcPtr crtc) static const xf86CrtcFuncsRec crtc_funcs = { .dpms = crtc_dpms, - - .lock = crtc_lock, - .unlock = crtc_unlock, - .mode_fixup = crtc_mode_fixup, - .prepare = crtc_prepare, - .mode_set = crtc_mode_set, - .commit = crtc_commit, + .set_mode_major = crtc_set_mode_major, .set_cursor_colors = crtc_set_cursor_colors, .set_cursor_position = crtc_set_cursor_position, @@ -322,6 +296,7 @@ crtc_init(ScrnInfoPtr pScrn) for (c = 0; c < res->count_crtcs; c++) { drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); + if (!drm_crtc) continue; @@ -338,7 +313,6 @@ crtc_init(ScrnInfoPtr pScrn) crtcp->drm_crtc = drm_crtc; crtc->driver_private = crtcp; - } out: diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 24d3c23fa6..2df954f18e 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -651,8 +651,8 @@ AdjustFrame(int scrnIndex, int x, int y, int flags) xf86CrtcPtr crtc = output->crtc; if (crtc && crtc->enabled) { - crtc->funcs->mode_set(crtc, pScrn->currentMode, pScrn->currentMode, x, - y); + crtc->funcs->set_mode_major(crtc, pScrn->currentMode, + RR_Rotate_0, x, y); crtc->x = output->initial_x + x; crtc->y = output->initial_y + y; } -- cgit v1.2.3 From 973aab1a528f0a42e8b5e979b4730649ea366363 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 19 Oct 2009 13:06:45 -0700 Subject: dri-st: Add EXT_provoking_vertex. Hm, I could have sworn I did this before? --- src/gallium/state_trackers/dri/dri_extensions.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/state_trackers/dri/dri_extensions.c b/src/gallium/state_trackers/dri/dri_extensions.c index f39a305531..800d462e32 100644 --- a/src/gallium/state_trackers/dri/dri_extensions.c +++ b/src/gallium/state_trackers/dri/dri_extensions.c @@ -37,6 +37,7 @@ #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 @@ -52,6 +53,7 @@ #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_APPLE_vertex_array_object #define need_GL_NV_vertex_program @@ -69,6 +71,7 @@ const struct dri_extension card_extensions[] = { {"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 }, @@ -97,6 +100,7 @@ const struct dri_extension card_extensions[] = { {"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_wrap", NULL}, {"GL_EXT_texture_edge_clamp", NULL}, -- cgit v1.2.3 From e5f1f6a0bece3d035bf5ac1685b5335af4862cea Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Mon, 19 Oct 2009 13:51:28 -0700 Subject: r300g: Demonstratory kludge to unbreak glxgears. We *must* recalculate something in vformat every rebind; let's see if we can't narrow it down a bit. --- src/gallium/drivers/r300/r300_state_derived.c | 28 +++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 1468b9d36e..5df1a0cd63 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -460,32 +460,36 @@ static void r300_update_derived_shader_state(struct r300_context* r300) value = (struct r300_shader_derived_value*) util_hash_table_get(r300->shader_hash_table, (void*)key); if (value) { - vformat = value->vformat; + //vformat = value->vformat; rs_block = value->rs_block; FREE(key); } else { - vformat = CALLOC_STRUCT(r300_vertex_format); rs_block = CALLOC_STRUCT(r300_rs_block); value = CALLOC_STRUCT(r300_shader_derived_value); - for (i = 0; i < 16; i++) { - vformat->vs_tab[i] = -1; - vformat->fs_tab[i] = -1; - } - - r300_vs_tab_routes(r300, vformat); - r300_vertex_psc(r300, vformat); - r300_update_fs_tab(r300, vformat); - r300_update_rs_block(r300, rs_block); - value->vformat = vformat; + //value->vformat = vformat; value->rs_block = rs_block; util_hash_table_set(r300->shader_hash_table, (void*)key, (void*)value); } + /* XXX This will be refactored ASAP. */ + vformat = CALLOC_STRUCT(r300_vertex_format); + + for (i = 0; i < 16; i++) { + vformat->vs_tab[i] = -1; + vformat->fs_tab[i] = -1; + } + + r300_vs_tab_routes(r300, vformat); + r300_vertex_psc(r300, vformat); + r300_update_fs_tab(r300, vformat); + + FREE(r300->vertex_info); + r300->vertex_info = vformat; r300->rs_block = rs_block; r300->dirty_state |= (R300_NEW_VERTEX_FORMAT | R300_NEW_RS_BLOCK); -- cgit v1.2.3 From a39a3cc14e816cc91a81028a27c4dbd4816cdc9d Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Tue, 13 Oct 2009 13:06:39 -0400 Subject: st/xorg: implement basic src/mask transformations plus fix filters --- src/gallium/state_trackers/xorg/Makefile | 1 + src/gallium/state_trackers/xorg/xorg_composite.c | 126 +++++++++++++++++++--- src/gallium/state_trackers/xorg/xorg_exa.c | 2 + src/gallium/state_trackers/xorg/xorg_exa.h | 8 ++ src/gallium/state_trackers/xorg/xorg_renderer.c | 130 ++++++++++++++++++----- src/gallium/state_trackers/xorg/xorg_renderer.h | 4 +- 6 files changed, 231 insertions(+), 40 deletions(-) diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile index 27a1990724..030bac5fff 100644 --- a/src/gallium/state_trackers/xorg/Makefile +++ b/src/gallium/state_trackers/xorg/Makefile @@ -5,6 +5,7 @@ LIBNAME = xorgtracker LIBRARY_INCLUDES = \ -DHAVE_CONFIG_H \ + -DHAVE_XEXTPROTO_71=1 \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index d6483fb72c..7379e3b746 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -9,6 +9,9 @@ #include "pipe/p_inlines.h" +/*XXX also in Xrender.h but the including it here breaks compilition */ +#define XFixedToDouble(f) (((double) (f)) / 65536.) + struct xorg_composite_blend { int op:8; @@ -144,6 +147,43 @@ render_repeat_to_gallium(int mode) return PIPE_TEX_WRAP_REPEAT; } +static INLINE boolean +render_filter_to_gallium(int xrender_filter, int *out_filter) +{ + + switch (xrender_filter) { + case PictFilterNearest: + *out_filter = PIPE_TEX_FILTER_NEAREST; + break; + case PictFilterBilinear: + *out_filter = PIPE_TEX_FILTER_LINEAR; + break; + case PictFilterFast: + *out_filter = PIPE_TEX_FILTER_NEAREST; + break; + case PictFilterGood: + *out_filter = PIPE_TEX_FILTER_LINEAR; + break; + case PictFilterBest: + *out_filter = PIPE_TEX_FILTER_LINEAR; + break; + default: + debug_printf("Unkown xrender filter"); + *out_filter = PIPE_TEX_FILTER_NEAREST; + return FALSE; + } + + return TRUE; +} + +static boolean is_filter_accelerated(PicturePtr pic) +{ + int filter; + if (pic && !render_filter_to_gallium(pic->filter, &filter)) + return FALSE; + return TRUE; +} + boolean xorg_composite_accelerated(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, @@ -156,6 +196,11 @@ boolean xorg_composite_accelerated(int op, unsigned accel_ops_count = sizeof(accelerated_ops)/sizeof(struct acceleration_info); + if (!is_filter_accelerated(pSrcPicture) || + !is_filter_accelerated(pMaskPicture)) { + XORG_FALLBACK("Unsupported Xrender filter"); + } + if (pSrcPicture->pSourcePict) { if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill) XORG_FALLBACK("gradients not enabled (haven't been well tested)"); @@ -163,13 +208,10 @@ boolean xorg_composite_accelerated(int op, for (i = 0; i < accel_ops_count; ++i) { if (op == accelerated_ops[i].op) { - /* Check for unsupported component alpha */ - if ((pSrcPicture->componentAlpha && - !accelerated_ops[i].component_alpha) || - (pMaskPicture && - (!accelerated_ops[i].with_mask || - (pMaskPicture->componentAlpha && - !accelerated_ops[i].component_alpha)))) + /* Check for component alpha */ + if (pMaskPicture && + (pMaskPicture->componentAlpha || + (!accelerated_ops[i].with_mask))) XORG_FALLBACK("component alpha unsupported (PictOpOver=%s(%d)", (accelerated_ops[i].op == PictOpOver) ? "yes" : "no", accelerated_ops[i].op); @@ -238,7 +280,6 @@ bind_shaders(struct exa_context *exa, int op, cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs); } - static void bind_samplers(struct exa_context *exa, int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, @@ -264,10 +305,15 @@ bind_samplers(struct exa_context *exa, int op, if (pSrcPicture && pSrc) { unsigned src_wrap = render_repeat_to_gallium( pSrcPicture->repeatType); + int filter; + + render_filter_to_gallium(pSrcPicture->filter, &filter); + src_sampler.wrap_s = src_wrap; src_sampler.wrap_t = src_wrap; - src_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST; - src_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST; + src_sampler.min_img_filter = filter; + src_sampler.mag_img_filter = filter; + src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; src_sampler.normalized_coords = 1; samplers[0] = &src_sampler; exa->bound_textures[0] = pSrc->tex; @@ -277,10 +323,15 @@ bind_samplers(struct exa_context *exa, int op, if (pMaskPicture && pMask) { unsigned mask_wrap = render_repeat_to_gallium( pMaskPicture->repeatType); + int filter; + + render_filter_to_gallium(pMaskPicture->filter, &filter); + mask_sampler.wrap_s = mask_wrap; mask_sampler.wrap_t = mask_wrap; - mask_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST; - mask_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST; + mask_sampler.min_img_filter = filter; + mask_sampler.mag_img_filter = filter; + src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; mask_sampler.normalized_coords = 1; samplers[1] = &mask_sampler; exa->bound_textures[1] = pMask->tex; @@ -328,6 +379,44 @@ setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst) setup_fs_constant_buffer(exa); } +static INLINE boolean matrix_from_pict_transform(PictTransform *trans, float *matrix) +{ + if (!trans) + return FALSE; + + matrix[0] = XFixedToDouble(trans->matrix[0][0]); + matrix[1] = XFixedToDouble(trans->matrix[0][1]); + matrix[2] = XFixedToDouble(trans->matrix[0][2]); + + matrix[3] = XFixedToDouble(trans->matrix[1][0]); + matrix[4] = XFixedToDouble(trans->matrix[1][1]); + matrix[5] = XFixedToDouble(trans->matrix[1][2]); + + matrix[6] = XFixedToDouble(trans->matrix[2][0]); + matrix[7] = XFixedToDouble(trans->matrix[2][1]); + matrix[8] = XFixedToDouble(trans->matrix[2][2]); + + return TRUE; +} + +static void +setup_transforms(struct exa_context *exa, + PicturePtr pSrcPicture, PicturePtr pMaskPicture) +{ + PictTransform *src_t = NULL; + PictTransform *mask_t = NULL; + + if (pSrcPicture) + src_t = pSrcPicture->transform; + if (pMaskPicture) + mask_t = pMaskPicture->transform; + + exa->transform.has_src = + matrix_from_pict_transform(src_t, exa->transform.src); + exa->transform.has_mask = + matrix_from_pict_transform(mask_t, exa->transform.mask); +} + boolean xorg_composite_bind_state(struct exa_context *exa, int op, PicturePtr pSrcPicture, @@ -346,6 +435,8 @@ boolean xorg_composite_bind_state(struct exa_context *exa, pDstPicture, pSrc, pMask, pDst); setup_constant_buffers(exa, pDst); + setup_transforms(exa, pSrcPicture, pMaskPicture); + return TRUE; } @@ -360,10 +451,19 @@ void xorg_composite(struct exa_context *exa, exa->solid_color); } else { int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY}; + float *src_matrix = NULL; + float *mask_matrix = NULL; + + if (exa->transform.has_src) + src_matrix = exa->transform.src; + if (exa->transform.has_mask) + mask_matrix = exa->transform.mask; + renderer_draw_textures(exa->renderer, pos, width, height, exa->bound_textures, - exa->num_bound_samplers); + exa->num_bound_samplers, + src_matrix, mask_matrix); } } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index ca25d90557..39c4d26ebe 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -92,6 +92,8 @@ xorg_exa_common_done(struct exa_context *exa) { exa->copy.src = NULL; exa->copy.dst = NULL; + exa->transform.has_src = FALSE; + exa->transform.has_mask = FALSE; exa->has_solid_color = FALSE; exa->num_bound_samplers = 0; } diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h index 292f964cec..45f88d9404 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.h +++ b/src/gallium/state_trackers/xorg/xorg_exa.h @@ -24,6 +24,14 @@ struct exa_context float solid_color[4]; boolean has_solid_color; + /* float[9] projective matrix bound to pictures */ + struct { + float src[9]; + float mask[9]; + boolean has_src; + boolean has_mask; + } transform; + struct { struct exa_pixmap_priv *src; struct exa_pixmap_priv *dst; diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index ca69e1e0e9..3dd5e6e811 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -11,11 +11,39 @@ #include "pipe/p_inlines.h" +#include + enum AxisOrientation { Y0_BOTTOM, Y0_TOP }; +#define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y))) +#define floatIsZero(x) (floatsEqual((x) + 1, 1)) + +static INLINE boolean is_affine(float *matrix) +{ + return floatIsZero(matrix[2]) && floatIsZero(matrix[5]) + && floatsEqual(matrix[8], 1); +} +static INLINE void map_point(float *mat, float x, float y, + float *out_x, float *out_y) +{ + if (!mat) { + *out_x = x; + *out_y = y; + return; + } + + *out_x = mat[0]*x + mat[3]*y + mat[6]; + *out_y = mat[1]*x + mat[4]*y + mat[7]; + if (!is_affine(mat)) { + float w = 1/(mat[2]*x + mat[5]*y + mat[8]); + *out_x *= w; + *out_y *= w; + } +} + static void renderer_init_state(struct xorg_renderer *r) { @@ -60,23 +88,38 @@ static struct pipe_buffer * setup_vertex_data1(struct xorg_renderer *r, int srcX, int srcY, int dstX, int dstY, int width, int height, - struct pipe_texture *src) + struct pipe_texture *src, float *src_matrix) { - float s0, t0, s1, t1; + float s0, t0, s1, t1, stmp, ttmp; s0 = srcX / src->width[0]; s1 = srcX + width / src->width[0]; t0 = srcY / src->height[0]; t1 = srcY + height / src->height[0]; - /* 1st vertex */ - setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0); - /* 2nd vertex */ - setup_vertex1(r->vertices2[1], dstX + width, dstY, s1, t0); - /* 3rd vertex */ - setup_vertex1(r->vertices2[2], dstX + width, dstY + height, s1, t1); - /* 4th vertex */ - setup_vertex1(r->vertices2[3], dstX, dstY + height, s0, t1); + if (src_matrix) { + /* 1st vertex */ + map_point(src_matrix, s0, t0, &stmp, &ttmp); + setup_vertex1(r->vertices2[0], dstX, dstY, stmp, ttmp); + /* 2nd vertex */ + map_point(src_matrix, s1, t0, &stmp, &ttmp); + setup_vertex1(r->vertices2[1], dstX + width, dstY, stmp, ttmp); + /* 3rd vertex */ + map_point(src_matrix, s1, t1, &stmp, &ttmp); + setup_vertex1(r->vertices2[2], dstX + width, dstY + height, stmp, ttmp); + /* 4th vertex */ + map_point(src_matrix, s0, t1, &stmp, &ttmp); + setup_vertex1(r->vertices2[3], dstX, dstY + height, stmp, ttmp); + } else { + /* 1st vertex */ + setup_vertex1(r->vertices2[0], dstX, dstY, s0, t0); + /* 2nd vertex */ + setup_vertex1(r->vertices2[1], dstX + width, dstY, s1, t0); + /* 3rd vertex */ + setup_vertex1(r->vertices2[2], dstX + width, dstY + height, s1, t1); + /* 4th vertex */ + setup_vertex1(r->vertices2[3], dstX, dstY + height, s0, t1); + } return pipe_user_buffer_create(r->pipe->screen, r->vertices2, @@ -128,9 +171,11 @@ setup_vertex_data2(struct xorg_renderer *r, int srcX, int srcY, int maskX, int maskY, int dstX, int dstY, int width, int height, struct pipe_texture *src, - struct pipe_texture *mask) + struct pipe_texture *mask, + float *src_matrix, float *mask_matrix) { float st0[4], st1[4]; + float pt0[2], pt1[2]; st0[0] = srcX / src->width[0]; st0[1] = srcY / src->height[0]; @@ -142,18 +187,49 @@ setup_vertex_data2(struct xorg_renderer *r, st1[2] = maskX + width / mask->width[0]; st1[3] = maskY + height / mask->height[0]; - /* 1st vertex */ - setup_vertex2(r->vertices3[0], dstX, dstY, - st0[0], st0[1], st1[0], st1[1]); - /* 2nd vertex */ - setup_vertex2(r->vertices3[1], dstX + width, dstY, - st0[2], st0[1], st1[2], st1[1]); - /* 3rd vertex */ - setup_vertex2(r->vertices3[2], dstX + width, dstY + height, - st0[2], st0[3], st1[2], st1[3]); - /* 4th vertex */ - setup_vertex2(r->vertices3[3], dstX, dstY + height, - st0[0], st0[3], st1[0], st1[3]); + if (src_matrix || mask_matrix) { + /* 1st vertex */ + map_point(src_matrix, st0[0], st0[1], + pt0 + 0, pt0 + 1); + map_point(mask_matrix, st1[0], st1[1], + pt1 + 0, pt1 + 1); + setup_vertex2(r->vertices3[0], dstX, dstY, + pt0[0], pt0[1], pt1[0], pt1[1]); + /* 2nd vertex */ + map_point(src_matrix, st0[2], st0[1], + pt0 + 0, pt0 + 1); + map_point(mask_matrix, st1[2], st1[1], + pt1 + 0, pt1 + 1); + setup_vertex2(r->vertices3[1], dstX + width, dstY, + pt0[0], pt0[1], pt1[0], pt1[1]); + /* 3rd vertex */ + map_point(src_matrix, st0[2], st0[3], + pt0 + 0, pt0 + 1); + map_point(mask_matrix, st1[2], st1[3], + pt1 + 0, pt1 + 1); + setup_vertex2(r->vertices3[2], dstX + width, dstY + height, + pt0[0], pt0[1], pt1[0], pt1[1]); + /* 4th vertex */ + map_point(src_matrix, st0[0], st0[3], + pt0 + 0, pt0 + 1); + map_point(mask_matrix, st1[0], st1[3], + pt1 + 0, pt1 + 1); + setup_vertex2(r->vertices3[3], dstX, dstY + height, + pt0[0], pt0[1], pt1[0], pt1[1]); + } else { + /* 1st vertex */ + setup_vertex2(r->vertices3[0], dstX, dstY, + st0[0], st0[1], st1[0], st1[1]); + /* 2nd vertex */ + setup_vertex2(r->vertices3[1], dstX + width, dstY, + st0[2], st0[1], st1[2], st1[1]); + /* 3rd vertex */ + setup_vertex2(r->vertices3[2], dstX + width, dstY + height, + st0[2], st0[3], st1[2], st1[3]); + /* 4th vertex */ + setup_vertex2(r->vertices3[3], dstX, dstY + height, + st0[0], st0[3], st1[0], st1[3]); + } return pipe_user_buffer_create(r->pipe->screen, r->vertices3, @@ -721,7 +797,8 @@ void renderer_draw_textures(struct xorg_renderer *r, int *pos, int width, int height, struct pipe_texture **textures, - int num_textures) + int num_textures, + float *src_matrix, float *mask_matrix) { struct pipe_context *pipe = r->pipe; struct pipe_buffer *buf = 0; @@ -732,7 +809,7 @@ void renderer_draw_textures(struct xorg_renderer *r, pos[0], pos[1], /* src */ pos[4], pos[5], /* dst */ width, height, - textures[0]); + textures[0], src_matrix); break; case 2: buf = setup_vertex_data2(r, @@ -740,7 +817,8 @@ void renderer_draw_textures(struct xorg_renderer *r, pos[2], pos[3], /* mask */ pos[4], pos[5], /* dst */ width, height, - textures[0], textures[1]); + textures[0], textures[1], + src_matrix, mask_matrix); break; default: debug_assert(!"Unsupported number of textures"); diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h index b6296d5fd6..3e37c9aa93 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.h +++ b/src/gallium/state_trackers/xorg/xorg_renderer.h @@ -47,7 +47,9 @@ void renderer_draw_textures(struct xorg_renderer *r, int *pos, int width, int height, struct pipe_texture **textures, - int num_textures); + int num_textures, + float *src_matrix, + float *mask_matrix); #endif -- cgit v1.2.3 From b7fbcfdb3bf220ceae5c994d49bcd806a51e177a Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Mon, 19 Oct 2009 23:48:38 -0400 Subject: st/xorg: makefile garbage --- src/gallium/state_trackers/xorg/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile index 030bac5fff..27a1990724 100644 --- a/src/gallium/state_trackers/xorg/Makefile +++ b/src/gallium/state_trackers/xorg/Makefile @@ -5,7 +5,6 @@ LIBNAME = xorgtracker LIBRARY_INCLUDES = \ -DHAVE_CONFIG_H \ - -DHAVE_XEXTPROTO_71=1 \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -- cgit v1.2.3 From 5f8f14e5ca994461c54ba547f6371c2f71474425 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 19 Oct 2009 07:49:40 +0200 Subject: st/xorg: Remove output functions not used --- src/gallium/state_trackers/xorg/xorg_output.c | 84 +++++---------------------- 1 file changed, 15 insertions(+), 69 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c index 964d9595a9..bfeddc5e11 100644 --- a/src/gallium/state_trackers/xorg/xorg_output.c +++ b/src/gallium/state_trackers/xorg/xorg_output.c @@ -70,52 +70,15 @@ static char *connector_enum_list[] = { }; static void -dpms(xf86OutputPtr output, int mode) -{ -} - -static void -save(xf86OutputPtr output) -{ -} - -static void -restore(xf86OutputPtr output) -{ -} - -static int -mode_valid(xf86OutputPtr output, DisplayModePtr pMode) -{ - return MODE_OK; -} - -static Bool -mode_fixup(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) -{ - return TRUE; -} - -static void -prepare(xf86OutputPtr output) -{ - dpms(output, DPMSModeOff); -} - -static void -mode_set(xf86OutputPtr output, DisplayModePtr mode, - DisplayModePtr adjusted_mode) +create_resources(xf86OutputPtr output) { +#ifdef RANDR_12_INTERFACE +#endif /* RANDR_12_INTERFACE */ } static void -commit(xf86OutputPtr output) +dpms(xf86OutputPtr output, int mode) { - dpms(output, DPMSModeOn); - - if (output->scrn->pScreen != NULL) - xf86_reload_cursors(output->scrn->pScreen); } static xf86OutputStatus @@ -171,17 +134,10 @@ get_modes(xf86OutputPtr output) return modes; } -static void -destroy(xf86OutputPtr output) -{ - drmModeFreeConnector(output->driver_private); -} - -static void -create_resources(xf86OutputPtr output) +static int +mode_valid(xf86OutputPtr output, DisplayModePtr pMode) { -#ifdef RANDR_12_INTERFACE -#endif /* RANDR_12_INTERFACE */ + return MODE_OK; } #ifdef RANDR_12_INTERFACE @@ -200,36 +156,26 @@ get_property(xf86OutputPtr output, Atom property) } #endif /* RANDR_13_INTERFACE */ -#ifdef RANDR_GET_CRTC_INTERFACE -static xf86CrtcPtr -get_crtc(xf86OutputPtr output) +static void +destroy(xf86OutputPtr output) { - return NULL; + drmModeFreeConnector(output->driver_private); } -#endif static const xf86OutputFuncsRec output_funcs = { .create_resources = create_resources, - .dpms = dpms, - .save = save, - .restore = restore, - .mode_valid = mode_valid, - .mode_fixup = mode_fixup, - .prepare = prepare, - .mode_set = mode_set, - .commit = commit, - .detect = detect, - .get_modes = get_modes, #ifdef RANDR_12_INTERFACE .set_property = set_property, #endif #ifdef RANDR_13_INTERFACE .get_property = get_property, #endif + .dpms = dpms, + .detect = detect, + + .get_modes = get_modes, + .mode_valid = mode_valid, .destroy = destroy, -#ifdef RANDR_GET_CRTC_INTERFACE - .get_crtc = get_crtc, -#endif }; void -- cgit v1.2.3 From 8123180ea649540fb7319bc79ad77dca0d5d68cd Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Mon, 19 Oct 2009 09:47:39 -0500 Subject: r600: Fix size calculation for 24 bit depth size was being calculated based on 3 bytes per pixel with 24 bit depth instead of 4 bytes. This caused corruption in the bottom 25% of objects. This finishes fixing the menu/text corruption in compiz/kde4. Signed-off-by: Robert Noland --- src/mesa/drivers/dri/r600/r600_texstate.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_texstate.c b/src/mesa/drivers/dri/r600/r600_texstate.c index 61ff7e8158..a30703e41b 100644 --- a/src/mesa/drivers/dri/r600/r600_texstate.c +++ b/src/mesa/drivers/dri/r600/r600_texstate.c @@ -723,7 +723,7 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname, radeonTexObjPtr t = radeon_tex_obj(tObj); int firstlevel = t->mt ? t->mt->firstLevel : 0; const struct gl_texture_image *firstImage; - uint32_t pitch_val, size, row_align; + uint32_t pitch_val, size, row_align, bpp; if (!tObj) return; @@ -733,9 +733,13 @@ void r600SetTexOffset(__DRIcontext * pDRICtx, GLint texname, if (!offset) return; + bpp = depth / 8; + if (bpp == 3) + bpp = 4; + firstImage = t->base.Image[0][firstlevel]; row_align = rmesa->radeon.texture_row_align - 1; - size = ((firstImage->Width * (depth / 8) + row_align) & ~row_align) * firstImage->Height; + size = ((firstImage->Width * bpp + row_align) & ~row_align) * firstImage->Height; if (t->bo) { radeon_bo_unref(t->bo); t->bo = NULL; -- cgit v1.2.3 From 16e21191e26084848c7e6e3ffd9e15ef670855c5 Mon Sep 17 00:00:00 2001 From: Mathias Fröhlich Date: Mon, 19 Oct 2009 11:47:21 -0400 Subject: r300: fix texture size handling with size > 2048 The in kernel texture check fails because of both bit11 flags being set on 16x16 textures. It tuns out that these bits are still set and not cleared in the pp_txpitch field of the texture. The attached patch at least helps for this case on my machine. It clears the bit 11 from the pitch field if the texture is smaller and masks out that hight bits on the conventional width and height field. Fixes bug 24584 --- src/mesa/drivers/dri/r300/r300_texstate.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index f030451b28..65cabccdc1 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -225,10 +225,10 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t) if (t->image_override && t->bo) return; - t->pp_txsize = (((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT) - | ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT) - | ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT) - | ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT)); + t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((firstImage->Width - 1) << R300_TX_WIDTHMASK_SHIFT))) + | ((R300_TX_HEIGHTMASK_MASK & ((firstImage->Height - 1) << R300_TX_HEIGHTMASK_SHIFT))) + | ((R300_TX_DEPTHMASK_MASK & ((firstImage->DepthLog2) << R300_TX_DEPTHMASK_SHIFT))) + | ((R300_TX_MAX_MIP_LEVEL_MASK & ((t->mt->lastLevel - t->mt->firstLevel) << R300_TX_MAX_MIP_LEVEL_SHIFT)))); t->tile_bits = 0; @@ -248,8 +248,12 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t) if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) { if (firstImage->Width > 2048) t->pp_txpitch |= R500_TXWIDTH_BIT11; + else + t->pp_txpitch &= ~R500_TXWIDTH_BIT11; if (firstImage->Height > 2048) t->pp_txpitch |= R500_TXHEIGHT_BIT11; + else + t->pp_txpitch &= ~R500_TXHEIGHT_BIT11; } } @@ -479,16 +483,20 @@ void r300SetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint glx_texture_fo break; } pitch_val--; - t->pp_txsize = ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT) | - ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT); + t->pp_txsize = (((R300_TX_WIDTHMASK_MASK & ((rb->base.Width - 1) << R300_TX_WIDTHMASK_SHIFT))) + | ((R300_TX_HEIGHTMASK_MASK & ((rb->base.Height - 1) << R300_TX_HEIGHTMASK_SHIFT)))); t->pp_txsize |= R300_TX_SIZE_TXPITCH_EN; t->pp_txpitch |= pitch_val; if (rmesa->radeon.radeonScreen->chip_family >= CHIP_FAMILY_RV515) { if (rb->base.Width > 2048) t->pp_txpitch |= R500_TXWIDTH_BIT11; + else + t->pp_txpitch &= ~R500_TXWIDTH_BIT11; if (rb->base.Height > 2048) t->pp_txpitch |= R500_TXHEIGHT_BIT11; + else + t->pp_txpitch &= ~R500_TXHEIGHT_BIT11; } t->validated = GL_TRUE; _mesa_unlock_texture(radeon->glCtx, texObj); -- cgit v1.2.3 From a9f71b3bba86771be56ff1def716beb370decd22 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 20 Oct 2009 17:18:25 +0200 Subject: st/xorg: Cleanly shutdown --- src/gallium/state_trackers/xorg/xorg_driver.c | 5 ++++- src/gallium/state_trackers/xorg/xorg_renderer.c | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 2df954f18e..7da10427ec 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -541,6 +541,9 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return FALSE; } + if (!ms->api) + ms->api = drm_api_create(); + if (!ms->screen) { ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL); @@ -774,7 +777,7 @@ CloseScreen(int scrnIndex, ScreenPtr pScreen) if (ms->exa) xorg_exa_close(pScrn); - if (ms->api->destroy) + if (ms->api && ms->api->destroy) ms->api->destroy(ms->api); ms->api = NULL; diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c index 3dd5e6e811..393f3fac3e 100644 --- a/src/gallium/state_trackers/xorg/xorg_renderer.c +++ b/src/gallium/state_trackers/xorg/xorg_renderer.c @@ -283,13 +283,15 @@ void renderer_destroy(struct xorg_renderer *r) if (fsbuf && fsbuf->buffer) pipe_buffer_reference(&fsbuf->buffer, NULL); + if (r->shaders) { + xorg_shaders_destroy(r->shaders); + r->shaders = NULL; + } + if (r->cso) { cso_release_all(r->cso); cso_destroy_context(r->cso); - } - - if (r->shaders) { - xorg_shaders_destroy(r->shaders); + r->cso = NULL; } } -- cgit v1.2.3 From fc07ca004aaa338217c49e95f51b072b32c4f8c6 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 20 Oct 2009 17:17:41 +0200 Subject: trace: Check for destroy before calling it --- src/gallium/drivers/trace/tr_drm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/trace/tr_drm.c b/src/gallium/drivers/trace/tr_drm.c index 781ca5d3bc..48d1c4051c 100644 --- a/src/gallium/drivers/trace/tr_drm.c +++ b/src/gallium/drivers/trace/tr_drm.c @@ -150,7 +150,9 @@ trace_drm_destroy(struct drm_api *_api) { struct trace_drm_api *tr_api = trace_drm_api(_api); struct drm_api *api = tr_api->api; - api->destroy(api); + + if (api->destroy) + api->destroy(api); free(tr_api); } -- cgit v1.2.3 From 478332b0c1f0198bc7063300d203c21e42796045 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 20 Oct 2009 17:52:33 +0200 Subject: st/xorg: Move drm init to own function --- src/gallium/state_trackers/xorg/xorg_driver.c | 65 +++++++++++++++------------ 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index 7da10427ec..847647c1e4 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -260,6 +260,37 @@ static const xf86CrtcConfigFuncsRec crtc_config_funcs = { crtc_resize }; +static Bool +InitDRM(ScrnInfoPtr pScrn) +{ + modesettingPtr ms = modesettingPTR(pScrn); + + /* deal with server regeneration */ + if (ms->fd < 0) { + char *BusID; + + BusID = xalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), + ms->PciInfo->dev, ms->PciInfo->func + ); + + ms->fd = drmOpen(NULL, BusID); + + if (ms->fd < 0) + return FALSE; + } + + if (!ms->api) { + ms->api = drm_api_create(); + + if (!ms->api) + return FALSE; + } + + return TRUE; +} + static Bool PreInit(ScrnInfoPtr pScrn, int flags) { @@ -268,7 +299,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) rgb defaultWeight = { 0, 0, 0 }; EntityInfoPtr pEnt; EntPtr msEnt = NULL; - char *BusID; int max_width, max_height; if (pScrn->numEntities != 1) @@ -317,16 +347,9 @@ PreInit(ScrnInfoPtr pScrn, int flags) } } - BusID = xalloc(64); - sprintf(BusID, "PCI:%d:%d:%d", - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func - ); - - ms->api = drm_api_create(); - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) + ms->fd = -1; + ms->api = NULL; + if (!InitDRM(pScrn)) return FALSE; pScrn->monitor = pScrn->confScreen->monitor; @@ -525,24 +548,8 @@ ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) modesettingPtr ms = modesettingPTR(pScrn); VisualPtr visual; - /* deal with server regeneration */ - if (ms->fd < 0) { - char *BusID; - - BusID = xalloc(64); - sprintf(BusID, "PCI:%d:%d:%d", - ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), - ms->PciInfo->dev, ms->PciInfo->func - ); - - ms->fd = drmOpen(NULL, BusID); - - if (ms->fd < 0) - return FALSE; - } - - if (!ms->api) - ms->api = drm_api_create(); + if (!InitDRM(pScrn)) + return FALSE; if (!ms->screen) { ms->screen = ms->api->create_screen(ms->api, ms->fd, NULL); -- cgit v1.2.3 From ca940a73a72c68c461344d27f9d1fac31cd73819 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 20 Oct 2009 10:43:46 -0600 Subject: mesa: Fix Mac OS build. strtod_l needs the xlocale.h header on Mac OS. It's possible other non-Linux OSes would need this header too. --- src/mesa/main/imports.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 87cb5ce0fb..30fa55997e 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -50,6 +50,9 @@ #ifdef _GNU_SOURCE #include +#ifdef __APPLE__ +#include +#endif #endif -- cgit v1.2.3 From 4b2cf92ad9caa384869371534c1f2154625a755a Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Sun, 18 Oct 2009 08:28:34 -0700 Subject: cell: fix compilation on cell s/LERP/LRP/ --- src/gallium/drivers/cell/ppu/cell_gen_fp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fp.c b/src/gallium/drivers/cell/ppu/cell_gen_fp.c index 312621fd53..b6b2f885af 100644 --- a/src/gallium/drivers/cell/ppu/cell_gen_fp.c +++ b/src/gallium/drivers/cell/ppu/cell_gen_fp.c @@ -674,7 +674,7 @@ emit_MAD(struct codegen *gen, const struct tgsi_full_instruction *inst) * Emit linear interpolate. See emit_ADD for comments. */ static boolean -emit_LERP(struct codegen *gen, const struct tgsi_full_instruction *inst) +emit_LRP(struct codegen *gen, const struct tgsi_full_instruction *inst) { int ch, s1_reg[4], s2_reg[4], s3_reg[4], d_reg[4], tmp_reg[4]; @@ -1766,7 +1766,7 @@ emit_instruction(struct codegen *gen, return emit_binop(gen, inst); case TGSI_OPCODE_MAD: return emit_MAD(gen, inst); - case TGSI_OPCODE_LERP: + case TGSI_OPCODE_LRP: return emit_LRP(gen, inst); case TGSI_OPCODE_DP3: return emit_DP3(gen, inst); -- cgit v1.2.3 From cbd20e18a0f82a653513d165694ed7bbb336e765 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 19 Oct 2009 17:54:42 -0700 Subject: meta: Fix the BufferSubData in meta clear to be BufferData. Fixes a 3.4% +/- 1.3% performance regression in my GL demo (n=3). The other meta code could probably also use the same treatment. --- src/mesa/drivers/common/meta.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index ceb929f694..b38f22e130 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1346,8 +1346,6 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers) /* create vertex array buffer */ _mesa_GenBuffersARB(1, &clear->VBO); _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO); - _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), - NULL, GL_DYNAMIC_DRAW_ARB); /* setup vertex arrays */ _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); @@ -1423,7 +1421,8 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers) } /* upload new vertex data */ - _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, + GL_DYNAMIC_DRAW_ARB); } /* draw quad */ -- cgit v1.2.3 From d56125a298106d81e10674f1c4b3b43b51a5139d Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 20 Oct 2009 14:51:53 -0700 Subject: intel: Fix flipped condition in ARB_sync GetSYnciv(GL_SYNC_STATUS). Bug #24435 --- src/mesa/drivers/dri/intel/intel_syncobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c index 1286fe929b..0d7889d3c2 100644 --- a/src/mesa/drivers/dri/intel/intel_syncobj.c +++ b/src/mesa/drivers/dri/intel/intel_syncobj.c @@ -114,7 +114,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s) { struct intel_sync_object *sync = (struct intel_sync_object *)s; - if (sync->bo && drm_intel_bo_busy(sync->bo)) { + if (sync->bo && !drm_intel_bo_busy(sync->bo)) { drm_intel_bo_unreference(sync->bo); sync->bo = NULL; s->StatusFlag = 1; -- cgit v1.2.3 From 5283a3fb25b2667501eb782fb461c981200a65ef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 20 Oct 2009 16:22:03 -0600 Subject: progs/trivial: check if GL_ARB_occlusion_query is supported --- progs/trivial/tri-query.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c index 85e39df2df..94956a86f3 100644 --- a/progs/trivial/tri-query.c +++ b/progs/trivial/tri-query.c @@ -39,6 +39,11 @@ GLenum doubleBuffer; static void Init(void) { + if (!glutExtensionSupported("GL_ARB_occlusion_query")) { + fprintf(stderr, "Sorry, this program requires GL_ARB_occlusion_query\n"); + exit(1); + } + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); -- cgit v1.2.3 From 58abfebaad80b72c4a4bedad2d96a3959651eea3 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 06:44:16 -0700 Subject: r300g: Kill r300_surface with fire. If you really want to see it again, check the history. --- src/gallium/drivers/r300/Makefile | 1 - src/gallium/drivers/r300/r300_surface.c | 381 -------------------------------- src/gallium/drivers/r300/r300_surface.h | 123 ----------- 3 files changed, 505 deletions(-) delete mode 100644 src/gallium/drivers/r300/r300_surface.c delete mode 100644 src/gallium/drivers/r300/r300_surface.h diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index 69e4724790..c4f2c021c4 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -20,7 +20,6 @@ C_SOURCES = \ r300_state_derived.c \ r300_state_invariant.c \ r300_vs.c \ - r300_surface.c \ r300_texture.c \ r300_tgsi_to_rc.c diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c deleted file mode 100644 index 5cf49d20aa..0000000000 --- a/src/gallium/drivers/r300/r300_surface.c +++ /dev/null @@ -1,381 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * Joakim Sindholt - * - * 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_surface.h" - -static void r300_surface_setup(struct r300_context* r300, - struct r300_texture* dest, - unsigned x, unsigned y, - unsigned w, unsigned h) -{ - struct r300_capabilities* caps = r300_screen(r300->context.screen)->caps; - unsigned pixpitch = r300_texture_get_stride(dest, 0) / dest->tex.block.size; - CS_LOCALS(r300); - - r300_emit_blend_state(r300, &blend_clear_state); - r300_emit_blend_color_state(r300, &blend_color_clear_state); - r300_emit_dsa_state(r300, &dsa_clear_state); - r300_emit_rs_state(r300, &rs_clear_state); - - BEGIN_CS(26); - - /* Viewport setup */ - OUT_CS_REG_SEQ(R300_SE_VPORT_XSCALE, 6); - OUT_CS_32F((float)w); - OUT_CS_32F((float)x); - OUT_CS_32F((float)h); - OUT_CS_32F((float)y); - OUT_CS_32F(1.0); - OUT_CS_32F(0.0); - - OUT_CS_REG(R300_VAP_VTE_CNTL, R300_VPORT_X_SCALE_ENA | - R300_VPORT_X_OFFSET_ENA | - R300_VPORT_Y_SCALE_ENA | - R300_VPORT_Y_OFFSET_ENA | - R300_VTX_XY_FMT | R300_VTX_Z_FMT); - - /* Pixel scissors. */ - OUT_CS_REG_SEQ(R300_SC_SCISSORS_TL, 2); - if (caps->is_r500) { - OUT_CS((x << R300_SCISSORS_X_SHIFT) | (y << R300_SCISSORS_Y_SHIFT)); - OUT_CS(((w - 1) << R300_SCISSORS_X_SHIFT) | ((h - 1) << R300_SCISSORS_Y_SHIFT)); - } else { - /* Non-R500 chipsets have an offset of 1440 in their scissors. */ - OUT_CS(((x + 1440) << R300_SCISSORS_X_SHIFT) | - ((y + 1440) << R300_SCISSORS_Y_SHIFT)); - OUT_CS((((w - 1) + 1440) << R300_SCISSORS_X_SHIFT) | - (((h - 1) + 1440) << R300_SCISSORS_Y_SHIFT)); - } - - /* Flush colorbuffer and blend caches. */ - OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, - R300_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D | - R300_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL); - OUT_CS_REG(R300_ZB_ZCACHE_CTLSTAT, - R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE | - R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE); - - /* Setup colorbuffer. */ - OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0, 1); - OUT_CS_RELOC(dest->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0); - OUT_CS_REG_SEQ(R300_RB3D_COLORPITCH0, 1); - OUT_CS_RELOC(dest->buffer, pixpitch | - r300_translate_colorformat(dest->tex.format), 0, - RADEON_GEM_DOMAIN_VRAM, 0); - OUT_CS_REG(RB3D_COLOR_CHANNEL_MASK, 0xf); - - END_CS; -} - -/* Provides pipe_context's "surface_fill". Commonly used for clearing - * buffers. */ -static void r300_surface_fill(struct pipe_context* pipe, - struct pipe_surface* dest, - unsigned x, unsigned y, - unsigned w, unsigned h, - unsigned color) -{ - float r, g, b, a; - struct r300_context* r300 = r300_context(pipe); - struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; - struct r300_texture* tex = (struct r300_texture*)dest->texture; - unsigned pixpitch = r300_texture_get_stride(tex, 0) / tex->tex.block.size; - boolean invalid = FALSE; - CS_LOCALS(r300); - - a = (float)((color >> 24) & 0xff) / 255.0f; - r = (float)((color >> 16) & 0xff) / 255.0f; - g = (float)((color >> 8) & 0xff) / 255.0f; - b = (float)((color >> 0) & 0xff) / 255.0f; - DBG(r300, DBG_SURF, "r300: Filling surface %p at (%d,%d)," - " dimensions %dx%d (pixel pitch %d), color 0x%x\n", - dest, x, y, w, h, pixpitch, color); - - /* Fallback? */ - if (!pipe->screen->is_format_supported(pipe->screen, dest->format, - PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { -fallback: - DBG(r300, DBG_SURF | DBG_FALL, - "r300: Falling back on surface clear...\n"); - util_surface_fill(pipe, dest, x, y, w, h, color); - return; - } - - /* Make sure our target BO is okay. */ -validate: - if (!r300->winsys->add_buffer(r300->winsys, tex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM)) { - r300->context.flush(&r300->context, 0, NULL); - goto validate; - } - if (!r300->winsys->validate(r300->winsys)) { - r300->context.flush(&r300->context, 0, NULL); - if (invalid) { - DBG(r300, DBG_SURF | DBG_FALL, "r300: Stuck in validation loop."); - goto fallback; - } - invalid = TRUE; - goto validate; - } - - r300_surface_setup(r300, tex, x, y, w, h); - - /* Vertex shader setup */ - if (caps->has_tcl) { - r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0); - } else { - BEGIN_CS(4); - OUT_CS_REG(R300_VAP_CNTL_STATUS, -#ifdef PIPE_ARCH_BIG_ENDIAN - R300_VC_32BIT_SWAP | -#endif - R300_VAP_TCL_BYPASS); - OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | - R300_PVS_NUM_CNTLRS(5) | - R300_PVS_NUM_FPUS(caps->num_vert_fpus) | - R300_PVS_VF_MAX_VTX_NUM(12)); - END_CS; - } - - /* Fragment shader setup */ - if (caps->is_r500) { - r500_emit_fragment_program_code(r300, &r5xx_passthrough_fragment_shader, 0); - r300_emit_rs_block_state(r300, &r5xx_rs_block_clear_state); - } else { - r300_emit_fragment_program_code(r300, &r3xx_passthrough_fragment_shader, 0); - r300_emit_rs_block_state(r300, &r3xx_rs_block_clear_state); - } - - BEGIN_CS(26); - - /* VAP stream control, mapping from input memory to PVS/RS memory */ - if (caps->has_tcl) { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); - } else { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_4 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (2 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_4) << R300_DATA_TYPE_1_SHIFT)); - } - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) | - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT)); - - /* VAP format controls */ - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, - R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT | - R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT); - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x0); - - /* Disable textures */ - OUT_CS_REG(R300_TX_ENABLE, 0x0); - - /* The size of the point we're about to draw, in sixths of pixels */ - OUT_CS_REG(R300_GA_POINT_SIZE, - ((h * 6) & R300_POINTSIZE_Y_MASK) | - ((w * 6) << R300_POINTSIZE_X_SHIFT)); - - /* Vertex size. */ - OUT_CS_REG(R300_VAP_VTX_SIZE, 0x8); - - /* Packet3 with our point vertex */ - OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 8); - OUT_CS(R300_PRIM_TYPE_POINT | R300_PRIM_WALK_RING | - (1 << R300_PRIM_NUM_VERTICES_SHIFT)); - /* Position */ - OUT_CS_32F(0.5); - OUT_CS_32F(0.5); - OUT_CS_32F(1.0); - OUT_CS_32F(1.0); - /* Color */ - OUT_CS_32F(r); - OUT_CS_32F(g); - OUT_CS_32F(b); - OUT_CS_32F(a); - - OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); - - END_CS; - - r300->dirty_hw++; -} - -static void r300_surface_copy(struct pipe_context* pipe, - struct pipe_surface* dest, - unsigned destx, unsigned desty, - struct pipe_surface* src, - unsigned srcx, unsigned srcy, - unsigned w, unsigned h) -{ - struct r300_context* r300 = r300_context(pipe); - struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; - struct r300_texture* srctex = (struct r300_texture*)src->texture; - struct r300_texture* desttex = (struct r300_texture*)dest->texture; - unsigned pixpitch = r300_texture_get_stride(srctex, 0) / srctex->tex.block.size; - boolean invalid = FALSE; - float fsrcx = srcx, fsrcy = srcy, fdestx = destx, fdesty = desty; - CS_LOCALS(r300); - - DBG(r300, DBG_SURF, "r300: Copying surface %p at (%d,%d) to %p at (%d, %d)," - " dimensions %dx%d (pixel pitch %d)\n", - src, srcx, srcy, dest, destx, desty, w, h, pixpitch); - - if ((srctex->buffer == desttex->buffer) && - ((destx < srcx + w) || (srcx < destx + w)) && - ((desty < srcy + h) || (srcy < desty + h))) { - goto fallback; - } - - if (!pipe->screen->is_format_supported(pipe->screen, src->format, - PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0) || - !pipe->screen->is_format_supported(pipe->screen, dest->format, - PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) { -fallback: - DBG(r300, DBG_SURF | DBG_FALL, "r300: Falling back on surface_copy\n"); - util_surface_copy(pipe, FALSE, dest, destx, desty, src, - srcx, srcy, w, h); - return; - } - - /* Add our target BOs to the list. */ -validate: - if (!r300->winsys->add_buffer(r300->winsys, srctex->buffer, - RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) { - r300->context.flush(&r300->context, 0, NULL); - goto validate; - } - if (!r300->winsys->add_buffer(r300->winsys, desttex->buffer, - 0, RADEON_GEM_DOMAIN_VRAM)) { - r300->context.flush(&r300->context, 0, NULL); - goto validate; - } - if (!r300->winsys->validate(r300->winsys)) { - r300->context.flush(&r300->context, 0, NULL); - if (invalid) { - DBG(r300, DBG_SURF | DBG_FALL, "r300: Stuck in validation loop."); - goto fallback; - } - invalid = TRUE; - goto validate; - } - - r300_surface_setup(r300, desttex, destx, desty, w, h); - - /* Setup the texture. */ - r300_emit_texture(r300, &r300_sampler_copy_state, srctex, 0); - - /* Flush and enable. */ - r300_flush_textures(r300); - - /* Vertex shader setup */ - if (caps->has_tcl) { - r300_emit_vertex_program_code(r300, &r300_passthrough_vertex_shader, 0); - } else { - BEGIN_CS(4); - OUT_CS_REG(R300_VAP_CNTL_STATUS, -#ifdef PIPE_ARCH_BIG_ENDIAN - R300_VC_32BIT_SWAP | -#endif - R300_VAP_TCL_BYPASS); - OUT_CS_REG(R300_VAP_CNTL, R300_PVS_NUM_SLOTS(5) | - R300_PVS_NUM_CNTLRS(5) | - R300_PVS_NUM_FPUS(caps->num_vert_fpus) | - R300_PVS_VF_MAX_VTX_NUM(12)); - END_CS; - } - - /* Fragment shader setup */ - if (caps->is_r500) { - r500_emit_fragment_program_code(r300, &r5xx_texture_fragment_shader, 0); - r300_emit_rs_block_state(r300, &r5xx_rs_block_copy_state); - } else { - r300_emit_fragment_program_code(r300, &r3xx_texture_fragment_shader, 0); - r300_emit_rs_block_state(r300, &r3xx_rs_block_copy_state); - } - - BEGIN_CS(30); - /* VAP stream control, mapping from input memory to PVS/RS memory */ - if (caps->has_tcl) { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (1 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT)); - } else { - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_0, - (R300_DATA_TYPE_FLOAT_2 << R300_DATA_TYPE_0_SHIFT) | - ((R300_LAST_VEC | (6 << R300_DST_VEC_LOC_SHIFT) | - R300_DATA_TYPE_FLOAT_2) << R300_DATA_TYPE_1_SHIFT)); - } - OUT_CS_REG(R300_VAP_PROG_STREAM_CNTL_EXT_0, - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE0_SHIFT) | - (R300_VAP_SWIZZLE_XYZW << R300_SWIZZLE1_SHIFT)); - - /* VAP format controls */ - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_0, - R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT); - /* Two components of texture 0 */ - OUT_CS_REG(R300_VAP_OUTPUT_VTX_FMT_1, 0x2); - - /* Vertex size. */ - OUT_CS_REG(R300_VAP_VTX_SIZE, 0x4); - - /* Packet3 with our texcoords */ - OUT_CS_PKT3(R200_3D_DRAW_IMMD_2, 16); - OUT_CS(R300_PRIM_TYPE_QUADS | R300_PRIM_WALK_RING | - (4 << R300_PRIM_NUM_VERTICES_SHIFT)); - /* (x , y ) */ - OUT_CS_32F(fdestx / dest->width); - OUT_CS_32F(fdesty / dest->height); - OUT_CS_32F(fsrcx / src->width); - OUT_CS_32F(fsrcy / src->height); - /* (x , y + h) */ - OUT_CS_32F(fdestx / dest->width); - OUT_CS_32F((fdesty + h) / dest->height); - OUT_CS_32F(fsrcx / src->width); - OUT_CS_32F((fsrcy + h) / src->height); - /* (x + w, y + h) */ - OUT_CS_32F((fdestx + w) / dest->width); - OUT_CS_32F((fdesty + h) / dest->height); - OUT_CS_32F((fsrcx + w) / src->width); - OUT_CS_32F((fsrcy + h) / src->height); - /* (x + w, y ) */ - OUT_CS_32F((fdestx + w) / dest->width); - OUT_CS_32F(fdesty / dest->height); - OUT_CS_32F((fsrcx + w) / src->width); - OUT_CS_32F(fsrcy / src->height); - - OUT_CS_REG(R300_RB3D_DSTCACHE_CTLSTAT, 0xA); - - END_CS; - - r300->dirty_hw++; -} - -void r300_init_surface_functions(struct r300_context* r300) -{ - r300->context.surface_fill = r300_surface_fill; - r300->context.surface_copy = r300_surface_copy; -} diff --git a/src/gallium/drivers/r300/r300_surface.h b/src/gallium/drivers/r300/r300_surface.h deleted file mode 100644 index d5998e6e6d..0000000000 --- a/src/gallium/drivers/r300/r300_surface.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * - * 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_SURFACE_H -#define R300_SURFACE_H - -#include "pipe/p_context.h" -#include "pipe/p_screen.h" - -#include "util/u_rect.h" - -#include "r300_context.h" -#include "r300_cs.h" -#include "r300_emit.h" -#include "r300_fs.h" -#include "r300_vs.h" -#include "r300_state_inlines.h" - -static struct r300_blend_state blend_clear_state = { - .blend_control = 0x0, - .alpha_blend_control = 0x0, - .rop = 0x0, - .dither = 0x0, -}; - -static struct r300_blend_color_state blend_color_clear_state = { - .blend_color = 0x0, - .blend_color_red_alpha = 0x0, - .blend_color_green_blue = 0x0, -}; - -static struct r300_dsa_state dsa_clear_state = { - .alpha_function = 0x0, - .alpha_reference = 0x0, - .z_buffer_control = 0x0, - .z_stencil_control = 0x0, - .stencil_ref_mask = R300_STENCILWRITEMASK_MASK, - .stencil_ref_bf = 0x0, -}; - -static struct r300_rs_state rs_clear_state = { - .point_minmax = 0x36000006, - .line_control = 0x00030006, - .depth_scale_front = 0x0, - .depth_offset_front = 0x0, - .depth_scale_back = 0x0, - .depth_offset_back = 0x0, - .polygon_offset_enable = 0x0, - .cull_mode = 0x0, - .line_stipple_config = 0x3BAAAAAB, - .line_stipple_value = 0x0, - .color_control = R300_SHADE_MODEL_FLAT, -}; - -static struct r300_rs_block r3xx_rs_block_clear_state = { - .ip[0] = R500_RS_SEL_S(R300_RS_SEL_C0) | - R500_RS_SEL_T(R300_RS_SEL_C0) | - R500_RS_SEL_R(R300_RS_SEL_C0) | - R500_RS_SEL_Q(R300_RS_SEL_K1), - .inst[0] = R300_RS_INST_COL_CN_WRITE, - .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN, - .inst_count = 0, -}; - -static struct r300_rs_block r5xx_rs_block_clear_state = { - .ip[0] = R500_RS_SEL_S(R500_RS_IP_PTR_K0) | - R500_RS_SEL_T(R500_RS_IP_PTR_K0) | - R500_RS_SEL_R(R500_RS_IP_PTR_K0) | - R500_RS_SEL_Q(R500_RS_IP_PTR_K1), - .inst[0] = R500_RS_INST_COL_CN_WRITE, - .count = R300_IT_COUNT(0) | R300_IC_COUNT(1) | R300_HIRES_EN, - .inst_count = 0, -}; - -/* The following state is used for surface_copy only. */ - -static struct r300_rs_block r3xx_rs_block_copy_state = { - .ip[0] = R500_RS_SEL_S(R300_RS_SEL_K0) | - R500_RS_SEL_T(R300_RS_SEL_K0) | - R500_RS_SEL_R(R300_RS_SEL_K0) | - R500_RS_SEL_Q(R300_RS_SEL_K1), - .inst[0] = R300_RS_INST_COL_CN_WRITE, - .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN, - .inst_count = R300_RS_TX_OFFSET(0), -}; - -static struct r300_rs_block r5xx_rs_block_copy_state = { - .ip[0] = R500_RS_SEL_S(0) | - R500_RS_SEL_T(1) | - R500_RS_SEL_R(R500_RS_IP_PTR_K0) | - R500_RS_SEL_Q(R500_RS_IP_PTR_K1), - .inst[0] = R500_RS_INST_TEX_CN_WRITE, - .count = R300_IT_COUNT(2) | R300_IC_COUNT(0) | R300_HIRES_EN, - .inst_count = R300_RS_TX_OFFSET(0), -}; - -static struct r300_sampler_state r300_sampler_copy_state = { - .filter0 = R300_TX_WRAP_S(R300_TX_CLAMP) | - R300_TX_WRAP_T(R300_TX_CLAMP) | - R300_TX_MAG_FILTER_NEAREST | - R300_TX_MIN_FILTER_NEAREST, -}; - -#endif /* R300_SURFACE_H */ -- cgit v1.2.3 From b21df2620ef970daa306e06c6ca69a9b66280cd6 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 06:47:05 -0700 Subject: r300g: Also kill r300_shader_inlines with fire. --- src/gallium/drivers/r300/r300_shader_inlines.h | 47 -------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/gallium/drivers/r300/r300_shader_inlines.h diff --git a/src/gallium/drivers/r300/r300_shader_inlines.h b/src/gallium/drivers/r300/r300_shader_inlines.h deleted file mode 100644 index a04f45b03e..0000000000 --- a/src/gallium/drivers/r300/r300_shader_inlines.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2009 Corbin Simpson - * Joakim Sindholt - * - * 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_SHADER_INLINES_H -#define R300_SHADER_INLINES_H - -/* TGSI constants. TGSI is like XML: If it can't solve your problems, you're - * not using enough of it. */ -static const struct tgsi_full_src_register r300_constant_zero = { - .SrcRegister.Extended = TRUE, - .SrcRegister.File = TGSI_FILE_NULL, - .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ZERO, - .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ZERO, - .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ZERO, - .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ZERO, -}; - -static const struct tgsi_full_src_register r300_constant_one = { - .SrcRegister.Extended = TRUE, - .SrcRegister.File = TGSI_FILE_NULL, - .SrcRegisterExtSwz.ExtSwizzleX = TGSI_EXTSWIZZLE_ONE, - .SrcRegisterExtSwz.ExtSwizzleY = TGSI_EXTSWIZZLE_ONE, - .SrcRegisterExtSwz.ExtSwizzleZ = TGSI_EXTSWIZZLE_ONE, - .SrcRegisterExtSwz.ExtSwizzleW = TGSI_EXTSWIZZLE_ONE, -}; - -#endif /* R300_SHADER_INLINES_H */ -- cgit v1.2.3 From b589e39809fa9d0b24a708d792b70ae5b120ffb8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 05:45:05 -0700 Subject: r300g: Examine vertex attribute type on HW TCL too. --- src/gallium/drivers/r300/r300_state_derived.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 5df1a0cd63..7297f9c653 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -244,10 +244,8 @@ static void r300_vertex_psc(struct r300_context* r300, assert(tab[i] != -1); /* Add the attribute to the PSC table. */ - temp = r300screen->caps->has_tcl ? - R300_DATA_TYPE_FLOAT_4 : - translate_vertex_data_type(vinfo->attrib[i].emit); - temp |= tab[i] << R300_DST_VEC_LOC_SHIFT; + temp = translate_vertex_data_type(vinfo->attrib[i].emit) | + tab[i] << R300_DST_VEC_LOC_SHIFT; if (i & 1) { vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff; -- cgit v1.2.3 From 5a0598f23569314a4ad72eda59e250ab9c43b46d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 05:48:45 -0700 Subject: r300g: Don't use the hashtable internally. As osiris pointed out, glxgears slowly gets slower for some reason when it's enabled, and it's not helping at the moment, so just turn it off. --- src/gallium/drivers/r300/r300_state_derived.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 7297f9c653..6e7679c39f 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -451,6 +451,7 @@ static void r300_update_derived_shader_state(struct r300_context* r300) struct r300_shader_derived_value* value; int i; + /* key = CALLOC_STRUCT(r300_shader_key); key->vs = r300->vs; key->fs = r300->fs; @@ -472,10 +473,11 @@ static void r300_update_derived_shader_state(struct r300_context* r300) value->rs_block = rs_block; util_hash_table_set(r300->shader_hash_table, (void*)key, (void*)value); - } + } */ /* XXX This will be refactored ASAP. */ vformat = CALLOC_STRUCT(r300_vertex_format); + rs_block = CALLOC_STRUCT(r300_rs_block); for (i = 0; i < 16; i++) { vformat->vs_tab[i] = -1; @@ -486,7 +488,10 @@ static void r300_update_derived_shader_state(struct r300_context* r300) r300_vertex_psc(r300, vformat); r300_update_fs_tab(r300, vformat); + r300_update_rs_block(r300, rs_block); + FREE(r300->vertex_info); + FREE(r300->rs_block); r300->vertex_info = vformat; r300->rs_block = rs_block; -- cgit v1.2.3 From babadb8bb9d68f3687a9c9cb80f98c732b1120c7 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 05:54:49 -0700 Subject: r300g: Don't use getenv; use debug_get_*_option instead. --- src/gallium/drivers/r300/r300_chipset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index d138866d33..9b763e2cb5 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -31,7 +31,7 @@ void r300_parse_chipset(struct r300_capabilities* caps) { /* Reasonable defaults */ caps->num_vert_fpus = 4; - caps->has_tcl = getenv("RADEON_NO_TCL") ? FALSE : TRUE; + caps->has_tcl = debug_get_bool_option("RADEON_NO_TCL", FALSE) ? FALSE : TRUE; caps->is_r500 = FALSE; caps->high_second_pipe = FALSE; -- cgit v1.2.3 From 6a448a525baf81173f92ee8c3074b98baa54397b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 06:31:36 -0700 Subject: r300g: Cleanup header includes. --- src/gallium/drivers/r300/r300_chipset.c | 1 + src/gallium/drivers/r300/r300_chipset.h | 6 +++--- src/gallium/drivers/r300/r300_clear.c | 3 +++ src/gallium/drivers/r300/r300_clear.h | 4 +--- src/gallium/drivers/r300/r300_context.c | 16 +++++++++++++++- src/gallium/drivers/r300/r300_context.h | 13 ------------- src/gallium/drivers/r300/r300_emit.c | 7 ++++++- src/gallium/drivers/r300/r300_emit.h | 7 ------- src/gallium/drivers/r300/r300_flush.c | 7 +++++++ src/gallium/drivers/r300/r300_flush.h | 7 ------- src/gallium/drivers/r300/r300_fs.c | 6 +++++- src/gallium/drivers/r300/r300_fs.h | 7 +++---- src/gallium/drivers/r300/r300_query.c | 8 +++++++- src/gallium/drivers/r300/r300_query.h | 4 ---- src/gallium/drivers/r300/r300_render.c | 5 ++++- src/gallium/drivers/r300/r300_screen.c | 7 +++++++ src/gallium/drivers/r300/r300_screen.h | 5 ----- src/gallium/drivers/r300/r300_state.c | 4 ++++ src/gallium/drivers/r300/r300_state_derived.c | 8 +++++++- src/gallium/drivers/r300/r300_state_inlines.h | 2 ++ src/gallium/drivers/r300/r300_state_invariant.c | 5 ++++- src/gallium/drivers/r300/r300_state_invariant.h | 6 +----- src/gallium/drivers/r300/r300_texture.c | 6 ++++++ src/gallium/drivers/r300/r300_texture.h | 3 --- 24 files changed, 86 insertions(+), 61 deletions(-) diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c index 9b763e2cb5..51fdb82ff3 100644 --- a/src/gallium/drivers/r300/r300_chipset.c +++ b/src/gallium/drivers/r300/r300_chipset.c @@ -21,6 +21,7 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r300_chipset.h" + #include "util/u_debug.h" /* r300_chipset: A file all to itself for deducing the various properties of diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h index f015a4243d..0633a8b8a7 100644 --- a/src/gallium/drivers/r300/r300_chipset.h +++ b/src/gallium/drivers/r300/r300_chipset.h @@ -33,11 +33,11 @@ struct r300_capabilities { /* Chipset family */ int family; /* The number of vertex floating-point units */ - int num_vert_fpus; + unsigned num_vert_fpus; /* The number of fragment pipes */ - int num_frag_pipes; + unsigned num_frag_pipes; /* The number of z pipes */ - int num_z_pipes; + unsigned num_z_pipes; /* Whether or not TCL is physically present */ boolean has_tcl; /* Whether or not this is an RV515 or newer; R500s have many differences diff --git a/src/gallium/drivers/r300/r300_clear.c b/src/gallium/drivers/r300/r300_clear.c index 8b9cb819ae..02d6d504fc 100644 --- a/src/gallium/drivers/r300/r300_clear.c +++ b/src/gallium/drivers/r300/r300_clear.c @@ -21,6 +21,9 @@ * USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "r300_clear.h" +#include "r300_context.h" + +#include "util/u_clear.h" /* Clears currently bound buffers. */ void r300_clear(struct pipe_context* pipe, diff --git a/src/gallium/drivers/r300/r300_clear.h b/src/gallium/drivers/r300/r300_clear.h index cd5900565e..b8fcdf273c 100644 --- a/src/gallium/drivers/r300/r300_clear.h +++ b/src/gallium/drivers/r300/r300_clear.h @@ -23,9 +23,7 @@ #ifndef R300_CLEAR_H #define R300_CLEAR_H -#include "util/u_clear.h" - -#include "r300_context.h" +struct pipe_context; void r300_clear(struct pipe_context* pipe, unsigned buffers, diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 7b370b3e95..4ba11a026e 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -20,10 +20,24 @@ * 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 "draw/draw_context.h" + +#include "pipe/p_inlines.h" + +#include "tgsi/tgsi_scan.h" +#include "util/u_hash_table.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" + +#include "r300_clear.h" +#include "r300_context.h" #include "r300_flush.h" +#include "r300_query.h" +#include "r300_screen.h" +#include "r300_state_derived.h" #include "r300_state_invariant.h" +#include "r300_winsys.h" static boolean r300_draw_range_elements(struct pipe_context* pipe, struct pipe_buffer* indexBuffer, diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 2d608d6afc..61a57df35e 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -23,23 +23,10 @@ #ifndef R300_CONTEXT_H #define R300_CONTEXT_H -#include "draw/draw_context.h" #include "draw/draw_vertex.h" #include "pipe/p_context.h" -#include "tgsi/tgsi_scan.h" - -#include "util/u_hash_table.h" -#include "util/u_memory.h" -#include "util/u_simple_list.h" - -#include "r300_clear.h" -#include "r300_query.h" -#include "r300_screen.h" -#include "r300_state_derived.h" -#include "r300_winsys.h" - struct r300_fragment_shader; struct r300_vertex_shader; diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index df2046bd0c..258c38fefd 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -22,10 +22,15 @@ /* r300_emit: Functions for emitting state. */ -#include "r300_emit.h" +#include "util/u_math.h" +#include "r300_context.h" +#include "r300_cs.h" +#include "r300_emit.h" #include "r300_fs.h" +#include "r300_screen.h" #include "r300_state_derived.h" +#include "r300_state_inlines.h" #include "r300_vs.h" void r300_emit_blend_state(struct r300_context* r300, diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h index 7e469ea0c7..02ac5bebbd 100644 --- a/src/gallium/drivers/r300/r300_emit.h +++ b/src/gallium/drivers/r300/r300_emit.h @@ -23,13 +23,6 @@ #ifndef R300_EMIT_H #define R300_EMIT_H -#include "util/u_math.h" - -#include "r300_context.h" -#include "r300_cs.h" -#include "r300_screen.h" -#include "r300_state_inlines.h" - struct rX00_fragment_program_code; struct r300_vertex_program_code; diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index d60652a021..c222ea09b1 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -20,6 +20,13 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "draw/draw_context.h" +#include "draw/draw_private.h" + +#include "util/u_simple_list.h" + +#include "r300_context.h" +#include "r300_cs.h" #include "r300_emit.h" #include "r300_flush.h" #include "r300_state_invariant.h" diff --git a/src/gallium/drivers/r300/r300_flush.h b/src/gallium/drivers/r300/r300_flush.h index 9a83d89daa..0e9e6106bb 100644 --- a/src/gallium/drivers/r300/r300_flush.h +++ b/src/gallium/drivers/r300/r300_flush.h @@ -23,13 +23,6 @@ #ifndef R300_FLUSH_H #define R300_FLUSH_H -#include "draw/draw_private.h" - -#include "pipe/p_context.h" - -#include "r300_context.h" -#include "r300_cs.h" - void r300_init_flush_functions(struct r300_context* r300); #endif /* R300_FLUSH_H */ diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 546ad545a5..2db185fd80 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -21,10 +21,14 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "r300_fs.h" +#include "tgsi/tgsi_dump.h" +#include "r300_context.h" +#include "r300_screen.h" +#include "r300_fs.h" #include "r300_tgsi_to_rc.h" +#include "radeon_code.h" #include "radeon_compiler.h" static void find_output_registers(struct r300_fragment_program_compiler * compiler, diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h index 04453274aa..8dfb139738 100644 --- a/src/gallium/drivers/r300/r300_fs.h +++ b/src/gallium/drivers/r300/r300_fs.h @@ -24,14 +24,13 @@ #ifndef R300_FS_H #define R300_FS_H -#include "tgsi/tgsi_dump.h" +#include "pipe/p_state.h" + +#include "tgsi/tgsi_scan.h" -#include "r300_context.h" #include "r3xx_fs.h" #include "r5xx_fs.h" -#include "radeon_code.h" - struct r300_fragment_shader { /* Parent class */ struct pipe_shader_state state; diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c index 2b0fbfb7d2..007f11efae 100644 --- a/src/gallium/drivers/r300/r300_query.c +++ b/src/gallium/drivers/r300/r300_query.c @@ -20,9 +20,15 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "r300_query.h" +#include "util/u_memory.h" +#include "util/u_simple_list.h" +#include "r300_context.h" +#include "r300_screen.h" +#include "r300_cs.h" #include "r300_emit.h" +#include "r300_query.h" +#include "r300_reg.h" static struct pipe_query *r300_create_query(struct pipe_context *pipe, unsigned query_type) diff --git a/src/gallium/drivers/r300/r300_query.h b/src/gallium/drivers/r300/r300_query.h index 4f50e8f844..48876da312 100644 --- a/src/gallium/drivers/r300/r300_query.h +++ b/src/gallium/drivers/r300/r300_query.h @@ -23,10 +23,6 @@ #ifndef R300_QUERY_H #define R300_QUERY_H -#include "r300_context.h" -#include "r300_cs.h" -#include "r300_reg.h" - struct r300_context; static INLINE struct r300_query* r300_query(struct pipe_query* q) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 4e778e1e57..79a33b53cb 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -20,8 +20,11 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "draw/draw_pipe.h" +#include "draw/draw_context.h" #include "draw/draw_vbuf.h" + +#include "pipe/p_inlines.h" + #include "util/u_memory.h" #include "r300_cs.h" diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index cc499d400a..a9058a25e5 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -20,7 +20,14 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "pipe/p_inlines.h" +#include "util/u_memory.h" +#include "util/u_simple_screen.h" + +#include "r300_context.h" #include "r300_screen.h" +#include "r300_texture.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_screen.h b/src/gallium/drivers/r300/r300_screen.h index 2a0e41fbc3..41df31f670 100644 --- a/src/gallium/drivers/r300/r300_screen.h +++ b/src/gallium/drivers/r300/r300_screen.h @@ -23,14 +23,9 @@ #ifndef R300_SCREEN_H #define R300_SCREEN_H -#include "pipe/p_inlines.h" #include "pipe/p_screen.h" -#include "util/u_memory.h" -#include "util/u_simple_screen.h" #include "r300_chipset.h" -#include "r300_texture.h" -#include "r300_winsys.h" struct r300_screen { /* Parent class */ diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 0a982a9d5d..c4c9e5d7c2 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -20,8 +20,11 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "draw/draw_context.h" + #include "util/u_debug.h" #include "util/u_math.h" +#include "util/u_memory.h" #include "util/u_pack_color.h" #include "tgsi/tgsi_parse.h" @@ -31,6 +34,7 @@ #include "r300_context.h" #include "r300_reg.h" +#include "r300_screen.h" #include "r300_state_inlines.h" #include "r300_fs.h" #include "r300_vs.h" diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 6e7679c39f..e749bd9cb9 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -20,9 +20,15 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "r300_state_derived.h" +#include "draw/draw_context.h" + +#include "util/u_math.h" +#include "util/u_memory.h" +#include "r300_context.h" #include "r300_fs.h" +#include "r300_screen.h" +#include "r300_state_derived.h" #include "r300_state_inlines.h" #include "r300_vs.h" diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index d7b57e1b22..9135c55ec4 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -24,6 +24,8 @@ #ifndef R300_STATE_INLINES_H #define R300_STATE_INLINES_H +#include "draw/draw_vertex.h" + #include "pipe/p_format.h" #include "r300_reg.h" diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c index 3865730d63..4865f16058 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.c +++ b/src/gallium/drivers/r300/r300_state_invariant.c @@ -21,9 +21,12 @@ * 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_cs.h" +#include "r300_reg.h" +#include "r300_screen.h" #include "r300_state_invariant.h" - struct pipe_viewport_state r300_viewport_identity = { .scale = {1.0, 1.0, 1.0, 1.0}, .translate = {0.0, 0.0, 0.0, 0.0}, diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h index 5bea6779fe..05cff0d6df 100644 --- a/src/gallium/drivers/r300/r300_state_invariant.h +++ b/src/gallium/drivers/r300/r300_state_invariant.h @@ -23,11 +23,7 @@ #ifndef R300_STATE_INVARIANT_H #define R300_STATE_INVARIANT_H -#include "r300_chipset.h" -#include "r300_context.h" -#include "r300_cs.h" -#include "r300_reg.h" -#include "r300_state_inlines.h" +struct r300_context; void r300_emit_invariant_state(struct r300_context* r300); diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 7ea4c33fa9..339fbb6242 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -20,6 +20,12 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include "pipe/p_screen.h" + +#include "util/u_math.h" +#include "util/u_memory.h" + +#include "r300_context.h" #include "r300_texture.h" static void r300_setup_texture_state(struct r300_texture* tex) diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 992dad77ab..2e58bda716 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -23,11 +23,8 @@ #ifndef R300_TEXTURE_H #define R300_TEXTURE_H -#include "pipe/p_screen.h" #include "pipe/p_video_state.h" -#include "util/u_math.h" -#include "r300_context.h" #include "r300_reg.h" struct r300_texture; -- cgit v1.2.3 From 3b8dad47f816667aa4166d6e27361d274fc2cf4d Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 06:49:16 -0700 Subject: r300g: No debug in r300_state. --- src/gallium/drivers/r300/r300_state.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index c4c9e5d7c2..a3e1bc621a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -22,7 +22,6 @@ #include "draw/draw_context.h" -#include "util/u_debug.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_pack_color.h" -- cgit v1.2.3 From ce98860012b10cc6cc124fd1ed6fa3a5e28712bb Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 20 Oct 2009 10:54:21 +0100 Subject: llvmpipe: Remove extraneous name in lp_type pre-declaration. --- src/gallium/drivers/llvmpipe/lp_bld_arit.h | 2 +- src/gallium/drivers/llvmpipe/lp_bld_const.h | 2 +- src/gallium/drivers/llvmpipe/lp_bld_conv.h | 2 +- src/gallium/drivers/llvmpipe/lp_bld_logic.h | 2 +- src/gallium/drivers/llvmpipe/lp_bld_swizzle.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.h b/src/gallium/drivers/llvmpipe/lp_bld_arit.h index 095a8e1cab..4e568c055e 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.h @@ -40,7 +40,7 @@ #include -struct lp_type type; +struct lp_type; struct lp_build_context; diff --git a/src/gallium/drivers/llvmpipe/lp_bld_const.h b/src/gallium/drivers/llvmpipe/lp_bld_const.h index ffb302f736..cb8e1c7b00 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_const.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_const.h @@ -42,7 +42,7 @@ #include -struct lp_type type; +struct lp_type; unsigned diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.h b/src/gallium/drivers/llvmpipe/lp_bld_conv.h index ca378804d2..948e68fae4 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_conv.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.h @@ -40,7 +40,7 @@ #include -struct lp_type type; +struct lp_type; LLVMValueRef diff --git a/src/gallium/drivers/llvmpipe/lp_bld_logic.h b/src/gallium/drivers/llvmpipe/lp_bld_logic.h index a4ee7723b5..d67500ef70 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_logic.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_logic.h @@ -42,7 +42,7 @@ #include "pipe/p_defines.h" /* For PIPE_FUNC_xxx */ -struct lp_type type; +struct lp_type; struct lp_build_context; diff --git a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h index 1f6da80448..b9472127a6 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_swizzle.h @@ -40,7 +40,7 @@ #include -struct lp_type type; +struct lp_type; struct lp_build_context; -- cgit v1.2.3 From cb351bdd6e09b40fe719c548c48ea40c6c4c3d11 Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 21 Oct 2009 21:56:09 +0200 Subject: nouveau: nv30: check number of colour buffers to bind --- src/gallium/drivers/nv30/nv30_state_fb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 9b0266fba5..197de82886 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -17,6 +17,10 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nv30_miptree *nv30mt; int colour_bits = 32, zeta_bits = 32; + if (fb->nr_cbufs == 0) { + return FALSE; + } + rt_enable = 0; for (i = 0; i < fb->nr_cbufs; i++) { if (colour_format) { -- cgit v1.2.3 From d364f662c685ba0f28aa865fbd7e1f0acc3c469e Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Wed, 21 Oct 2009 22:01:03 +0200 Subject: nouveau: nv30: Do not use assert to return NULL --- src/gallium/drivers/nv30/nv30_fragtex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index 822e1d8def..a2ce947a72 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -69,7 +69,7 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) tf = nv30_fragtex_format(pt->format); if (!tf) - assert(0); + return NULL; txf = tf->format; txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0); -- cgit v1.2.3 From 2cc5a0e6bb8fe2aa0733d70fec65df934b1093f6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 20 Oct 2009 16:13:08 -0600 Subject: mesa: added _mesa_dump_renderbuffers() debug code --- src/mesa/main/debug.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++-- src/mesa/main/debug.h | 3 ++ 2 files changed, 77 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 490cc9c26b..8b1707bab3 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -27,6 +27,7 @@ #include "attrib.h" #include "colormac.h" #include "context.h" +#include "enums.h" #include "hash.h" #include "imports.h" #include "debug.h" @@ -264,10 +265,13 @@ write_ppm(const char *filename, const GLubyte *buffer, int width, int height, /** - * Write level[0] image to a ppm file. + * Write a texture image to a ppm file. + * \param face cube face in [0,5] + * \param level mipmap level */ static void -write_texture_image(struct gl_texture_object *texObj, GLuint face, GLuint level) +write_texture_image(struct gl_texture_object *texObj, + GLuint face, GLuint level) { struct gl_texture_image *img = texObj->Image[face][level]; if (img) { @@ -299,6 +303,45 @@ write_texture_image(struct gl_texture_object *texObj, GLuint face, GLuint level) } +/** + * Write renderbuffer image to a ppm file. + */ +static void +write_renderbuffer_image(const struct gl_renderbuffer *rb) +{ + GET_CURRENT_CONTEXT(ctx); + GLubyte *buffer; + char s[100]; + GLenum format, type; + + if (rb->_BaseFormat == GL_RGB || + rb->_BaseFormat == GL_RGBA) { + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + } + else if (rb->_BaseFormat == GL_DEPTH_STENCIL) { + format = GL_DEPTH_STENCIL; + type = GL_UNSIGNED_INT_24_8; + } + else { + return; + } + + buffer = (GLubyte *) _mesa_malloc(rb->Width * rb->Height * 4); + + ctx->Driver.ReadPixels(ctx, 0, 0, rb->Width, rb->Height, + format, type, &ctx->DefaultPacking, buffer); + + /* make filename */ + _mesa_sprintf(s, "/tmp/renderbuffer%u.ppm", rb->Name); + + _mesa_printf(" Writing renderbuffer image to %s\n", s); + write_ppm(s, buffer, rb->Width, rb->Height, 4, 0, 1, 2, GL_TRUE); + + _mesa_free(buffer); +} + + static GLboolean DumpImages; @@ -341,6 +384,35 @@ _mesa_dump_textures(GLboolean dumpImages) } +static void +dump_renderbuffer_cb(GLuint id, void *data, void *userData) +{ + const struct gl_renderbuffer *rb = (const struct gl_renderbuffer *) data; + (void) userData; + + _mesa_printf("Renderbuffer %u: %u x %u IntFormat = %s\n", + rb->Name, rb->Width, rb->Height, + _mesa_lookup_enum_by_nr(rb->InternalFormat)); + if (DumpImages) { + write_renderbuffer_image(rb); + } +} + + +/** + * Print basic info about all renderbuffers to stdout. + * If dumpImages is true, write PPM of level[0] image to a file. + */ +void +_mesa_dump_renderbuffers(GLboolean dumpImages) +{ + GET_CURRENT_CONTEXT(ctx); + DumpImages = dumpImages; + _mesa_HashWalk(ctx->Shared->RenderBuffers, dump_renderbuffer_cb, ctx); +} + + + void _mesa_dump_color_buffer(const char *filename) { diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h index bb384c4324..2a7de9c6b6 100644 --- a/src/mesa/main/debug.h +++ b/src/mesa/main/debug.h @@ -60,6 +60,9 @@ extern void _mesa_init_debug( GLcontext *ctx ); extern void _mesa_dump_textures(GLboolean dumpImages); +extern void +_mesa_dump_renderbuffers(GLboolean dumpImages); + extern void _mesa_dump_color_buffer(const char *filename); -- cgit v1.2.3 From b2b239691dfe593676aaee0cd990fa76354ac96f Mon Sep 17 00:00:00 2001 From: Marc Dietrich Date: Sun, 18 Oct 2009 08:28:33 -0700 Subject: gallium/util: fix cpu detection on ppc As we are compiling with -D_BSD_SOURCE, sigjmp_buf and siglongjmp should be replaced by the non-sig functions (see man 3 setjmp). Tested on linux/cell. --- src/gallium/auxiliary/util/u_cpu_detect.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c index b94390aef9..7330d5dbd0 100644 --- a/src/gallium/auxiliary/util/u_cpu_detect.c +++ b/src/gallium/auxiliary/util/u_cpu_detect.c @@ -131,7 +131,7 @@ win32_sig_handler_sse(EXCEPTION_POINTERS* ep) #if defined(PIPE_ARCH_PPC) && !defined(PIPE_OS_DARWIN) -static sigjmp_buf __lv_powerpc_jmpbuf; +static jmp_buf __lv_powerpc_jmpbuf; static volatile sig_atomic_t __lv_powerpc_canjump = 0; static void @@ -143,9 +143,11 @@ sigill_handler(int sig) } __lv_powerpc_canjump = 0; - siglongjmp(__lv_powerpc_jmpbuf, 1); + longjmp(__lv_powerpc_jmpbuf, 1); } +#endif +#if defined(PIPE_ARCH_PPC) static void check_os_altivec_support(void) { @@ -166,7 +168,7 @@ check_os_altivec_support(void) /* no Darwin, do it the brute-force way */ /* this is borrowed from the libmpeg2 library */ signal(SIGILL, sigill_handler); - if (sigsetjmp(__lv_powerpc_jmpbuf, 1)) { + if (setjmp(__lv_powerpc_jmpbuf)) { signal(SIGILL, SIG_DFL); } else { __lv_powerpc_canjump = 1; @@ -180,9 +182,9 @@ check_os_altivec_support(void) signal(SIGILL, SIG_DFL); util_cpu_caps.has_altivec = 1; } -#endif +#endif /* PIPE_OS_DARWIN */ } -#endif +#endif /* PIPE_ARCH_PPC */ /* If we're running on a processor that can do SSE, let's see if we * are allowed to or not. This will catch 2.4.0 or later kernels that @@ -190,6 +192,7 @@ check_os_altivec_support(void) * and RedHat patched 2.2 kernels that have broken exception handling * support for user space apps that do SSE. */ +#if defined(PIPE_ARCH_X86) || defined (PIPE_ARCH_X86_64) static void check_os_katmai_support(void) { @@ -370,6 +373,7 @@ cpuid(uint32_t ax, uint32_t *p) return ret; } +#endif /* X86 or X86_64 */ void util_cpu_detect(void) -- cgit v1.2.3 From 40247d87d215d0f1b6370b2888548544eedf0d89 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 22:53:37 -0700 Subject: r300g: Cleanup old static shader state. --- src/gallium/drivers/r300/Makefile | 2 - src/gallium/drivers/r300/r300_fs.c | 11 +--- src/gallium/drivers/r300/r300_fs.h | 3 +- src/gallium/drivers/r300/r300_vs.c | 86 ------------------------- src/gallium/drivers/r300/r3xx_fs.c | 74 ---------------------- src/gallium/drivers/r300/r3xx_fs.h | 32 ---------- src/gallium/drivers/r300/r5xx_fs.c | 125 ------------------------------------- src/gallium/drivers/r300/r5xx_fs.h | 32 ---------- 8 files changed, 4 insertions(+), 361 deletions(-) delete mode 100644 src/gallium/drivers/r300/r3xx_fs.c delete mode 100644 src/gallium/drivers/r300/r3xx_fs.h delete mode 100644 src/gallium/drivers/r300/r5xx_fs.c delete mode 100644 src/gallium/drivers/r300/r5xx_fs.h diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile index c4f2c021c4..f73d80de88 100644 --- a/src/gallium/drivers/r300/Makefile +++ b/src/gallium/drivers/r300/Makefile @@ -4,8 +4,6 @@ include $(TOP)/configs/current LIBNAME = r300 C_SOURCES = \ - r3xx_fs.c \ - r5xx_fs.c \ r300_chipset.c \ r300_clear.c \ r300_context.c \ diff --git a/src/gallium/drivers/r300/r300_fs.c b/src/gallium/drivers/r300/r300_fs.c index 2db185fd80..29ddc84c41 100644 --- a/src/gallium/drivers/r300/r300_fs.c +++ b/src/gallium/drivers/r300/r300_fs.c @@ -130,14 +130,9 @@ void r300_translate_fragment_shader(struct r300_context* r300, /* Invoke the compiler */ r3xx_compile_fragment_program(&compiler); if (compiler.Base.Error) { - /* Todo: Fallback to software rendering gracefully? */ - fprintf(stderr, "r300 FP: Compiler error: %s\n", compiler.Base.ErrorMsg); - - if (compiler.is_r500) { - memcpy(compiler.code, &r5xx_passthrough_fragment_shader, sizeof(r5xx_passthrough_fragment_shader)); - } else { - memcpy(compiler.code, &r3xx_passthrough_fragment_shader, sizeof(r3xx_passthrough_fragment_shader)); - } + /* XXX failover maybe? */ + DBG(r300, DBG_FP, "r300: Error compiling fragment program: %s\n", + compiler.Base.ErrorMsg); } /* And, finally... */ diff --git a/src/gallium/drivers/r300/r300_fs.h b/src/gallium/drivers/r300/r300_fs.h index 8dfb139738..e831c30301 100644 --- a/src/gallium/drivers/r300/r300_fs.h +++ b/src/gallium/drivers/r300/r300_fs.h @@ -28,8 +28,7 @@ #include "tgsi/tgsi_scan.h" -#include "r3xx_fs.h" -#include "r5xx_fs.h" +#include "radeon_code.h" struct r300_fragment_shader { /* Parent class */ diff --git a/src/gallium/drivers/r300/r300_vs.c b/src/gallium/drivers/r300/r300_vs.c index 8460cfaf51..eca85879a7 100644 --- a/src/gallium/drivers/r300/r300_vs.c +++ b/src/gallium/drivers/r300/r300_vs.c @@ -146,89 +146,3 @@ void r300_translate_vertex_shader(struct r300_context* r300, rc_destroy(&compiler.Base); vs->translated = TRUE; } - - -/* XXX get these to r300_reg */ -#define R300_PVS_DST_OPCODE(x) ((x) << 0) -# define R300_VE_DOT_PRODUCT 1 -# define R300_VE_MULTIPLY 2 -# define R300_VE_ADD 3 -# define R300_VE_MAXIMUM 7 -# define R300_VE_SET_LESS_THAN 10 -#define R300_PVS_DST_MATH_INST (1 << 6) -# define R300_ME_RECIP_DX 6 -#define R300_PVS_DST_MACRO_INST (1 << 7) -# define R300_PVS_MACRO_OP_2CLK_MADD 0 -#define R300_PVS_DST_REG_TYPE(x) ((x) << 8) -# define R300_PVS_DST_REG_TEMPORARY 0 -# define R300_PVS_DST_REG_A0 1 -# define R300_PVS_DST_REG_OUT 2 -# define R300_PVS_DST_REG_OUT_REPL_X 3 -# define R300_PVS_DST_REG_ALT_TEMPORARY 4 -# define R300_PVS_DST_REG_INPUT 5 -#define R300_PVS_DST_OFFSET(x) ((x) << 13) -#define R300_PVS_DST_WE(x) ((x) << 20) -#define R300_PVS_DST_WE_XYZW (0xf << 20) - -#define R300_PVS_SRC_REG_TYPE(x) ((x) << 0) -# define R300_PVS_SRC_REG_TEMPORARY 0 -# define R300_PVS_SRC_REG_INPUT 1 -# define R300_PVS_SRC_REG_CONSTANT 2 -# define R300_PVS_SRC_REG_ALT_TEMPORARY 3 -#define R300_PVS_SRC_OFFSET(x) ((x) << 5) -#define R300_PVS_SRC_SWIZZLE(x) ((x) << 13) -# define R300_PVS_SRC_SELECT_X 0 -# define R300_PVS_SRC_SELECT_Y 1 -# define R300_PVS_SRC_SELECT_Z 2 -# define R300_PVS_SRC_SELECT_W 3 -# define R300_PVS_SRC_SELECT_FORCE_0 4 -# define R300_PVS_SRC_SELECT_FORCE_1 5 -# define R300_PVS_SRC_SWIZZLE_XYZW \ - ((R300_PVS_SRC_SELECT_X | (R300_PVS_SRC_SELECT_Y << 3) | \ - (R300_PVS_SRC_SELECT_Z << 6) | (R300_PVS_SRC_SELECT_W << 9)) << 13) -# define R300_PVS_SRC_SWIZZLE_ZERO \ - ((R300_PVS_SRC_SELECT_FORCE_0 | (R300_PVS_SRC_SELECT_FORCE_0 << 3) | \ - (R300_PVS_SRC_SELECT_FORCE_0 << 6) | \ - (R300_PVS_SRC_SELECT_FORCE_0 << 9)) << 13) -# define R300_PVS_SRC_SWIZZLE_ONE \ - ((R300_PVS_SRC_SELECT_FORCE_1 | (R300_PVS_SRC_SELECT_FORCE_1 << 3) | \ - (R300_PVS_SRC_SELECT_FORCE_1 << 6) | \ - (R300_PVS_SRC_SELECT_FORCE_1 << 9)) << 13) -#define R300_PVS_MODIFIER_X (1 << 25) -#define R300_PVS_MODIFIER_Y (1 << 26) -#define R300_PVS_MODIFIER_Z (1 << 27) -#define R300_PVS_MODIFIER_W (1 << 28) -#define R300_PVS_NEGATE_XYZW \ - (R300_PVS_MODIFIER_X | R300_PVS_MODIFIER_Y | \ - R300_PVS_MODIFIER_Z | R300_PVS_MODIFIER_W) - -struct r300_vertex_program_code r300_passthrough_vertex_shader = { - .length = 8, /* two instructions */ - - /* MOV out[0], in[0] */ - .body.d[0] = R300_PVS_DST_OPCODE(R300_VE_ADD) | - R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | - R300_PVS_DST_OFFSET(0) | R300_PVS_DST_WE_XYZW, - .body.d[1] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | - R300_PVS_SRC_OFFSET(0) | R300_PVS_SRC_SWIZZLE_XYZW, - .body.d[2] = R300_PVS_SRC_SWIZZLE_ZERO, - .body.d[3] = 0x0, - - /* MOV out[1], in[1] */ - .body.d[4] = R300_PVS_DST_OPCODE(R300_VE_ADD) | - R300_PVS_DST_REG_TYPE(R300_PVS_DST_REG_OUT) | - R300_PVS_DST_OFFSET(1) | R300_PVS_DST_WE_XYZW, - .body.d[5] = R300_PVS_SRC_REG_TYPE(R300_PVS_SRC_REG_INPUT) | - R300_PVS_SRC_OFFSET(1) | R300_PVS_SRC_SWIZZLE_XYZW, - .body.d[6] = R300_PVS_SRC_SWIZZLE_ZERO, - .body.d[7] = 0x0, - - .inputs[0] = 0, - .inputs[1] = 1, - .outputs[0] = 0, - .outputs[1] = 1, - - .InputsRead = 3, - .OutputsWritten = 3 -}; - diff --git a/src/gallium/drivers/r300/r3xx_fs.c b/src/gallium/drivers/r300/r3xx_fs.c deleted file mode 100644 index c1c1194d58..0000000000 --- a/src/gallium/drivers/r300/r3xx_fs.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * Joakim Sindholt - * - * 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 "r3xx_fs.h" - -#include "r300_reg.h" - -struct rX00_fragment_program_code r3xx_passthrough_fragment_shader = { - .code.r300.alu.length = 1, - .code.r300.tex.length = 0, - - .code.r300.config = 0, - .code.r300.pixsize = 0, - .code.r300.code_offset = 0, - .code.r300.code_addr[3] = R300_RGBA_OUT, - - .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | - R300_ALU_OUTC_CMP, - .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | - R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ, - .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | - R300_ALU_OUTA_CMP, - .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) | - R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, -}; - -struct rX00_fragment_program_code r3xx_texture_fragment_shader = { - .code.r300.alu.length = 1, - .code.r300.tex.length = 1, - - .code.r300.config = R300_PFS_CNTL_FIRST_NODE_HAS_TEX, - .code.r300.pixsize = 0, - .code.r300.code_offset = 0, - .code.r300.code_addr[3] = R300_RGBA_OUT, - - .code.r300.tex.inst[0] = R300_TEX_OP_LD << R300_TEX_INST_SHIFT, - - .code.r300.alu.inst[0].rgb_inst = R300_RGB_SWIZA(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZB(R300_ALU_ARGC_SRC0C_XYZ) | - R300_RGB_SWIZC(R300_ALU_ARGC_ZERO) | - R300_ALU_OUTC_CMP, - .code.r300.alu.inst[0].rgb_addr = R300_RGB_ADDR0(0) | R300_RGB_ADDR1(0) | - R300_RGB_ADDR2(0) | R300_ALU_DSTC_OUTPUT_XYZ, - .code.r300.alu.inst[0].alpha_inst = R300_ALPHA_SWIZA(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZB(R300_ALU_ARGA_SRC0A) | - R300_ALPHA_SWIZC(R300_ALU_ARGA_ZERO) | - R300_ALU_OUTA_CMP, - .code.r300.alu.inst[0].alpha_addr = R300_ALPHA_ADDR0(0) | - R300_ALPHA_ADDR1(0) | R300_ALPHA_ADDR2(0) | R300_ALU_DSTA_OUTPUT, -}; diff --git a/src/gallium/drivers/r300/r3xx_fs.h b/src/gallium/drivers/r300/r3xx_fs.h deleted file mode 100644 index 51cd245724..0000000000 --- a/src/gallium/drivers/r300/r3xx_fs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * Joakim Sindholt - * - * 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 R3XX_FS_H -#define R3XX_FS_H - -#include "radeon_code.h" - -struct rX00_fragment_program_code r3xx_passthrough_fragment_shader; -struct rX00_fragment_program_code r3xx_texture_fragment_shader; - -#endif /* R3XX_FS_H */ diff --git a/src/gallium/drivers/r300/r5xx_fs.c b/src/gallium/drivers/r300/r5xx_fs.c deleted file mode 100644 index f072deab0d..0000000000 --- a/src/gallium/drivers/r300/r5xx_fs.c +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * Joakim Sindholt - * - * 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 "r5xx_fs.h" - -#include "r300_reg.h" - -/* XXX this all should find its way back to r300_reg */ -/* Swizzle tools */ -#define R500_SWIZZLE_ZERO 4 -#define R500_SWIZZLE_HALF 5 -#define R500_SWIZZLE_ONE 6 -#define R500_SWIZ_RGB_ZERO ((4 << 0) | (4 << 3) | (4 << 6)) -#define R500_SWIZ_RGB_ONE ((6 << 0) | (6 << 3) | (6 << 6)) -#define R500_SWIZ_RGB_RGB ((0 << 0) | (1 << 3) | (2 << 6)) -#define R500_SWIZ_MOD_NEG 1 -#define R500_SWIZ_MOD_ABS 2 -#define R500_SWIZ_MOD_NEG_ABS 3 -/* Swizzles for inst2 */ -#define R500_SWIZ_TEX_STRQ(x) ((x) << 8) -#define R500_SWIZ_TEX_RGBA(x) ((x) << 24) -/* Swizzles for inst3 */ -#define R500_SWIZ_RGB_A(x) ((x) << 2) -#define R500_SWIZ_RGB_B(x) ((x) << 15) -/* Swizzles for inst4 */ -#define R500_SWIZ_ALPHA_A(x) ((x) << 14) -#define R500_SWIZ_ALPHA_B(x) ((x) << 21) -/* Swizzle for inst5 */ -#define R500_SWIZ_RGBA_C(x) ((x) << 14) -#define R500_SWIZ_ALPHA_C(x) ((x) << 27) -/* Writemasks */ -#define R500_TEX_WMASK(x) ((x) << 11) -#define R500_ALU_WMASK(x) ((x) << 11) -#define R500_ALU_OMASK(x) ((x) << 15) -#define R500_W_OMASK (1 << 31) - -struct rX00_fragment_program_code r5xx_passthrough_fragment_shader = { - .code.r500.max_temp_idx = 0, - .code.r500.inst_end = 0, - - .code.r500.inst[0].inst0 = R500_INST_TYPE_OUT | - R500_INST_TEX_SEM_WAIT | R500_INST_LAST | - R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | - R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, - .code.r500.inst[0].inst1 = - R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST | - R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST, - .code.r500.inst[0].inst2 = - R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST | - R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST, - .code.r500.inst[0].inst3 = - R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R | - R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B | - R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R | - R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B, - .code.r500.inst[0].inst4 = - R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A, - .code.r500.inst[0].inst5 = - R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 | - R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 | - R500_ALU_RGBA_A_SWIZ_0, -}; - -struct rX00_fragment_program_code r5xx_texture_fragment_shader = { - .code.r500.max_temp_idx = 0, - .code.r500.inst_end = 1, - - .code.r500.inst[0].inst0 = R500_INST_TYPE_TEX | - R500_INST_TEX_SEM_WAIT | - R500_INST_RGB_WMASK_RGB | R500_INST_ALPHA_WMASK | - R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, - .code.r500.inst[0].inst1 = R500_TEX_ID(0) | R500_TEX_INST_LD | - R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED, - .code.r500.inst[0].inst2 = R500_TEX_SRC_ADDR(0) | - R500_TEX_SRC_S_SWIZ_R | R500_TEX_SRC_T_SWIZ_G | - R500_TEX_SRC_R_SWIZ_B | R500_TEX_SRC_Q_SWIZ_A | - R500_TEX_DST_ADDR(0) | - R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G | - R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A, - .code.r500.inst[0].inst3 = 0x0, - .code.r500.inst[0].inst4 = 0x0, - .code.r500.inst[0].inst5 = 0x0, - - .code.r500.inst[1].inst0 = R500_INST_TYPE_OUT | - R500_INST_TEX_SEM_WAIT | R500_INST_LAST | - R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK | - R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP, - .code.r500.inst[1].inst1 = - R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST | - R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST, - .code.r500.inst[1].inst2 = - R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST | - R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST, - .code.r500.inst[1].inst3 = - R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R | - R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B | - R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R | - R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B, - .code.r500.inst[1].inst4 = - R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A, - .code.r500.inst[1].inst5 = - R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 | - R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 | - R500_ALU_RGBA_A_SWIZ_0, -}; diff --git a/src/gallium/drivers/r300/r5xx_fs.h b/src/gallium/drivers/r300/r5xx_fs.h deleted file mode 100644 index a4addde32b..0000000000 --- a/src/gallium/drivers/r300/r5xx_fs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2008 Corbin Simpson - * Joakim Sindholt - * - * 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 R5XX_FS_H -#define R5XX_FS_H - -#include "radeon_code.h" - -struct rX00_fragment_program_code r5xx_passthrough_fragment_shader; -struct rX00_fragment_program_code r5xx_texture_fragment_shader; - -#endif /* R5XX_FS_H */ -- cgit v1.2.3 From 5a653ada4143c24b00b0ca12b4898064afd59c29 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 22:54:52 -0700 Subject: r300g: Remove unused debug flag. --- src/gallium/drivers/r300/r300_context.h | 5 ++--- src/gallium/drivers/r300/r300_debug.c | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 61a57df35e..4e2c0ec34e 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -317,9 +317,8 @@ void r300_init_surface_functions(struct r300_context* r300); #define DBG_VP 0x0000004 #define DBG_CS 0x0000008 #define DBG_DRAW 0x0000010 -#define DBG_SURF 0x0000020 -#define DBG_TEX 0x0000040 -#define DBG_FALL 0x0000080 +#define DBG_TEX 0x0000020 +#define DBG_FALL 0x0000040 /*@}*/ static INLINE boolean DBG_ON(struct r300_context * ctx, unsigned flags) diff --git a/src/gallium/drivers/r300/r300_debug.c b/src/gallium/drivers/r300/r300_debug.c index bfd4ab018a..421253ca72 100644 --- a/src/gallium/drivers/r300/r300_debug.c +++ b/src/gallium/drivers/r300/r300_debug.c @@ -37,7 +37,6 @@ static struct debug_option debug_options[] = { { "vp", DBG_VP, "Vertex program handling" }, { "cs", DBG_CS, "Command submissions" }, { "draw", DBG_DRAW, "Draw and emit" }, - { "surf", DBG_SURF, "Surface drawing" }, { "tex", DBG_TEX, "Textures" }, { "fall", DBG_FALL, "Fallbacks" }, -- cgit v1.2.3 From 034db65f08b943ee9940947db69e4e190f751061 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 23:23:37 -0700 Subject: r300g: Update comments, asserts, indents in r300_texture. I wish I knew enough about textures to really really REALLY fix that file. --- src/gallium/drivers/r300/r300_texture.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index 339fbb6242..3c8ff24e17 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -42,16 +42,16 @@ static void r300_setup_texture_state(struct r300_texture* tex) /* XXX */ state->format1 = r300_translate_texformat(pt->format); if (pt->target == PIPE_TEXTURE_CUBE) { - state->format1 |= R300_TX_FORMAT_CUBIC_MAP; + state->format1 |= R300_TX_FORMAT_CUBIC_MAP; } if (pt->target == PIPE_TEXTURE_3D) { - state->format1 |= R300_TX_FORMAT_3D; + state->format1 |= R300_TX_FORMAT_3D; } state->format2 = (r300_texture_get_stride(tex, 0) / pt->block.size) - 1; - /* Assume (somewhat foolishly) that oversized textures will - * not be permitted by the state tracker. */ + /* Don't worry about accidentally setting this bit on non-r500; + * the kernel should catch it. */ if (pt->width[0] > 2048) { state->format2 |= R500_TXWIDTH_BIT11; } @@ -73,7 +73,8 @@ unsigned r300_texture_get_stride(struct r300_texture* tex, unsigned level) return tex->stride_override; if (level > tex->tex.last_level) { - debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__, level, tex->tex.last_level); + debug_printf("%s: level (%u) > last_level (%u)\n", __FUNCTION__, + level, tex->tex.last_level); return 0; } @@ -96,11 +97,6 @@ static void r300_setup_miptree(struct r300_texture* tex) base->nblocksx[i] = pf_get_nblocksx(&base->block, base->width[i]); base->nblocksy[i] = pf_get_nblocksy(&base->block, base->height[i]); - /* Radeons enjoy things in multiples of 64. - * - * XXX - * POT, uncompressed, unmippmapped textures can be aligned to 32, - * instead of 64. */ stride = r300_texture_get_stride(tex, i); size = stride * base->nblocksy[i] * base->depth[i]; @@ -195,9 +191,7 @@ static struct pipe_texture* { struct r300_texture* tex; - /* XXX we should start doing mips now... */ if (base->target != PIPE_TEXTURE_2D || - base->last_level != 0 || base->depth[0] != 1) { return NULL; } @@ -213,7 +207,6 @@ static struct pipe_texture* tex->stride_override = *stride; - /* XXX */ r300_setup_texture_state(tex); pipe_buffer_reference(&tex->buffer, buffer); -- cgit v1.2.3 From 0a8cd4862c4f04308ab818077bab94417ffbf50b Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Wed, 21 Oct 2009 23:26:02 -0700 Subject: r300g: Update comments, function names in r300_state_inlines. --- src/gallium/drivers/r300/r300_state_derived.c | 2 +- src/gallium/drivers/r300/r300_state_inlines.h | 24 +++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index e749bd9cb9..42aee7231e 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -250,7 +250,7 @@ static void r300_vertex_psc(struct r300_context* r300, assert(tab[i] != -1); /* Add the attribute to the PSC table. */ - temp = translate_vertex_data_type(vinfo->attrib[i].emit) | + temp = translate_draw_vertex_data_type(vinfo->attrib[i].emit) | tab[i] << R300_DST_VEC_LOC_SHIFT; if (i & 1) { diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 9135c55ec4..c82d8e5f08 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -53,6 +53,7 @@ static INLINE uint32_t r300_translate_blend_function(int blend_func) return R300_COMB_FCN_MAX; default: debug_printf("r300: Unknown blend function %d\n", blend_func); + assert(0); break; } return 0; @@ -100,6 +101,7 @@ static INLINE uint32_t r300_translate_blend_factor(int blend_fact) case PIPE_BLENDFACTOR_INV_SRC1_ALPHA: */ default: debug_printf("r300: Unknown blend factor %d\n", blend_fact); + assert(0); break; } return 0; @@ -129,6 +131,7 @@ static INLINE uint32_t r300_translate_depth_stencil_function(int zs_func) default: debug_printf("r300: Unknown depth/stencil function %d\n", zs_func); + assert(0); break; } return 0; @@ -155,6 +158,7 @@ static INLINE uint32_t r300_translate_stencil_op(int s_op) return R300_ZS_INVERT; default: debug_printf("r300: Unknown stencil op %d", s_op); + assert(0); break; } return 0; @@ -181,6 +185,7 @@ static INLINE uint32_t r300_translate_alpha_function(int alpha_func) return R300_FG_ALPHA_FUNC_ALWAYS; default: debug_printf("r300: Unknown alpha function %d", alpha_func); + assert(0); break; } return 0; @@ -209,6 +214,7 @@ static INLINE uint32_t r300_translate_wrap(int wrap) return R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED; default: debug_printf("r300: Unknown texture wrap %d", wrap); + assert(0); return 0; } } @@ -228,6 +234,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip) break; default: debug_printf("r300: Unknown texture filter %d\n", min); + assert(0); break; } switch (mag) { @@ -242,6 +249,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip) break; default: debug_printf("r300: Unknown texture filter %d\n", mag); + assert(0); break; } switch (mip) { @@ -256,6 +264,7 @@ static INLINE uint32_t r300_translate_tex_filters(int min, int mag, int mip) break; default: debug_printf("r300: Unknown texture filter %d\n", mip); + assert(0); break; } @@ -279,6 +288,8 @@ static INLINE uint32_t r300_anisotropy(float max_aniso) /* Buffer formats. */ +/* Colorbuffer formats. This is the unswizzled format of the RB3D block's + * output. For the swizzling of the targets, check the shader's format. */ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format) { switch (format) { @@ -313,11 +324,13 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format) debug_printf("r300: Implementation error: " "Got unsupported color format %s in %s\n", pf_name(format), __FUNCTION__); + assert(0); break; } return 0; } +/* Depthbuffer and stencilbuffer. Thankfully, we only support two kinds. */ static INLINE uint32_t r300_translate_zsformat(enum pipe_format format) { switch (format) { @@ -331,18 +344,22 @@ static INLINE uint32_t r300_translate_zsformat(enum pipe_format format) debug_printf("r300: Implementation error: " "Got unsupported ZS format %s in %s\n", pf_name(format), __FUNCTION__); + assert(0); break; } return 0; } -/* Translate pipe_format into US_OUT_FMT. +/* Shader output formats. This is essentially the swizzle from the shader + * to the RB3D block. + * * Note that formats are stored from C3 to C0. */ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format) { switch (format) { case PIPE_FORMAT_A8R8G8B8_UNORM: case PIPE_FORMAT_X8R8G8B8_UNORM: + /* XXX */ case PIPE_FORMAT_Z24S8_UNORM: return R300_US_OUT_FMT_C4_8 | R300_C0_SEL_B | R300_C1_SEL_G | @@ -356,6 +373,7 @@ static INLINE uint32_t r300_translate_out_fmt(enum pipe_format format) debug_printf("r300: Implementation error: " "Got unsupported output format %s in %s\n", pf_name(format), __FUNCTION__); + assert(0); return R300_US_OUT_FMT_UNUSED; } return 0; @@ -382,7 +400,8 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) return 0; } -static INLINE uint32_t translate_vertex_data_type(int type) { +/* Translate Draw vertex types into PSC vertex types. */ +static INLINE uint32_t translate_draw_vertex_data_type(int type) { switch (type) { case EMIT_1F: case EMIT_1F_PSIZE: @@ -406,7 +425,6 @@ static INLINE uint32_t translate_vertex_data_type(int type) { assert(0); break; } - return 0; } -- cgit v1.2.3 From b86302283b48654682e0580c53ece01bf095fa95 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Tue, 20 Oct 2009 11:45:39 +0300 Subject: r600: add beginnings of ARL instruction --- src/mesa/drivers/dri/r600/r700_assembler.c | 35 +++++++++++++++++++++++++++--- src/mesa/drivers/dri/r600/r700_assembler.h | 1 + 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index a683008746..d0eb9949a6 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -355,6 +355,7 @@ unsigned int r700GetNumOperands(r700_AssemblerBase* pAsm) return 2; case SQ_OP2_INST_MOV: + case SQ_OP2_INST_MOVA_FLOOR: case SQ_OP2_INST_FRACT: case SQ_OP2_INST_FLOOR: case SQ_OP2_INST_EXP_IEEE: @@ -2064,7 +2065,7 @@ GLboolean assemble_alu_instruction(r700_AssemblerBase *pAsm) } //other bits - alu_instruction_ptr->m_Word0.f.index_mode = SQ_INDEX_LOOP; + alu_instruction_ptr->m_Word0.f.index_mode = SQ_INDEX_AR_X; if( (is_single_scalar_operation == GL_TRUE) || (GL_TRUE == bSplitInst) ) @@ -2398,6 +2399,35 @@ GLboolean assemble_ADD(r700_AssemblerBase *pAsm) return GL_TRUE; } +GLboolean assemble_ARL(r700_AssemblerBase *pAsm) +{ /* TODO: ar values dont' persist between clauses */ + if( GL_FALSE == checkop1(pAsm) ) + { + return GL_FALSE; + } + + pAsm->D.dst.opcode = SQ_OP2_INST_MOVA_FLOOR; + setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); + pAsm->D.dst.rtype = DST_REG_TEMPORARY; + pAsm->D.dst.reg = 0; + pAsm->D.dst.writex = 0; + pAsm->D.dst.writey = 0; + pAsm->D.dst.writez = 0; + pAsm->D.dst.writew = 0; + + if( GL_FALSE == assemble_src(pAsm, 0, -1) ) + { + return GL_FALSE; + } + + if( GL_FALSE == next_ins(pAsm) ) + { + return GL_FALSE; + } + + return GL_TRUE; +} + GLboolean assemble_BAD(char *opcode_str) { radeon_error("Not yet implemented instruction (%s)\n", opcode_str); @@ -3812,8 +3842,7 @@ GLboolean AssembleInstr(GLuint uiNumberInsts, break; case OPCODE_ARL: - radeon_error("Not yet implemented instruction OPCODE_ARL \n"); - //if ( GL_FALSE == assemble_BAD("ARL") ) + if ( GL_FALSE == assemble_ARL(pR700AsmCode) ) return GL_FALSE; break; case OPCODE_ARR: diff --git a/src/mesa/drivers/dri/r600/r700_assembler.h b/src/mesa/drivers/dri/r600/r700_assembler.h index 73bb8bac55..d639592702 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.h +++ b/src/mesa/drivers/dri/r600/r700_assembler.h @@ -461,6 +461,7 @@ GLboolean next_ins(r700_AssemblerBase *pAsm); GLboolean assemble_math_function(r700_AssemblerBase* pAsm, BITS opcode); GLboolean assemble_ABS(r700_AssemblerBase *pAsm); GLboolean assemble_ADD(r700_AssemblerBase *pAsm); +GLboolean assemble_ARL(r700_AssemblerBase *pAsm); GLboolean assemble_BAD(char *opcode_str); GLboolean assemble_CMP(r700_AssemblerBase *pAsm); GLboolean assemble_COS(r700_AssemblerBase *pAsm); -- cgit v1.2.3 From a88c9296cb079ff42ef901113d0fe772228e6feb Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 21 Oct 2009 12:23:27 +0300 Subject: r600: need to export something from PS Also avoids empty shader for "END" - seems to be somewhat valid fp Maybe this can be done differently in the future (fake FRAG_RESULT_COLOR already in Map_Fragment_Program() or is there a way to program the chip to not hang in case of no exports. --- src/mesa/drivers/dri/r600/r700_assembler.c | 11 ++++++++++- src/mesa/drivers/dri/r600/r700_fragprog.c | 10 +++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index d0eb9949a6..6ff08e1cfb 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -4187,6 +4187,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode, GLbitfield OutputsWritten) { unsigned int unBit; + GLuint export_count = 0; if(pR700AsmCode->depth_export_register_number >= 0) { @@ -4208,6 +4209,7 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode, { return GL_FALSE; } + export_count++; } unBit = 1 << FRAG_RESULT_DEPTH; if(OutputsWritten & unBit) @@ -4221,8 +4223,15 @@ GLboolean Process_Fragment_Exports(r700_AssemblerBase *pR700AsmCode, { return GL_FALSE; } + export_count++; } - + /* Need to export something, otherwise we'll hang + * results are undefined anyway */ + if(export_count == 0) + { + Process_Export(pR700AsmCode, SQ_EXPORT_PIXEL, 0, 1, 0, GL_FALSE); + } + if(pR700AsmCode->cf_last_export_ptr != NULL) { pR700AsmCode->cf_last_export_ptr->m_Word1.f.cf_inst = SQ_CF_INST_EXPORT_DONE; diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c index 62a1ea1a22..3736bce11c 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.c +++ b/src/mesa/drivers/dri/r600/r700_fragprog.c @@ -251,7 +251,15 @@ GLboolean r700TranslateFragmentShader(struct r700_fragment_program *fp, number_of_colors_exported--; } - fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled; + /* illegal to set this to 0 */ + if(number_of_colors_exported || z_enabled) + { + fp->r700Shader.exportMode = number_of_colors_exported << 1 | z_enabled; + } + else + { + fp->r700Shader.exportMode = (1 << 1); + } fp->translated = GL_TRUE; -- cgit v1.2.3 From 869e20bcb7db9c6540eb6b538104303df738d302 Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 21 Oct 2009 19:04:21 +0300 Subject: r600: set barrier for tex inst if dst is used earlier, might overwrite it otherwise --- src/mesa/drivers/dri/r600/r700_fragprog.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_fragprog.c b/src/mesa/drivers/dri/r600/r700_fragprog.c index 3736bce11c..0f549ead9c 100644 --- a/src/mesa/drivers/dri/r600/r700_fragprog.c +++ b/src/mesa/drivers/dri/r600/r700_fragprog.c @@ -135,15 +135,19 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, { GLuint i, j; GLint * puiTEMPwrites; + GLint * puiTEMPreads; struct prog_instruction * pILInst; InstDeps *pInstDeps; struct prog_instruction * texcoord_DepInst; GLint nDepInstID; puiTEMPwrites = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries); + puiTEMPreads = (GLint*) MALLOC(sizeof(GLuint)*mesa_fp->Base.NumTemporaries); + for(i=0; iBase.NumTemporaries; i++) { puiTEMPwrites[i] = -1; + puiTEMPreads[i] = -1; } pInstDeps = (InstDeps*)MALLOC(sizeof(InstDeps)*mesa_fp->Base.NumInstructions); @@ -167,6 +171,11 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, { //Set dep. pInstDeps[i].nSrcDeps[j] = puiTEMPwrites[pILInst->SrcReg[j].Index]; + //Set first read + if(puiTEMPreads[pILInst->SrcReg[j].Index] < 0 ) + { + puiTEMPreads[pILInst->SrcReg[j].Index] = i; + } } else { @@ -177,8 +186,6 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, fp->r700AsmCode.pInstDeps = pInstDeps; - FREE(puiTEMPwrites); - //Find dep for tex inst for(i=0; iBase.NumInstructions; i++) { @@ -203,9 +210,25 @@ GLboolean Find_Instruction_Dependencies_fp(struct r700_fragment_program *fp, { //... other deps? } } + // make sure that we dont overwrite src used earlier + nDepInstID = puiTEMPreads[pILInst->DstReg.Index]; + if(nDepInstID < i) + { + pInstDeps[i].nDstDep = puiTEMPreads[pILInst->DstReg.Index]; + texcoord_DepInst = &(mesa_fp->Base.Instructions[nDepInstID]); + if(GL_TRUE == IsAlu(texcoord_DepInst->Opcode) ) + { + pInstDeps[nDepInstID].nDstDep = i; + } + + } + } } + FREE(puiTEMPwrites); + FREE(puiTEMPreads); + return GL_TRUE; } -- cgit v1.2.3 From 511bd5f32b67f903b590f00f7ccf8132127ef2e4 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 00:21:08 -0700 Subject: r300g: Check for NULL Draw during flush. Split from the fastpath WIP. --- src/gallium/drivers/r300/r300_flush.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/r300/r300_flush.c b/src/gallium/drivers/r300/r300_flush.c index c222ea09b1..14a08241fc 100644 --- a/src/gallium/drivers/r300/r300_flush.c +++ b/src/gallium/drivers/r300/r300_flush.c @@ -40,8 +40,10 @@ static void r300_flush(struct pipe_context* pipe, CS_LOCALS(r300); /* We probably need to flush Draw, but we may have been called from - * within Draw. This feels kludgy, but it might be the best thing. */ - if (!r300->draw->flushing) { + * within Draw. This feels kludgy, but it might be the best thing. + * + * Of course, the best thing is to kill Draw with fire. :3 */ + if (r300->draw && !r300->draw->flushing) { draw_flush(r300->draw); } -- cgit v1.2.3 From eebf4b5299a880f4cdf8a916b4e1ca0bd79a6f07 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 22 Oct 2009 21:55:22 +1000 Subject: nv50: support 3D class 0x8597, remove redundant unknown chipset detection --- src/gallium/drivers/nv50/nv50_screen.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index 0bd5487695..63dce0f4c2 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -218,7 +218,16 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) tesla_class = NV54TCL; break; case 0xa0: - tesla_class = NVA0TCL; + switch (chipset) { + case 0xa0: + case 0xaa: + case 0xac: + tesla_class = NVA0TCL; + break; + default: + tesla_class = 0x8597; + break; + } break; default: NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset); @@ -226,12 +235,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev) return NULL; } - if (tesla_class == 0) { - NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset); - nv50_screen_destroy(pscreen); - return NULL; - } - ret = nouveau_grobj_alloc(chan, 0xbeef5097, tesla_class, &screen->tesla); if (ret) { -- cgit v1.2.3 From 326baecd757747a52b028e1f590437597776d7e6 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 16 Oct 2009 12:18:25 +0800 Subject: egl: Correct conversion of native visual type. Signed-off-by: Chia-I Wu --- src/egl/main/eglconfigutil.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/egl/main/eglconfigutil.c b/src/egl/main/eglconfigutil.c index a5fcdcd287..36e94f0d2d 100644 --- a/src/egl/main/eglconfigutil.c +++ b/src/egl/main/eglconfigutil.c @@ -102,7 +102,12 @@ _eglConfigFromContextModesRec(_EGLConfig *conf, const __GLcontextModes *m, SET_CONFIG_ATTRIB(conf, EGL_NATIVE_RENDERABLE, m->xRenderable); SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, m->visualID); - SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType); + + if (m->visualType != GLX_NONE) + SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, m->visualType); + else + SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); + SET_CONFIG_ATTRIB(conf, EGL_RENDERABLE_TYPE, renderable_type); SET_CONFIG_ATTRIB(conf, EGL_SAMPLE_BUFFERS, m->sampleBuffers); SET_CONFIG_ATTRIB(conf, EGL_SAMPLES, m->samples); -- cgit v1.2.3 From 78c3a351bc91eed49a07108682013a323d87540e Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 18:16:10 +0800 Subject: egl_glx: Clean up the initialization code. Proper detection of GLX extensions. Convert fbconfigs or visuals in a more unified way and validate the resulting configs. Signed-off-by: Chia-I Wu --- src/egl/drivers/glx/egl_glx.c | 658 ++++++++++++++++++++++++------------------ 1 file changed, 371 insertions(+), 287 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 4685f600e2..404c998dcb 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -40,16 +40,14 @@ */ -#include -#include -#include -#include -#include -#include "dlfcn.h" +#include +#include #include -#include +#include + #include "glxclient.h" +#include "eglconfigutil.h" #include "eglconfig.h" #include "eglcontext.h" #include "egldisplay.h" @@ -58,46 +56,19 @@ #include "egllog.h" #include "eglsurface.h" -#include - #define CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) -static const EGLint all_apis = (EGL_OPENGL_ES_BIT - | EGL_OPENGL_ES2_BIT - | EGL_OPENVG_BIT - /* | EGL_OPENGL_BIT */); /* can't do */ +#ifndef GLX_VERSION_1_4 +#error "GL/glx.h must be equal to or greater than GLX 1.4" +#endif + +/* + * report OpenGL ES bits because apps usually forget to specify + * EGL_RENDERABLE_TYPE when choosing configs + */ +#define GLX_EGL_APIS (EGL_OPENGL_BIT | EGL_OPENGL_ES_BIT | EGL_OPENGL_ES2_BIT) -struct visual_attribs -{ - /* X visual attribs */ - int id; - int klass; - int depth; - int redMask, greenMask, blueMask; - int colormapSize; - int bitsPerRGB; - - /* GL visual attribs */ - int supportsGL; - int transparentType; - int transparentRedValue; - int transparentGreenValue; - int transparentBlueValue; - int transparentAlphaValue; - int transparentIndexValue; - int bufferSize; - int level; - int render_type; - int doubleBuffer; - int stereo; - int auxBuffers; - int redSize, greenSize, blueSize, alphaSize; - int depthSize; - int stencilSize; - int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; - int numSamples, numMultisample; - int visualCaveat; -}; /** subclass of _EGLDriver */ struct GLX_egl_driver @@ -114,6 +85,21 @@ struct GLX_egl_display GLXFBConfig *fbconfigs; int glx_maj, glx_min; + + const char *extensions; + EGLBoolean have_1_3; + EGLBoolean have_make_current_read; + EGLBoolean have_fbconfig; + EGLBoolean have_pbuffer; + + /* GLX_SGIX_pbuffer */ + PFNGLXCREATEGLXPBUFFERSGIXPROC glXCreateGLXPbufferSGIX; + PFNGLXDESTROYGLXPBUFFERSGIXPROC glXDestroyGLXPbufferSGIX; + + /* workaround quirks of different GLX implementations */ + EGLBoolean single_buffered_quirk; + EGLBoolean glx_window_quirk; + }; @@ -139,6 +125,7 @@ struct GLX_egl_surface struct GLX_egl_config { _EGLConfig Base; /**< base class */ + EGLBoolean double_buffered; int index; }; @@ -173,288 +160,369 @@ GLX_egl_config_index(_EGLConfig *conf) return ((struct GLX_egl_config *) conf)->index; } -static GLboolean -get_visual_attribs(Display *dpy, XVisualInfo *vInfo, - struct visual_attribs *attribs) -{ - const char *ext = glXQueryExtensionsString(dpy, vInfo->screen); - int rgba; - memset(attribs, 0, sizeof(struct visual_attribs)); +#define MAP_ATTRIB(attr, memb) \ + { attr, offsetof(__GLcontextModes, memb) } + + +static const struct { + int attr; + int offset; +} fbconfig_attributes[] = { + /* table 3.1 of GLX 1.4 */ + MAP_ATTRIB(GLX_FBCONFIG_ID, fbconfigID), + MAP_ATTRIB(GLX_BUFFER_SIZE, rgbBits), + MAP_ATTRIB(GLX_LEVEL, level), + MAP_ATTRIB(GLX_DOUBLEBUFFER, doubleBufferMode), + MAP_ATTRIB(GLX_STEREO, stereoMode), + MAP_ATTRIB(GLX_AUX_BUFFERS, numAuxBuffers), + MAP_ATTRIB(GLX_RED_SIZE, redBits), + MAP_ATTRIB(GLX_GREEN_SIZE, greenBits), + MAP_ATTRIB(GLX_BLUE_SIZE, blueBits), + MAP_ATTRIB(GLX_ALPHA_SIZE, alphaBits), + MAP_ATTRIB(GLX_DEPTH_SIZE, depthBits), + MAP_ATTRIB(GLX_STENCIL_SIZE, stencilBits), + MAP_ATTRIB(GLX_ACCUM_RED_SIZE, accumRedBits), + MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE, accumGreenBits), + MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE, accumBlueBits), + MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE, accumAlphaBits), + MAP_ATTRIB(GLX_SAMPLE_BUFFERS, sampleBuffers), + MAP_ATTRIB(GLX_SAMPLES, samples), + MAP_ATTRIB(GLX_RENDER_TYPE, renderType), + MAP_ATTRIB(GLX_DRAWABLE_TYPE, drawableType), + MAP_ATTRIB(GLX_X_RENDERABLE, xRenderable), + MAP_ATTRIB(GLX_X_VISUAL_TYPE, visualType), + MAP_ATTRIB(GLX_CONFIG_CAVEAT, visualRating), + MAP_ATTRIB(GLX_TRANSPARENT_TYPE, transparentPixel), + MAP_ATTRIB(GLX_TRANSPARENT_INDEX_VALUE, transparentIndex), + MAP_ATTRIB(GLX_TRANSPARENT_RED_VALUE, transparentRed), + MAP_ATTRIB(GLX_TRANSPARENT_GREEN_VALUE, transparentGreen), + MAP_ATTRIB(GLX_TRANSPARENT_BLUE_VALUE, transparentBlue), + MAP_ATTRIB(GLX_TRANSPARENT_ALPHA_VALUE, transparentAlpha), + MAP_ATTRIB(GLX_MAX_PBUFFER_WIDTH, maxPbufferWidth), + MAP_ATTRIB(GLX_MAX_PBUFFER_HEIGHT, maxPbufferHeight), + MAP_ATTRIB(GLX_MAX_PBUFFER_PIXELS, maxPbufferPixels), + MAP_ATTRIB(GLX_VISUAL_ID, visualID), +}; - attribs->id = vInfo->visualid; -#if defined(__cplusplus) || defined(c_plusplus) - attribs->klass = vInfo->c_class; -#else - attribs->klass = vInfo->class; -#endif - attribs->depth = vInfo->depth; - attribs->redMask = vInfo->red_mask; - attribs->greenMask = vInfo->green_mask; - attribs->blueMask = vInfo->blue_mask; - attribs->colormapSize = vInfo->colormap_size; - attribs->bitsPerRGB = vInfo->bits_per_rgb; - - if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 || - !attribs->supportsGL) - return GL_FALSE; - glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize); - glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level); - glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba); - if (!rgba) - return GL_FALSE; - attribs->render_type = GLX_RGBA_BIT; - - glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); - if (!attribs->doubleBuffer) - return GL_FALSE; - - glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo); - glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers); - glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize); - glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize); - glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize); - glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize); - glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize); - glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize); - glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); - glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); - glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); - glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); - - /* get transparent pixel stuff */ - glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType); - if (attribs->transparentType == GLX_TRANSPARENT_RGB) { - glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); - glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); - glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); - glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); - } - else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { - glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); - } - /* multisample attribs */ -#ifdef GLX_ARB_multisample - if (ext && strstr(ext, "GLX_ARB_multisample")) { - glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample); - glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples); - } -#endif - else { - attribs->numSamples = 0; - attribs->numMultisample = 0; +static EGLBoolean +convert_fbconfig(Display *dpy, GLXFBConfig fbconfig, + struct GLX_egl_config *GLX_conf) +{ + __GLcontextModes mode; + int err = 0, attr, val, i; + + memset(&mode, 0, sizeof(mode)); + + for (i = 0; i < ARRAY_SIZE(fbconfig_attributes); i++) { + int offset = fbconfig_attributes[i].offset; + attr = fbconfig_attributes[i].attr; + err = glXGetFBConfigAttrib(dpy, fbconfig, attr, &val); + if (err) { + if (err == GLX_BAD_ATTRIBUTE) { + err = 0; + continue; + } + break; + } + *((int *) ((char *) &mode + offset)) = val; } + if (err) + return EGL_FALSE; -#if defined(GLX_EXT_visual_rating) - if (ext && strstr(ext, "GLX_EXT_visual_rating")) { - glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat); - } - else { - attribs->visualCaveat = GLX_NONE_EXT; + /* must have rgba bit */ + if (!(mode.renderType & GLX_RGBA_BIT)) + return EGL_FALSE; + + /* pixmap and pbuffer surfaces must be single-buffered in EGL */ + if (mode.doubleBufferMode) { + mode.drawableType &= ~(GLX_PIXMAP_BIT | GLX_PBUFFER_BIT); + if (!mode.drawableType) + return EGL_FALSE; } -#else - attribs->visualCaveat = 0; -#endif - return GL_TRUE; + mode.rgbMode = GL_TRUE; + mode.haveAccumBuffer = (mode.accumRedBits + + mode.accumGreenBits + + mode.accumBlueBits + + mode.accumAlphaBits > 0); + mode.haveDepthBuffer = (mode.depthBits > 0); + mode.haveStencilBuffer = (mode.stencilBits > 0); + + GLX_conf->double_buffered = (mode.doubleBufferMode != 0); + return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode, + GLX_EGL_APIS, GLX_EGL_APIS); } -#ifdef GLX_VERSION_1_3 + +static const struct { + int attr; + int offset; +} visual_attributes[] = { + /* table 3.7 of GLX 1.4 */ + /* no GLX_USE_GL */ + MAP_ATTRIB(GLX_BUFFER_SIZE, rgbBits), + MAP_ATTRIB(GLX_LEVEL, level), + MAP_ATTRIB(GLX_RGBA, rgbMode), + MAP_ATTRIB(GLX_DOUBLEBUFFER, doubleBufferMode), + MAP_ATTRIB(GLX_STEREO, stereoMode), + MAP_ATTRIB(GLX_AUX_BUFFERS, numAuxBuffers), + MAP_ATTRIB(GLX_RED_SIZE, redBits), + MAP_ATTRIB(GLX_GREEN_SIZE, greenBits), + MAP_ATTRIB(GLX_BLUE_SIZE, blueBits), + MAP_ATTRIB(GLX_ALPHA_SIZE, alphaBits), + MAP_ATTRIB(GLX_DEPTH_SIZE, depthBits), + MAP_ATTRIB(GLX_STENCIL_SIZE, stencilBits), + MAP_ATTRIB(GLX_ACCUM_RED_SIZE, accumRedBits), + MAP_ATTRIB(GLX_ACCUM_GREEN_SIZE, accumGreenBits), + MAP_ATTRIB(GLX_ACCUM_BLUE_SIZE, accumBlueBits), + MAP_ATTRIB(GLX_ACCUM_ALPHA_SIZE, accumAlphaBits), + MAP_ATTRIB(GLX_SAMPLE_BUFFERS, sampleBuffers), + MAP_ATTRIB(GLX_SAMPLES, samples), + MAP_ATTRIB(GLX_FBCONFIG_ID, fbconfigID), + /* GLX_EXT_visual_rating */ + MAP_ATTRIB(GLX_VISUAL_CAVEAT_EXT, visualRating), +}; + static int -glx_token_to_visual_class(int visual_type) -{ - switch (visual_type) { - case GLX_TRUE_COLOR: - return TrueColor; - case GLX_DIRECT_COLOR: - return DirectColor; - case GLX_PSEUDO_COLOR: - return PseudoColor; - case GLX_STATIC_COLOR: - return StaticColor; - case GLX_GRAY_SCALE: - return GrayScale; - case GLX_STATIC_GRAY: - return StaticGray; - case GLX_NONE: +get_visual_type(const XVisualInfo *vis) +{ + int klass; + +#if defined(__cplusplus) || defined(c_plusplus) + klass = vis->c_class; +#else + klass = vis->class; +#endif + + switch (klass) { + case TrueColor: + return GLX_TRUE_COLOR; + case DirectColor: + return GLX_DIRECT_COLOR; + case PseudoColor: + return GLX_PSEUDO_COLOR; + case StaticColor: + return GLX_STATIC_COLOR; + case GrayScale: + return GLX_GRAY_SCALE; + case StaticGray: + return GLX_STATIC_GRAY; default: - return None; + return GLX_NONE; } } -static int -get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, - struct visual_attribs *attribs) -{ - int visual_type; - int fbconfig_id; - memset(attribs, 0, sizeof(struct visual_attribs)); +static EGLBoolean +convert_visual(Display *dpy, XVisualInfo *vinfo, + struct GLX_egl_config *GLX_conf) +{ + __GLcontextModes mode; + int err, attr, val, i; - glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &fbconfig_id); + /* the visual must support OpenGL */ + err = glXGetConfig(dpy, vinfo, GLX_USE_GL, &val); + if (err || !val) + return EGL_FALSE; - glXGetFBConfigAttrib(dpy, fbconfig, GLX_VISUAL_ID, &attribs->id); + memset(&mode, 0, sizeof(mode)); + + for (i = 0; i < ARRAY_SIZE(visual_attributes); i++) { + int offset = visual_attributes[i].offset; + attr = visual_attributes[i].attr; + err = glXGetConfig(dpy, vinfo, attr, &val); + if (err) { + if (err == GLX_BAD_ATTRIBUTE) { + err = 0; + continue; + } + break; + } + *((int *) ((char *) &mode + offset)) = val; + } + if (err) + return EGL_FALSE; -#if 0 - attribs->depth = vInfo->depth; - attribs->redMask = vInfo->red_mask; - attribs->greenMask = vInfo->green_mask; - attribs->blueMask = vInfo->blue_mask; - attribs->colormapSize = vInfo->colormap_size; - attribs->bitsPerRGB = vInfo->bits_per_rgb; -#endif + /* must be RGB mode */ + if (!mode.rgbMode) + return EGL_FALSE; - glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type); - attribs->klass = glx_token_to_visual_class(visual_type); - - glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type); - if (!(attribs->render_type & GLX_RGBA_BIT)) - return 0; - - glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); - if (!attribs->doubleBuffer) - return 0; - - glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers); - - glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize); - - glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); - - /* get transparent pixel stuff */ - glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType); - if (attribs->transparentType == GLX_TRANSPARENT_RGB) { - glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); - } - else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { - glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); - } + mode.visualID = vinfo->visualid; + mode.visualType = get_visual_type(vinfo); + mode.redMask = vinfo->red_mask; + mode.greenMask = vinfo->green_mask; + mode.blueMask = vinfo->blue_mask; + + mode.drawableType = GLX_WINDOW_BIT; + /* pixmap surfaces must be single-buffered in EGL */ + if (!mode.doubleBufferMode) + mode.drawableType |= GLX_PIXMAP_BIT; + + mode.renderType = GLX_RGBA_BIT; + mode.xRenderable = GL_TRUE; + mode.haveAccumBuffer = (mode.accumRedBits + + mode.accumGreenBits + + mode.accumBlueBits + + mode.accumAlphaBits > 0); + mode.haveDepthBuffer = (mode.depthBits > 0); + mode.haveStencilBuffer = (mode.stencilBits > 0); + + GLX_conf->double_buffered = (mode.doubleBufferMode != 0); + return _eglConfigFromContextModesRec(&GLX_conf->Base, &mode, + GLX_EGL_APIS, GLX_EGL_APIS); +} - glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples); - glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); +static void +fix_config(struct GLX_egl_display *GLX_dpy, struct GLX_egl_config *GLX_conf) +{ + _EGLConfig *conf = &GLX_conf->Base; + EGLint surface_type, r, g, b, a; + + surface_type = GET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE); + if (!GLX_conf->double_buffered && GLX_dpy->single_buffered_quirk) { + /* some GLX impls do not like single-buffered window surface */ + surface_type &= ~EGL_WINDOW_BIT; + /* pbuffer bit is usually not set */ + if (GLX_dpy->have_pbuffer) + surface_type |= EGL_PBUFFER_BIT; + SET_CONFIG_ATTRIB(conf, EGL_SURFACE_TYPE, surface_type); + } - if (attribs->id == 0) { - attribs->id = fbconfig_id; - return EGL_PBUFFER_BIT | EGL_PIXMAP_BIT; + /* no visual attribs unless window bit is set */ + if (!(surface_type & EGL_WINDOW_BIT)) { + SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_ID, 0); + SET_CONFIG_ATTRIB(conf, EGL_NATIVE_VISUAL_TYPE, EGL_NONE); } - return EGL_WINDOW_BIT; + /* make sure buffer size is set correctly */ + r = GET_CONFIG_ATTRIB(conf, EGL_RED_SIZE); + g = GET_CONFIG_ATTRIB(conf, EGL_GREEN_SIZE); + b = GET_CONFIG_ATTRIB(conf, EGL_BLUE_SIZE); + a = GET_CONFIG_ATTRIB(conf, EGL_ALPHA_SIZE); + SET_CONFIG_ATTRIB(conf, EGL_BUFFER_SIZE, r + g + b + a); } -#endif static EGLBoolean -create_configs(_EGLDisplay *disp, struct GLX_egl_display *GLX_dpy) +create_configs(_EGLDisplay *dpy, struct GLX_egl_display *GLX_dpy, + EGLint screen) { - XVisualInfo theTemplate; - int numVisuals; - long mask; - int i; - struct visual_attribs attribs; + EGLint num_configs = 0, i; + EGLint id = 1; - GLX_dpy->fbconfigs = NULL; - -#ifdef GLX_VERSION_1_3 - /* get list of all fbconfigs on this screen */ - GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, DefaultScreen(GLX_dpy->dpy), &numVisuals); + if (GLX_dpy->have_fbconfig) { + GLX_dpy->fbconfigs = glXGetFBConfigs(GLX_dpy->dpy, screen, &num_configs); + } + else { + XVisualInfo vinfo_template; + long mask; - if (numVisuals == 0) { - GLX_dpy->fbconfigs = NULL; - goto xvisual; + vinfo_template.screen = screen; + mask = VisualScreenMask; + GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &vinfo_template, + &num_configs); } - for (i = 0; i < numVisuals; i++) { - struct GLX_egl_config *config; - int bit; + if (!num_configs) + return EGL_FALSE; - bit = get_fbconfig_attribs(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &attribs); - if (!bit) + for (i = 0; i < num_configs; i++) { + struct GLX_egl_config *GLX_conf, template; + EGLBoolean ok; + + memset(&template, 0, sizeof(template)); + _eglInitConfig(&template.Base, id); + if (GLX_dpy->have_fbconfig) + ok = convert_fbconfig(GLX_dpy->dpy, GLX_dpy->fbconfigs[i], &template); + else + ok = convert_visual(GLX_dpy->dpy, &GLX_dpy->visuals[i], &template); + if (!ok) + continue; + + fix_config(GLX_dpy, &template); + if (!_eglValidateConfig(&template.Base, EGL_FALSE)) { + _eglLog(_EGL_DEBUG, "GLX: failed to validate config %d", i); continue; + } + + GLX_conf = CALLOC_STRUCT(GLX_egl_config); + if (GLX_conf) { + memcpy(GLX_conf, &template, sizeof(template)); + GLX_conf->index = i; - config = CALLOC_STRUCT(GLX_egl_config); - - config->index = i; - _eglInitConfig(&config->Base, (i+1)); - SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id); - SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples); - SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample); - SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis); - SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis); - SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, bit); - - /* XXX possibly other things to init... */ - - _eglAddConfig(disp, &config->Base); + _eglAddConfig(dpy, &GLX_conf->Base); + id++; + } } - goto end; -#endif + return EGL_TRUE; +} + + +static void +check_extensions(struct GLX_egl_display *GLX_dpy, EGLint screen) +{ + GLX_dpy->extensions = + glXQueryExtensionsString(GLX_dpy->dpy, screen); + if (GLX_dpy->extensions) { + /* glXGetProcAddress is assumed */ + + if (strstr(GLX_dpy->extensions, "GLX_SGI_make_current_read")) { + /* GLX 1.3 entry points are used */ + GLX_dpy->have_make_current_read = EGL_TRUE; + } -xvisual: - /* get list of all visuals on this screen */ - theTemplate.screen = DefaultScreen(GLX_dpy->dpy); - mask = VisualScreenMask; - GLX_dpy->visuals = XGetVisualInfo(GLX_dpy->dpy, mask, &theTemplate, &numVisuals); - - for (i = 0; i < numVisuals; i++) { - struct GLX_egl_config *config; - - if (!get_visual_attribs(GLX_dpy->dpy, &GLX_dpy->visuals[i], &attribs)) - continue; - - config = CALLOC_STRUCT(GLX_egl_config); - - config->index = i; - _eglInitConfig(&config->Base, (i+1)); - SET_CONFIG_ATTRIB(&config->Base, EGL_NATIVE_VISUAL_ID, attribs.id); - SET_CONFIG_ATTRIB(&config->Base, EGL_BUFFER_SIZE, attribs.bufferSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_RED_SIZE, attribs.redSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_GREEN_SIZE, attribs.greenSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_BLUE_SIZE, attribs.blueSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_ALPHA_SIZE, attribs.alphaSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_DEPTH_SIZE, attribs.depthSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_STENCIL_SIZE, attribs.stencilSize); - SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLES, attribs.numSamples); - SET_CONFIG_ATTRIB(&config->Base, EGL_SAMPLE_BUFFERS, attribs.numMultisample); - SET_CONFIG_ATTRIB(&config->Base, EGL_CONFORMANT, all_apis); - SET_CONFIG_ATTRIB(&config->Base, EGL_RENDERABLE_TYPE, all_apis); - SET_CONFIG_ATTRIB(&config->Base, EGL_SURFACE_TYPE, - (EGL_WINDOW_BIT /*| EGL_PBUFFER_BIT | EGL_PIXMAP_BIT*/)); - - /* XXX possibly other things to init... */ - - _eglAddConfig(disp, &config->Base); + if (strstr(GLX_dpy->extensions, "GLX_SGIX_fbconfig")) { + /* GLX 1.3 entry points are used */ + GLX_dpy->have_fbconfig = EGL_TRUE; + } + + if (strstr(GLX_dpy->extensions, "GLX_SGIX_pbuffer")) { + GLX_dpy->glXCreateGLXPbufferSGIX = (PFNGLXCREATEGLXPBUFFERSGIXPROC) + glXGetProcAddress((const GLubyte *) "glXCreateGLXPbufferSGIX"); + GLX_dpy->glXDestroyGLXPbufferSGIX = (PFNGLXDESTROYGLXPBUFFERSGIXPROC) + glXGetProcAddress((const GLubyte *) "glXDestroyGLXPbufferSGIX"); + + if (GLX_dpy->glXCreateGLXPbufferSGIX && + GLX_dpy->glXDestroyGLXPbufferSGIX && + GLX_dpy->have_fbconfig) + GLX_dpy->have_pbuffer = EGL_TRUE; + } } -end: - return EGL_TRUE; + if (GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3) { + GLX_dpy->have_1_3 = EGL_TRUE; + GLX_dpy->have_make_current_read = EGL_TRUE; + GLX_dpy->have_fbconfig = EGL_TRUE; + GLX_dpy->have_pbuffer = EGL_TRUE; + } +} + + +static void +check_quirks(struct GLX_egl_display *GLX_dpy, EGLint screen) +{ + const char *vendor; + + GLX_dpy->single_buffered_quirk = EGL_TRUE; + GLX_dpy->glx_window_quirk = EGL_TRUE; + + vendor = glXGetClientString(GLX_dpy->dpy, GLX_VENDOR); + if (vendor && strstr(vendor, "NVIDIA")) { + vendor = glXQueryServerString(GLX_dpy->dpy, screen, GLX_VENDOR); + if (vendor && strstr(vendor, "NVIDIA")) { + _eglLog(_EGL_DEBUG, "disable quirks"); + GLX_dpy->single_buffered_quirk = EGL_FALSE; + GLX_dpy->glx_window_quirk = EGL_FALSE; + } + } } + /** * Called via eglInitialize(), GLX_drv->API.Initialize(). */ @@ -478,17 +546,33 @@ GLX_eglInitialize(_EGLDriver *drv, _EGLDisplay *disp, } } - disp->DriverData = (void *) GLX_dpy; - disp->ClientAPIsMask = all_apis; + if (!glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min)) { + _eglLog(_EGL_WARNING, "GLX: glXQueryVersion failed"); + if (!disp->NativeDisplay) + XCloseDisplay(GLX_dpy->dpy); + free(GLX_dpy); + return EGL_FALSE; + } - glXQueryVersion(GLX_dpy->dpy, &GLX_dpy->glx_maj, &GLX_dpy->glx_min); + check_extensions(GLX_dpy, DefaultScreen(GLX_dpy->dpy)); + check_quirks(GLX_dpy, DefaultScreen(GLX_dpy->dpy)); + + create_configs(disp, GLX_dpy, DefaultScreen(GLX_dpy->dpy)); + if (!disp->NumConfigs) { + _eglLog(_EGL_WARNING, "GLX: failed to create any config"); + if (!disp->NativeDisplay) + XCloseDisplay(GLX_dpy->dpy); + free(GLX_dpy); + return EGL_FALSE; + } + + disp->DriverData = (void *) GLX_dpy; + disp->ClientAPIsMask = GLX_EGL_APIS; /* we're supporting EGL 1.4 */ *major = 1; *minor = 4; - create_configs(disp, GLX_dpy); - return EGL_TRUE; } -- cgit v1.2.3 From c407c7024495b19eec5ce978b611c7359c247f81 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 18:22:33 +0800 Subject: egl_glx: Clean up surface functions. Separete Drawable and GLXDrawable. Add support for pbuffer and pixmap surfaces on GLX <= 1.3. Remove surface binding code that will never work. Signed-off-by: Chia-I Wu --- src/egl/drivers/glx/egl_glx.c | 205 ++++++++++++++++++++++-------------------- 1 file changed, 106 insertions(+), 99 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 404c998dcb..e09cbe744e 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -33,20 +33,12 @@ * Authors: Alan Hourihane */ -/* - * TODO: - * - * test eglBind/ReleaseTexImage - */ - - #include #include #include +#include #include -#include "glxclient.h" - #include "eglconfigutil.h" #include "eglconfig.h" #include "eglcontext.h" @@ -117,7 +109,8 @@ struct GLX_egl_surface { _EGLSurface Base; /**< base class */ - GLXDrawable drawable; + Drawable drawable; + GLXDrawable glx_drawable; }; @@ -673,8 +666,8 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, if (!_eglMakeCurrent(drv, disp, dsurf, rsurf, ctx)) return EGL_FALSE; - ddraw = (GLX_dsurf) ? GLX_dsurf->drawable : None; - rdraw = (GLX_rsurf) ? GLX_rsurf->drawable : None; + ddraw = (GLX_dsurf) ? GLX_dsurf->glx_drawable : None; + rdraw = (GLX_rsurf) ? GLX_rsurf->glx_drawable : None; cctx = (GLX_ctx) ? GLX_ctx->context : NULL; #ifdef GLX_VERSION_1_3 @@ -726,6 +719,20 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, } GLX_surf->drawable = window; + + if (GLX_dpy->have_1_3 && !GLX_dpy->glx_window_quirk) + GLX_surf->glx_drawable = + glXCreateWindow(GLX_dpy->dpy, + GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], + GLX_surf->drawable, NULL); + else + GLX_surf->glx_drawable = GLX_surf->drawable; + + if (!GLX_surf->glx_drawable) { + free(GLX_surf); + return NULL; + } + get_drawable_size(GLX_dpy->dpy, window, &width, &height); GLX_surf->Base.Width = width; GLX_surf->Base.Height = height; @@ -733,18 +740,13 @@ GLX_eglCreateWindowSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, return &GLX_surf->Base; } -#ifdef GLX_VERSION_1_3 static _EGLSurface * GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, NativePixmapType pixmap, const EGLint *attrib_list) { struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); struct GLX_egl_surface *GLX_surf; - int i; - - /* GLX must >= 1.3 */ - if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3)) - return NULL; + uint width, height; GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) { @@ -758,25 +760,39 @@ GLX_eglCreatePixmapSurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, return NULL; } - for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) { - switch (attrib_list[i]) { - /* no attribs at this time */ - default: - _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface"); - free(GLX_surf); - return NULL; + GLX_surf->drawable = pixmap; + + if (GLX_dpy->have_1_3) { + GLX_surf->glx_drawable = + glXCreatePixmap(GLX_dpy->dpy, + GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], + GLX_surf->drawable, NULL); + } + else if (GLX_dpy->have_fbconfig) { + GLXFBConfig fbconfig = GLX_dpy->fbconfigs[GLX_egl_config_index(conf)]; + XVisualInfo *vinfo = glXGetVisualFromFBConfig(GLX_dpy->dpy, fbconfig); + if (vinfo) { + GLX_surf->glx_drawable = + glXCreateGLXPixmap(GLX_dpy->dpy, vinfo, GLX_surf->drawable); + XFree(vinfo); } } + else { + GLX_surf->glx_drawable = + glXCreateGLXPixmap(GLX_dpy->dpy, + &GLX_dpy->visuals[GLX_egl_config_index(conf)], + GLX_surf->drawable); + } - GLX_surf->drawable = - glXCreatePixmap(GLX_dpy->dpy, - GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], - pixmap, NULL); - if (!GLX_surf->drawable) { + if (!GLX_surf->glx_drawable) { free(GLX_surf); return NULL; } + get_drawable_size(GLX_dpy->dpy, pixmap, &width, &height); + GLX_surf->Base.Width = width; + GLX_surf->Base.Height = height; + return &GLX_surf->Base; } @@ -787,11 +803,7 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); struct GLX_egl_surface *GLX_surf; int attribs[5]; - int i = 0, j = 0; - - /* GLX must >= 1.3 */ - if (!(GLX_dpy->glx_maj == 1 && GLX_dpy->glx_min >= 3)) - return NULL; + int i; GLX_surf = CALLOC_STRUCT(GLX_egl_surface); if (!GLX_surf) { @@ -805,33 +817,44 @@ GLX_eglCreatePbufferSurface(_EGLDriver *drv, _EGLDisplay *disp, return NULL; } - while(attrib_list[i] != EGL_NONE) { - switch (attrib_list[i]) { - case EGL_WIDTH: - attribs[j++] = GLX_PBUFFER_WIDTH; - attribs[j++] = attrib_list[i+1]; - break; - case EGL_HEIGHT: - attribs[j++] = GLX_PBUFFER_HEIGHT; - attribs[j++] = attrib_list[i+1]; - break; + i = 0; + attribs[i] = None; + + GLX_surf->drawable = None; + + if (GLX_dpy->have_1_3) { + /* put geometry in attribs */ + if (GLX_surf->Base.Width) { + attribs[i++] = GLX_PBUFFER_WIDTH; + attribs[i++] = GLX_surf->Base.Width; + } + if (GLX_surf->Base.Height) { + attribs[i++] = GLX_PBUFFER_HEIGHT; + attribs[i++] = GLX_surf->Base.Height; } - i++; + attribs[i] = None; + + GLX_surf->glx_drawable = + glXCreatePbuffer(GLX_dpy->dpy, + GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], + attribs); + } + else if (GLX_dpy->have_pbuffer) { + GLX_surf->glx_drawable = GLX_dpy->glXCreateGLXPbufferSGIX( + GLX_dpy->dpy, + GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], + GLX_surf->Base.Width, + GLX_surf->Base.Height, + attribs); } - attribs[j++] = 0; - GLX_surf->drawable = - glXCreatePbuffer(GLX_dpy->dpy, - GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], - attribs); - if (!GLX_surf->drawable) { + if (!GLX_surf->glx_drawable) { free(GLX_surf); return NULL; } return &GLX_surf->Base; } -#endif static EGLBoolean GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) @@ -839,15 +862,35 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); if (!_eglIsSurfaceBound(surf)) { struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf); - switch (surf->Type) { - case EGL_PBUFFER_BIT: - glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->drawable); - break; - case EGL_PIXMAP_BIT: - glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->drawable); - break; - default: - break; + + if (GLX_dpy->have_1_3) { + switch (surf->Type) { + case EGL_WINDOW_BIT: + if (!GLX_dpy->glx_window_quirk) + glXDestroyWindow(GLX_dpy->dpy, GLX_surf->glx_drawable); + break; + case EGL_PBUFFER_BIT: + glXDestroyPbuffer(GLX_dpy->dpy, GLX_surf->glx_drawable); + break; + case EGL_PIXMAP_BIT: + glXDestroyPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable); + break; + default: + break; + } + } + else { + switch (surf->Type) { + case EGL_PBUFFER_BIT: + GLX_dpy->glXDestroyGLXPbufferSGIX(GLX_dpy->dpy, + GLX_surf->glx_drawable); + break; + case EGL_PIXMAP_BIT: + glXDestroyGLXPixmap(GLX_dpy->dpy, GLX_surf->glx_drawable); + break; + default: + break; + } } free(surf); } @@ -856,45 +899,13 @@ GLX_eglDestroySurface(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf) } -static EGLBoolean -GLX_eglBindTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint buffer) -{ - struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); - struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf); - - /* buffer ?? */ - glXBindTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable, - GLX_FRONT_LEFT_EXT, NULL); - - return EGL_TRUE; -} - - -static EGLBoolean -GLX_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, - EGLint buffer) -{ - struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); - struct GLX_egl_surface *GLX_surf = GLX_egl_surface(surf); - - /* buffer ?? */ - glXReleaseTexImageEXT(GLX_dpy->dpy, GLX_surf->drawable, - GLX_FRONT_LEFT_EXT); - - return EGL_TRUE; -} - - static EGLBoolean GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) { struct GLX_egl_display *GLX_dpy = GLX_egl_display(disp); struct GLX_egl_surface *GLX_surf = GLX_egl_surface(draw); - _eglLog(_EGL_DEBUG, "GLX: EGL SwapBuffers 0x%x",draw); - - glXSwapBuffers(GLX_dpy->dpy, GLX_surf->drawable); + glXSwapBuffers(GLX_dpy->dpy, GLX_surf->glx_drawable); return EGL_TRUE; } @@ -949,13 +960,9 @@ _eglMain(const char *args) GLX_drv->Base.API.CreateContext = GLX_eglCreateContext; GLX_drv->Base.API.MakeCurrent = GLX_eglMakeCurrent; GLX_drv->Base.API.CreateWindowSurface = GLX_eglCreateWindowSurface; -#ifdef GLX_VERSION_1_3 GLX_drv->Base.API.CreatePixmapSurface = GLX_eglCreatePixmapSurface; GLX_drv->Base.API.CreatePbufferSurface = GLX_eglCreatePbufferSurface; -#endif GLX_drv->Base.API.DestroySurface = GLX_eglDestroySurface; - GLX_drv->Base.API.BindTexImage = GLX_eglBindTexImage; - GLX_drv->Base.API.ReleaseTexImage = GLX_eglReleaseTexImage; GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers; GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress; -- cgit v1.2.3 From a20643657723094197620976402aeec2f40a84a0 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 18:23:41 +0800 Subject: egl_glx: Clean up context functions. This lifts the requirement that a context must be direct. Signed-off-by: Chia-I Wu --- src/egl/drivers/glx/egl_glx.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index e09cbe744e..aa0c8c88b1 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -616,8 +616,7 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, return NULL; } -#ifdef GLX_VERSION_1_3 - if (GLX_dpy->fbconfigs) + if (GLX_dpy->have_fbconfig) GLX_ctx->context = glXCreateNewContext(GLX_dpy->dpy, GLX_dpy->fbconfigs[GLX_egl_config_index(conf)], @@ -625,7 +624,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, GLX_ctx_shared ? GLX_ctx_shared->context : NULL, GL_TRUE); else -#endif GLX_ctx->context = glXCreateContext(GLX_dpy->dpy, &GLX_dpy->visuals[GLX_egl_config_index(conf)], @@ -636,15 +634,6 @@ GLX_eglCreateContext(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf, return NULL; } -#if 1 - /* (maybe?) need to have a direct rendering context */ - if (!glXIsDirect(GLX_dpy->dpy, GLX_ctx->context)) { - glXDestroyContext(GLX_dpy->dpy, GLX_ctx->context); - free(GLX_ctx); - return NULL; - } -#endif - return &GLX_ctx->Base; } @@ -670,13 +659,10 @@ GLX_eglMakeCurrent(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf, rdraw = (GLX_rsurf) ? GLX_rsurf->glx_drawable : None; cctx = (GLX_ctx) ? GLX_ctx->context : NULL; -#ifdef GLX_VERSION_1_3 - if (glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx)) - return EGL_TRUE; -#endif - - if (ddraw == rdraw && glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx)) - return EGL_TRUE; + if (GLX_dpy->have_make_current_read) + return glXMakeContextCurrent(GLX_dpy->dpy, ddraw, rdraw, cctx); + else if (ddraw == rdraw) + return glXMakeCurrent(GLX_dpy->dpy, ddraw, cctx); return EGL_FALSE; } -- cgit v1.2.3 From 7ffe64a7ae912974f9c2da43dd362cd832e2ba99 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 1 Oct 2009 18:23:58 +0800 Subject: egl_glx: Clean up eglGetProcAddress. Signed-off-by: Chia-I Wu --- src/egl/drivers/glx/egl_glx.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index aa0c8c88b1..71b26181c1 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -37,7 +37,6 @@ #include #include #include -#include #include "eglconfigutil.h" #include "eglconfig.h" @@ -902,21 +901,7 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw) static _EGLProc GLX_eglGetProcAddress(const char *procname) { - /* This is a bit of a hack to get at the gallium/Mesa state tracker - * function st_get_proc_address(). This will probably change at - * some point. - */ - _EGLProc (*get_proc_addr)(const char *procname); - _EGLProc proc_addr; - get_proc_addr = dlsym(NULL, "st_get_proc_address"); - if (get_proc_addr) - return get_proc_addr(procname); - - proc_addr = glXGetProcAddress((const GLubyte *)procname); - if (proc_addr) - return proc_addr; - - return (_EGLProc)dlsym(NULL, procname); + return (_EGLProc) glXGetProcAddress((const GLubyte *) procname); } -- cgit v1.2.3 From 60cf250d4705d5005399a53ab334fbc10b4bf9c4 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Fri, 2 Oct 2009 10:38:14 +0800 Subject: egl_glx: Add support for eglWaitClient and eglWaitNative. Signed-off-by: Chia-I Wu --- src/egl/drivers/glx/egl_glx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/egl/drivers/glx/egl_glx.c b/src/egl/drivers/glx/egl_glx.c index 71b26181c1..96292b0e9e 100644 --- a/src/egl/drivers/glx/egl_glx.c +++ b/src/egl/drivers/glx/egl_glx.c @@ -904,6 +904,21 @@ GLX_eglGetProcAddress(const char *procname) return (_EGLProc) glXGetProcAddress((const GLubyte *) procname); } +static EGLBoolean +GLX_eglWaitClient(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx) +{ + glXWaitGL(); + return EGL_TRUE; +} + +static EGLBoolean +GLX_eglWaitNative(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine) +{ + if (engine != EGL_CORE_NATIVE_ENGINE) + return _eglError(EGL_BAD_PARAMETER, "eglWaitNative"); + glXWaitX(); + return EGL_TRUE; +} static void GLX_Unload(_EGLDriver *drv) @@ -936,6 +951,8 @@ _eglMain(const char *args) GLX_drv->Base.API.DestroySurface = GLX_eglDestroySurface; GLX_drv->Base.API.SwapBuffers = GLX_eglSwapBuffers; GLX_drv->Base.API.GetProcAddress = GLX_eglGetProcAddress; + GLX_drv->Base.API.WaitClient = GLX_eglWaitClient; + GLX_drv->Base.API.WaitNative = GLX_eglWaitNative; GLX_drv->Base.Name = "GLX"; GLX_drv->Base.Unload = GLX_Unload; -- cgit v1.2.3 From 4e2bdd66352cf9a2e951bb21151edee25c8c0a8c Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sun, 18 Oct 2009 13:15:30 +0800 Subject: progs/egl: Add support for pixmap and pbuffer surface to xeglgears. Signed-off-by: Chia-I Wu --- progs/egl/xeglgears.c | 399 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 289 insertions(+), 110 deletions(-) diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index 72ed005283..614a625603 100644 --- a/progs/egl/xeglgears.c +++ b/progs/egl/xeglgears.c @@ -95,9 +95,6 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; -static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ - - /* * * Draw a gear wheel. You'll probably want to call this function when @@ -327,122 +324,235 @@ init(void) } -/* - * Create an RGB, double-buffered X window. - * Return the window and context handles. - */ -static void -make_x_window(Display *x_dpy, EGLDisplay egl_dpy, - const char *name, - int x, int y, int width, int height, - Window *winRet, - EGLContext *ctxRet, - EGLSurface *surfRet) -{ - static const EGLint attribs[] = { - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - /*EGL_DOUBLEBUFFER,*/ - EGL_DEPTH_SIZE, 1, - EGL_NONE - }; +struct egl_manager { + EGLNativeDisplayType xdpy; + EGLNativeWindowType xwin; + EGLNativePixmapType xpix; - int scrnum; - XSetWindowAttributes attr; - unsigned long mask; - Window root; - Window win; - XVisualInfo *visInfo, visTemplate; - int num_visuals; + EGLDisplay dpy; + EGLConfig conf; EGLContext ctx; - EGLConfig config; - EGLint num_configs, vid; - scrnum = DefaultScreen( x_dpy ); - root = RootWindow( x_dpy, scrnum ); + EGLSurface win; + EGLSurface pix; + EGLSurface pbuf; - if (fullscreen) { - x = 0; y = 0; - width = DisplayWidth( x_dpy, scrnum ); - height = DisplayHeight( x_dpy, scrnum ); + EGLBoolean verbose; + EGLint major, minor; +}; + +static struct egl_manager * +egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list, + EGLBoolean verbose) +{ + struct egl_manager *eman; + const char *ver; + EGLint num_conf; + + eman = calloc(1, sizeof(*eman)); + if (!eman) + return NULL; + + eman->verbose = verbose; + eman->xdpy = xdpy; + + eman->dpy = eglGetDisplay(eman->xdpy); + if (eman->dpy == EGL_NO_DISPLAY) { + printf("eglGetDisplay() failed\n"); + free(eman); + return NULL; } - if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { - printf("Error: couldn't get an EGL visual config\n"); - exit(1); + if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) { + printf("eglInitialize() failed\n"); + free(eman); + return NULL; } - if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { - printf("Error: eglGetConfigAttrib() failed\n"); - exit(1); + ver = eglQueryString(eman->dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", ver); + + if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) || + !num_conf) { + printf("eglChooseConfig() failed\n"); + eglTerminate(eman->dpy); + free(eman); + return NULL; } - /* The X window visual must match the EGL config */ - visTemplate.visualid = vid; - visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); - if (!visInfo) { - printf("Error: couldn't get X visual\n"); - exit(1); + eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL); + if (eman->ctx == EGL_NO_CONTEXT) { + printf("eglCreateContext() failed\n"); + eglTerminate(eman->dpy); + free(eman); + return NULL; + } + + return eman; +} + +static EGLBoolean +egl_manager_create_window(struct egl_manager *eman, const char *name, + EGLint w, EGLint h, EGLBoolean need_surface, + EGLBoolean fullscreen, const EGLint *attrib_list) +{ + XVisualInfo vinfo_template, *vinfo = NULL; + EGLint val, num_vinfo; + Window root; + XSetWindowAttributes attrs; + unsigned long mask; + EGLint x = 0, y = 0; + + if (!eglGetConfigAttrib(eman->dpy, eman->conf, + EGL_NATIVE_VISUAL_ID, &val)) { + printf("eglGetConfigAttrib() failed\n"); + return EGL_FALSE; + } + if (val) { + vinfo_template.visualid = (VisualID) val; + vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo); + } + /* try harder if window surface is not needed */ + if (!vinfo && !need_surface && + eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) { + if (val == 32) + val = 24; + vinfo_template.depth = val; + vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo); + } + + if (!vinfo) { + printf("XGetVisualInfo() failed\n"); + return EGL_FALSE; + } + + root = DefaultRootWindow(eman->xdpy); + if (fullscreen) { + x = y = 0; + w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy)); + h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy)); } /* window attributes */ - attr.background_pixel = 0; - attr.border_pixel = 0; - attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); - attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - attr.override_redirect = fullscreen; + attrs.background_pixel = 0; + attrs.border_pixel = 0; + attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone); + attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attrs.override_redirect = fullscreen; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; - win = XCreateWindow( x_dpy, root, 0, 0, width, height, - 0, visInfo->depth, InputOutput, - visInfo->visual, mask, &attr ); + eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h, + 0, vinfo->depth, InputOutput, + vinfo->visual, mask, &attrs); + XFree(vinfo); /* set hints and properties */ { XSizeHints sizehints; sizehints.x = x; sizehints.y = y; - sizehints.width = width; - sizehints.height = height; + sizehints.width = w; + sizehints.height = h; sizehints.flags = USSize | USPosition; - XSetNormalHints(x_dpy, win, &sizehints); - XSetStandardProperties(x_dpy, win, name, name, - None, (char **)NULL, 0, &sizehints); + XSetNormalHints(eman->xdpy, eman->xwin, &sizehints); + XSetStandardProperties(eman->xdpy, eman->xwin, name, name, + None, (char **)NULL, 0, &sizehints); } - eglBindAPI(EGL_OPENGL_API); + if (need_surface) { + eman->win = eglCreateWindowSurface(eman->dpy, eman->conf, + eman->xwin, attrib_list); + if (eman->win == EGL_NO_SURFACE) { + printf("eglCreateWindowSurface() failed\n"); + XDestroyWindow(eman->xdpy, eman->xwin); + eman->xwin = None; + return EGL_FALSE; + } + } + + XMapWindow(eman->xdpy, eman->xwin); + + return EGL_TRUE; +} - ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); - if (!ctx) { - printf("Error: glXCreateContext failed\n"); - exit(1); +static EGLBoolean +egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin, + EGLBoolean need_surface, const EGLint *attrib_list) +{ + XWindowAttributes attrs; + + if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) { + printf("XGetWindowAttributes() failed\n"); + return EGL_FALSE; + } + + eman->xpix = XCreatePixmap(eman->xdpy, xwin, + attrs.width, attrs.height, attrs.depth); + + if (need_surface) { + eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf, + eman->xpix, attrib_list); + if (eman->pix == EGL_NO_SURFACE) { + printf("eglCreatePixmapSurface() failed\n"); + XFreePixmap(eman->xdpy, eman->xpix); + eman->xpix = None; + return EGL_FALSE; + } } - *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + return EGL_TRUE; +} - XFree(visInfo); +static EGLBoolean +egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list) +{ + eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list); + if (eman->pbuf == EGL_NO_SURFACE) { + printf("eglCreatePbufferSurface() failed\n"); + return EGL_FALSE; + } - *winRet = win; - *ctxRet = ctx; + return EGL_TRUE; } +static void +egl_manager_destroy(struct egl_manager *eman) +{ + eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglTerminate(eman->dpy); + + if (eman->xwin != None) + XDestroyWindow(eman->xdpy, eman->xwin); + if (eman->xpix != None) + XFreePixmap(eman->xdpy, eman->xpix); + + free(eman); +} static void -event_loop(Display *dpy, Window win, - EGLDisplay egl_dpy, EGLSurface egl_surf) +event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h) { + GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL); + EGLint orig_w = w, orig_h = h; + + if (surface_type == EGL_PBUFFER_BIT) + printf("there will be no screen update if " + "eglCopyBuffers() is not implemented\n"); + while (1) { - while (XPending(dpy) > 0) { + while (XPending(eman->xdpy) > 0) { XEvent event; - XNextEvent(dpy, &event); + XNextEvent(eman->xdpy, &event); switch (event.type) { - case Expose: + case Expose: /* we'll redraw below */ - break; - case ConfigureNotify: - reshape(event.xconfigure.width, event.xconfigure.height); - break; + break; + case ConfigureNotify: + w = event.xconfigure.width; + h = event.xconfigure.height; + if (surface_type == EGL_WINDOW_BIT) + reshape(w, h); + break; case KeyPress: { char buffer[10]; @@ -476,6 +586,7 @@ event_loop(Display *dpy, Window win, static int frames = 0; static double tRot0 = -1.0, tRate0 = -1.0; double dt, t = current_time(); + int x, y; if (tRot0 < 0.0) tRot0 = t; dt = t - tRot0; @@ -487,7 +598,25 @@ event_loop(Display *dpy, Window win, angle -= 3600.0; draw(); - eglSwapBuffers(egl_dpy, egl_surf); + switch (surface_type) { + case EGL_WINDOW_BIT: + eglSwapBuffers(eman->dpy, eman->win); + break; + case EGL_PBUFFER_BIT: + eglWaitClient(); + if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix)) + break; + /* fall through */ + case EGL_PIXMAP_BIT: + eglWaitClient(); + for (x = 0; x < w; x += orig_w) { + for (y = 0; y < h; y += orig_h) { + XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc, + 0, 0, orig_w, orig_h, x, y); + } + } + break; + } frames++; @@ -503,6 +632,8 @@ event_loop(Display *dpy, Window win, } } } + + XFreeGC(eman->xdpy, gc); } @@ -513,6 +644,8 @@ usage(void) printf(" -display set the display to run on\n"); printf(" -fullscreen run in fullscreen mode\n"); printf(" -info display OpenGL renderer info\n"); + printf(" -pixmap use pixmap surface\n"); + printf(" -pbuffer use pbuffer surface\n"); } @@ -521,15 +654,23 @@ main(int argc, char *argv[]) { const int winWidth = 300, winHeight = 300; Display *x_dpy; - Window win; - EGLSurface egl_surf; - EGLContext egl_ctx; - EGLDisplay egl_dpy; char *dpyName = NULL; + struct egl_manager *eman; + EGLint attribs[] = { + EGL_SURFACE_TYPE, 0, /* filled later */ + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_NONE + }; + char win_title[] = "xeglgears (window/pixmap/pbuffer)"; + EGLint surface_type = EGL_WINDOW_BIT; GLboolean printInfo = GL_FALSE; - EGLint egl_major, egl_minor; + GLboolean fullscreen = GL_FALSE; + EGLBoolean ret; int i; - const char *s; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0) { @@ -542,12 +683,21 @@ main(int argc, char *argv[]) else if (strcmp(argv[i], "-fullscreen") == 0) { fullscreen = GL_TRUE; } + else if (strcmp(argv[i], "-pixmap") == 0) { + surface_type = EGL_PIXMAP_BIT; + } + else if (strcmp(argv[i], "-pbuffer") == 0) { + surface_type = EGL_PBUFFER_BIT; + } else { usage(); return -1; } } + /* set surface type */ + attribs[1] = surface_type; + x_dpy = XOpenDisplay(dpyName); if (!x_dpy) { printf("Error: couldn't open display %s\n", @@ -555,26 +705,60 @@ main(int argc, char *argv[]) return -1; } - egl_dpy = eglGetDisplay(x_dpy); - if (!egl_dpy) { - printf("Error: eglGetDisplay() failed\n"); - return -1; - } + eglBindAPI(EGL_OPENGL_API); - if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { - printf("Error: eglInitialize() failed\n"); + eman = egl_manager_new(x_dpy, attribs, printInfo); + if (!eman) { + XCloseDisplay(x_dpy); return -1; } - s = eglQueryString(egl_dpy, EGL_VERSION); - printf("EGL_VERSION = %s\n", s); - - make_x_window(x_dpy, egl_dpy, - "glxgears", 0, 0, winWidth, winHeight, - &win, &egl_ctx, &egl_surf); + snprintf(win_title, sizeof(win_title), "xeglgears (%s)", + (surface_type == EGL_WINDOW_BIT) ? "window" : + (surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer"); + + /* create surface(s) */ + switch (surface_type) { + case EGL_WINDOW_BIT: + ret = egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_TRUE, fullscreen, NULL); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx); + break; + case EGL_PIXMAP_BIT: + ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_FALSE, fullscreen, NULL) && + egl_manager_create_pixmap(eman, eman->xwin, + EGL_TRUE, NULL)); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx); + break; + case EGL_PBUFFER_BIT: + { + EGLint pbuf_attribs[] = { + EGL_WIDTH, winWidth, + EGL_HEIGHT, winHeight, + EGL_NONE + }; + ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_FALSE, fullscreen, NULL) && + egl_manager_create_pixmap(eman, eman->xwin, + EGL_FALSE, NULL) && + egl_manager_create_pbuffer(eman, pbuf_attribs)); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx); + } + break; + default: + ret = EGL_FALSE; + break; + } - XMapWindow(x_dpy, win); - eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx); + if (!ret) { + egl_manager_destroy(eman); + XCloseDisplay(x_dpy); + return -1; + } if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); @@ -590,18 +774,13 @@ main(int argc, char *argv[]) */ reshape(winWidth, winHeight); - event_loop(x_dpy, win, egl_dpy, egl_surf); + event_loop(eman, surface_type, winWidth, winHeight); glDeleteLists(gear1, 1); glDeleteLists(gear2, 1); glDeleteLists(gear3, 1); - eglDestroyContext(egl_dpy, egl_ctx); - eglDestroySurface(egl_dpy, egl_surf); - eglTerminate(egl_dpy); - - - XDestroyWindow(x_dpy, win); + egl_manager_destroy(eman); XCloseDisplay(x_dpy); return 0; -- cgit v1.2.3 From c4af8ce69e1a7105b0178da8a085b73ab984e432 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Oct 2009 11:49:19 -0400 Subject: st/xorg: lots of render fixes fixes all the blend modes, fixes flushing/finishing semantics, adds acceleration for the component alpha modes that we can support, fixes src in mask shader and general cleanups --- src/gallium/state_trackers/xorg/xorg_composite.c | 168 ++++++++++++----------- src/gallium/state_trackers/xorg/xorg_exa.c | 19 ++- src/gallium/state_trackers/xorg/xorg_exa_tgsi.c | 37 ++--- src/gallium/state_trackers/xorg/xorg_exa_tgsi.h | 3 +- 4 files changed, 114 insertions(+), 113 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 7379e3b746..297b6c5f5d 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -13,68 +13,43 @@ #define XFixedToDouble(f) (((double) (f)) / 65536.) struct xorg_composite_blend { - int op:8; + int op : 8; - unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ - unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned alpha_dst : 4; + unsigned alpha_src : 4; - unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ - unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned rgb_src : 8; /**< PIPE_BLENDFACTOR_x */ + unsigned rgb_dst : 8; /**< PIPE_BLENDFACTOR_x */ }; #define BLEND_OP_OVER 3 static const struct xorg_composite_blend xorg_blends[] = { { PictOpClear, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO }, - + 0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO}, { PictOpSrc, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO }, - + 0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO}, { PictOpDst, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE }, - + 0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE}, { PictOpOver, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 0, 1, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, { PictOpOverReverse, - PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE}, { PictOpIn, - PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 1, 0, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ZERO}, { PictOpInReverse, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE }, - + 0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_SRC_ALPHA}, { PictOpOut, - PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ZERO}, { PictOpOutReverse, - PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, { PictOpAtop, - PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 1, 1, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, { PictOpAtopReverse, - PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA }, - + 1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_SRC_ALPHA}, { PictOpXor, - PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_ONE }, - + 1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, { PictOpAdd, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE, - PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE }, + 0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE}, }; @@ -95,38 +70,62 @@ pixel_to_float4(Pixel pixel, float *color) struct acceleration_info { int op : 16; - int with_mask : 1; - int component_alpha : 1; }; static const struct acceleration_info accelerated_ops[] = { - {PictOpClear, 1, 0}, - {PictOpSrc, 1, 0}, - {PictOpDst, 1, 0}, - {PictOpOver, 1, 0}, - {PictOpOverReverse, 1, 0}, - {PictOpIn, 1, 0}, - {PictOpInReverse, 1, 0}, - {PictOpOut, 1, 0}, - {PictOpOutReverse, 1, 0}, - {PictOpAtop, 1, 0}, - {PictOpAtopReverse, 1, 0}, - {PictOpXor, 1, 0}, - {PictOpAdd, 1, 0}, - {PictOpSaturate, 1, 0}, + {PictOpClear, }, + {PictOpSrc, }, + {PictOpDst, }, + {PictOpOver, }, + {PictOpOverReverse, }, + {PictOpIn, }, + {PictOpInReverse, }, + {PictOpOut, }, + {PictOpOutReverse, }, + {PictOpAtop, }, + {PictOpAtopReverse, }, + {PictOpXor, }, + {PictOpAdd, }, + {PictOpSaturate, }, }; static struct xorg_composite_blend -blend_for_op(int op) +blend_for_op(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, + PicturePtr pDstPicture) { const int num_blends = sizeof(xorg_blends)/sizeof(struct xorg_composite_blend); int i; + struct xorg_composite_blend blend = xorg_blends[BLEND_OP_OVER]; for (i = 0; i < num_blends; ++i) { if (xorg_blends[i].op == op) - return xorg_blends[i]; + blend = xorg_blends[i]; } - return xorg_blends[BLEND_OP_OVER]; + + /* If there's no dst alpha channel, adjust the blend op so that we'll treat + * it as always 1. + */ + if (pDstPicture && + PICT_FORMAT_A(pDstPicture->format) == 0 && blend.alpha_dst) { + if (blend.rgb_src == PIPE_BLENDFACTOR_DST_ALPHA) + blend.rgb_src = PIPE_BLENDFACTOR_ONE; + else if (blend.rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA) + blend.rgb_src = PIPE_BLENDFACTOR_ZERO; + } + + /* If the source alpha is being used, then we should only be in a case where + * the source blend factor is 0, and the source blend value is the mask + * channels multiplied by the source picture's alpha. + */ + if (pMaskPicture && pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format) && blend.alpha_src) { + if (blend.rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) { + blend.rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR; + } else if (blend.rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) { + blend.rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR; + } + } + return blend; } static INLINE int @@ -203,41 +202,50 @@ boolean xorg_composite_accelerated(int op, if (pSrcPicture->pSourcePict) { if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill) - XORG_FALLBACK("gradients not enabled (haven't been well tested)"); + XORG_FALLBACK("Gradients not enabled (haven't been well tested)"); } for (i = 0; i < accel_ops_count; ++i) { if (op == accelerated_ops[i].op) { + struct xorg_composite_blend blend = blend_for_op(op, + pSrcPicture, + pMaskPicture, + pDstPicture); /* Check for component alpha */ - if (pMaskPicture && - (pMaskPicture->componentAlpha || - (!accelerated_ops[i].with_mask))) - XORG_FALLBACK("component alpha unsupported (PictOpOver=%s(%d)", - (accelerated_ops[i].op == PictOpOver) ? "yes" : "no", - accelerated_ops[i].op); + if (pMaskPicture && pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format)) { + if (blend.alpha_src && + blend.rgb_src != PIPE_BLENDFACTOR_ZERO) { + XORG_FALLBACK("Component alpha not supported with source " + "alpha and source value blending. (op=%d)", + op); + } + } return TRUE; } } - XORG_FALLBACK("unsupported operation"); + XORG_FALLBACK("Unsupported composition operation = %d", op); } static void bind_blend_state(struct exa_context *exa, int op, - PicturePtr pSrcPicture, PicturePtr pMaskPicture) + PicturePtr pSrcPicture, + PicturePtr pMaskPicture, + PicturePtr pDstPicture) { struct xorg_composite_blend blend_opt; struct pipe_blend_state blend; - blend_opt = blend_for_op(op); + blend_opt = blend_for_op(op, pSrcPicture, pMaskPicture, pDstPicture); - memset(&blend, 0, sizeof(struct pipe_blend_state)); + memset(&blend, 0, sizeof(struct pipe_blend_state)); blend.blend_enable = 1; blend.colormask |= PIPE_MASK_RGBA; - blend.rgb_src_factor = blend_opt.rgb_src_factor; - blend.alpha_src_factor = blend_opt.alpha_src_factor; - blend.rgb_dst_factor = blend_opt.rgb_dst_factor; - blend.alpha_dst_factor = blend_opt.alpha_dst_factor; + blend.rgb_src_factor = blend_opt.rgb_src; + blend.alpha_src_factor = blend_opt.rgb_src; + blend.rgb_dst_factor = blend_opt.rgb_dst; + blend.alpha_dst_factor = blend_opt.rgb_dst; cso_set_blend(exa->renderer->cso, &blend); } @@ -273,6 +281,8 @@ bind_shaders(struct exa_context *exa, int op, if (pMaskPicture) { vs_traits |= VS_MASK; fs_traits |= FS_MASK; + if (pMaskPicture->componentAlpha) + fs_traits |= FS_COMPONENT_ALPHA; } shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); @@ -428,7 +438,7 @@ boolean xorg_composite_bind_state(struct exa_context *exa, { renderer_bind_framebuffer(exa->renderer, pDst); renderer_bind_viewport(exa->renderer, pDst); - bind_blend_state(exa, op, pSrcPicture, pMaskPicture); + bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture); renderer_bind_rasterizer(exa->renderer); bind_shaders(exa, op, pSrcPicture, pMaskPicture); bind_samplers(exa, op, pSrcPicture, pMaskPicture, @@ -491,7 +501,7 @@ boolean xorg_solid_bind_state(struct exa_context *exa, renderer_bind_framebuffer(exa->renderer, pixmap); renderer_bind_viewport(exa->renderer, pixmap); renderer_bind_rasterizer(exa->renderer); - bind_blend_state(exa, PictOpSrc, NULL, NULL); + bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL); setup_constant_buffers(exa, pixmap); shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c index 39c4d26ebe..b83d97bdb6 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa.c +++ b/src/gallium/state_trackers/xorg/xorg_exa.c @@ -105,12 +105,21 @@ xorg_exa_common_done(struct exa_context *exa) static void ExaWaitMarker(ScreenPtr pScreen, int marker) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + modesettingPtr ms = modesettingPTR(pScrn); + struct exa_context *exa = ms->exa; + +#if 0 + xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL); +#else + xorg_exa_finish(exa); +#endif } static int ExaMarkSync(ScreenPtr pScreen) { - return 1; + return 1; } static Bool @@ -258,11 +267,6 @@ ExaDone(PixmapPtr pPixmap) if (!priv) return; -#if 1 - xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, NULL); -#else - xorg_exa_finish(exa); -#endif xorg_exa_common_done(exa); } @@ -442,7 +446,8 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture, struct exa_pixmap_priv *priv; #if DEBUG_PRINT - debug_printf("ExaPrepareComposite\n"); + debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n", + op, pSrcPicture, pMaskPicture, pDstPicture); #endif if (!exa->pipe) XORG_FALLBACK("accle not enabled"); diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c index 8c9b674b4b..041f4f96dc 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c @@ -50,36 +50,20 @@ struct xorg_shaders { struct cso_hash *fs_hash; }; -static const char over_op[] = - "SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n" - "MAD TEMP[3], TEMP[0], TEMP[3], TEMP[0]\n"; - - -static INLINE void -create_preamble(struct ureg_program *ureg) -{ -} - - static INLINE void src_in_mask(struct ureg_program *ureg, struct ureg_dst dst, struct ureg_src src, - struct ureg_src mask) + struct ureg_src mask, + boolean component_alpha) { -#if 0 - /* MUL dst, src, mask.a */ - ureg_MUL(ureg, dst, src, - ureg_scalar(mask, TGSI_SWIZZLE_W)); -#else - /* MOV dst, src */ - /* MUL dst.a, src.a, mask.a */ - ureg_MOV(ureg, dst, src); - ureg_MUL(ureg, - ureg_writemask(dst, TGSI_WRITEMASK_W), - ureg_scalar(src, TGSI_SWIZZLE_W), - ureg_scalar(mask, TGSI_SWIZZLE_W)); -#endif + if (component_alpha) { + ureg_MUL(ureg, dst, src, mask); + } + else { + ureg_MUL(ureg, dst, src, + ureg_scalar(mask, TGSI_SWIZZLE_W)); + } } static struct ureg_src @@ -305,6 +289,7 @@ create_fs(struct pipe_context *pipe, boolean is_solid = fs_traits & FS_SOLID_FILL; boolean is_lingrad = fs_traits & FS_LINGRAD_FILL; boolean is_radgrad = fs_traits & FS_RADGRAD_FILL; + boolean is_comp_alpha = fs_traits & FS_COMPONENT_ALPHA; ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); if (ureg == NULL) @@ -401,7 +386,7 @@ create_fs(struct pipe_context *pipe, ureg_TEX(ureg, mask, TGSI_TEXTURE_2D, mask_pos, mask_sampler); /* src IN mask */ - src_in_mask(ureg, out, ureg_src(src), ureg_src(mask)); + src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), is_comp_alpha); ureg_release_temporary(ureg, mask); } diff --git a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h index 33c272070b..c290d44e8f 100644 --- a/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h +++ b/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h @@ -23,7 +23,8 @@ enum xorg_fs_traits { FS_RADGRAD_FILL = 1 << 4, FS_FILL = (FS_SOLID_FILL | FS_LINGRAD_FILL | - FS_RADGRAD_FILL) + FS_RADGRAD_FILL), + FS_COMPONENT_ALPHA = 1 << 5 }; struct xorg_shader { -- cgit v1.2.3 From 1f5b568fbeda9e48f0ea6473cf8193e9502bb21a Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Oct 2009 12:13:02 -0400 Subject: st/xorg: cleanup the checks for whether the op is accelerated --- src/gallium/state_trackers/xorg/xorg_composite.c | 96 +++++++++--------------- 1 file changed, 36 insertions(+), 60 deletions(-) diff --git a/src/gallium/state_trackers/xorg/xorg_composite.c b/src/gallium/state_trackers/xorg/xorg_composite.c index 297b6c5f5d..e039bb12b6 100644 --- a/src/gallium/state_trackers/xorg/xorg_composite.c +++ b/src/gallium/state_trackers/xorg/xorg_composite.c @@ -68,64 +68,48 @@ pixel_to_float4(Pixel pixel, float *color) color[3] = ((float)a) / 255.; } -struct acceleration_info { - int op : 16; -}; -static const struct acceleration_info accelerated_ops[] = { - {PictOpClear, }, - {PictOpSrc, }, - {PictOpDst, }, - {PictOpOver, }, - {PictOpOverReverse, }, - {PictOpIn, }, - {PictOpInReverse, }, - {PictOpOut, }, - {PictOpOutReverse, }, - {PictOpAtop, }, - {PictOpAtopReverse, }, - {PictOpXor, }, - {PictOpAdd, }, - {PictOpSaturate, }, -}; - -static struct xorg_composite_blend -blend_for_op(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, +static boolean +blend_for_op(struct xorg_composite_blend *blend, + int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture) { const int num_blends = sizeof(xorg_blends)/sizeof(struct xorg_composite_blend); int i; - struct xorg_composite_blend blend = xorg_blends[BLEND_OP_OVER]; + boolean supported = FALSE; + + /* our default in case something goes wrong */ + *blend = xorg_blends[BLEND_OP_OVER]; for (i = 0; i < num_blends; ++i) { - if (xorg_blends[i].op == op) - blend = xorg_blends[i]; + if (xorg_blends[i].op == op) { + *blend = xorg_blends[i]; + supported = TRUE; + } } /* If there's no dst alpha channel, adjust the blend op so that we'll treat - * it as always 1. - */ + * it as always 1. */ if (pDstPicture && - PICT_FORMAT_A(pDstPicture->format) == 0 && blend.alpha_dst) { - if (blend.rgb_src == PIPE_BLENDFACTOR_DST_ALPHA) - blend.rgb_src = PIPE_BLENDFACTOR_ONE; - else if (blend.rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA) - blend.rgb_src = PIPE_BLENDFACTOR_ZERO; + PICT_FORMAT_A(pDstPicture->format) == 0 && blend->alpha_dst) { + if (blend->rgb_src == PIPE_BLENDFACTOR_DST_ALPHA) + blend->rgb_src = PIPE_BLENDFACTOR_ONE; + else if (blend->rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA) + blend->rgb_src = PIPE_BLENDFACTOR_ZERO; } /* If the source alpha is being used, then we should only be in a case where * the source blend factor is 0, and the source blend value is the mask - * channels multiplied by the source picture's alpha. - */ + * channels multiplied by the source picture's alpha. */ if (pMaskPicture && pMaskPicture->componentAlpha && - PICT_FORMAT_RGB(pMaskPicture->format) && blend.alpha_src) { - if (blend.rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) { - blend.rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR; - } else if (blend.rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) { - blend.rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR; + PICT_FORMAT_RGB(pMaskPicture->format) && blend->alpha_src) { + if (blend->rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) { + blend->rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR; + } else if (blend->rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) { + blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR; } } - return blend; + return supported; } static INLINE int @@ -191,9 +175,7 @@ boolean xorg_composite_accelerated(int op, ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; modesettingPtr ms = modesettingPTR(pScrn); - unsigned i; - unsigned accel_ops_count = - sizeof(accelerated_ops)/sizeof(struct acceleration_info); + struct xorg_composite_blend blend; if (!is_filter_accelerated(pSrcPicture) || !is_filter_accelerated(pMaskPicture)) { @@ -205,24 +187,18 @@ boolean xorg_composite_accelerated(int op, XORG_FALLBACK("Gradients not enabled (haven't been well tested)"); } - for (i = 0; i < accel_ops_count; ++i) { - if (op == accelerated_ops[i].op) { - struct xorg_composite_blend blend = blend_for_op(op, - pSrcPicture, - pMaskPicture, - pDstPicture); - /* Check for component alpha */ - if (pMaskPicture && pMaskPicture->componentAlpha && - PICT_FORMAT_RGB(pMaskPicture->format)) { - if (blend.alpha_src && - blend.rgb_src != PIPE_BLENDFACTOR_ZERO) { - XORG_FALLBACK("Component alpha not supported with source " - "alpha and source value blending. (op=%d)", - op); - } + if (blend_for_op(&blend, op, + pSrcPicture, pMaskPicture, pDstPicture)) { + /* Check for component alpha */ + if (pMaskPicture && pMaskPicture->componentAlpha && + PICT_FORMAT_RGB(pMaskPicture->format)) { + if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) { + XORG_FALLBACK("Component alpha not supported with source " + "alpha and source value blending. (op=%d)", + op); } - return TRUE; } + return TRUE; } XORG_FALLBACK("Unsupported composition operation = %d", op); } @@ -236,7 +212,7 @@ bind_blend_state(struct exa_context *exa, int op, struct xorg_composite_blend blend_opt; struct pipe_blend_state blend; - blend_opt = blend_for_op(op, pSrcPicture, pMaskPicture, pDstPicture); + blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture); memset(&blend, 0, sizeof(struct pipe_blend_state)); blend.blend_enable = 1; -- cgit v1.2.3 From 1acd891ed31b14ac6c81fd869a681c4b89c7d901 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 21 Oct 2009 17:03:52 +0100 Subject: scons: Disable more MSVC pedantic security warnings. --- scons/gallium.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scons/gallium.py b/scons/gallium.py index 587294af71..34877b2f8b 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -263,7 +263,10 @@ def generate(env): if msvc and env['toolchain'] != 'winddk': cppdefines += [ 'VC_EXTRALEAN', + '_CRT_SECURE_NO_WARNINGS', '_CRT_SECURE_NO_DEPRECATE', + '_SCL_SECURE_NO_WARNINGS', + '_SCL_SECURE_NO_DEPRECATE', ] if debug: cppdefines += ['_DEBUG'] -- cgit v1.2.3 From 4797ce0d194720369b46d51733536d02b4a14473 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 18:09:37 +0100 Subject: util: Set cpu endianness too. --- src/gallium/auxiliary/util/u_cpu_detect.c | 2 ++ src/gallium/auxiliary/util/u_cpu_detect.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/gallium/auxiliary/util/u_cpu_detect.c b/src/gallium/auxiliary/util/u_cpu_detect.c index 7330d5dbd0..c93e0db23c 100644 --- a/src/gallium/auxiliary/util/u_cpu_detect.c +++ b/src/gallium/auxiliary/util/u_cpu_detect.c @@ -394,8 +394,10 @@ util_cpu_detect(void) util_cpu_caps.arch = UTIL_CPU_ARCH_SPARC; #elif defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) util_cpu_caps.arch = UTIL_CPU_ARCH_X86; + util_cpu_caps.little_endian = 1; #elif defined(PIPE_ARCH_PPC) util_cpu_caps.arch = UTIL_CPU_ARCH_POWERPC; + util_cpu_caps.little_endian = 0; #else util_cpu_caps.arch = UTIL_CPU_ARCH_UNKNOWN; #endif diff --git a/src/gallium/auxiliary/util/u_cpu_detect.h b/src/gallium/auxiliary/util/u_cpu_detect.h index 7ea0121c07..4b3dc39c34 100644 --- a/src/gallium/auxiliary/util/u_cpu_detect.h +++ b/src/gallium/auxiliary/util/u_cpu_detect.h @@ -54,6 +54,8 @@ struct util_cpu_caps { int x86_cpu_type; unsigned cacheline; + unsigned little_endian:1; + unsigned has_tsc:1; unsigned has_mmx:1; unsigned has_mmx2:1; -- cgit v1.2.3 From a07437f8a6a863654487c5586cbd02bfc20f0a3b Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 18:10:19 +0100 Subject: llvmpipe: Call util_cpu_detect() from the unit tests. --- src/gallium/drivers/llvmpipe/lp_test_format.c | 3 +++ src/gallium/drivers/llvmpipe/lp_test_main.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c index ab80c0143f..5dc8297fe9 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_format.c +++ b/src/gallium/drivers/llvmpipe/lp_test_format.c @@ -35,6 +35,7 @@ #include #include +#include "util/u_cpu_detect.h" #include "util/u_format.h" #include "lp_bld_format.h" @@ -263,6 +264,8 @@ int main(int argc, char **argv) LLVMInitializeNativeTarget(); #endif + util_cpu_detect(); + for (i = 0; i < sizeof(test_cases)/sizeof(test_cases[0]); ++i) if(!test_format(&test_cases[i])) ret = 1; diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c index f07fa256f1..d4767ff52b 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_main.c +++ b/src/gallium/drivers/llvmpipe/lp_test_main.c @@ -34,6 +34,8 @@ */ +#include "util/u_cpu_detect.h" + #include "lp_bld_const.h" #include "lp_test.h" @@ -370,6 +372,8 @@ int main(int argc, char **argv) LLVMInitializeNativeTarget(); #endif + util_cpu_detect(); + if(fp) { /* Warm up the caches */ test_some(0, NULL, 100); -- cgit v1.2.3 From 421507de06bd42a322c5864d887e67e385eb458c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 18:28:17 +0100 Subject: llvmpipe: Factor vector packing/unpacking to a separate source file. These functions will be needed to implement many of the 8bit operations, and they are quite complex on its own. --- src/gallium/drivers/llvmpipe/Makefile | 1 + src/gallium/drivers/llvmpipe/SConscript | 1 + src/gallium/drivers/llvmpipe/lp_bld_conv.c | 240 +---------------- src/gallium/drivers/llvmpipe/lp_bld_pack.c | 419 +++++++++++++++++++++++++++++ src/gallium/drivers/llvmpipe/lp_bld_pack.h | 95 +++++++ 5 files changed, 519 insertions(+), 237 deletions(-) create mode 100644 src/gallium/drivers/llvmpipe/lp_bld_pack.c create mode 100644 src/gallium/drivers/llvmpipe/lp_bld_pack.h diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile index 21aff1967a..b96ee23a99 100644 --- a/src/gallium/drivers/llvmpipe/Makefile +++ b/src/gallium/drivers/llvmpipe/Makefile @@ -21,6 +21,7 @@ C_SOURCES = \ lp_bld_interp.c \ lp_bld_intr.c \ lp_bld_logic.c \ + lp_bld_pack.c \ lp_bld_sample_soa.c \ lp_bld_swizzle.c \ lp_bld_struct.c \ diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index 13cd465838..403e4daa43 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -33,6 +33,7 @@ llvmpipe = env.ConvenienceLibrary( 'lp_bld_format_soa.c', 'lp_bld_interp.c', 'lp_bld_intr.c', + 'lp_bld_pack.c', 'lp_bld_sample_soa.c', 'lp_bld_struct.c', 'lp_bld_logic.c', diff --git a/src/gallium/drivers/llvmpipe/lp_bld_conv.c b/src/gallium/drivers/llvmpipe/lp_bld_conv.c index 20c8710214..9935209437 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_conv.c @@ -69,6 +69,7 @@ #include "lp_bld_const.h" #include "lp_bld_intr.h" #include "lp_bld_arit.h" +#include "lp_bld_pack.h" #include "lp_bld_conv.h" @@ -198,241 +199,6 @@ lp_build_unsigned_norm_to_float(LLVMBuilderRef builder, } -/** - * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions. - */ -static LLVMValueRef -lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi) -{ - LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; - unsigned i, j; - - assert(n <= LP_MAX_VECTOR_LENGTH); - assert(lo_hi < 2); - - /* TODO: cache results in a static table */ - - for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) { - elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0); - elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0); - } - - return LLVMConstVector(elems, n); -} - - -/** - * Build shuffle vectors that match PACKxx instructions. - */ -static LLVMValueRef -lp_build_const_pack_shuffle(unsigned n) -{ - LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; - unsigned i; - - assert(n <= LP_MAX_VECTOR_LENGTH); - - /* TODO: cache results in a static table */ - - for(i = 0; i < n; ++i) - elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0); - - return LLVMConstVector(elems, n); -} - - -/** - * Expand the bit width. - * - * This will only change the number of bits the values are represented, not the - * values themselves. - */ -static void -lp_build_expand(LLVMBuilderRef builder, - struct lp_type src_type, - struct lp_type dst_type, - LLVMValueRef src, - LLVMValueRef *dst, unsigned num_dsts) -{ - unsigned num_tmps; - unsigned i; - - /* Register width must remain constant */ - assert(src_type.width * src_type.length == dst_type.width * dst_type.length); - - /* We must not loose or gain channels. Only precision */ - assert(src_type.length == dst_type.length * num_dsts); - - num_tmps = 1; - dst[0] = src; - - while(src_type.width < dst_type.width) { - struct lp_type new_type = src_type; - LLVMTypeRef new_vec_type; - - new_type.width *= 2; - new_type.length /= 2; - new_vec_type = lp_build_vec_type(new_type); - - for(i = num_tmps; i--; ) { - LLVMValueRef zero; - LLVMValueRef shuffle_lo; - LLVMValueRef shuffle_hi; - LLVMValueRef lo; - LLVMValueRef hi; - - zero = lp_build_zero(src_type); - shuffle_lo = lp_build_const_unpack_shuffle(src_type.length, 0); - shuffle_hi = lp_build_const_unpack_shuffle(src_type.length, 1); - - /* PUNPCKLBW, PUNPCKHBW */ - lo = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_lo, ""); - hi = LLVMBuildShuffleVector(builder, dst[i], zero, shuffle_hi, ""); - - dst[2*i + 0] = LLVMBuildBitCast(builder, lo, new_vec_type, ""); - dst[2*i + 1] = LLVMBuildBitCast(builder, hi, new_vec_type, ""); - } - - src_type = new_type; - - num_tmps *= 2; - } - - assert(num_tmps == num_dsts); -} - - -/** - * Non-interleaved pack. - * - * This will move values as - * - * lo = __ l0 __ l1 __ l2 __.. __ ln - * hi = __ h0 __ h1 __ h2 __.. __ hn - * res = l0 l1 l2 .. ln h0 h1 h2 .. hn - * - * TODO: handle saturation consistently. - */ -static LLVMValueRef -lp_build_pack2(LLVMBuilderRef builder, - struct lp_type src_type, - struct lp_type dst_type, - boolean clamped, - LLVMValueRef lo, - LLVMValueRef hi) -{ - LLVMTypeRef src_vec_type = lp_build_vec_type(src_type); - LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type); - LLVMValueRef shuffle; - LLVMValueRef res; - - /* Register width must remain constant */ - assert(src_type.width * src_type.length == dst_type.width * dst_type.length); - - /* We must not loose or gain channels. Only precision */ - assert(src_type.length * 2 == dst_type.length); - - assert(!src_type.floating); - assert(!dst_type.floating); - - if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) { - /* All X86 non-interleaved pack instructions all take signed inputs and - * saturate them, so saturate beforehand. */ - if(!src_type.sign && !clamped) { - struct lp_build_context bld; - unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width; - LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1); - lp_build_context_init(&bld, builder, src_type); - lo = lp_build_min(&bld, lo, dst_max); - hi = lp_build_min(&bld, hi, dst_max); - } - - switch(src_type.width) { - case 32: - if(dst_type.sign || !util_cpu_caps.has_sse4_1) - res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi); - else - /* PACKUSDW is the only instrinsic with a consistent signature */ - return lp_build_intrinsic_binary(builder, "llvm.x86.sse41.packusdw", dst_vec_type, lo, hi); - break; - - case 16: - if(dst_type.sign) - res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi); - else - res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi); - break; - - default: - assert(0); - return LLVMGetUndef(dst_vec_type); - break; - } - - res = LLVMBuildBitCast(builder, res, dst_vec_type, ""); - return res; - } - - lo = LLVMBuildBitCast(builder, lo, dst_vec_type, ""); - hi = LLVMBuildBitCast(builder, hi, dst_vec_type, ""); - - shuffle = lp_build_const_pack_shuffle(dst_type.length); - - res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, ""); - - return res; -} - - -/** - * Truncate the bit width. - * - * TODO: Handle saturation consistently. - */ -static LLVMValueRef -lp_build_pack(LLVMBuilderRef builder, - struct lp_type src_type, - struct lp_type dst_type, - boolean clamped, - const LLVMValueRef *src, unsigned num_srcs) -{ - LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH]; - unsigned i; - - /* Register width must remain constant */ - assert(src_type.width * src_type.length == dst_type.width * dst_type.length); - - /* We must not loose or gain channels. Only precision */ - assert(src_type.length * num_srcs == dst_type.length); - - for(i = 0; i < num_srcs; ++i) - tmp[i] = src[i]; - - while(src_type.width > dst_type.width) { - struct lp_type new_type = src_type; - - new_type.width /= 2; - new_type.length *= 2; - - /* Take in consideration the sign changes only in the last step */ - if(new_type.width == dst_type.width) - new_type.sign = dst_type.sign; - - num_srcs /= 2; - - for(i = 0; i < num_srcs; ++i) - tmp[i] = lp_build_pack2(builder, src_type, new_type, clamped, - tmp[2*i + 0], tmp[2*i + 1]); - - src_type = new_type; - } - - assert(num_srcs == 1); - - return tmp[0]; -} - - /** * Generic type conversion. * @@ -572,7 +338,7 @@ lp_build_conv(LLVMBuilderRef builder, if(tmp_type.width < dst_type.width) { assert(num_tmps == 1); - lp_build_expand(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts); + lp_build_unpack(builder, tmp_type, dst_type, tmp[0], tmp, num_dsts); tmp_type.width = dst_type.width; tmp_type.length = dst_type.length; num_tmps = num_dsts; @@ -692,7 +458,7 @@ lp_build_conv_mask(LLVMBuilderRef builder, } else if(src_type.width < dst_type.width) { assert(num_srcs == 1); - lp_build_expand(builder, src_type, dst_type, src[0], dst, num_dsts); + lp_build_unpack(builder, src_type, dst_type, src[0], dst, num_dsts); } else { assert(num_srcs == num_dsts); diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.c b/src/gallium/drivers/llvmpipe/lp_bld_pack.c new file mode 100644 index 0000000000..fe82fda039 --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_bld_pack.c @@ -0,0 +1,419 @@ +/************************************************************************** + * + * 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 + * Helper functions for packing/unpacking. + * + * Pack/unpacking is necessary for conversion between types of different + * bit width. + * + * They are also commonly used when an computation needs higher + * precision for the intermediate values. For example, if one needs the + * function: + * + * c = compute(a, b); + * + * to use more precision for intermediate results then one should implement it + * as: + * + * LLVMValueRef + * compute(LLVMBuilderRef builder struct lp_type type, LLVMValueRef a, LLVMValueRef b) + * { + * struct lp_type wide_type = lp_wider_type(type); + * LLVMValueRef al, ah, bl, bh, cl, ch, c; + * + * lp_build_unpack2(builder, type, wide_type, a, &al, &ah); + * lp_build_unpack2(builder, type, wide_type, b, &bl, &bh); + * + * cl = compute_half(al, bl); + * ch = compute_half(ah, bh); + * + * c = lp_build_pack2(bld->builder, wide_type, type, cl, ch); + * + * return c; + * } + * + * where compute_half() would do the computation for half the elements with + * twice the precision. + * + * @author Jose Fonseca + */ + + +#include "util/u_debug.h" +#include "util/u_math.h" +#include "util/u_cpu_detect.h" + +#include "lp_bld_type.h" +#include "lp_bld_const.h" +#include "lp_bld_intr.h" +#include "lp_bld_arit.h" +#include "lp_bld_pack.h" + + +/** + * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions. + */ +static LLVMValueRef +lp_build_const_unpack_shuffle(unsigned n, unsigned lo_hi) +{ + LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; + unsigned i, j; + + assert(n <= LP_MAX_VECTOR_LENGTH); + assert(lo_hi < 2); + + /* TODO: cache results in a static table */ + + for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) { + elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0); + elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0); + } + + return LLVMConstVector(elems, n); +} + + +/** + * Build shuffle vectors that match PACKxx instructions. + */ +static LLVMValueRef +lp_build_const_pack_shuffle(unsigned n) +{ + LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; + unsigned i; + + assert(n <= LP_MAX_VECTOR_LENGTH); + + /* TODO: cache results in a static table */ + + for(i = 0; i < n; ++i) + elems[i] = LLVMConstInt(LLVMInt32Type(), 2*i, 0); + + return LLVMConstVector(elems, n); +} + + +/** + * Interleave vector elements. + * + * Matches the PUNPCKLxx and PUNPCKHxx SSE instructions. + */ +LLVMValueRef +lp_build_interleave2(LLVMBuilderRef builder, + struct lp_type type, + LLVMValueRef a, + LLVMValueRef b, + unsigned lo_hi) +{ + LLVMValueRef shuffle; + + shuffle = lp_build_const_unpack_shuffle(type.length, lo_hi); + + return LLVMBuildShuffleVector(builder, a, b, shuffle, ""); +} + + +/** + * Double the bit width. + * + * This will only change the number of bits the values are represented, not the + * values themselves. + */ +void +lp_build_unpack2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef src, + LLVMValueRef *dst_lo, + LLVMValueRef *dst_hi) +{ + LLVMValueRef msb; + LLVMTypeRef dst_vec_type; + + assert(!src_type.floating); + assert(!dst_type.floating); + assert(dst_type.sign == src_type.sign); + assert(dst_type.width == src_type.width * 2); + assert(dst_type.length * 2 == src_type.length); + + if(src_type.sign) { + /* Replicate the sign bit in the most significant bits */ + msb = LLVMBuildAShr(builder, src, lp_build_int_const_scalar(src_type, src_type.width - 1), ""); + } + else + /* Most significant bits always zero */ + msb = lp_build_zero(src_type); + + /* Interleave bits */ + if(util_cpu_caps.little_endian) { + *dst_lo = lp_build_interleave2(builder, src_type, src, msb, 0); + *dst_hi = lp_build_interleave2(builder, src_type, src, msb, 1); + } + else { + *dst_lo = lp_build_interleave2(builder, src_type, msb, src, 0); + *dst_hi = lp_build_interleave2(builder, src_type, msb, src, 1); + } + + /* Cast the result into the new type (twice as wide) */ + + dst_vec_type = lp_build_vec_type(dst_type); + + *dst_lo = LLVMBuildBitCast(builder, *dst_lo, dst_vec_type, ""); + *dst_hi = LLVMBuildBitCast(builder, *dst_hi, dst_vec_type, ""); +} + + +/** + * Expand the bit width. + * + * This will only change the number of bits the values are represented, not the + * values themselves. + */ +void +lp_build_unpack(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef src, + LLVMValueRef *dst, unsigned num_dsts) +{ + unsigned num_tmps; + unsigned i; + + /* Register width must remain constant */ + assert(src_type.width * src_type.length == dst_type.width * dst_type.length); + + /* We must not loose or gain channels. Only precision */ + assert(src_type.length == dst_type.length * num_dsts); + + num_tmps = 1; + dst[0] = src; + + while(src_type.width < dst_type.width) { + struct lp_type tmp_type = src_type; + + tmp_type.width *= 2; + tmp_type.length /= 2; + + for(i = num_tmps; i--; ) { + lp_build_unpack2(builder, src_type, tmp_type, dst[i], &dst[2*i + 0], &dst[2*i + 1]); + } + + src_type = tmp_type; + + num_tmps *= 2; + } + + assert(num_tmps == num_dsts); +} + + +/** + * Non-interleaved pack. + * + * This will move values as + * + * lo = __ l0 __ l1 __ l2 __.. __ ln + * hi = __ h0 __ h1 __ h2 __.. __ hn + * res = l0 l1 l2 .. ln h0 h1 h2 .. hn + * + * This will only change the number of bits the values are represented, not the + * values themselves. + * + * It is assumed the values are already clamped into the destination type range. + * Values outside that range will produce undefined results. Use + * lp_build_packs2 instead. + */ +LLVMValueRef +lp_build_pack2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef lo, + LLVMValueRef hi) +{ + LLVMTypeRef src_vec_type = lp_build_vec_type(src_type); + LLVMTypeRef dst_vec_type = lp_build_vec_type(dst_type); + LLVMValueRef shuffle; + LLVMValueRef res; + + dst_vec_type = lp_build_vec_type(dst_type); + + assert(!src_type.floating); + assert(!dst_type.floating); + assert(src_type.width == dst_type.width * 2); + assert(src_type.length * 2 == dst_type.length); + + if(util_cpu_caps.has_sse2 && src_type.width * src_type.length == 128) { + switch(src_type.width) { + case 32: + if(dst_type.sign) { + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packssdw.128", src_vec_type, lo, hi); + } + 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 { + assert(0); + return LLVMGetUndef(dst_vec_type); + } + } + break; + + case 16: + if(dst_type.sign) + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packsswb.128", src_vec_type, lo, hi); + else + res = lp_build_intrinsic_binary(builder, "llvm.x86.sse2.packuswb.128", src_vec_type, lo, hi); + break; + + default: + assert(0); + return LLVMGetUndef(dst_vec_type); + break; + } + + res = LLVMBuildBitCast(builder, res, dst_vec_type, ""); + return res; + } + + lo = LLVMBuildBitCast(builder, lo, dst_vec_type, ""); + hi = LLVMBuildBitCast(builder, hi, dst_vec_type, ""); + + shuffle = lp_build_const_pack_shuffle(dst_type.length); + + res = LLVMBuildShuffleVector(builder, lo, hi, shuffle, ""); + + return res; +} + + + +/** + * Non-interleaved pack and saturate. + * + * Same as lp_build_pack2 but will saturate values so that they fit into the + * destination type. + */ +LLVMValueRef +lp_build_packs2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef lo, + LLVMValueRef hi) +{ + boolean clamp; + + assert(!src_type.floating); + assert(!dst_type.floating); + assert(src_type.sign == dst_type.sign); + assert(src_type.width == dst_type.width * 2); + assert(src_type.length * 2 == dst_type.length); + + clamp = TRUE; + + /* All X86 SSE non-interleaved pack instructions take signed inputs and + * saturate them, so no need to clamp for those cases. */ + if(util_cpu_caps.has_sse2 && + src_type.width * src_type.length == 128 && + src_type.sign) + clamp = FALSE; + + if(clamp) { + struct lp_build_context bld; + unsigned dst_bits = dst_type.sign ? dst_type.width - 1 : dst_type.width; + LLVMValueRef dst_max = lp_build_int_const_scalar(src_type, ((unsigned long long)1 << dst_bits) - 1); + lp_build_context_init(&bld, builder, src_type); + lo = lp_build_min(&bld, lo, dst_max); + hi = lp_build_min(&bld, hi, dst_max); + /* FIXME: What about lower bound? */ + } + + return lp_build_pack2(builder, src_type, dst_type, lo, hi); +} + + +/** + * Truncate the bit width. + * + * TODO: Handle saturation consistently. + */ +LLVMValueRef +lp_build_pack(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + boolean clamped, + const LLVMValueRef *src, unsigned num_srcs) +{ + LLVMValueRef (*pack2)(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef lo, + LLVMValueRef hi); + LLVMValueRef tmp[LP_MAX_VECTOR_LENGTH]; + unsigned i; + + + /* Register width must remain constant */ + assert(src_type.width * src_type.length == dst_type.width * dst_type.length); + + /* We must not loose or gain channels. Only precision */ + assert(src_type.length * num_srcs == dst_type.length); + + if(clamped) + pack2 = &lp_build_pack2; + else + pack2 = &lp_build_packs2; + + for(i = 0; i < num_srcs; ++i) + tmp[i] = src[i]; + + while(src_type.width > dst_type.width) { + struct lp_type tmp_type = src_type; + + tmp_type.width /= 2; + tmp_type.length *= 2; + + /* Take in consideration the sign changes only in the last step */ + if(tmp_type.width == dst_type.width) + tmp_type.sign = dst_type.sign; + + num_srcs /= 2; + + for(i = 0; i < num_srcs; ++i) + tmp[i] = pack2(builder, src_type, tmp_type, tmp[2*i + 0], tmp[2*i + 1]); + + src_type = tmp_type; + } + + assert(num_srcs == 1); + + return tmp[0]; +} diff --git a/src/gallium/drivers/llvmpipe/lp_bld_pack.h b/src/gallium/drivers/llvmpipe/lp_bld_pack.h new file mode 100644 index 0000000000..fb2a34984a --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_bld_pack.h @@ -0,0 +1,95 @@ +/************************************************************************** + * + * 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 + * Helper functions for packing/unpacking conversions. + * + * @author Jose Fonseca + */ + + +#ifndef LP_BLD_PACK_H +#define LP_BLD_PACK_H + + +#include + + +struct lp_type; + + +LLVMValueRef +lp_build_interleave2(LLVMBuilderRef builder, + struct lp_type type, + LLVMValueRef a, + LLVMValueRef b, + unsigned lo_hi); + + +void +lp_build_unpack2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef src, + LLVMValueRef *dst_lo, + LLVMValueRef *dst_hi); + + +void +lp_build_unpack(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef src, + LLVMValueRef *dst, unsigned num_dsts); + + +LLVMValueRef +lp_build_packs2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef lo, + LLVMValueRef hi); + + +LLVMValueRef +lp_build_pack2(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + LLVMValueRef lo, + LLVMValueRef hi); + + +LLVMValueRef +lp_build_pack(LLVMBuilderRef builder, + struct lp_type src_type, + struct lp_type dst_type, + boolean clamped, + const LLVMValueRef *src, unsigned num_srcs); + + +#endif /* !LP_BLD_PACK_H */ -- cgit v1.2.3 From 4458695bdafb13eba639d986e2f20953f0f7445c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 18:28:37 +0100 Subject: llvmpipe: Utility function to double the bit width of a type. --- src/gallium/drivers/llvmpipe/lp_bld_type.c | 29 ++++++++++++++++++++++++----- src/gallium/drivers/llvmpipe/lp_bld_type.h | 4 ++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.c b/src/gallium/drivers/llvmpipe/lp_bld_type.c index 606243d6c5..1320a26721 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_type.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_type.c @@ -160,12 +160,31 @@ lp_build_int_vec_type(struct lp_type type) struct lp_type lp_int_type(struct lp_type type) { - struct lp_type int_type; + struct lp_type res_type; - memset(&int_type, 0, sizeof int_type); - int_type.width = type.width; - int_type.length = type.length; - return int_type; + memset(&res_type, 0, sizeof res_type); + res_type.width = type.width; + res_type.length = type.length; + + return res_type; +} + + +/** + * Return the type with twice the bit width (hence half the number of elements). + */ +struct lp_type +lp_wider_type(struct lp_type type) +{ + struct lp_type res_type; + + memcpy(&res_type, &type, sizeof res_type); + res_type.width *= 2; + res_type.length /= 2; + + assert(res_type.length); + + return res_type; } diff --git a/src/gallium/drivers/llvmpipe/lp_bld_type.h b/src/gallium/drivers/llvmpipe/lp_bld_type.h index ee5ca3483c..46c298fa20 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_type.h +++ b/src/gallium/drivers/llvmpipe/lp_bld_type.h @@ -166,6 +166,10 @@ struct lp_type lp_int_type(struct lp_type type); +struct lp_type +lp_wider_type(struct lp_type type); + + void lp_build_context_init(struct lp_build_context *bld, LLVMBuilderRef builder, -- cgit v1.2.3 From 01b85e292352d710586344348fff5a81459e5486 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 18:28:57 +0100 Subject: llvmpipe: Use the pack/unpack functions for 8bit unsigned norm multiplication. --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 96 ++++++------------------------ 1 file changed, 17 insertions(+), 79 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index d27ef0de04..83ca06acf8 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -54,6 +54,7 @@ #include "lp_bld_const.h" #include "lp_bld_intr.h" #include "lp_bld_logic.h" +#include "lp_bld_pack.h" #include "lp_bld_debug.h" #include "lp_bld_arit.h" @@ -279,45 +280,6 @@ lp_build_sub(struct lp_build_context *bld, } -/** - * Build shuffle vectors that match PUNPCKLxx and PUNPCKHxx instructions. - */ -static LLVMValueRef -lp_build_unpack_shuffle(unsigned n, unsigned lo_hi) -{ - LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; - unsigned i, j; - - assert(n <= LP_MAX_VECTOR_LENGTH); - assert(lo_hi < 2); - - for(i = 0, j = lo_hi*n/2; i < n; i += 2, ++j) { - elems[i + 0] = LLVMConstInt(LLVMInt32Type(), 0 + j, 0); - elems[i + 1] = LLVMConstInt(LLVMInt32Type(), n + j, 0); - } - - return LLVMConstVector(elems, n); -} - - -/** - * Build constant int vector of width 'n' and value 'c'. - */ -static LLVMValueRef -lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c) -{ - LLVMValueRef elems[LP_MAX_VECTOR_LENGTH]; - unsigned i; - - assert(n <= LP_MAX_VECTOR_LENGTH); - - for(i = 0; i < n; ++i) - elems[i] = LLVMConstInt(type, c, 0); - - return LLVMConstVector(elems, n); -} - - /** * Normalized 8bit multiplication. * @@ -361,33 +323,30 @@ lp_build_const_vec(LLVMTypeRef type, unsigned n, long long c) */ static LLVMValueRef lp_build_mul_u8n(LLVMBuilderRef builder, + struct lp_type i16_type, LLVMValueRef a, LLVMValueRef b) { - static LLVMValueRef c01 = NULL; - static LLVMValueRef c08 = NULL; - static LLVMValueRef c80 = NULL; + LLVMValueRef c8; LLVMValueRef ab; - if(!c01) c01 = lp_build_const_vec(LLVMInt16Type(), 8, 0x01); - if(!c08) c08 = lp_build_const_vec(LLVMInt16Type(), 8, 0x08); - if(!c80) c80 = lp_build_const_vec(LLVMInt16Type(), 8, 0x80); + c8 = lp_build_int_const_scalar(i16_type, 8); #if 0 /* a*b/255 ~= (a*(b + 1)) >> 256 */ - b = LLVMBuildAdd(builder, b, c01, ""); + b = LLVMBuildAdd(builder, b, lp_build_int_const_scalar(i16_type, 1), ""); ab = LLVMBuildMul(builder, a, b, ""); #else - /* t/255 ~= (t + (t >> 8) + 0x80) >> 8 */ + /* ab/255 ~= (ab + (ab >> 8) + 0x80) >> 8 */ ab = LLVMBuildMul(builder, a, b, ""); - ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c08, ""), ""); - ab = LLVMBuildAdd(builder, ab, c80, ""); + ab = LLVMBuildAdd(builder, ab, LLVMBuildLShr(builder, ab, c8, ""), ""); + ab = LLVMBuildAdd(builder, ab, lp_build_int_const_scalar(i16_type, 0x80), ""); #endif - ab = LLVMBuildLShr(builder, ab, c08, ""); + ab = LLVMBuildLShr(builder, ab, c8, ""); return ab; } @@ -415,39 +374,18 @@ lp_build_mul(struct lp_build_context *bld, return bld->undef; if(!type.floating && !type.fixed && type.norm) { - if(util_cpu_caps.has_sse2 && type.width == 8 && type.length == 16) { - LLVMTypeRef i16x8 = LLVMVectorType(LLVMInt16Type(), 8); - LLVMTypeRef i8x16 = LLVMVectorType(LLVMInt8Type(), 16); - static LLVMValueRef ml = NULL; - static LLVMValueRef mh = NULL; - LLVMValueRef al, ah, bl, bh; - LLVMValueRef abl, abh; - LLVMValueRef ab; - - if(!ml) ml = lp_build_unpack_shuffle(16, 0); - if(!mh) mh = lp_build_unpack_shuffle(16, 1); + if(type.width == 8) { + struct lp_type i16_type = lp_wider_type(type); + LLVMValueRef al, ah, bl, bh, abl, abh, ab; - /* PUNPCKLBW, PUNPCKHBW */ - al = LLVMBuildShuffleVector(bld->builder, a, bld->zero, ml, ""); - bl = LLVMBuildShuffleVector(bld->builder, b, bld->zero, ml, ""); - ah = LLVMBuildShuffleVector(bld->builder, a, bld->zero, mh, ""); - bh = LLVMBuildShuffleVector(bld->builder, b, bld->zero, mh, ""); - - /* NOP */ - al = LLVMBuildBitCast(bld->builder, al, i16x8, ""); - bl = LLVMBuildBitCast(bld->builder, bl, i16x8, ""); - ah = LLVMBuildBitCast(bld->builder, ah, i16x8, ""); - bh = LLVMBuildBitCast(bld->builder, bh, i16x8, ""); + lp_build_unpack2(bld->builder, type, i16_type, a, &al, &ah); + lp_build_unpack2(bld->builder, type, i16_type, b, &bl, &bh); /* PMULLW, PSRLW, PADDW */ - abl = lp_build_mul_u8n(bld->builder, al, bl); - abh = lp_build_mul_u8n(bld->builder, ah, bh); - - /* PACKUSWB */ - ab = lp_build_intrinsic_binary(bld->builder, "llvm.x86.sse2.packuswb.128" , i16x8, abl, abh); + abl = lp_build_mul_u8n(bld->builder, i16_type, al, bl); + abh = lp_build_mul_u8n(bld->builder, i16_type, ah, bh); - /* NOP */ - ab = LLVMBuildBitCast(bld->builder, ab, i8x16, ""); + ab = lp_build_pack2(bld->builder, i16_type, type, abl, abh); return ab; } -- cgit v1.2.3 From 9aafa1fbd247cd6d1bb0ab47bc5b318bd0d67bc5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 19:02:04 +0100 Subject: llvmpipe: Avoid variable size arrays. Not really variable size, but MSVC still doesn't like them. --- src/gallium/drivers/llvmpipe/lp_test.h | 3 +++ src/gallium/drivers/llvmpipe/lp_test_blend.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_test_conv.c | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_test.h b/src/gallium/drivers/llvmpipe/lp_test.h index a88e110c66..21016fefe3 100644 --- a/src/gallium/drivers/llvmpipe/lp_test.h +++ b/src/gallium/drivers/llvmpipe/lp_test.h @@ -56,6 +56,9 @@ #include "lp_bld_type.h" +#define LP_TEST_NUM_SAMPLES 32 + + void write_tsv_header(FILE *fp); diff --git a/src/gallium/drivers/llvmpipe/lp_test_blend.c b/src/gallium/drivers/llvmpipe/lp_test_blend.c index 94b661dcba..e3af81cffb 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_test_blend.c @@ -477,8 +477,8 @@ test_one(unsigned verbose, char *error = NULL; blend_test_ptr_t blend_test_ptr; boolean success; - const unsigned n = 32; - int64_t cycles[n]; + const unsigned n = LP_TEST_NUM_SAMPLES; + int64_t cycles[LP_TEST_NUM_SAMPLES]; double cycles_avg = 0.0; unsigned i, j; diff --git a/src/gallium/drivers/llvmpipe/lp_test_conv.c b/src/gallium/drivers/llvmpipe/lp_test_conv.c index 9dcf58e5dc..ac2a6d05e3 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_conv.c +++ b/src/gallium/drivers/llvmpipe/lp_test_conv.c @@ -156,8 +156,8 @@ test_one(unsigned verbose, char *error = NULL; conv_test_ptr_t conv_test_ptr; boolean success; - const unsigned n = 32; - int64_t cycles[n]; + const unsigned n = LP_TEST_NUM_SAMPLES; + int64_t cycles[LP_TEST_NUM_SAMPLES]; double cycles_avg = 0.0; unsigned num_srcs; unsigned num_dsts; -- cgit v1.2.3 From ba8c11923a13bdec53128988ffc26ceb5c4f7310 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 19:02:42 +0100 Subject: llvmpipe: Define rdtsc for MSVC. --- src/gallium/drivers/llvmpipe/lp_test.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_test.h b/src/gallium/drivers/llvmpipe/lp_test.h index 21016fefe3..39d80726e6 100644 --- a/src/gallium/drivers/llvmpipe/lp_test.h +++ b/src/gallium/drivers/llvmpipe/lp_test.h @@ -71,17 +71,28 @@ boolean test_all(unsigned verbose, FILE *fp); +#if defined(PIPE_CC_MSVC) + +unsigned __int64 __rdtsc(); +#pragma intrinsic(__rdtsc) +#define rdtsc() __rdtsc() + +#elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)) + static INLINE uint64_t rdtsc(void) { -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) uint32_t hi, lo; __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi)); return ((uint64_t)lo) | (((uint64_t)hi) << 32); +} + #else - return 0; + +#define rdtsc() 0 + #endif -} + float -- cgit v1.2.3 From 719984afca3864cfe86ca734f3e2bd6eb5834bd1 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 19:03:04 +0100 Subject: llvmpipe: Avoid yet another variable size array. --- src/gallium/drivers/llvmpipe/lp_setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c index b14c265b7f..c43b3da450 100644 --- a/src/gallium/drivers/llvmpipe/lp_setup.c +++ b/src/gallium/drivers/llvmpipe/lp_setup.c @@ -278,11 +278,13 @@ clip_emit_quad( struct setup_context *setup, struct quad_header *quad ) * until we codegenerate single-quad variants of the fragment pipeline * we need this hack. */ const unsigned nr_quads = TILE_VECTOR_HEIGHT*TILE_VECTOR_WIDTH/QUAD_SIZE; - struct quad_header quads[nr_quads]; - struct quad_header *quad_ptrs[nr_quads]; + struct quad_header quads[4]; + struct quad_header *quad_ptrs[4]; int x0 = block_x(quad->input.x0); unsigned i; + assert(nr_quads == 4); + for(i = 0; i < nr_quads; ++i) { int x = x0 + 2*i; if(x == quad->input.x0) -- cgit v1.2.3 From bf48447cafc8069839ad41c9c11078c794f4b307 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 22 Oct 2009 19:11:48 +0100 Subject: scons: Hack LLVM support on Windows. Doesn't quite work yet though, as small differences in the compilation flags used when building LLVM and Mesa cause link failures for STL symbols. --- scons/llvm.py | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/scons/llvm.py b/scons/llvm.py index d3293bb404..73e9310f71 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -29,6 +29,7 @@ Tool-specific initialization for LLVM import os import os.path +import sys import SCons.Errors import SCons.Util @@ -39,7 +40,7 @@ def generate(env): llvm_dir = os.environ['LLVM'] except KeyError: # Do nothing -- use the system headers/libs - pass + llvm_dir = None else: if not os.path.isdir(llvm_dir): raise SCons.Errors.InternalError, "Specified LLVM directory not found" @@ -57,7 +58,47 @@ def generate(env): env.PrependENVPath('PATH', llvm_bin_dir) - if env.Detect('llvm-config'): + if env['msvc']: + # XXX: There is no llvm-config on Windows, so assume a standard layout + if llvm_dir is not None: + env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) + env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) + env.Prepend(LIBS = [ + 'LLVMBitWriter', + 'LLVMCore', + 'LLVMSupport', + 'LLVMSystem', + 'LLVMSupport', + 'LLVMSystem', + 'LLVMCore', + 'LLVMCodeGen', + 'LLVMSelectionDAG', + 'LLVMAsmPrinter', + 'LLVMBitReader', + 'LLVMBitWriter', + 'LLVMTransformUtils', + 'LLVMInstrumentation', + 'LLVMScalarOpts', + 'LLVMipo', + 'LLVMHello', + 'LLVMLinker', + 'LLVMAnalysis', + 'LLVMipa', + 'LLVMX86CodeGen', + 'LLVMX86AsmPrinter', + 'LLVMExecutionEngine', + 'LLVMInterpreter', + 'LLVMJIT', + 'LLVMTarget', + 'LLVMAsmParser', + 'LLVMDebugger', + 'LLVMArchive', + 'imagehlp', + 'psapi', + ]) + env['LLVM_VERSION'] = '2.5' + return + elif env.Detect('llvm-config'): version = env.backtick('llvm-config --version').rstrip() try: -- cgit v1.2.3 From 1f7f9bab8139681e1dcbc6c10fb42965059d1395 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 11:39:59 -0700 Subject: r300g: Move render functions to r300_render. Part of the fastpath cleanup. --- src/gallium/drivers/r300/r300_context.c | 67 +---------- src/gallium/drivers/r300/r300_context.h | 3 + src/gallium/drivers/r300/r300_render.c | 192 ++++++++++++++++++++++++++++++++ src/gallium/drivers/r300/r300_render.h | 52 +++++++++ 4 files changed, 249 insertions(+), 65 deletions(-) create mode 100644 src/gallium/drivers/r300/r300_render.h diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 4ba11a026e..c34fbb1123 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -34,75 +34,12 @@ #include "r300_context.h" #include "r300_flush.h" #include "r300_query.h" +#include "r300_render.h" #include "r300_screen.h" #include "r300_state_derived.h" #include "r300_state_invariant.h" #include "r300_winsys.h" -static boolean r300_draw_range_elements(struct pipe_context* pipe, - struct pipe_buffer* indexBuffer, - unsigned indexSize, - unsigned minIndex, - unsigned maxIndex, - unsigned mode, - unsigned start, - unsigned count) -{ - struct r300_context* r300 = r300_context(pipe); - int i; - - for (i = 0; i < r300->vertex_buffer_count; i++) { - void* buf = pipe_buffer_map(pipe->screen, - r300->vertex_buffers[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_vertex_buffer(r300->draw, i, buf); - } - - if (indexBuffer) { - void* indices = pipe_buffer_map(pipe->screen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); - draw_set_mapped_element_buffer_range(r300->draw, indexSize, - minIndex, maxIndex, indices); - } else { - draw_set_mapped_element_buffer(r300->draw, 0, NULL); - } - - draw_set_mapped_constant_buffer(r300->draw, - r300->shader_constants[PIPE_SHADER_VERTEX].constants, - r300->shader_constants[PIPE_SHADER_VERTEX].count * - (sizeof(float) * 4)); - - draw_arrays(r300->draw, mode, start, count); - - for (i = 0; i < r300->vertex_buffer_count; i++) { - pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer); - draw_set_mapped_vertex_buffer(r300->draw, i, NULL); - } - - if (indexBuffer) { - pipe_buffer_unmap(pipe->screen, indexBuffer); - draw_set_mapped_element_buffer_range(r300->draw, 0, start, - start + count - 1, NULL); - } - - return TRUE; -} - -static boolean r300_draw_elements(struct pipe_context* pipe, - struct pipe_buffer* indexBuffer, - unsigned indexSize, unsigned mode, - unsigned start, unsigned count) -{ - return r300_draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0, - mode, start, count); -} - -static boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode, - unsigned start, unsigned count) -{ - return r300_draw_elements(pipe, NULL, 0, mode, start, count); -} - static enum pipe_error r300_clear_hash_table(void* key, void* value, void* data) { @@ -189,7 +126,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen, r300->context.draw_arrays = r300_draw_arrays; r300->context.draw_elements = r300_draw_elements; - r300->context.draw_range_elements = r300_draw_range_elements; + r300->context.draw_range_elements = r300_swtcl_draw_range_elements; r300->context.is_texture_referenced = r300_is_texture_referenced; r300->context.is_buffer_referenced = r300_is_buffer_referenced; diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 4e2c0ec34e..30b80fa9db 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -273,6 +273,9 @@ struct r300_context { /* Vertex buffers for Gallium. */ struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS]; int vertex_buffer_count; + /* Vertex elements for Gallium. */ + struct pipe_vertex_element vertex_elements[PIPE_MAX_ATTRIBS]; + int vertex_element_count; /* Vertex shader. */ struct r300_vertex_shader* vs; /* Viewport state. */ diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 79a33b53cb..4916152bd6 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -31,11 +31,203 @@ #include "r300_context.h" #include "r300_emit.h" #include "r300_reg.h" +#include "r300_render.h" #include "r300_state_derived.h" /* r300_render: Vertex and index buffer primitive emission. */ #define R300_MAX_VBO_SIZE (1024 * 1024) +static uint32_t r300_translate_primitive(unsigned prim) +{ + switch (prim) { + case PIPE_PRIM_POINTS: + return R300_VAP_VF_CNTL__PRIM_POINTS; + case PIPE_PRIM_LINES: + return R300_VAP_VF_CNTL__PRIM_LINES; + case PIPE_PRIM_LINE_LOOP: + return R300_VAP_VF_CNTL__PRIM_LINE_LOOP; + case PIPE_PRIM_LINE_STRIP: + return R300_VAP_VF_CNTL__PRIM_LINE_STRIP; + case PIPE_PRIM_TRIANGLES: + return R300_VAP_VF_CNTL__PRIM_TRIANGLES; + case PIPE_PRIM_TRIANGLE_STRIP: + return R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP; + case PIPE_PRIM_TRIANGLE_FAN: + return R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN; + case PIPE_PRIM_QUADS: + return R300_VAP_VF_CNTL__PRIM_QUADS; + case PIPE_PRIM_QUAD_STRIP: + return R300_VAP_VF_CNTL__PRIM_QUAD_STRIP; + case PIPE_PRIM_POLYGON: + return R300_VAP_VF_CNTL__PRIM_POLYGON; + default: + return 0; + } +} + +/* This is the fast-path drawing & emission for HW TCL. */ +boolean r300_draw_range_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count) +{ + struct r300_context* r300 = r300_context(pipe); + CS_LOCALS(r300); + uint32_t prim = r300_translate_primitive(mode); + struct pipe_vertex_buffer* aos = r300->vertex_buffers; + unsigned aos_count = r300->vertex_buffer_count; + short* indices; + unsigned packet_size; + unsigned i; + bool invalid = FALSE; + +validate: + for (i = 0; i < aos_count; i++) { + if (!r300->winsys->add_buffer(r300->winsys, aos[i].buffer, + RADEON_GEM_DOMAIN_GTT, 0)) { + pipe->flush(pipe, 0, NULL); + goto validate; + } + } + if (!r300->winsys->validate(r300->winsys)) { + pipe->flush(pipe, 0, NULL); + if (invalid) { + /* Well, hell. */ + debug_printf("r300: Stuck in validation loop, gonna quit now."); + exit(1); + } + invalid = TRUE; + goto validate; + } + + r300_emit_dirty_state(r300); + + packet_size = (aos_count >> 1) * 3 + (aos_count & 1) * 2; + + BEGIN_CS(3 + packet_size + (aos_count * 2)); + OUT_CS_PKT3(R300_PACKET3_3D_LOAD_VBPNTR, packet_size); + OUT_CS(aos_count); + for (i = 0; i < aos_count - 1; i += 2) { + OUT_CS(aos[i].stride | + (aos[i].stride << 8) | + (aos[i + 1].stride << 16) | + (aos[i + 1].stride << 24)); + OUT_CS(aos[i].buffer_offset + start * 4 * aos[i].stride); + OUT_CS(aos[i + 1].buffer_offset + start * 4 * aos[i + 1].stride); + } + if (aos_count & 1) { + OUT_CS(aos[i].stride | (aos[i].stride << 8)); + OUT_CS(aos[i].buffer_offset + start * 4 * aos[i].stride); + } + for (i = 0; i < aos_count; i++) { + OUT_CS_RELOC(aos[i].buffer, 0, RADEON_GEM_DOMAIN_GTT, 0, 0); + } + END_CS; + + if (indexBuffer) { + indices = (short*)pipe_buffer_map(pipe->screen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); + + /* Set the starting point. */ + indices += start; + + BEGIN_CS(2 + (count+1)/2); + OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count + 1)/2); + OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) | prim); + for (i = 0; i < count - 1; i += 2) { + OUT_CS(indices[i + 1] << 16 | indices[i]); + } + if (count % 2) { + OUT_CS(indices[count - 1]); + } + END_CS; + } else { + BEGIN_CS(2); + OUT_CS_PKT3(R300_PACKET3_3D_DRAW_VBUF_2, 0); + OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (count << 16) | + prim); + END_CS; + } + + return TRUE; +} + +/* Simple helpers for context setup. Should probably be moved to util. */ +boolean r300_draw_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, unsigned mode, + unsigned start, unsigned count) +{ + return pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0, + mode, start, count); +} + +boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode, + unsigned start, unsigned count) +{ + return pipe->draw_elements(pipe, NULL, 0, mode, start, count); +} + +/**************************************************************************** + * The rest of this file is for SW TCL rendering only. Please be polite and * + * keep these functions separated so that they are easier to locate. ~C. * + ***************************************************************************/ + +/* Draw-based drawing for SW TCL chipsets. */ +boolean r300_swtcl_draw_range_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count) +{ + struct r300_context* r300 = r300_context(pipe); + int i; + + for (i = 0; i < r300->vertex_buffer_count; i++) { + void* buf = pipe_buffer_map(pipe->screen, + r300->vertex_buffers[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_vertex_buffer(r300->draw, i, buf); + } + + if (indexBuffer) { + void* indices = pipe_buffer_map(pipe->screen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); + draw_set_mapped_element_buffer_range(r300->draw, indexSize, + minIndex, maxIndex, indices); + } else { + draw_set_mapped_element_buffer(r300->draw, 0, NULL); + } + + draw_set_mapped_constant_buffer(r300->draw, + r300->shader_constants[PIPE_SHADER_VERTEX].constants, + r300->shader_constants[PIPE_SHADER_VERTEX].count * + (sizeof(float) * 4)); + + draw_arrays(r300->draw, mode, start, count); + + for (i = 0; i < r300->vertex_buffer_count; i++) { + pipe_buffer_unmap(pipe->screen, r300->vertex_buffers[i].buffer); + draw_set_mapped_vertex_buffer(r300->draw, i, NULL); + } + + if (indexBuffer) { + pipe_buffer_unmap(pipe->screen, indexBuffer); + draw_set_mapped_element_buffer_range(r300->draw, 0, start, + start + count - 1, NULL); + } + + return TRUE; +} + +/* Object for rendering using Draw. */ struct r300_render { /* Parent class */ struct vbuf_render base; diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h new file mode 100644 index 0000000000..3d8f47ba75 --- /dev/null +++ b/src/gallium/drivers/r300/r300_render.h @@ -0,0 +1,52 @@ +/* + * Copyright 2009 Corbin Simpson + * + * 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_RENDER_H +#define R300_RENDER_H + +boolean r300_draw_range_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count); + +boolean r300_draw_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, unsigned mode, + unsigned start, unsigned count); + +boolean r300_draw_arrays(struct pipe_context* pipe, unsigned mode, + unsigned start, unsigned count); + +boolean r300_swtcl_draw_range_elements(struct pipe_context* pipe, + struct pipe_buffer* indexBuffer, + unsigned indexSize, + unsigned minIndex, + unsigned maxIndex, + unsigned mode, + unsigned start, + unsigned count); + +#endif /* R300_RENDER_H */ -- cgit v1.2.3 From 06e464c2d57552d5ccde2b98885aeef953d8b2a1 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 11:45:36 -0700 Subject: r300g: Clean up duplicate code in r300_render. --- src/gallium/drivers/r300/r300_render.c | 49 +++------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 4916152bd6..6e2bcc62da 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -331,54 +331,13 @@ static boolean r300_render_set_primitive(struct vbuf_render* render, unsigned prim) { struct r300_render* r300render = r300_render(render); - r300render->prim = prim; - switch (prim) { - case PIPE_PRIM_POINTS: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POINTS; - break; - case PIPE_PRIM_LINES: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINES; - break; - case PIPE_PRIM_LINE_LOOP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_LOOP; - break; - case PIPE_PRIM_LINE_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_LINE_STRIP; - break; - case PIPE_PRIM_TRIANGLES: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLES; - break; - case PIPE_PRIM_TRIANGLE_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP; - break; - case PIPE_PRIM_TRIANGLE_FAN: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN; - break; - case PIPE_PRIM_QUADS: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUADS; - break; - case PIPE_PRIM_QUAD_STRIP: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_QUAD_STRIP; - break; - case PIPE_PRIM_POLYGON: - r300render->hwprim = R300_VAP_VF_CNTL__PRIM_POLYGON; - break; - default: - return FALSE; - break; - } + r300render->prim = prim; + r300render->hwprim = r300_translate_primitive(prim); return TRUE; } -static void r300_prepare_render(struct r300_render* render, unsigned count) -{ - struct r300_context* r300 = render->r300; - - r300_emit_dirty_state(r300); -} - static void r300_render_draw_arrays(struct vbuf_render* render, unsigned start, unsigned count) @@ -388,7 +347,7 @@ static void r300_render_draw_arrays(struct vbuf_render* render, CS_LOCALS(r300); - r300_prepare_render(r300render, count); + r300_emit_dirty_state(r300); DBG(r300, DBG_DRAW, "r300: Doing vbuf render, count %d\n", count); @@ -409,7 +368,7 @@ static void r300_render_draw(struct vbuf_render* render, CS_LOCALS(r300); - r300_prepare_render(r300render, count); + r300_emit_dirty_state(r300); BEGIN_CS(2 + (count+1)/2); OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, (count+1)/2); -- cgit v1.2.3 From 8e4657a9d4cbb899d388068cff0f8c267071fa50 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 12:29:30 -0700 Subject: Nuke s3v. As per FDO #17889. --- configs/linux-dri | 2 +- configs/linux-dri-xcb | 2 +- configure.ac | 2 +- src/mesa/drivers/dri/common/drirenderbuffer.h | 2 +- src/mesa/drivers/dri/s3v/Makefile | 35 - src/mesa/drivers/dri/s3v/s3v_common.h | 83 --- src/mesa/drivers/dri/s3v/s3v_context.c | 260 ------- src/mesa/drivers/dri/s3v/s3v_context.h | 443 ------------ src/mesa/drivers/dri/s3v/s3v_dd.c | 90 --- src/mesa/drivers/dri/s3v/s3v_dri.h | 143 ---- src/mesa/drivers/dri/s3v/s3v_inithw.c | 79 --- src/mesa/drivers/dri/s3v/s3v_lock.c | 62 -- src/mesa/drivers/dri/s3v/s3v_lock.h | 99 --- src/mesa/drivers/dri/s3v/s3v_macros.h | 230 ------- src/mesa/drivers/dri/s3v/s3v_regs.h | 367 ---------- src/mesa/drivers/dri/s3v/s3v_render.c | 203 ------ src/mesa/drivers/dri/s3v/s3v_screen.c | 99 --- src/mesa/drivers/dri/s3v/s3v_screen.h | 39 -- src/mesa/drivers/dri/s3v/s3v_span.c | 219 ------ src/mesa/drivers/dri/s3v/s3v_state.c | 888 ------------------------ src/mesa/drivers/dri/s3v/s3v_tex.c | 548 --------------- src/mesa/drivers/dri/s3v/s3v_tex.h | 28 - src/mesa/drivers/dri/s3v/s3v_texmem.c | 582 ---------------- src/mesa/drivers/dri/s3v/s3v_texstate.c | 300 -------- src/mesa/drivers/dri/s3v/s3v_tris.c | 850 ----------------------- src/mesa/drivers/dri/s3v/s3v_tris.h | 11 - src/mesa/drivers/dri/s3v/s3v_tritmp.h | 958 -------------------------- src/mesa/drivers/dri/s3v/s3v_vb.c | 339 --------- src/mesa/drivers/dri/s3v/s3v_vb.h | 39 -- src/mesa/drivers/dri/s3v/s3v_xmesa.c | 341 --------- src/mesa/drivers/dri/s3v/s3virgetri.h | 383 ---------- 31 files changed, 4 insertions(+), 7722 deletions(-) delete mode 100644 src/mesa/drivers/dri/s3v/Makefile delete mode 100644 src/mesa/drivers/dri/s3v/s3v_common.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_context.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_context.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_dd.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_dri.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_inithw.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_lock.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_lock.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_macros.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_regs.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_render.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_screen.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_screen.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_span.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_state.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_tex.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_tex.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_texmem.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_texstate.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_tris.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_tris.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_tritmp.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_vb.c delete mode 100644 src/mesa/drivers/dri/s3v/s3v_vb.h delete mode 100644 src/mesa/drivers/dri/s3v/s3v_xmesa.c delete mode 100644 src/mesa/drivers/dri/s3v/s3virgetri.h diff --git a/configs/linux-dri b/configs/linux-dri index 0998ba8549..89a7d07f45 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -63,5 +63,5 @@ GALLIUM_WINSYS_DIRS = drm GALLIUM_WINSYS_DRM_DIRS = intel GALLIUM_STATE_TRACKERS_DIRS = egl -DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \ +DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ savage sis tdfx trident unichrome ffb swrast diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index e9c15a82e4..d97f0b477e 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -68,5 +68,5 @@ WINDOW_SYSTEM=dri # gamma are missing because they have not been converted to use the new # interface. -DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \ +DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \ savage sis tdfx trident unichrome ffb diff --git a/configure.ac b/configure.ac index f8b9b53810..6622b0aa49 100644 --- a/configure.ac +++ b/configure.ac @@ -768,7 +768,7 @@ if test "$mesa_driver" = dri; then # default drivers if test "x$DRI_DIRS" = "xyes"; then - DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon s3v \ + DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \ savage sis tdfx trident unichrome ffb swrast" fi diff --git a/src/mesa/drivers/dri/common/drirenderbuffer.h b/src/mesa/drivers/dri/common/drirenderbuffer.h index cf55286b30..5ae28cb53a 100644 --- a/src/mesa/drivers/dri/common/drirenderbuffer.h +++ b/src/mesa/drivers/dri/common/drirenderbuffer.h @@ -56,7 +56,7 @@ typedef struct { * A handy flag to know if this is the back color buffer. * * \note - * This is currently only used by s3v and tdfx. + * This is currently only used by tdfx. */ GLboolean backBuffer; } driRenderbuffer; diff --git a/src/mesa/drivers/dri/s3v/Makefile b/src/mesa/drivers/dri/s3v/Makefile deleted file mode 100644 index da7e6cdc20..0000000000 --- a/src/mesa/drivers/dri/s3v/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -# src/mesa/drivers/dri/s3v/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = s3v_dri.so - -# Doesn't exist yet. -#MINIGLX_SOURCES = server/savage_dri.c - -DRIVER_SOURCES = \ - s3v_context.c \ - s3v_dd.c \ - s3v_inithw.c \ - s3v_lock.c \ - s3v_render.c \ - s3v_screen.c \ - s3v_span.c \ - s3v_state.c \ - s3v_tex.c \ - s3v_texmem.c \ - s3v_texstate.c \ - s3v_tris.c \ - s3v_vb.c \ - s3v_xmesa.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - - -include ../Makefile.template - diff --git a/src/mesa/drivers/dri/s3v/s3v_common.h b/src/mesa/drivers/dri/s3v/s3v_common.h deleted file mode 100644 index b66cdf1df0..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_common.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Author: Max Lingua - */ - -/* WARNING: If you change any of these defines, make sure to change - * the kernel include file as well (s3v_drm.h) - */ - -#ifndef _XF86DRI_S3V_H_ -#define _XF86DRI_S3V_H_ - -#ifndef _S3V_DEFINES_ -#define _S3V_DEFINES_ -#define S3V_USE_BATCH 1 - -/* #define S3V_BUF_4K 1 */ - -#ifdef S3V_BUF_4K -#define S3V_DMA_BUF_ORDER 12 -#define S3V_DMA_BUF_NR 256 -#else -#define S3V_DMA_BUF_ORDER 16 /* -much- better */ -#define S3V_DMA_BUF_NR 16 -#endif -/* on s3virge you can only choose between * - * 4k (2^12) and 64k (2^16) dma bufs */ -#define S3V_DMA_BUF_SZ (1< - */ - -#include "s3v_context.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "main/context.h" -#include "main/simple_list.h" -#include "main/matrix.h" -#include "main/extensions.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif -#include "main/simple_list.h" -#include "main/mm.h" - -#include "drivers/common/driverfuncs.h" -#include "s3v_vb.h" -#include "s3v_tris.h" - -#if 0 -extern const struct tnl_pipeline_stage _s3v_render_stage; - -static const struct tnl_pipeline_stage *s3v_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_fog_coordinate_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - /* REMOVE: point attenuation stage */ -#if 1 - &_s3v_render_stage, /* ADD: unclipped rastersetup-to-dma */ -#endif - &_tnl_render_stage, - 0, -}; -#endif - -GLboolean s3vCreateContext(const __GLcontextModes *glVisual, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) -{ - GLcontext *ctx, *shareCtx; - __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - s3vContextPtr vmesa; - s3vScreenPtr s3vScrn; - S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) + - sizeof(drm_sarea_t)); - struct dd_function_table functions; - - DEBUG_WHERE(("*** s3vCreateContext ***\n")); - - vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) ); - if ( !vmesa ) return GL_FALSE; - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - _mesa_init_driver_functions(&functions); - - vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions, - (void *)vmesa); - if (!vmesa->glCtx) { - FREE(vmesa); - return GL_FALSE; - } - - vmesa->driContext = driContextPriv; - vmesa->driScreen = sPriv; - vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */ - - vmesa->hHWContext = driContextPriv->hHWContext; - vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock; - vmesa->driFd = sPriv->fd; - vmesa->sarea = saPriv; - - s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private); - - ctx = vmesa->glCtx; - - ctx->Const.MaxTextureLevels = 11; /* it is (11-1) -> 1024 * 1024 FIXME */ - - ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */ - - /* No wide points. - */ - ctx->Const.MinPointSize = 1.0; - ctx->Const.MinPointSizeAA = 1.0; - ctx->Const.MaxPointSize = 1.0; - ctx->Const.MaxPointSizeAA = 1.0; - - /* No wide lines. - */ - ctx->Const.MinLineWidth = 1.0; - ctx->Const.MinLineWidthAA = 1.0; - ctx->Const.MaxLineWidth = 1.0; - ctx->Const.MaxLineWidthAA = 1.0; - ctx->Const.LineWidthGranularity = 1.0; - - ctx->Const.MaxDrawBuffers = 1; - - vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize ); - DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n", - vmesa->s3vScreen->textureSize)); - - /* NOTE */ - /* mmInit(offset, size); */ - - /* allocates a structure like this: - - struct mem_block_t { - struct mem_block_t *next; - struct mem_block_t *heap; - int ofs,size; - int align; - int free:1; - int reserved:1; - }; - - */ - - make_empty_list(&vmesa->TexObjList); - make_empty_list(&vmesa->SwappedOut); - - vmesa->CurrentTexObj[0] = 0; - vmesa->CurrentTexObj[1] = 0; /* FIXME */ - - vmesa->RenderIndex = ~0; - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ -#if 0 - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, s3v_pipeline ); -#endif - /* Configure swrast to match hardware characteristics: - */ -#if 0 - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); -#endif - vmesa->_3d_mode = 0; - - /* 3D lines / gouraud tris */ - vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555 - | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF - | Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR - | TEX_COL_ARGB1555 | CMD_3D ); - - vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF; - vmesa->alpha_cmd = vmesa->_alpha[0]; - vmesa->_tri[0] = DO_GOURAUD_TRI; - vmesa->_tri[1] = DO_TEX_LIT_TRI; - vmesa->prim_cmd = vmesa->_tri[0]; - - /* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */ - - vmesa->TexOffset = vmesa->s3vScreen->texOffset; - - s3vInitVB( ctx ); - s3vInitExtensions( ctx ); - s3vInitDriverFuncs( ctx ); - s3vInitStateFuncs( ctx ); - s3vInitSpanFuncs( ctx ); - s3vInitTextureFuncs( ctx ); - s3vInitTriFuncs( ctx ); - s3vInitState( vmesa ); - - driContextPriv->driverPrivate = (void *)vmesa; - - /* HACK */ - vmesa->bufSize = S3V_DMA_BUF_SZ; - - DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize)); - DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount)); - - - /* dma init */ - DEBUG_BUFS(("GET_FIRST_DMA\n")); - - vmesa->_bufNum = 0; - - GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext, - 1, &(vmesa->bufIndex[0]), &(vmesa->bufSize), - &vmesa->_buf[0], &vmesa->bufCount, s3vScrn); - - GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext, - 1, &(vmesa->bufIndex[1]), &(vmesa->bufSize), - &vmesa->_buf[1], &vmesa->bufCount, s3vScrn); - - vmesa->buf = vmesa->_buf[vmesa->_bufNum]; - -/* - vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555 - | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF - | DO_GOURAUD_TRI | CMD_3D); - - vmesa->TexOffset = vmesa->s3vScreen->texOffset; -*/ - -/* ... but we should support only 15 bit in virge (out of 8/15/24)... */ - - DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits)); - - switch (glVisual->depthBits) { - case 8: - break; - - case 15: - case 16: - vmesa->depth_scale = 1.0f / 0xffff; - break; - case 24: - vmesa->depth_scale = 1.0f / 0xffffff; - break; - default: - break; - } - - vmesa->cull_zero = 0.0f; - - vmesa->DepthSize = glVisual->depthBits; - vmesa->Flags = S3V_FRONT_BUFFER; - vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0); - vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0); - - vmesa->EnabledFlags = S3V_FRONT_BUFFER; - vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0); - - - if (vmesa->Flags & S3V_BACK_BUFFER) { - vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset; - } else { - vmesa->readOffset = vmesa->drawOffset = 0; - } - - s3vInitHW( vmesa ); - - driContextPriv->driverPrivate = (void *)vmesa; - - return GL_TRUE; -} diff --git a/src/mesa/drivers/dri/s3v/s3v_context.h b/src/mesa/drivers/dri/s3v/s3v_context.h deleted file mode 100644 index 671ba90d78..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_context.h +++ /dev/null @@ -1,443 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_CONTEXT_H_ -#define _S3V_CONTEXT_H_ - -#include "dri_util.h" - -#include "s3v_dri.h" -#include "s3v_regs.h" -#include "s3v_macros.h" -#include "s3v_screen.h" -#include "main/colormac.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "drm.h" -#include "main/mm.h" -#include "drirenderbuffer.h" - -/* Flags for context */ -#define S3V_FRONT_BUFFER 0x00000001 -#define S3V_BACK_BUFFER 0x00000002 -#define S3V_DEPTH_BUFFER 0x00000004 - - /* FIXME: check */ -#define S3V_MAX_TEXTURE_SIZE 2048 - -/* These are the minimum requirements and should probably be increased */ -#define MAX_MODELVIEW_STACK 16 -#define MAX_PROJECTION_STACK 2 -#define MAX_TEXTURE_STACK 2 - -extern void s3vDDUpdateHWState(GLcontext *ctx); -extern s3vScreenPtr s3vCreateScreen(__DRIscreenPrivate *sPriv); -extern void s3vDestroyScreen(__DRIscreenPrivate *sPriv); -extern GLboolean s3vCreateContext(const __GLcontextModes *glVisual, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate); - -#define S3V_UPLOAD_ALL 0xffffffff -/* #define S3V_UPLOAD_CLIPRECTS 0x00000002 */ -#define S3V_UPLOAD_ALPHA 0x00000004 -#define S3V_UPLOAD_BLEND 0x00000008 -#define S3V_UPLOAD_DEPTH 0x00000010 -#define S3V_UPLOAD_VIEWPORT 0x00000020 -#define S3V_UPLOAD_SHADE 0x00000040 -#define S3V_UPLOAD_CLIP 0x00000080 -#define S3V_UPLOAD_MASKS 0x00000100 -#define S3V_UPLOAD_WINDOW 0x00000200 /* defunct */ -#define S3V_UPLOAD_GEOMETRY 0x00000400 -#define S3V_UPLOAD_POLYGON 0x00000800 -#define S3V_UPLOAD_DITHER 0x00001000 -#define S3V_UPLOAD_LOGICOP 0x00002000 -#define S3V_UPLOAD_FOG 0x00004000 -#define S3V_UPLOAD_LIGHT 0x00008000 -#define S3V_UPLOAD_CONTEXT 0x00010000 -#define S3V_UPLOAD_TEX0 0x00020000 -#define S3V_UPLOAD_STIPPLE 0x00040000 -#define S3V_UPLOAD_TRANSFORM 0x00080000 -#define S3V_UPLOAD_LINEMODE 0x00100000 -#define S3V_UPLOAD_POINTMODE 0x00200000 -#define S3V_UPLOAD_TRIMODE 0x00400000 - -#define S3V_NEW_CLIP 0x00000001 -#define S3V_NEW_WINDOW 0x00000002 -#define S3V_NEW_CONTEXT 0x00000004 -#define S3V_NEW_TEXTURE 0x00000008 /* defunct */ -#define S3V_NEW_ALPHA 0x00000010 -#define S3V_NEW_DEPTH 0x00000020 -#define S3V_NEW_MASKS 0x00000040 -#define S3V_NEW_POLYGON 0x00000080 -#define S3V_NEW_CULL 0x00000100 -#define S3V_NEW_LOGICOP 0x00000200 -#define S3V_NEW_FOG 0x00000400 -#define S3V_NEW_LIGHT 0x00000800 -#define S3V_NEW_STIPPLE 0x00001000 -#define S3V_NEW_ALL 0xffffffff - -#define S3V_FALLBACK_TRI 0x00000001 -#define S3V_FALLBACK_TEXTURE 0x00000002 - -struct s3v_context; -typedef struct s3v_context s3vContextRec; -typedef struct s3v_context *s3vContextPtr; -typedef struct s3v_texture_object_t *s3vTextureObjectPtr; - -#define VALID_S3V_TEXTURE_OBJECT(tobj) (tobj) - -#define S3V_TEX_MAXLEVELS 12 - -/* For shared texture space managment, these texture objects may also - * be used as proxies for regions of texture memory containing other - * client's textures. Such proxy textures (not to be confused with GL - * proxy textures) are subject to the same LRU aging we use for our - * own private textures, and thus we have a mechanism where we can - * fairly decide between kicking out our own textures and those of - * other clients. - * - * Non-local texture objects have a valid MemBlock to describe the - * region managed by the other client, and can be identified by - * 't->globj == 0' - */ -struct s3v_texture_object_t { - struct s3v_texture_object_t *next, *prev; - - GLuint age; - struct gl_texture_object *globj; - - int Pitch; - int Height; - int WidthLog2; - int texelBytes; - int totalSize; - int bound; - - struct mem_block *MemBlock; - GLuint BufAddr; - - GLuint min_level; - GLuint max_level; - GLuint dirty_images; - - GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */ - - struct { - const struct gl_texture_image *image; - int offset; /* into BufAddr */ - int height; - int internalFormat; - } image[S3V_TEX_MAXLEVELS]; - - GLuint TextureCMD; - - GLuint TextureColorMode; - GLuint TextureFilterMode; - GLuint TextureBorderColor; - GLuint TextureWrap; - GLuint TextureMipSize; - - GLuint TextureBaseAddr[S3V_TEX_MAXLEVELS]; - GLuint TextureFormat; - GLuint TextureReadMode; -}; - -#define S3V_NO_PALETTE 0x0 -#define S3V_USE_PALETTE 0x1 -#define S3V_UPDATE_PALETTE 0x2 -#define S3V_FALLBACK_PALETTE 0x4 - -void s3vUpdateTextureState( GLcontext *ctx ); - -void s3vDestroyTexObj( s3vContextPtr vmesa, s3vTextureObjectPtr t); -void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t ); - -void s3vResetGlobalLRU( s3vContextPtr vmesa ); -void s3vTexturesGone( s3vContextPtr vmesa, - GLuint start, GLuint end, - GLuint in_use ); - -void s3vEmitHwState( s3vContextPtr vmesa ); -void s3vGetLock( s3vContextPtr vmesa, GLuint flags ); -void s3vInitExtensions( GLcontext *ctx ); -void s3vInitDriverFuncs( GLcontext *ctx ); -void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis); -void s3vInitState( s3vContextPtr vmesa ); -void s3vInitHW( s3vContextPtr vmesa ); -void s3vInitStateFuncs( GLcontext *ctx ); -void s3vInitTextureFuncs( GLcontext *ctx ); -void s3vInitTriFuncs( GLcontext *ctx ); - -void s3vUpdateWindow( GLcontext *ctx ); -void s3vUpdateViewportOffset( GLcontext *ctx ); - -void s3vPrintLocalLRU( s3vContextPtr vmesa ); -void s3vPrintGlobalLRU( s3vContextPtr vmesa ); - -extern void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode ); -#define FALLBACK( imesa, bit, mode ) s3vFallback( imesa, bit, mode ) - -/* Use the templated vertex formats. Only one of these is used in s3v. - */ -#define TAG(x) s3v##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -typedef void (*s3v_quad_func)( s3vContextPtr, - const s3vVertex *, - const s3vVertex *, - const s3vVertex *, - const s3vVertex * ); -typedef void (*s3v_tri_func)( s3vContextPtr, - const s3vVertex *, - const s3vVertex *, - const s3vVertex * ); -typedef void (*s3v_line_func)( s3vContextPtr, - const s3vVertex *, - const s3vVertex * ); -typedef void (*s3v_point_func)( s3vContextPtr, - const s3vVertex * ); - - -/* static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); */ -typedef void (*emit_func)( GLcontext *, GLuint, GLuint); - -struct s3v_context { - GLcontext *glCtx; /* Mesa context */ - - __DRIcontextPrivate *driContext; - __DRIscreenPrivate *driScreen; - __DRIdrawablePrivate *driDrawable; - - GLuint new_gl_state; - GLuint new_state; - GLuint dirty; - - S3VSAREAPtr sarea; - - /* Temporaries for translating away float colors - */ - struct gl_client_array UbyteColor; - struct gl_client_array UbyteSecondaryColor; - - /* Mirrors of some DRI state - */ - - drm_context_t hHWContext; - drmLock *driHwLock; - int driFd; - - GLuint numClipRects; /* Cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - - GLuint* buf; /* FIXME */ - GLuint* _buf[2]; - int _bufNum; - int bufIndex[2]; - int bufSize; - int bufCount; - - s3vScreenPtr s3vScreen; /* Screen private DRI data */ - - int drawOffset; - int readOffset; - - s3v_point_func draw_point; - s3v_line_func draw_line; - s3v_tri_func draw_tri; - s3v_quad_func draw_quad; - - GLuint Fallback; - GLuint RenderIndex; - GLuint SetupNewInputs; - GLuint SetupIndex; - - GLuint vertex_format; - GLuint vertex_size; - GLuint vertex_stride_shift; - char *verts; - - GLfloat hw_viewport[16]; - GLuint hw_primitive; - GLenum render_primitive; - - GLfloat depth_scale; - - s3vTextureObjectPtr CurrentTexObj[2]; - struct s3v_texture_object_t TexObjList; - struct s3v_texture_object_t SwappedOut; - GLenum TexEnvImageFmt[2]; - - struct mem_block *texHeap; - - int lastSwap; - int texAge; - int ctxAge; - int dirtyAge; - int lastStamp; - - /* max was here: don't touch */ - - unsigned int S3V_REG[S3V_REGS_NUM]; - - GLuint texMode; - GLuint alphaMode; - GLuint lightMode; - - GLuint SrcBase; - GLuint DestBase; - GLuint DestBlit; - GLuint ScissorLR; - GLuint ScissorTB; - GLuint ScissorWH; /* SubScissorWH */ /* RectWH */ - GLuint FrontStride; - GLuint BackStride; - GLuint SrcStride; - GLuint DestStride; - GLuint SrcXY; - GLuint DestXY; - - GLuint ClearColor; - GLuint Color; - GLuint DitherMode; - GLuint ClearDepth; - - GLuint TextureBorderColor; - GLuint TexOffset; - GLuint TexStride; - - GLuint CMD; - GLuint prim_cmd; - GLuint _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */ - GLuint alpha_cmd; /* actual alpha cmd */ - GLuint _alpha[2]; - GLuint _alpha_tex; /* tex alpha type */ - /* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */ - GLuint _3d_mode; - - GLfloat backface_sign; - GLfloat cull_zero; - - int restore_primitive; - -/* *** 2check *** */ - - GLuint FogMode; - GLuint AreaStippleMode; - GLuint LBReadFormat; - GLuint LBWriteFormat; - GLuint LineMode; - GLuint PointMode; - GLuint TriangleMode; - GLuint AntialiasMode; - GLfloat ViewportScaleX; - GLfloat ViewportScaleY; - GLfloat ViewportScaleZ; - GLfloat ViewportOffsetX; - GLfloat ViewportOffsetY; - GLfloat ViewportOffsetZ; - int MatrixMode; - int DepthMode; - int TransformMode; - int LBReadMode; - int FBReadMode; - int FBWindowBase; - int LBWindowBase; - int ColorDDAMode; - int GeometryMode; - int AlphaTestMode; - int AlphaBlendMode; - int AB_FBReadMode; - int AB_FBReadMode_Save; - int DeltaMode; - int ColorMaterialMode; - int FBHardwareWriteMask; - int MaterialMode; - int NormalizeMode; - int LightingMode; - int Light0Mode; - int Light1Mode; - int Light2Mode; - int Light3Mode; - int Light4Mode; - int Light5Mode; - int Light6Mode; - int Light7Mode; - int Light8Mode; - int Light9Mode; - int Light10Mode; - int Light11Mode; - int Light12Mode; - int Light13Mode; - int Light14Mode; - int Light15Mode; - int LogicalOpMode; - int ScissorMode; - int ScissorMaxXY; - int ScissorMinXY; - int Window; /* GID part probably should be in draw priv */ - int WindowOrigin; - int x, y, w, h; /* Probably should be in drawable priv */ - int FrameCount; /* Probably should be in drawable priv */ - int NotClipped; /* Probably should be in drawable priv */ - int WindowChanged; /* Probably should be in drawabl... */ - int Flags; - int EnabledFlags; - int DepthSize; - int Begin; - GLenum ErrorValue; - int Texture1DEnabled; - int Texture2DEnabled; - - float ModelView[16]; - float Proj[16]; - float ModelViewProj[16]; - float Texture[16]; - - float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16]; - int ModelViewCount; - float ProjStack[(MAX_PROJECTION_STACK-1)*16]; - int ProjCount; - float TextureStack[(MAX_TEXTURE_STACK-1)*16]; - int TextureCount; -}; - -#define S3VIRGEPACKCOLOR555( r, g, b, a ) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define S3VIRGEPACKCOLOR565( r, g, b ) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define S3VIRGEPACKCOLOR888( r, g, b ) \ - (((r) << 16) | ((g) << 8) | (b)) - -#define S3VIRGEPACKCOLOR8888( r, g, b, a ) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define S3VIRGEPACKCOLOR4444( r, g, b, a ) \ - ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) - -static INLINE GLuint s3vPackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - unsigned int ret; - DEBUG(("cpp = %i, r=0x%x, g=0x%x, b=0x%x, a=0x%x\n", cpp, r, g, b, a)); - - switch ( cpp ) { - case 2: - ret = S3VIRGEPACKCOLOR555( r, g, b, a ); - DEBUG(("ret = 0x%x\n", ret)); - return ret; - case 4: - return PACK_COLOR_8888( a, r, g, b ); - default: - return 0; - } -} - -#define S3V_CONTEXT(ctx) ((s3vContextPtr)(ctx->DriverCtx)) - -#endif /* _S3V_CONTEXT_H_ */ diff --git a/src/mesa/drivers/dri/s3v/s3v_dd.c b/src/mesa/drivers/dri/s3v/s3v_dd.c deleted file mode 100644 index e340116f5e..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_dd.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" -#include "s3v_vb.h" -#include "s3v_lock.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif - -#include "main/context.h" -#include "main/framebuffer.h" -#include "swrast/swrast.h" - -#define S3V_DATE "20020207" - - -/* Return the width and height of the current color buffer. - */ -static void s3vDDGetBufferSize( GLframebuffer *buffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - -/* S3VHW_LOCK( vmesa ); */ - *width = vmesa->driDrawable->w; - *height = vmesa->driDrawable->h; -/* S3VHW_UNLOCK( vmesa ); */ -} - - -/* Return various strings for glGetString(). - */ -static const GLubyte *s3vDDGetString( GLcontext *ctx, GLenum name ) -{ - static char buffer[128]; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte *)"Max Lingua (ladybug)"; - - case GL_RENDERER: - sprintf( buffer, "Mesa DRI S3 Virge " S3V_DATE ); - - /* Append any CPU-specific information. - */ -#ifdef USE_X86_ASM - if ( _mesa_x86_cpu_features ) { - strncat( buffer, " x86", 4 ); - -} -#ifdef USE_MMX_ASM - if ( cpu_has_mmx ) { - strncat( buffer, "/MMX", 4 ); - } -#endif -#ifdef USE_3DNOW_ASM - if ( cpu_has_3dnow ) { - strncat( buffer, "/3DNow!", 7 ); - } -#endif -#ifdef USE_SSE_ASM - if ( cpu_has_xmm ) { - strncat( buffer, "/SSE", 4 ); - } -#endif -#endif - return (GLubyte *)buffer; - - default: - return NULL; - } -} - -/* Enable the extensions supported by this driver. - */ -void s3vInitExtensions( GLcontext *ctx ) -{ - /* None... */ -} - -/* Initialize the driver's misc functions. - */ -void s3vInitDriverFuncs( GLcontext *ctx ) -{ - ctx->Driver.GetBufferSize = s3vDDGetBufferSize; - ctx->Driver.GetString = s3vDDGetString; -} diff --git a/src/mesa/drivers/dri/s3v/s3v_dri.h b/src/mesa/drivers/dri/s3v/s3v_dri.h deleted file mode 100644 index 339c579f7f..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_dri.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_DRI -#define _S3V_DRI - -#include "s3v_common.h" - -#define S3V_MAX_DRAWABLES (S3V_DMA_BUF_NR/2) /* 32 */ /* 256 */ /* FIXME */ - -typedef struct -{ - int deviceID; - int width; - int height; - int mem; - int cpp; - int bitsPerPixel; - - int fbOffset; - int fbStride; - - int logTextureGranularity; - int textureOffset; - - drm_handle_t regs; - drmSize regsSize; - - unsigned int sarea_priv_offset; -/* - drmAddress regsMap; - - drmSize textureSize; - drm_handle_t textures; -*/ - -#if 0 - drm_handle_t agp_buffers; - drmSize agp_buf_size; -#endif - -/* - drmBufMapPtr drmBufs; - int irq; - unsigned int sarea_priv_offset; -*/ - -/* FIXME: cleanup ! */ - - drmSize registerSize; /* == S3V_MMIO_REGSIZE */ - drm_handle_t registerHandle; - - drmSize pciSize; - drm_handle_t pciMemHandle; - - drmSize frontSize; /* == videoRambytes */ -/* drm_handle_t frontHandle; */ - unsigned long frontOffset; /* == fbOffset */ - int frontPitch; -/* unsigned char *front; */ - - unsigned int bufferSize; /* size of depth/back buffer */ - - drmSize backSize; -/* drm_handle_t backHandle; */ - unsigned long backOffset; - int backPitch; -/* unsigned char *back; */ - - drmSize depthSize; -/* drm_handle_t depthHandle; */ - unsigned long depthOffset; - int depthPitch; -/* unsigned char *depth; */ - - drmSize texSize; -/* drm_handle_t texHandle; */ - unsigned long texOffset; - int texPitch; -/* unsigned char *tex; */ - - drmSize dmaBufSize; /* Size of buffers (in bytes) */ - drm_handle_t dmaBufHandle; /* Handle from drmAddMap */ - unsigned long dmaBufOffset; /* Offset/Start */ - int dmaBufPitch; /* Pitch */ - unsigned char *dmaBuf; /* Map */ - int bufNumBufs; /* Number of buffers */ - drmBufMapPtr buffers; /* Buffer map */ - -} S3VDRIRec, *S3VDRIPtr; - -/* WARNING: Do not change the SAREA structure without changing the kernel - * as well */ - -typedef struct { - unsigned char next, prev; /* indices to form a circular LRU */ - unsigned char in_use; /* owned by a client, or free? */ - int age; /* tracked by clients to update local LRU's */ -} S3VTexRegionRec, *S3VTexRegionPtr; - -typedef struct { - unsigned int nbox; - drm_clip_rect_t boxes[S3V_NR_SAREA_CLIPRECTS]; - - /* Maintain an LRU of contiguous regions of texture space. If - * you think you own a region of texture memory, and it has an - * age different to the one you set, then you are mistaken and - * it has been stolen by another client. If global texAge - * hasn't changed, there is no need to walk the list. - * - * These regions can be used as a proxy for the fine-grained - * texture information of other clients - by maintaining them - * in the same lru which is used to age their own textures, - * clients have an approximate lru for the whole of global - * texture space, and can make informed decisions as to which - * areas to kick out. There is no need to choose whether to - * kick out your own texture or someone else's - simply eject - * them all in LRU order. - */ - S3VTexRegionRec texList[S3V_NR_TEX_REGIONS+1]; /* Last elt is sentinal */ - - int texAge; /* last time texture was uploaded */ - - int last_enqueue; /* last time a buffer was enqueued */ - int last_dispatch; /* age of the most recently dispatched buffer */ - int last_quiescent; /* */ - - int ctxOwner; /* last context to upload state */ -} S3VSAREARec, *S3VSAREAPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} S3VConfigPrivRec, *S3VConfigPrivPtr; - -typedef struct { - /* Nothing here yet */ - int dummy; -} S3VDRIContextRec, *S3VDRIContextPtr; - - -#endif diff --git a/src/mesa/drivers/dri/s3v/s3v_inithw.c b/src/mesa/drivers/dri/s3v/s3v_inithw.c deleted file mode 100644 index bdc9effb79..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_inithw.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include - -#include "s3v_context.h" - -void s3vInitHW( s3vContextPtr vmesa ) -{ - int i; - static short _reset = 1; - - DEBUG(("vmesa->driDrawable = %p\n", vmesa->driDrawable)); - DEBUG(("stride = %i\n", - vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp)); - DEBUG(("frontOffset = 0x%x\n", vmesa->s3vScreen->frontOffset)); - DEBUG(("backOffset = 0x%x\n", vmesa->s3vScreen->backOffset)); - DEBUG(("depthOffset = 0x%x\n", vmesa->s3vScreen->depthOffset)); - DEBUG(("textureOffset = 0x%x\n", vmesa->s3vScreen->texOffset)); - -/* if (_reset) { */ -/* ioctl(vmesa->driFd, 0x4a); */ - ioctl(vmesa->driFd, 0x41); /* reset */ - _reset = 0; -/* ioctl(vmesa->driFd, 0x4c); */ -/* } */ - - /* FIXME */ - switch (vmesa->s3vScreen->cpp) { - case 2: - break; - case 4: - break; - } - - /* FIXME for stencil, gid, etc */ - switch (vmesa->DepthSize) { - case 15: - case 16: - break; - case 24: - break; - case 32: - break; - } - - vmesa->FogMode = 1; - vmesa->ClearDepth = 0xffff; - vmesa->x = 0; - vmesa->y = 0; - vmesa->w = 0; - vmesa->h = 0; - vmesa->FrameCount = 0; - vmesa->MatrixMode = GL_MODELVIEW; - vmesa->ModelViewCount = 0; - vmesa->ProjCount = 0; - vmesa->TextureCount = 0; - - - /* FIXME: do we need the following? */ - - for (i = 0; i < 16; i++) - if (i % 5 == 0) - vmesa->ModelView[i] = - vmesa->Proj[i] = - vmesa->ModelViewProj[i] = - vmesa->Texture[i] = 1.0; - else - vmesa->ModelView[i] = - vmesa->Proj[i] = - vmesa->ModelViewProj[i] = - vmesa->Texture[i] = 0.0; - - vmesa->LBWindowBase = vmesa->driScreen->fbWidth * - (vmesa->driScreen->fbHeight - 1); - vmesa->FBWindowBase = vmesa->driScreen->fbWidth * - (vmesa->driScreen->fbHeight - 1); -} diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.c b/src/mesa/drivers/dri/s3v/s3v_lock.c deleted file mode 100644 index 52bb87ecec..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_lock.c +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" - -#if DEBUG_LOCKING -char *prevLockFile = NULL; -int prevLockLine = 0; -#endif - - -/* Update the hardware state. This is called if another context has - * grabbed the hardware lock, which includes the X server. This - * function also updates the driver's window state after the X server - * moves, resizes or restacks a window -- the change will be reflected - * in the drawable position and clip rects. Since the X server grabs - * the hardware lock when it changes the window state, this routine will - * automatically be called after such a change. - */ -void s3vGetLock( s3vContextPtr vmesa, GLuint flags ) -{ - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; -/* __DRIscreenPrivate *sPriv = vmesa->driScreen; */ - - printf("s3vGetLock <- ***\n"); - - drmGetLock( vmesa->driFd, vmesa->hHWContext, flags ); - - /* The window might have moved, so we might need to get new clip - * rects. - * - * NOTE: This releases and regrabs the hw lock to allow the X server - * to respond to the DRI protocol request for new drawable info. - * Since the hardware state depends on having the latest drawable - * clip rects, all state checking must be done _after_ this call. - */ - /* DRI_VALIDATE_DRAWABLE_INFO( vmesa->display, sPriv, dPriv ); */ - - if ( vmesa->lastStamp != dPriv->lastStamp ) { - vmesa->lastStamp = dPriv->lastStamp; - vmesa->new_state |= S3V_NEW_WINDOW | S3V_NEW_CLIP; - } - - vmesa->numClipRects = dPriv->numClipRects; - vmesa->pClipRects = dPriv->pClipRects; - -#if 0 - vmesa->dirty = ~0; - - if ( sarea->ctxOwner != vmesa->hHWContext ) { - sarea->ctxOwner = vmesa->hHWContext; - vmesa->dirty = S3V_UPLOAD_ALL; - } - - for ( i = 0 ; i < vmesa->lastTexHeap ; i++ ) { - if ( sarea->texAge[i] != vmesa->lastTexAge[i] ) { - s3vAgeTextures( vmesa, i ); - } - } -#endif -} diff --git a/src/mesa/drivers/dri/s3v/s3v_lock.h b/src/mesa/drivers/dri/s3v/s3v_lock.h deleted file mode 100644 index c39d24a38a..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_lock.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef __S3V_LOCK_H__ -#define __S3V_LOCK_H__ - -#include - -extern void s3vGetLock( s3vContextPtr vmesa, GLuint flags ); - -/* Turn DEBUG_LOCKING on to find locking conflicts. - */ -#define DEBUG_LOCKING 0 - -#if DEBUG_LOCKING -extern char *prevLockFile; -extern int prevLockLine; - -#define DEBUG_LOCK() \ - do { \ - prevLockFile = (__FILE__); \ - prevLockLine = (__LINE__); \ - } while (0) - -#define DEBUG_RESET() \ - do { \ - prevLockFile = 0; \ - prevLockLine = 0; \ - } while (0) - -#define DEBUG_CHECK_LOCK() \ - do { \ - if ( prevLockFile ) { \ - fprintf( stderr, \ - "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \ - prevLockFile, prevLockLine, __FILE__, __LINE__ ); \ - exit(1); \ - } \ - } while (0) - -#else - -#define DEBUG_LOCK() -#define DEBUG_RESET() -#define DEBUG_CHECK_LOCK() - -#endif - -/* - * !!! We may want to separate locks from locks with validation. This - * could be used to improve performance for those things commands that - * do not do any drawing !!! - */ - -/* Lock the hardware and validate our state. - */ -#define LOCK_HARDWARE( vmesa ) \ - do { \ - char __ret = 0; \ - DEBUG_CHECK_LOCK(); \ - DRM_CAS( vmesa->driHwLock, vmesa->hHWContext, \ - (DRM_LOCK_HELD | vmesa->hHWContext), __ret ); \ - if ( __ret ) \ - s3vGetLock( vmesa, 0 ); \ - DEBUG_LOCK(); \ - } while (0) - -/* Unlock the hardware. - */ -#define UNLOCK_HARDWARE( vmesa ) \ - do { \ - DRM_UNLOCK( vmesa->driFd, \ - vmesa->driHwLock, \ - vmesa->hHWContext ); \ - DEBUG_RESET(); \ - } while (0) - -#define S3VHW_LOCK( vmesa ) \ - DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \ - DRM_SPINLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \ - vmesa->driScreen->drawLockID); \ - /* VALIDATE_DRAWABLE_INFO_NO_LOCK(vmesa); */ - -#define S3VHW_UNLOCK( vmesa ) \ - DRM_SPINUNLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \ - vmesa->driScreen->drawLockID); \ - /* VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(vmesa); */ - -#define S3V_SIMPLE_LOCK( vmesa ) \ - ioctl(vmesa->driFd, 0x4a) - -#define S3V_SIMPLE_FLUSH_LOCK( vmesa ) \ - ioctl(vmesa->driFd, 0x4b) - -#define S3V_SIMPLE_UNLOCK( vmesa ) \ - ioctl(vmesa->driFd, 0x4c) - -#endif /* __S3V_LOCK_H__ */ diff --git a/src/mesa/drivers/dri/s3v/s3v_macros.h b/src/mesa/drivers/dri/s3v/s3v_macros.h deleted file mode 100644 index 7e9b4529df..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_macros.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_MACROS_H_ -#define _S3V_MACROS_H_ - -/**************/ -/* DRI macros */ -/**************/ - -#define GENERIC_DEBUG 0 -#define FLOW_DEBUG 0 -#define DMABUFS_DEBUG 0 - -/* Note: The argument to DEBUG*() _must_ be enclosed in parenthesis */ - -#if (GENERIC_DEBUG || FLOW_DEBUG || DMABUFS_DEBUG) -#include -#endif - -#undef DEBUG -#if GENERIC_DEBUG -#define DEBUG(str) printf str -#else -#define DEBUG(str) -#endif - -#if FLOW_DEBUG -#define DEBUG_WHERE(str) printf str -#else -#define DEBUG_WHERE(str) -#endif - -#if DMABUFS_DEBUG -#define DEBUG_BUFS(str) printf str -#else -#define DEBUG_BUFS(str) -#endif - - -#if 0 -#define S3V_DMA_SEND_FLAGS DRM_DMA_PRIORITY -#define S3V_DMA_SEND_FLAGS DRM_DMA_BLOCK -#else -#define S3V_DMA_SEND_FLAGS 0 -#endif - -#if 0 -#define S3V_DMA_GET_FLAGS \ - (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT) -#else -#define S3V_DMA_GET_FLAGS DRM_DMA_WAIT -#endif - - -#define DMAOUT_CHECK(reg,len) \ -do { \ - DEBUG(("DMAOUT_CHECK: reg = 0x%x\n", S3V_##reg##_REG)); \ - DEBUG_BUFS(("DMAOUT_CHECK (was): ")); \ - DEBUG_BUFS(("vmesa->bufCount=%i of vmesa->bufSize=%i\n", \ - vmesa->bufCount, vmesa->bufSize)); \ - /* FIXME: > or >= */ \ - if (vmesa->bufCount+(len+1) >= vmesa->bufSize) \ - DMAFLUSH(); \ -\ - vmesa->bufCount += (len+1); \ - DEBUG_BUFS(("DMAOUT_CHECK (is): vmesa->bufCount=%i len=%i, reg=%x\n", \ - vmesa->bufCount, len, S3V_##reg##_REG)); \ - DMAOUT( ((len & 0xffff) | ((S3V_##reg##_REG & 0xfffc) << 14)) ); \ -} while (0) - -#define DMAOUT(val) \ -do { \ - *(vmesa->buf++)=val; \ - DEBUG_BUFS(("DMAOUT: val=0x%x\n", (unsigned int)val)); \ -} while(0) - -#define DMAFINISH() \ -do { \ - /* NOTE: it does nothing - it just prints some summary infos */ \ - DEBUG(("DMAFINISH: vmesa->bufCount=%i\n", vmesa->bufCount)); \ - DEBUG(("buf: index=%i; addr=%p\n", vmesa->bufIndex[vmesa->_bufNum], \ - vmesa->s3vScreen->bufs->list[vmesa->bufIndex[vmesa->_bufNum]].address)); \ -} while(0) - -#define DMAFLUSH() \ -do { \ - if (vmesa->bufCount) { \ - SEND_DMA(vmesa->driFd, vmesa->hHWContext, 1, \ - &vmesa->bufIndex[vmesa->_bufNum], &vmesa->bufCount); \ -/* - GET_DMA(vmesa->driFd, vmesa->hHWContext, 1, \ - &vmesa->bufIndex, &vmesa->bufSize); \ -*/ \ - vmesa->_bufNum = !(vmesa->_bufNum); \ - vmesa->buf = vmesa->_buf[vmesa->_bufNum]; \ -/* - vmesa->buf = \ - vmesa->s3vScreen->bufs->list[vmesa->bufIndex].address; \ -*/ \ - vmesa->bufCount = 0; \ - } \ -} while (0) - -#define CMDCHANGE() \ -do { \ - DMAOUT_CHECK(3DTRI_CMDSET, 1); /* FIXME: TRI/LINE */ \ - DMAOUT(vmesa->CMD); \ - DMAFINISH(); \ -} while (0) - -#ifdef DONT_SEND_DMA -#define GET_DMA(fd, hHWCtx, n, idx, size) -#define SEND_DMA(fd, hHWCtx,n, idx, cnt) -#else -#define GET_DMA(fd, hHWCtx, n, idx, size) \ -do { \ - drmDMAReq dma; \ - int retcode, i; \ -\ - DEBUG(("GET_DMA: ")); \ - DEBUG(("req_count=%i; req_list[#0]=%i; req_size[#0]=%i\n", \ - n, (idx)[n-1], (size)[n-1])); \ -\ - dma.context = (hHWCtx); \ - dma.send_count = 0; \ - dma.send_list = NULL; \ - dma.send_sizes = NULL; \ - dma.flags = S3V_DMA_GET_FLAGS; \ - dma.request_count = (n); \ - dma.request_size = S3V_DMA_BUF_SZ; \ - dma.request_list = (idx); \ - dma.request_sizes = (size); \ -\ - do { \ - if ((retcode = drmDMA((fd), &dma))) { \ - DEBUG_BUFS(("drmDMA (get) returned %d\n", retcode)); \ - } \ -} while (!(dma).granted_count); \ -\ - for (i = 0; i < (n); i++) { \ - DEBUG(("Got buffer %i (index #%i)\n", (idx)[i], i)); \ - DEBUG(("of %i bytes (%i words) size\n", \ - (size)[i], (size)[i] >>2)); \ - /* Convert from bytes to words */ \ - (size)[i] >>= 2; \ - } \ -} while (0) - -#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \ -do { \ - drmDMAReq dma; \ - int retcode, i; \ -\ - DEBUG(("SEND_DMA: ")); \ - DEBUG(("send_count=%i; send_list[#0]=%i; send_sizes[#0]=%i\n", \ - n, (idx)[n-1], (cnt)[n-1])); \ -\ - for (i = 0; i < (n); i++) { \ - /* Convert from words to bytes */ \ - (cnt)[i] <<= 2; \ - } \ -\ - dma.context = (hHWCtx); \ - dma.send_count = (n); \ - dma.send_list = (idx); \ - dma.send_sizes = (cnt); \ - dma.flags = S3V_DMA_SEND_FLAGS; \ - dma.request_count = 0; \ - dma.request_size = 0; \ - dma.request_list = NULL; \ - dma.request_sizes = NULL; \ -\ - if ((retcode = drmDMA((fd), &dma))) { \ - DEBUG_BUFS(("drmDMA (send) returned %d\n", retcode)); \ - } \ -\ - for (i = 0; i < (n); i++) { \ - DEBUG(("Sent buffer %i (index #%i)\n", (idx)[i], i)); \ - DEBUG(("of %i bytes (%i words) size\n", \ - (cnt)[i], (cnt)[i] >>2)); \ - (cnt)[i] = 0; \ - } \ -} while (0) -#endif /* DONT_SEND_DMA */ - -#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, vPriv) \ -do { \ - int i; \ - DEBUG_BUFS(("GET_FIRST_DMA\n")); \ - DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, *idx, *size)); \ - DEBUG_BUFS(("going to GET_DMA\n")); \ - GET_DMA(fd, hHWCtx, n, idx, size); \ - DEBUG_BUFS(("coming from GET_DMA\n")); \ - DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, (idx)[0], (size)[0])); \ - for (i = 0; i < (n); i++) { \ - DEBUG_BUFS(("buf #%i @%p\n", \ - i, (vPriv)->bufs->list[(idx)[i]].address)); \ - (buf)[i] = (vPriv)->bufs->list[(idx)[i]].address; \ - (cnt)[i] = 0; \ - } \ - DEBUG(("GOING HOME\n")); \ -} while (0) - -/**************************/ -/* generic, global macros */ -/**************************/ - -#define CALC_LOG2(l2,s) \ -do { \ - int __s = s; \ - l2 = 0; \ - while (__s > 1) { ++l2; __s >>= 1; } \ -} while (0) - -#define PrimType_Null 0x00000000 -#define PrimType_Points 0x10000000 -#define PrimType_Lines 0x20000000 -#define PrimType_LineLoop 0x30000000 -#define PrimType_LineStrip 0x40000000 -#define PrimType_Triangles 0x50000000 -#define PrimType_TriangleStrip 0x60000000 -#define PrimType_TriangleFan 0x70000000 -#define PrimType_Quads 0x80000000 -#define PrimType_QuadStrip 0x90000000 -#define PrimType_Polygon 0xa0000000 -#define PrimType_Mask 0xf0000000 - -#endif /* _S3V_MACROS_H_ */ diff --git a/src/mesa/drivers/dri/s3v/s3v_regs.h b/src/mesa/drivers/dri/s3v/s3v_regs.h deleted file mode 100644 index 26a7c54af5..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_regs.h +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_REG_H -#define _S3V_REG_H - -#define S3V_REGS_NUM 256 - -/************ - * DMA REGS * - ************/ - -#define S3V_DMA_ID 0 -#define S3V_DMA_REG 0x8590 -#define S3V_DMA_WRITEP_ID 1 -#define S3V_DMA_WRITEP_REG 0x8594 -#define S3V_DMA_READP_ID 2 -#define S3V_DMA_READP_REG 0x8598 -#define S3V_DMA_ENABLE_ID 3 -#define S3V_DMA_ENABLE_REG 0x859C -#define S3V_DMA_UPDATE_ID 4 -#define S3V_DMA_UPDATE_REG 0x10000 - -/*************** - * STATUS REGS * - ***************/ - -#define S3V_STAT_ID 10 -#define S3V_STAT_REG 0x8504 -#define S3V_STAT_VSYNC_ID 11 -#define S3V_STAT_VSYNC_REG 0x8505 -#define S3V_STAT_3D_DONE_ID 12 -#define S3V_STAT_3D_DONE_REG 0x8506 -#define S3V_STAT_FIFO_OVER_ID 13 -#define S3V_STAT_FIFO_OVER_REG 0x8508 -#define S3V_STAT_FIFO_EMPTY_ID 14 -#define S3V_STAT_FIFO_EMPTY_REG 0x850C -#define S3V_STAT_HDMA_DONE_ID 15 -#define S3V_STAT_HDMA_DONE_REG 0x8514 -#define S3V_STAT_CDMA_DONE_ID 16 -#define S3V_STAT_CDMA_DONE_REG 0x8524 -#define S3V_STAT_3D_FIFO_EMPTY_ID 17 -#define S3V_STAT_3D_FIFO_EMPTY_REG 0x8544 -#define S3V_STAT_LPB_ID 18 -#define S3V_STAT_LPB_REG 0x8584 -#define S3V_STAT_3D_BUSY_ID 19 -#define S3V_STAT_3D_BUSY_REG 0x8704 - -/*********** - * 2D REGS * - ***********/ - -#define S3V_BITBLT_ID 30 -#define S3V_BITBLT_REG 0xA400 -#define S3V_BITBLT_SRC_BASE_ID 31 -#define S3V_BITBLT_SRC_BASE_REG 0xA4D4 -#define S3V_BITBLT_DEST_BASE_ID 32 -#define S3V_BITBLT_DEST_BASE_REG 0xA4D8 -#define S3V_BITBLT_CLIP_L_R_ID 33 -#define S3V_BITBLT_CLIP_L_R_REG 0xA4DC -#define S3V_BITBLT_CLIP_T_B_ID 34 -#define S3V_BITBLT_CLIP_T_B_REG 0xA4E0 -#define S3V_BITBLT_DEST_SRC_STRIDE_ID 35 -#define S3V_BITBLT_DEST_SRC_STRIDE_REG 0xA4E4 -#define S3V_BITBLT_MONO_PAT0_ID 36 -#define S3V_BITBLT_MONO_PAT0_REG 0xA4E8 -#define S3V_BITBLT_MONO_PAT1_ID 37 -#define S3V_BITBLT_MONO_PAT1_REG 0xA4EC -#define S3V_BITBLT_PAT_BG_COLOR_ID 38 -#define S3V_BITBLT_PAT_BG_COLOR_REG 0xA4F0 -#define S3V_BITBLT_PAT_FG_COLOR_ID 39 -#define S3V_BITBLT_PAT_FG_COLOR_REG 0xA4F4 -#define S3V_BITBLT_CMDSET_ID 40 -#define S3V_BITBLT_CMDSET_REG 0xA500 -#define S3V_BITBLT_WIDTH_HEIGHT_ID 41 -#define S3V_BITBLT_WIDTH_HEIGHT_REG 0xA504 -#define S3V_BITBLT_SRC_X_Y_ID 42 -#define S3V_BITBLT_SRC_X_Y_REG 0xA508 -#define S3V_BITBLT_DEST_X_Y_ID 43 -#define S3V_BITBLT_DEST_X_Y_REG 0xA50C -#define S3V_2DLINE_ID 44 -#define S3V_2DLINE_REG 0xA800 -#define S3V_2DPOLY_ID 45 -#define S3V_2DPOLY_REG 0xAC00 - -/*************** - * 3DLINE REGS * - ***************/ -/* base regs */ -#define S3V_3DLINE_ID 50 -#define S3V_3DLINE_REG 0xB000 -#define S3V_3DLINE_Z_BASE_ID 51 -#define S3V_3DLINE_Z_BASE_REG 0xB0D4 -#define S3V_3DLINE_SRC_BASE_ID 52 /* it is the same reg */ -#define S3V_3DLINE_SRC_BASE_REG 0xB0D4 -#define S3V_3DLINE_DEST_BASE_ID 53 -#define S3V_3DLINE_DEST_BASE_REG 0xB0D8 -#define S3V_3DLINE_CLIP_L_R_ID 54 -#define S3V_3DLINE_CLIP_L_R_REG 0xB0DC -#define S3V_3DLINE_CLIP_T_B_ID 55 -#define S3V_3DLINE_CLIP_T_B_REG 0xB0E0 -#define S3V_3DLINE_DEST_SRC_STRIDE_ID 56 -#define S3V_3DLINE_DEST_SRC_STRIDE_REG 0xB0E4 -#define S3V_3DLINE_Z_STRIDE_ID 57 -#define S3V_3DLINE_Z_STRIDE_REG 0xB0E8 -#define S3V_3DLINE_TEX_BASE_ID 58 -#define S3V_3DLINE_TEX_BASE_REG 0xB0EC -#define S3V_3DLINE_TEX_B_COLOR_ID 59 -#define S3V_3DLINE_TEX_B_COLOR_REG 0xB0F0 -#define S3V_3DLINE_FOG_COLOR_ID 60 -#define S3V_3DLINE_FOG_COLOR_REG 0xB0F4 -#define S3V_3DLINE_COLOR0_ID 61 -#define S3V_3DLINE_COLOR0_REG 0xB0F8 -#define S3V_3DLINE_COLOR1_ID 62 -#define S3V_3DLINE_COLOR1_REG 0xB0FC -#define S3V_3DLINE_CMDSET_ID 63 -#define S3V_3DLINE_CMDSET_REG 0xB100 /* special */ -/* tex regs */ -/* FIXME: shouldn't it be a 1D tex for lines? */ -#define S3V_3DLINE_BASEV_ID 64 -#define S3V_3DLINE_BASEV_REG 0xB104 -#define S3V_3DLINE_BASEU_ID 65 -#define S3V_3DLINE_BASEU_REG 0xB108 -#define S3V_3DLINE_WXD_ID 66 -#define S3V_3DLINE_WXD_REG 0xB10C -#define S3V_3DLINE_WYD_ID 67 -#define S3V_3DLINE_WYD_REG 0xB110 -#define S3V_3DLINE_WSTART_ID 68 -#define S3V_3DLINE_WSTART_REG 0xB114 -#define S3V_3DLINE_DXD_ID 69 -#define S3V_3DLINE_DXD_REG 0xB118 -#define S3V_3DLINE_VXD_ID 70 -#define S3V_3DLINE_VXD_REG 0xB11C -#define S3V_3DLINE_UXD_ID 71 -#define S3V_3DLINE_UXD_REG 0xB120 -#define S3V_3DLINE_DYD_ID 72 -#define S3V_3DLINE_DYD_REG 0xB124 -#define S3V_3DLINE_VYD_ID 73 -#define S3V_3DLINE_VYD_REG 0xB128 -#define S3V_3DLINE_UYD_ID 74 -#define S3V_3DLINE_UYD_REG 0xB12C -#define S3V_3DLINE_DSTART_ID 75 -#define S3V_3DLINE_DSTART_REG 0xB130 -#define S3V_3DLINE_VSTART_ID 76 -#define S3V_3DLINE_VSTART_REG 0xB134 -#define S3V_3DLINE_USTART_ID 77 -#define S3V_3DLINE_USTART_REG 0xB138 -/* gourad regs */ -#define S3V_3DLINE_GBD_ID 78 -#define S3V_3DLINE_GBD_REG 0xB144 -#define S3V_3DLINE_ARD_ID 79 -#define S3V_3DLINE_ARD_REG 0xB148 -#define S3V_3DLINE_GS_BS_ID 80 -#define S3V_3DLINE_GS_BS_REG 0xB14C -#define S3V_3DLINE_AS_RS_ID 81 -#define S3V_3DLINE_AS_RS_REG 0xB150 -/* vertex regs */ -#define S3V_3DLINE_DZ_ID 82 -#define S3V_3DLINE_DZ_REG 0xB158 -#define S3V_3DLINE_ZSTART_ID 83 -#define S3V_3DLINE_ZSTART_REG 0xB15C -#define S3V_3DLINE_XEND0_END1_ID 84 -#define S3V_3DLINE_XEND0_END1_REG 0xB16C -#define S3V_3DLINE_DX_ID 85 -#define S3V_3DLINE_DX_REG 0xB170 -#define S3V_3DLINE_XSTART_ID 86 -#define S3V_3DLINE_XSTART_REG 0xB174 -#define S3V_3DLINE_YSTART_ID 87 -#define S3V_3DLINE_YSTART_REG 0xB178 -#define S3V_3DLINE_YCNT_ID 88 -#define S3V_3DLINE_YCNT_REG 0xB17C - -/************** - * 3DTRI REGS * - **************/ -/* base regs */ -#define S3V_3DTRI_ID 100 -#define S3V_3DTRI_REG 0xB400 -#define S3V_3DTRI_Z_BASE_ID 101 -#define S3V_3DTRI_Z_BASE_REG 0xB4D4 -#define S3V_3DTRI_SRC_BASE_ID 102 /* it is the same reg */ -#define S3V_3DTRI_SRC_BASE_REG 0xB4D4 -#define S3V_3DTRI_DEST_BASE_ID 103 -#define S3V_3DTRI_DEST_BASE_REG 0xB4D8 -#define S3V_3DTRI_CLIP_L_R_ID 104 -#define S3V_3DTRI_CLIP_L_R_REG 0xB4DC -#define S3V_3DTRI_CLIP_T_B_ID 105 -#define S3V_3DTRI_CLIP_T_B_REG 0xB4E0 -#define S3V_3DTRI_DEST_SRC_STRIDE_ID 106 -#define S3V_3DTRI_DEST_SRC_STRIDE_REG 0xB4E4 -#define S3V_3DTRI_Z_STRIDE_ID 107 -#define S3V_3DTRI_Z_STRIDE_REG 0xB4E8 -#define S3V_3DTRI_TEX_BASE_ID 108 -#define S3V_3DTRI_TEX_BASE_REG 0xB4EC -#define S3V_3DTRI_TEX_B_COLOR_ID 109 -#define S3V_3DTRI_TEX_B_COLOR_REG 0xB4F0 -#define S3V_3DTRI_FOG_COLOR_ID 110 -#define S3V_3DTRI_FOG_COLOR_REG 0xB4F4 -#define S3V_3DTRI_COLOR0_ID 111 -#define S3V_3DTRI_COLOR0_REG 0xB4F8 -#define S3V_3DTRI_COLOR1_ID 112 -#define S3V_3DTRI_COLOR1_REG 0xB4FC -#define S3V_3DTRI_CMDSET_ID 113 /* special */ -#define S3V_3DTRI_CMDSET_REG 0xB500 -/* tex regs */ -#define S3V_3DTRI_BASEV_ID 114 -#define S3V_3DTRI_BASEV_REG 0xB504 -#define S3V_3DTRI_BASEU_ID 115 -#define S3V_3DTRI_BASEU_REG 0xB508 -#define S3V_3DTRI_WXD_ID 116 -#define S3V_3DTRI_WXD_REG 0xB50C -#define S3V_3DTRI_WYD_ID 117 -#define S3V_3DTRI_WYD_REG 0xB510 -#define S3V_3DTRI_WSTART_ID 118 -#define S3V_3DTRI_WSTART_REG 0xB514 -#define S3V_3DTRI_DXD_ID 119 -#define S3V_3DTRI_DXD_REG 0xB518 -#define S3V_3DTRI_VXD_ID 120 -#define S3V_3DTRI_VXD_REG 0xB51C -#define S3V_3DTRI_UXD_ID 121 -#define S3V_3DTRI_UXD_REG 0xB520 -#define S3V_3DTRI_DYD_ID 122 -#define S3V_3DTRI_DYD_REG 0xB524 -#define S3V_3DTRI_VYD_ID 123 -#define S3V_3DTRI_VYD_REG 0xB528 -#define S3V_3DTRI_UYD_ID 124 -#define S3V_3DTRI_UYD_REG 0xB52C -#define S3V_3DTRI_DSTART_ID 125 -#define S3V_3DTRI_DSTART_REG 0xB530 -#define S3V_3DTRI_VSTART_ID 126 -#define S3V_3DTRI_VSTART_REG 0xB534 -#define S3V_3DTRI_USTART_ID 127 -#define S3V_3DTRI_USTART_REG 0xB538 -/* gourad regs */ -#define S3V_3DTRI_GBX_ID 128 -#define S3V_3DTRI_GBX_REG 0xB53C -#define S3V_3DTRI_ARX_ID 129 -#define S3V_3DTRI_ARX_REG 0xB540 -#define S3V_3DTRI_GBY_ID 130 -#define S3V_3DTRI_GBY_REG 0xB544 -#define S3V_3DTRI_ARY_ID 131 -#define S3V_3DTRI_ARY_REG 0xB548 -#define S3V_3DTRI_GS_BS_ID 132 -#define S3V_3DTRI_GS_BS_REG 0xB54C -#define S3V_3DTRI_AS_RS_ID 133 -#define S3V_3DTRI_AS_RS_REG 0xB550 -/* vertex regs */ -#define S3V_3DTRI_ZXD_ID 134 -#define S3V_3DTRI_ZXD_REG 0xB554 -#define S3V_3DTRI_ZYD_ID 135 -#define S3V_3DTRI_ZYD_REG 0xB558 -#define S3V_3DTRI_ZSTART_ID 136 -#define S3V_3DTRI_ZSTART_REG 0xB55C -#define S3V_3DTRI_TXDELTA12_ID 137 -#define S3V_3DTRI_TXDELTA12_REG 0xB560 -#define S3V_3DTRI_TXEND12_ID 138 -#define S3V_3DTRI_TXEND12_REG 0xB564 -#define S3V_3DTRI_TXDELTA01_ID 139 -#define S3V_3DTRI_TXDELTA01_REG 0xB568 -#define S3V_3DTRI_TXEND01_ID 140 -#define S3V_3DTRI_TXEND01_REG 0xB56C -#define S3V_3DTRI_TXDELTA02_ID 141 -#define S3V_3DTRI_TXDELTA02_REG 0xB570 -#define S3V_3DTRI_TXSTART02_ID 142 -#define S3V_3DTRI_TXSTART02_REG 0xB574 -#define S3V_3DTRI_TYS_ID 143 -#define S3V_3DTRI_TYS_REG 0xB578 -#define S3V_3DTRI_TY01_Y12_ID 144 -#define S3V_3DTRI_TY01_Y12_REG 0xB57C - -/* COMMANDS (to 0xB100 [lines] or 0xB500 [tris]) */ - -/* Auto execute */ -#define AUTO_EXEC_MASK 0x00000001 -#define AUTO_EXEC_OFF (0x0) -#define AUTO_EXEC_ON (0x1) -/* HW clipping */ -#define HW_CLIP_MASK 0x00000002 -#define HW_CLIP_OFF (0x0 << 1) -#define HW_CLIP_ON (0x1 << 1) -/* Destination color */ -#define DEST_COL_MASK 0x0000001c -#define DEST_COL_PAL (0x0 << 2) /* 8 bpp - palettized */ -#define DEST_COL_1555 (0x1 << 2) /* 16 bpp - ZRGB */ -#define DEST_COL_888 (0x2 << 2) /* 24 bpp - RGB */ -/* Texture color */ -#define TEX_COL_MASK 0x000000e0 -#define TEX_COL_ARGB8888 (0x0 << 5) /* 32 bpp - ARGB */ -#define TEX_COL_ARGB4444 (0x1 << 5) /* 16 bpp - ARGB */ -#define TEX_COL_ARGB1555 (0x2 << 5) /* 16 bpp - ARGB */ -#define TEX_COL_ALPHA4 (0x3 << 5) /* 8 bpp - ALPHA4 */ -#define TEX_COL_BLEND4_LOW (0x4 << 5) /* 4 bpp - BLEND4 low nibble */ -#define TEX_COL_BLEND4_HIGH (0x5 << 5) /* 4 bpp - BLEND4 high nibble */ -#define TEX_COL_PAL (0x6 << 5) /* 8 bpp - palettized */ -#define TEX_COL_YUV (0x7 << 5) /* 16 bpp - YUV */ -/* Mipmap level */ -#define MIP_MASK 0x00000f00 -#define MIPMAP_LEVEL(s) (s << 8) /* 8 -> 11 bits */ -/* Texture filtering */ -#define TEX_FILTER_MASK 0x00007000 -#define MIP_NEAREST (0x0 << 12) -#define LINEAR_MIP_NEAREST (0x1 << 12) -#define MIP_LINEAR (0x2 << 12) -#define LINEAR_MIP_LINEAR (0x3 << 12) -#define NEAREST (0x4 << 12) -#define FAST_BILINEAR (0x5 << 12) -#define LINEAR (0x6 << 12) -/* Texture blending */ -#define TEX_BLEND_MAKS 0x00018000 -#define TEX_REFLECT (0x0 << 15) -#define TEX_MODULATE (0x1 << 15) -#define TEX_DECAL (0x2 << 15) -/* Fog */ -#define FOG_MASK 0x00020000 -#define FOG_OFF (0x0 << 17) -#define FOG_ON (0x1 << 17) -/* Alpha blending */ -#define ALPHA_BLEND_MASK 0x000c0000 -#define ALPHA_OFF (0x0 << 18) | (0x0 << 19) -#define ALPHA_TEX (0x2 << 18) -#define ALPHA_SRC (0x3 << 18) -/* Depth compare mode */ -#define Z_MODE_MASK 0x00700000 -#define Z_NEVER (0x0 << 20) -#define Z_GREATER (0x1 << 20) -#define Z_EQUAL (0x2 << 20) -#define Z_GEQUAL (0x3 << 20) -#define Z_LESS (0x4 << 20) -#define Z_NOTEQUAL (0x5 << 20) -#define Z_LEQUAL (0x6 << 20) -#define Z_ALWAYS (0x7 << 20) -/* Depth update */ -#define Z_UPDATE_MASK 0x00800000 -#define Z_UPDATE_OFF (0x0 << 23) /* disable z update */ -#define Z_UPDATE_ON (0x1 << 23) -/* Depth buffering mode */ -#define Z_BUFFER_MASK 0x03000000 -#define Z_BUFFER (0x0 << 24) | (0x0 << 25) -#define Z_MUX_BUF (0x1 << 24) | (0x0 << 25) -#define Z_MUX_DRAW (0x2 << 24) -#define Z_OFF (0x3 << 24) /* no z buffering */ -/* Texture wrapping */ -#define TEX_WRAP_MASK 0x04000000 -#define TEX_WRAP_OFF (0x0 << 26) -#define TEX_WRAP_ON (0x1 << 26) -/* 3d command */ -#define DO_MASK 0x78000000 -#define DO_GOURAUD_TRI (0x0 << 27) -#define DO_TEX_LIT_TRI_OLD (0x1 << 27) -#define DO_TEX_UNLIT_TRI_OLD (0x2 << 27) -#define DO_TEX_LIT_TRI (0x5 << 27) -#define DO_TEX_UNLIT_TRI (0x6 << 27) -#define DO_3D_LINE (0x8 << 27) -#define DO_NOP (0xf << 27) /* turn on autoexec */ -/* status */ -#define CMD_MASK 0x80000000 -#define CMD_2D (0x0 << 31) /* execute a 2d cmd */ -#define CMD_3D (0x1 << 31) /* execute a 3d cmd */ - -/* global masks */ -#define TEX_MASK ( TEX_COL_MASK | TEX_WRAP_MASK | MIP_MASK \ - | TEX_FILTER_MASK | TEX_BLEND_MAKS \ - | TEX_WRAP_MASK ) -#define Z_MASK ( Z_MODE_MASK | Z_UPDATE_MASK | Z_BUFFER_MASK ) - -#endif /* _S3V_REG_H */ diff --git a/src/mesa/drivers/dri/s3v/s3v_render.c b/src/mesa/drivers/dri/s3v/s3v_render.c deleted file mode 100644 index 5023f3c464..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_render.c +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "main/glheader.h" -#include "main/context.h" -#include "main/macros.h" -#include "main/mtypes.h" - -#include "tnl/t_context.h" - -#include "s3v_context.h" -#include "s3v_tris.h" -#include "s3v_vb.h" - - -#define HAVE_POINTS 0 -#define HAVE_LINES 0 -#define HAVE_LINE_STRIPS 0 -#define HAVE_TRIANGLES 0 -#define HAVE_TRI_STRIPS 0 -#define HAVE_TRI_STRIP_1 0 -#define HAVE_TRI_FANS 0 -#define HAVE_QUADS 0 -#define HAVE_QUAD_STRIPS 0 -#define HAVE_POLYGONS 0 - -#define HAVE_ELTS 0 - -#if 0 -static void VERT_FALLBACK( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); -/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */ - int _flags; - - DEBUG(("VERT_FALLBACK: flags & PRIM_MODE_MASK = %i\n", - flags & PRIM_MODE_MASK)); - DEBUG(("VERT_FALLBACK: flags=%i PRIM_MODE_MASK=%i\n", - flags, PRIM_MODE_MASK)); -#if 0 - tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK ); -#endif - tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 ); - - _flags = flags & PRIM_MODE_MASK; - - tnl->Driver.Render.PrimTabVerts[_flags]( ctx, start, count, flags ); - S3V_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS; -} -#endif - -static const GLuint hw_prim[GL_POLYGON+1] = { - PrimType_Points, - PrimType_Lines, - PrimType_LineLoop, - PrimType_LineStrip, - PrimType_Triangles, - PrimType_TriangleStrip, - PrimType_TriangleFan, - PrimType_Quads, - PrimType_QuadStrip, - PrimType_Polygon -}; - -static INLINE void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim ) -{ - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - - int _hw_prim = hw_prim[prim]; - - DEBUG(("s3vStartPrimitive (new #%i) ", prim)); - - if (_hw_prim != vmesa->restore_primitive) { - - if (prim == 4) { /* TRI */ - DEBUG(("switching to tri\n")); - vmesa->prim_cmd = vmesa->_tri[vmesa->_3d_mode]; - vmesa->alpha_cmd = vmesa->_alpha[vmesa->_3d_mode]; - DMAOUT_CHECK(3DTRI_Z_BASE, 12); - } else if (prim == 1) { /* LINE */ - DEBUG(("switching to line\n")); - vmesa->prim_cmd = DO_3D_LINE; - vmesa->alpha_cmd = vmesa->_alpha[0]; - DMAOUT_CHECK(3DLINE_Z_BASE, 12); - } else { - DEBUG(("Never mind the bollocks!\n")); - } - - DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8); - DMAOUT(vmesa->DestBase); - /* DMAOUT(vmesa->ScissorLR); */ - /* DMAOUT(vmesa->ScissorTB); */ - DMAOUT( (0 << 16) | (dPriv->w-1) ); - DMAOUT( (0 << 16) | (dPriv->h-1) ); - DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride ); - DMAOUT(vmesa->SrcStride); - DMAOUT(vmesa->TexOffset); - DMAOUT(vmesa->TextureBorderColor); - DMAOUT(0); /* FOG */ - DMAOUT(0); - DMAOUT(0); - DMAOUT(vmesa->CMD | vmesa->prim_cmd | vmesa->alpha_cmd); - DMAFINISH(); - } - - vmesa->restore_primitive = _hw_prim; -} - -static INLINE void s3vEndPrimitive( s3vContextPtr vmesa ) -{ -/* GLcontext *ctx = vmesa->glCtx; */ - DEBUG(("s3vEndPrimitive\n")); -} - -#define LOCAL_VARS s3vContextPtr vmesa = S3V_CONTEXT(ctx) -#define INIT( prim ) s3vStartPrimitive( vmesa, prim ) -#define FINISH s3vEndPrimitive( vmesa ) -#define NEW_PRIMITIVE() (void) vmesa -#define NEW_BUFFER() (void) vmesa -#define FIRE_VERTICES() (void) vmesa -#define GET_CURRENT_VB_MAX_VERTS() \ - (vmesa->bufSize - vmesa->bufCount) / 2 -#define GET_SUBSEQUENT_VB_MAX_VERTS() \ - S3V_DMA_BUF_SZ / 2 -/* XXX */ -#define ALLOC_VERTS(nr) NULL -#define EMIT_VERTS(ctx, start, count, buf) NULL -#define FLUSH() s3vEndPrimitive( vmesa ) - -#define TAG(x) s3v_##x - -#include "tnl_dd/t_dd_dmatmp.h" - -/**********************************************************************/ -/* Render pipeline stage */ -/**********************************************************************/ - - -static GLboolean s3v_run_render( GLcontext *ctx, - struct tnl_pipeline_stage *stage ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - GLuint i; - tnl_render_func *tab; - - DEBUG(("s3v_run_render\n")); - - /* FIXME: hw clip */ - if (VB->ClipOrMask || vmesa->RenderIndex != 0) { - DEBUG(("*** CLIPPED in render ***\n")); -#if 1 - return GL_TRUE; /* don't handle clipping here */ -#endif - } - - - /* We don't do elts */ - if (VB->Elts) - return GL_TRUE; - - tab = TAG(render_tab_verts); - - tnl->Driver.Render.Start( ctx ); - - for (i = 0 ; i < VB->PrimitiveCount ; i++ ) - { - GLuint prim = _tnl_translate_prim(&VB->Primitive[i]); - GLuint start = VB->Primitive[i].start; - GLuint length = VB->Primitive[i].count; - - DEBUG(("s3v_run_render (loop=%i) (lenght=%i)\n", i, length)); - - if (length) { - tnl->Driver.Render.BuildVertices( ctx, start, - start+length, ~0 /*stage->inputs*/); /* XXX */ - tnl->Driver.Render.PrimTabVerts[prim & PRIM_MODE_MASK] - ( ctx, start, start + length, prim ); - vmesa->SetupNewInputs = VERT_BIT_POS; - } - } - - tnl->Driver.Render.Finish( ctx ); - - return GL_FALSE; /* finished the pipe */ -} - - - -const struct tnl_pipeline_stage _s3v_render_stage = -{ - "s3v render", - NULL, - NULL, - NULL, - NULL, - s3v_run_render /* run */ -}; diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.c b/src/mesa/drivers/dri/s3v/s3v_screen.c deleted file mode 100644 index f1810597e6..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_screen.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" -#include "s3v_vb.h" -#include "s3v_dri.h" - -s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv ) -{ - s3vScreenPtr s3vScreen; - S3VDRIPtr vDRIPriv = (S3VDRIPtr)sPriv->pDevPriv; - -/* int i; */ - - DEBUG(("s3vCreateScreen\n")); - DEBUG(("sPriv->pDevPriv at %p\n", sPriv->pDevPriv)); - DEBUG(("size = %i\n", sizeof(*vDRIPriv))); - - if (sPriv->devPrivSize != sizeof(S3VDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(S3VDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - s3vScreen = (s3vScreenPtr) CALLOC( sizeof(*s3vScreen) ); - if ( !s3vScreen ) return NULL; - - s3vScreen->regionCount = 4; /* Magic number. Can we fix this? */ - - s3vScreen->regions = _mesa_malloc(s3vScreen->regionCount * - sizeof(s3vRegion)); - DEBUG(("sPriv->fd = %i\nvDRIPriv->dmaBufHandle = %x\n", - sPriv->fd, vDRIPriv->dmaBufHandle)); - - DEBUG(("vDRIPriv->dmaBufSize=%i\nvDRIPriv->dmaBuf=%p\n", - vDRIPriv->dmaBufSize, vDRIPriv->dmaBuf)); - - - /* Get the list of dma buffers */ - s3vScreen->bufs = drmMapBufs(sPriv->fd); - - if (!s3vScreen->bufs) { - DEBUG(("Helter/skelter with drmMapBufs\n")); - return GL_FALSE; - } - - s3vScreen->textureSize = vDRIPriv->texSize; - s3vScreen->logTextureGranularity = vDRIPriv->logTextureGranularity; - s3vScreen->cpp = vDRIPriv->cpp; - s3vScreen->frontOffset = vDRIPriv->frontOffset; - s3vScreen->frontPitch = vDRIPriv->frontPitch; - s3vScreen->backOffset = vDRIPriv->backOffset; - s3vScreen->backPitch = vDRIPriv->frontPitch; /* FIXME: check */ - s3vScreen->depthOffset = vDRIPriv->depthOffset; - s3vScreen->depthPitch = vDRIPriv->frontPitch; - s3vScreen->texOffset = vDRIPriv->texOffset; - - s3vScreen->driScreen = sPriv; - - DEBUG(("vDRIPriv->width =%i; vDRIPriv->deviceID =%x\n", vDRIPriv->width, - vDRIPriv->deviceID)); - DEBUG(("vDRIPriv->mem =%i\n", vDRIPriv->mem)); - DEBUG(("vDRIPriv->fbOffset =%i\n", vDRIPriv->fbOffset)); - DEBUG((" ps3vDRI->fbStride =%i\n", vDRIPriv->fbStride)); - DEBUG(("s3vScreen->cpp = %i\n", s3vScreen->cpp)); - DEBUG(("s3vScreen->backOffset = %x\n", s3vScreen->backOffset)); - DEBUG(("s3vScreen->depthOffset = %x\n", s3vScreen->depthOffset)); - DEBUG(("s3vScreen->texOffset = %x\n", s3vScreen->texOffset)); - DEBUG(("I will return from s3vCreateScreen now\n")); - - DEBUG(("s3vScreen->bufs = 0x%x\n", s3vScreen->bufs)); - return s3vScreen; -} - -/* Destroy the device specific screen private data struct. - */ -void s3vDestroyScreen( __DRIscreenPrivate *sPriv ) -{ - s3vScreenPtr s3vScreen = (s3vScreenPtr)sPriv->private; - - DEBUG(("s3vDestroyScreen\n")); - - /* First, unmap the dma buffers */ -/* - drmUnmapBufs( s3vScreen->bufs ); -*/ - /* Next, unmap all the regions */ -/* while (s3vScreen->regionCount > 0) { - - (void)drmUnmap(s3vScreen->regions[s3vScreen->regionCount].map, - s3vScreen->regions[s3vScreen->regionCount].size); - s3vScreen->regionCount--; - - } - FREE(s3vScreen->regions); */ - if (s3vScreen) - FREE(s3vScreen); -} diff --git a/src/mesa/drivers/dri/s3v/s3v_screen.h b/src/mesa/drivers/dri/s3v/s3v_screen.h deleted file mode 100644 index c49bc8587d..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_screen.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "main/mtypes.h" - -typedef struct _s3vRegion { - drm_handle_t handle; - drmSize size; - drmAddress map; -} s3vRegion, *s3vRegionPtr; - -typedef struct { - - int regionCount; /* Count of register regions */ - s3vRegion *regions; /* Vector of mapped region info */ - - drmBufMapPtr bufs; /* Map of DMA buffers */ - - __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */ - - int cpp; - int frontPitch; - int frontOffset; - - int backPitch; - int backOffset; - int backX; - int backY; - - int depthOffset; - int depthPitch; - - int texOffset; - int textureOffset; - int textureSize; - int logTextureGranularity; -} s3vScreenRec, *s3vScreenPtr; - diff --git a/src/mesa/drivers/dri/s3v/s3v_span.c b/src/mesa/drivers/dri/s3v/s3v_span.c deleted file mode 100644 index f9f7c0d1ee..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_span.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" -#include "s3v_lock.h" - -#include "swrast/swrast.h" - -#define _SPANLOCK 1 -#define DBG 0 - -#define LOCAL_VARS \ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); \ - __DRIscreenPrivate *sPriv = vmesa->driScreen; \ - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint cpp = drb->cpp; \ - GLuint pitch = ( (drb->backBuffer) ? \ - ((dPriv->w+31)&~31) * cpp \ - : sPriv->fbWidth * cpp); \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + drb->offset \ - + (drb->backBuffer ? 0 : dPriv->x * cpp + dPriv->y * pitch));\ - GLuint p; \ - (void) p - -/* FIXME! Depth/Stencil read/writes don't work ! */ -#define LOCAL_DEPTH_VARS \ - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \ - __DRIscreenPrivate *sPriv = vmesa->driScreen; \ - driRenderbuffer *drb = (driRenderbuffer *) rb; \ - GLuint pitch = drb->pitch; \ - GLuint height = dPriv->h; \ - char *buf = (char *)(sPriv->pFB + drb->offset); \ - (void) pitch - -#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS - -#define Y_FLIP( _y ) (height - _y - 1) - -#if _SPANLOCK /* OK, we lock */ - -#define HW_LOCK() \ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); \ - (void) vmesa; \ - DMAFLUSH(); \ - S3V_SIMPLE_FLUSH_LOCK(vmesa); -#define HW_UNLOCK() S3V_SIMPLE_UNLOCK(vmesa); - -#else /* plz, don't lock */ - -#define HW_LOCK() \ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); \ - (void) vmesa; \ - DMAFLUSH(); -#define HW_UNLOCK() - -#endif - - -/* ================================================================ - * Color buffer - */ - -/* 16 bit, RGB565 color spanline and pixel functions - */ -#define INIT_MONO_PIXEL(p, color) \ - p = S3VIRGEPACKCOLOR555( color[0], color[1], color[2], color[3] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ -do { \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 7) | \ - (((int)g & 0xf8) << 2) | \ - (((int)b & 0xf8) >> 3)); \ - DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i drb->cpp=%i dPriv->y=%i pitch=%i\n", \ - sPriv->pFB, vmesa->drawOffset, dPriv->x, drb->cpp, dPriv->y, pitch)); \ - DEBUG(("dPriv->w = %i\n", dPriv->w)); \ -} while(0) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ - do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p >> 7) & 0xf8; \ - rgba[1] = (p >> 2) & 0xf8; \ - rgba[2] = (p << 3) & 0xf8; \ - rgba[3] = 0xff; /* - if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \ - if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \ - if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; */ \ - } while (0) - -#define TAG(x) s3v##x##_RGB555 -#include "spantmp.h" - - -/* 32 bit, ARGB8888 color spanline and pixel functions - */ - -#undef INIT_MONO_PIXEL -#define INIT_MONO_PIXEL(p, color) \ - p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] ) - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \ - (g << 8) | \ - (r << 16) | \ - (a << 24) ) - -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = (p >> 24) & 0xff; \ -} while (0) - -#define TAG(x) s3v##x##_ARGB8888 -#include "spantmp.h" - - -/* 16 bit depthbuffer functions. - */ -#define VALUE_TYPE GLushort - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLushort *)(buf + _x*2 + _y*dPriv->w*2); - -#define TAG(x) s3v##x##_z16 -#include "depthtmp.h" - - - - -/* 32 bit depthbuffer functions. - */ -#if 0 -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = d; - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLuint *)(buf + _x*4 + _y*pitch); - -#define TAG(x) s3v##x##_32 -#include "depthtmp.h" -#endif - - -/* 24/8 bit interleaved depth/stencil functions - */ -#if 0 -#define VALUE_TYPE GLuint - -#define WRITE_DEPTH( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ - tmp &= 0xff; \ - tmp |= (d) & 0xffffff00; \ - *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ -} - -#define READ_DEPTH( d, _x, _y ) \ - d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff - - -#define TAG(x) s3v##x##_24_8 -#include "depthtmp.h" - -#define WRITE_STENCIL( _x, _y, d ) { \ - GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \ - tmp &= 0xffffff00; \ - tmp |= d & 0xff; \ - *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \ -} - -#define READ_STENCIL( d, _x, _y ) \ - d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff - -#define TAG(x) s3v##x##_24_8 -#include "stenciltmp.h" - -#endif - - -/** - * Plug in the Get/Put routines for the given driRenderbuffer. - */ -void -s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis) -{ - if (drb->Base.InternalFormat == GL_RGBA) { - if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) { - s3vInitPointers_RGB555(&drb->Base); - } - else { - s3vInitPointers_ARGB8888(&drb->Base); - } - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) { - s3vInitDepthPointers_z16(&drb->Base); - } - else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) { - /* not done yet */ - } - else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) { - /* not done yet */ - } -} diff --git a/src/mesa/drivers/dri/s3v/s3v_state.c b/src/mesa/drivers/dri/s3v/s3v_state.c deleted file mode 100644 index 561f42c705..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_state.c +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" -#include "s3v_macros.h" -#include "s3v_dri.h" -#include "main/macros.h" -#include "main/colormac.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" -#include "tnl/tnl.h" - -/* #define DEBUG(str) printf str */ -#define ENABLELIGHTING 0 - - -/* ============================================================= - * Alpha blending - */ - -static void s3vUpdateAlphaMode( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - uint32_t cmd = vmesa->CMD; - cmd &= ~ALPHA_BLEND_MASK; - - if ( ctx->Color.BlendEnabled ) { - DEBUG(("ctx->Color.AlphaEnabled = 1")); - vmesa->_alpha[0] = ALPHA_SRC; - vmesa->_alpha[1] = vmesa->_alpha_tex; /* FIXME: not all tex modes - support alpha */ - } else { - DEBUG(("ctx->Color.AlphaEnabled = 0")); - vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF; - } -#if 1 - if ((cmd & DO_MASK) & DO_3D_LINE) { /* we are drawing 3d lines */ - /* which don't support tex */ - cmd |= vmesa->_alpha[0]; - } else { - cmd |= vmesa->_alpha[vmesa->_3d_mode]; - } - - vmesa->CMD = cmd; /* FIXME: enough? */ -#else - vmesa->restore_primitive = -1; -#endif - -} - -static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - DEBUG(("s3vDDAlphaFunc\n")); - - vmesa->new_state |= S3V_NEW_ALPHA; -} - -static void s3vDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - DEBUG(("s3vDDBlendFunc\n")); - - vmesa->new_state |= S3V_NEW_ALPHA; -} - -/* ================================================================ - * Buffer clear - */ - -static void s3vDDClear( GLcontext *ctx, GLbitfield mask ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - unsigned int _stride; - GLint cx = ctx->DrawBuffer->_Xmin; - GLint cy = ctx->DrawBuffer->_Ymin; - GLint cw = ctx->DrawBuffer->_Xmax - cx; - GLint ch = ctx->DrawBuffer->_Ymax - cy; - - /* XXX FIX ME: the cx,cy,cw,ch vars are currently ignored! */ - - vmesa->restore_primitive = -1; - - /* Update and emit any new state. We need to do this here to catch - * changes to the masks. - * FIXME: Just update the masks? - */ - - if ( vmesa->new_state ) - s3vDDUpdateHWState( ctx ); - -/* s3vUpdateMasks( ctx ); */ -/* s3vUpdateClipping( ctx ); */ -/* s3vEmitHwState( vmesa ); */ - - -#if 1 /* soft (0)/hw (1)*/ - - DEBUG(("*** s3vDDClear ***\n")); - - DMAOUT_CHECK(BITBLT_SRC_BASE, 15); - DMAOUT(vmesa->SrcBase); - DMAOUT(vmesa->DestBlit); - DMAOUT( vmesa->ScissorLR ); - DMAOUT( vmesa->ScissorTB ); - DMAOUT( (vmesa->SrcStride << 16) | vmesa->SrcStride ); /* FIXME: unify */ - DMAOUT( (~(0)) ); /* masks */ - DMAOUT( (~(0)) ); - DMAOUT(0); - DMAOUT(vmesa->ClearColor); - DMAOUT(0); - DMAOUT(0); - /* FIXME */ - DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */ - DMAOUT(vmesa->ScissorWH); - DMAOUT(vmesa->SrcXY); - DMAOUT(vmesa->DestXY); - DMAFINISH(); - - if (mask & BUFFER_BIT_DEPTH) { /* depth */ - DEBUG(("BUFFER_BIT_DEPTH\n")); - - _stride = ((cw+31)&~31) * 2; /* XXX cw or Buffer->Width??? */ - - DMAOUT_CHECK(BITBLT_SRC_BASE, 15); - DMAOUT(0); - DMAOUT(vmesa->s3vScreen->depthOffset); - DMAOUT( (0 << 16) | cw ); - DMAOUT( (0 << 16) | ch ); - DMAOUT( (vmesa->SrcStride << 16) | vmesa->DestStride ); - DMAOUT( (~(0)) ); /* masks */ - DMAOUT( (~(0)) ); - DMAOUT(0); - DMAOUT(vmesa->ClearDepth); /* 0x7FFF */ - /* FIXME */ - DMAOUT(0); - DMAOUT(0); - DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); - DMAOUT( ((cw-1) << 16) | (ch-1) ); - DMAOUT(0); - DMAOUT( (0 << 16) | 0 ); - DMAFINISH(); - - DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth)); - mask &= ~BUFFER_BIT_DEPTH; - } - - if (!vmesa->NotClipped) { - DEBUG(("vmesa->NotClipped\n")); /* yes */ - } - - if (!(vmesa->EnabledFlags & S3V_BACK_BUFFER)) { - DEBUG(("!S3V_BACK_BUFFER -> flush\n")); - DMAFLUSH(); - } -/* - if ( mask ) - DEBUG(("still masked ;3(\n")); */ /* yes */ -#else - _swrast_Clear( ctx, mask ); -#endif -} - -/* ============================================================= - * Depth testing - */ - -static void s3vUpdateZMode( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - uint32_t cmd = vmesa->CMD; - - DEBUG(("Depth.Test = %i\n", ctx->Depth.Test)); - DEBUG(("CMD was = 0x%x ", cmd)); - -/* printf("depth --- CMD was = 0x%x \n", cmd); */ - - cmd &= ~Z_MASK; /* 0xfc0fffff; */ - /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */ - - if (!ctx->Depth.Test) - cmd |= Z_OFF; - - if ( ctx->Depth.Mask ) - cmd |= Z_UPDATE_ON; - - switch ( ctx->Depth.Func ) { - case GL_NEVER: - cmd |= Z_NEVER; - break; - case GL_ALWAYS: - cmd |= Z_ALWAYS; - break; - case GL_LESS: - cmd |= Z_LESS; - break; - case GL_LEQUAL: - cmd |= Z_LEQUAL; - break; - case GL_EQUAL: - cmd |= Z_EQUAL; - break; - case GL_GEQUAL: - cmd |= Z_GEQUAL; - break; - case GL_GREATER: - cmd |= Z_GREATER; - break; - case GL_NOTEQUAL: - cmd |= Z_NOTEQUAL; - break; - } - - DEBUG(("CMD is 0x%x\n", cmd)); - - vmesa->dirty |= S3V_UPLOAD_DEPTH; - vmesa->CMD = cmd; -} - -static void s3vDDDepthFunc( GLcontext *ctx, GLenum func ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - -/* FLUSH_BATCH( vmesa ); */ - DEBUG(("s3vDDDepthFunc\n")); - vmesa->new_state |= S3V_NEW_DEPTH; -} - -static void s3vDDDepthMask( GLcontext *ctx, GLboolean flag ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - /* FLUSH_BATCH( vmesa ); */ - DEBUG(("s3vDDDepthMask\n")); - vmesa->new_state |= S3V_NEW_DEPTH; -} - -static void s3vDDClearDepth( GLcontext *ctx, GLclampd d ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - switch ( vmesa->DepthSize ) { - case 15: - case 16: - vmesa->ClearDepth = d * 0x0000ffff; /* 65536 */ - DEBUG(("GLclampd d = %f\n", d)); - DEBUG(("ctx->Depth.Clear = %f\n", ctx->Depth.Clear)); - DEBUG(("(They should be the same)\n")); - break; - case 24: - vmesa->ClearDepth = d * 0x00ffffff; - break; - case 32: - vmesa->ClearDepth = d * 0xffffffff; - break; - } -} - -static void s3vDDFinish( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - DMAFLUSH(); -} - -static void s3vDDFlush( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - DMAFLUSH(); -} - -/* ============================================================= - * Fog - */ - -static void s3vUpdateFogAttrib( GLcontext *ctx ) -{ -/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */ - - if (ctx->Fog.Enabled) { - } else { - } - - switch (ctx->Fog.Mode) { - case GL_LINEAR: - break; - case GL_EXP: - break; - case GL_EXP2: - break; - } -} - -static void s3vDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - vmesa->new_state |= S3V_NEW_FOG; -} - -/* ============================================================= - * Lines - */ -static void s3vDDLineWidth( GLcontext *ctx, GLfloat width ) -{ - /* FIXME: on virge you only have one size of 3d lines * - * if we wanted more, we should start using tris instead * - * but virge has problem with some tris when all of the * - * vertices stay on a line */ -} - -/* ============================================================= - * Points - */ -static void s3vDDPointSize( GLcontext *ctx, GLfloat size ) -{ - /* FIXME: we use 3d line to fake points. So same limitations - * as above apply */ -} - -/* ============================================================= - * Polygon - */ - -static void s3vUpdatePolygon( GLcontext *ctx ) -{ - /* FIXME: I don't think we could do much here */ - - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - vmesa->dirty |= S3V_UPLOAD_POLYGON; -} - -/* ============================================================= - * Clipping - */ - -static void s3vUpdateClipping( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - - int x0,y0,x1,y1; - - DEBUG((">>> s3vUpdateClipping <<<\n")); -/* - if ( vmesa->driDrawable ) { - DEBUG(("s3vUpdateClipping\n")); -*/ - if (vmesa->EnabledFlags & S3V_BACK_BUFFER) { - DEBUG(("S3V_BACK_BUFFER\n")); - - x0 = 0; - y0 = 0; - x1 = dPriv->w - 1; - y1 = dPriv->h - 1; - - vmesa->SrcBase = 0; - vmesa->DestBase = vmesa->s3vScreen->backOffset; - vmesa->DestBlit = vmesa->DestBase; - vmesa->ScissorLR = ( (0 << 16) | (dPriv->w-1) ); - vmesa->ScissorTB = ( (0 << 16) | (dPriv->h-1) ); -/* - vmesa->ScissorLR = ( (x0 << 16) | x1 ); - vmesa->ScissorTB = ( (y0 << 16) | y1 ); -*/ - vmesa->SrcStride = ( ((dPriv->w+31)&~31) * vmesa->s3vScreen->cpp ); - vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp; - vmesa->ScissorWH = ( (dPriv->w << 16) | dPriv->h ); - vmesa->SrcXY = 0; -/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */ - vmesa->DestXY = ( (0 << 16) | 0 ); - } else { - DEBUG(("S3V_FRONT_BUFFER\n")); - - x0 = dPriv->x; - y0 = dPriv->y; - x1 = x0 + dPriv->w - 1; - y1 = y0 + dPriv->h - 1; - - vmesa->SrcBase = 0; - vmesa->DestBase = 0; - vmesa->ScissorLR = ( (x0 << 16) | x1 ); - vmesa->ScissorTB = ( (y0 << 16) | y1 ); - vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp; - vmesa->SrcStride = vmesa->DestStride; - vmesa->DestBase = (y0 * vmesa->DestStride) - + x0*vmesa->s3vScreen->cpp; - vmesa->DestBlit = 0; - vmesa->ScissorWH = ( (x1 << 16) | y1 ); - vmesa->SrcXY = 0; - vmesa->DestXY = ( (0 << 16) | 0 ); -/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */ - } - - DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0, y0, x1, y1)); - DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa->DestStride, vmesa->ScissorWH)); - - /* FIXME: how could we use the following info? */ - /* if (ctx->Scissor.Enabled) {} */ - - vmesa->dirty |= S3V_UPLOAD_CLIP; -/* } */ -} - -static void s3vDDScissor( GLcontext *ctx, - GLint x, GLint y, GLsizei w, GLsizei h ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - DEBUG((">>> s3vDDScissor <<<")); - /* FLUSH_BATCH( vmesa ); */ - vmesa->new_state |= S3V_NEW_CLIP; -} - -/* ============================================================= - * Culling - */ - -static void s3vUpdateCull( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - GLfloat backface_sign = 1; - - DEBUG(("s3vUpdateCull\n")); - /* FIXME: GL_FRONT_AND_BACK */ - - switch ( ctx->Polygon.CullFaceMode ) { - case GL_BACK: - if (ctx->Polygon.FrontFace == GL_CCW) - backface_sign = -1; - break; - - case GL_FRONT: - if (ctx->Polygon.FrontFace != GL_CCW) - backface_sign = -1; - break; - - default: - break; - } - - vmesa->backface_sign = backface_sign; - vmesa->dirty |= S3V_UPLOAD_GEOMETRY; -} - - -static void s3vDDCullFace( GLcontext *ctx, GLenum mode ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - /* FLUSH_BATCH( vmesa ); */ - vmesa->new_state |= S3V_NEW_CULL; -} - -static void s3vDDFrontFace( GLcontext *ctx, GLenum mode ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - /* FLUSH_BATCH( vmesa ); */ - vmesa->new_state |= S3V_NEW_CULL; -} - -/* ============================================================= - * Masks - */ - -static void s3vUpdateMasks( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - GLuint mask = s3vPackColor( vmesa->s3vScreen->cpp, - ctx->Color.ColorMask[RCOMP], - ctx->Color.ColorMask[GCOMP], - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] ); - - if (vmesa->s3vScreen->cpp == 2) mask |= mask << 16; - - /* FIXME: can we do something in virge? */ -} -/* -static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g, - GLboolean b, GLboolean a) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - FLUSH_BATCH( vmesa ); - vmesa->new_state |= S3V_NEW_MASKS; -} -*/ -/* ============================================================= - * Rendering attributes - */ - -/* ============================================================= - * Miscellaneous - */ - -static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4]) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - DEBUG(("*** s3vDDClearColor\n")); - - vmesa->ClearColor = s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */ - color[0], color[1], color[2], color[3] ); - -#if 0 - if (vmesa->s3vScreen->cpp == 2) vmesa->ClearColor |= vmesa->ClearColor<<16; -#endif -} - -static void s3vDDSetDrawBuffer( GLcontext *ctx, GLenum mode ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - int found = GL_TRUE; - - DEBUG(("*** s3vDDSetDrawBuffer ***\n")); - - /* FLUSH_BATCH( vmesa ); */ - - switch ( mode ) { - case GL_FRONT_LEFT: - vmesa->drawOffset = vmesa->s3vScreen->frontOffset; - break; - case GL_BACK_LEFT: - vmesa->drawOffset = vmesa->s3vScreen->backOffset; - /* vmesa->driScreen->fbHeight * - * vmesa->driScreen->fbWidth * - * vmesa->s3vScreen->cpp; */ - break; - default: - found = GL_FALSE; - break; - } - - DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa->drawOffset)); -/* return GL_TRUE; */ -} - -/* ============================================================= - * Window position and viewport transformation - */ - -void s3vUpdateWindow( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - GLfloat xoffset = (GLfloat)dPriv->x; - GLfloat yoffset = - vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; - - GLfloat sx = v[MAT_SX]; - GLfloat tx = v[MAT_TX] + xoffset; - GLfloat sy = v[MAT_SY]; - GLfloat ty = v[MAT_TY] + yoffset; - GLfloat sz = v[MAT_SZ] * vmesa->depth_scale; - GLfloat tz = v[MAT_TZ] * vmesa->depth_scale; - - vmesa->dirty |= S3V_UPLOAD_VIEWPORT; - - vmesa->ViewportScaleX = sx; - vmesa->ViewportScaleY = sy; - vmesa->ViewportScaleZ = sz; - vmesa->ViewportOffsetX = tx; - vmesa->ViewportOffsetY = ty; - vmesa->ViewportOffsetZ = tz; -} - - -/* -static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - s3vUpdateWindow( ctx ); -} - -static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval, - GLclampd farval ) -{ - s3vUpdateWindow( ctx ); -} -*/ -void s3vUpdateViewportOffset( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - GLfloat xoffset = (GLfloat)dPriv->x; - GLfloat yoffset = - vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h; - const GLfloat *v = ctx->Viewport._WindowMap.m; - - GLfloat tx = v[MAT_TX] + xoffset; - GLfloat ty = v[MAT_TY] + yoffset; - - DEBUG(("*** s3vUpdateViewportOffset ***\n")); - - if ( vmesa->ViewportOffsetX != tx || - vmesa->ViewportOffsetY != ty ) - { - vmesa->ViewportOffsetX = tx; - vmesa->ViewportOffsetY = ty; - - vmesa->new_state |= S3V_NEW_WINDOW; - } - -/* vmesa->new_state |= S3V_NEW_CLIP; */ -} - -/* ============================================================= - * State enable/disable - */ - -static void s3vDDEnable( GLcontext *ctx, GLenum cap, GLboolean state ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - switch ( cap ) { - case GL_ALPHA_TEST: - case GL_BLEND: - vmesa->new_state |= S3V_NEW_ALPHA; - DEBUG(("s3vDDEnable: GL_BLEND\n")); - break; - - case GL_CULL_FACE: - vmesa->new_state |= S3V_NEW_CULL; - DEBUG(("s3vDDEnable: GL_CULL_FACE\n")); - break; - - case GL_DEPTH_TEST: - vmesa->new_state |= S3V_NEW_DEPTH; - DEBUG(("s3vDDEnable: GL_DEPTH\n")); - break; -#if 0 - case GL_FOG: - vmesa->new_state |= S3V_NEW_FOG; - break; -#endif - - case GL_SCISSOR_TEST: - vmesa->new_state |= S3V_NEW_CLIP; - break; - - case GL_TEXTURE_2D: - DEBUG(("*** GL_TEXTURE_2D: %i\n", state)); - vmesa->_3d_mode = state; - vmesa->restore_primitive = -1; - break; - - default: - return; - } -} - -/* ============================================================= - * State initialization, management - */ - - -/* - * Load the current context's state into the hardware. - * - * NOTE: Be VERY careful about ensuring the context state is marked for - * upload, the only place it shouldn't be uploaded is when the setup - * state has changed in ReducedPrimitiveChange as this comes right after - * a state update. - * - * Blits of any type should always upload the context and masks after - * they are done. - */ -void s3vEmitHwState( s3vContextPtr vmesa ) -{ - if (!vmesa->driDrawable) return; - if (!vmesa->dirty) return; - - DEBUG(("**********************\n")); - DEBUG(("*** s3vEmitHwState ***\n")); - DEBUG(("**********************\n")); - - if (vmesa->dirty & S3V_UPLOAD_VIEWPORT) { - vmesa->dirty &= ~S3V_UPLOAD_VIEWPORT; - DEBUG(("S3V_UPLOAD_VIEWPORT\n")); - } - - if ( (vmesa->dirty & S3V_UPLOAD_POINTMODE) || - (vmesa->dirty & S3V_UPLOAD_LINEMODE) || - (vmesa->dirty & S3V_UPLOAD_TRIMODE) ) { - - } - - if (vmesa->dirty & S3V_UPLOAD_POINTMODE) { - vmesa->dirty &= ~S3V_UPLOAD_POINTMODE; - } - - if (vmesa->dirty & S3V_UPLOAD_LINEMODE) { - vmesa->dirty &= ~S3V_UPLOAD_LINEMODE; - } - - if (vmesa->dirty & S3V_UPLOAD_TRIMODE) { - vmesa->dirty &= ~S3V_UPLOAD_TRIMODE; - } - - if (vmesa->dirty & S3V_UPLOAD_FOG) { - GLchan c[3], col; - UNCLAMPED_FLOAT_TO_RGB_CHAN( c, vmesa->glCtx->Fog.Color ); - DEBUG(("uploading ** FOG **\n")); - col = s3vPackColor(2, c[0], c[1], c[2], 0); - vmesa->dirty &= ~S3V_UPLOAD_FOG; - } - - if (vmesa->dirty & S3V_UPLOAD_DITHER) { - vmesa->dirty &= ~S3V_UPLOAD_DITHER; - } - - if (vmesa->dirty & S3V_UPLOAD_LOGICOP) { - vmesa->dirty &= ~S3V_UPLOAD_LOGICOP; - } - - if (vmesa->dirty & S3V_UPLOAD_CLIP) { - vmesa->dirty &= ~S3V_UPLOAD_CLIP; - DEBUG(("S3V_UPLOAD_CLIP\n")); - DEBUG(("vmesa->ScissorLR: %i\n", vmesa->ScissorLR)); - DEBUG(("vmesa->ScissorTB: %i\n", vmesa->ScissorTB)); - } - - if (vmesa->dirty & S3V_UPLOAD_MASKS) { - vmesa->dirty &= ~S3V_UPLOAD_MASKS; - DEBUG(("S3V_UPLOAD_BLEND\n")); - } - - if (vmesa->dirty & S3V_UPLOAD_ALPHA) { - vmesa->dirty &= ~S3V_UPLOAD_ALPHA; - DEBUG(("S3V_UPLOAD_ALPHA\n")); - } - - if (vmesa->dirty & S3V_UPLOAD_SHADE) { - vmesa->dirty &= ~S3V_UPLOAD_SHADE; - } - - if (vmesa->dirty & S3V_UPLOAD_POLYGON) { - vmesa->dirty &= ~S3V_UPLOAD_POLYGON; - } - - if (vmesa->dirty & S3V_UPLOAD_DEPTH) { - vmesa->dirty &= ~S3V_UPLOAD_DEPTH; - DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa->DepthMode)); - } - - if (vmesa->dirty & S3V_UPLOAD_GEOMETRY) { - vmesa->dirty &= ~S3V_UPLOAD_GEOMETRY; - } - - if (vmesa->dirty & S3V_UPLOAD_TRANSFORM) { - vmesa->dirty &= ~S3V_UPLOAD_TRANSFORM; - } - - if (vmesa->dirty & S3V_UPLOAD_TEX0) { - s3vTextureObjectPtr curTex = vmesa->CurrentTexObj[0]; - vmesa->dirty &= ~S3V_UPLOAD_TEX0; - DEBUG(("S3V_UPLOAD_TEX0\n")); - if (curTex) { - DEBUG(("S3V_UPLOAD_TEX0: curTex\n")); - } else { - DEBUG(("S3V_UPLOAD_TEX0: !curTex\n")); - } - } -} - -void s3vDDUpdateHWState( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - int new_state = vmesa->new_state; - - /* s3vUpdateClipping( ctx ); */ - - if ( new_state ) - { - - vmesa->new_state = 0; - - /* Update the various parts of the context's state. - */ - if ( new_state & S3V_NEW_ALPHA ) - s3vUpdateAlphaMode( ctx ); - - if ( new_state & S3V_NEW_DEPTH ) - s3vUpdateZMode( ctx ); - - if ( new_state & S3V_NEW_FOG ) - s3vUpdateFogAttrib( ctx ); - - if ( new_state & S3V_NEW_CLIP ) - { - DEBUG(("---> going to s3vUpdateClipping\n")); - s3vUpdateClipping( ctx ); - } - - if ( new_state & S3V_NEW_POLYGON ) - s3vUpdatePolygon( ctx ); - - if ( new_state & S3V_NEW_CULL ) - s3vUpdateCull( ctx ); - - if ( new_state & S3V_NEW_MASKS ) - s3vUpdateMasks( ctx ); - - if ( new_state & S3V_NEW_WINDOW ) - s3vUpdateWindow( ctx ); -/* - if ( new_state & S3_NEW_TEXTURE ) - s3vUpdateTextureState( ctx ); -*/ - CMDCHANGE(); - } - - /* HACK ! */ - s3vEmitHwState( vmesa ); -} - - -static void s3vDDUpdateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - S3V_CONTEXT(ctx)->new_gl_state |= new_state; -} - - -/* Initialize the context's hardware state. - */ -void s3vInitState( s3vContextPtr vmesa ) -{ - vmesa->new_state = 0; -} - -/* Initialize the driver's state functions. - */ -void s3vInitStateFuncs( GLcontext *ctx ) -{ - ctx->Driver.UpdateState = s3vDDUpdateState; - - ctx->Driver.Clear = s3vDDClear; - ctx->Driver.ClearIndex = NULL; - ctx->Driver.ClearColor = s3vDDClearColor; - ctx->Driver.DrawBuffer = s3vDDSetDrawBuffer; - ctx->Driver.ReadBuffer = NULL; /* XXX */ - - ctx->Driver.IndexMask = NULL; - ctx->Driver.ColorMask = NULL; /* s3vDDColorMask; */ /* FIXME */ - - ctx->Driver.AlphaFunc = s3vDDAlphaFunc; /* FIXME */ -#if 0 - ctx->Driver.BlendEquation = NULL; /* s3vDDBlendEquation; */ - ctx->Driver.BlendFunc = s3vDDBlendFunc; /* FIXME */ -#endif - ctx->Driver.BlendFuncSeparate = NULL; /* s3vDDBlendFuncSeparate; */ - ctx->Driver.ClearDepth = s3vDDClearDepth; - ctx->Driver.CullFace = s3vDDCullFace; - ctx->Driver.FrontFace = s3vDDFrontFace; - ctx->Driver.DepthFunc = s3vDDDepthFunc; /* FIXME */ - ctx->Driver.DepthMask = s3vDDDepthMask; /* FIXME */ - ctx->Driver.DepthRange = NULL; /* s3vDDDepthRange; */ - ctx->Driver.Enable = s3vDDEnable; /* FIXME */ - ctx->Driver.Finish = s3vDDFinish; - ctx->Driver.Flush = s3vDDFlush; -#if 1 - ctx->Driver.Fogfv = NULL; /* s3vDDFogfv; */ -#endif - ctx->Driver.Hint = NULL; - ctx->Driver.LineWidth = NULL; /* s3vDDLineWidth; */ - ctx->Driver.LineStipple = NULL; /* s3vDDLineStipple; */ -#if ENABLELIGHTING - ctx->Driver.Lightfv = NULL; /* s3vDDLightfv; */ - - ctx->Driver.LightModelfv = NULL; /* s3vDDLightModelfv; */ -#endif - ctx->Driver.LogicOpcode = NULL; /* s3vDDLogicalOpcode; */ - ctx->Driver.PointSize = NULL; /* s3vDDPointSize; */ - ctx->Driver.PolygonMode = NULL; /* s3vDDPolygonMode; */ - ctx->Driver.PolygonStipple = NULL; /* s3vDDPolygonStipple; */ - ctx->Driver.Scissor = s3vDDScissor; /* ScissorLR / ScissorTB */ - ctx->Driver.ShadeModel = NULL; /* s3vDDShadeModel; */ - ctx->Driver.Viewport = NULL; /* s3vDDViewport; */ -} diff --git a/src/mesa/drivers/dri/s3v/s3v_tex.c b/src/mesa/drivers/dri/s3v/s3v_tex.c deleted file mode 100644 index ec1182f34f..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_tex.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include -#include - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" -#include "main/mm.h" -#include "main/texstore.h" -#include "main/texformat.h" -#include "main/teximage.h" -#include "swrast/swrast.h" - -#include "s3v_context.h" -#include "s3v_tex.h" - - -extern void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t); -extern void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t); - -/* -static GLuint s3vComputeLodBias(GLfloat bias) -{ -#if TEX_DEBUG_ON - DEBUG_TEX(("*** s3vComputeLodBias ***\n")); -#endif - return bias; -} -*/ - -static void s3vSetTexWrapping(s3vContextPtr vmesa, - s3vTextureObjectPtr t, - GLenum wraps, GLenum wrapt) -{ - GLuint t0 = t->TextureCMD; - GLuint cmd = vmesa->CMD; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vSetTexWrapping: #%i ***\n", ++times)); -#endif - - - t0 &= ~TEX_WRAP_MASK; - cmd &= ~TEX_WRAP_MASK; - - if ((wraps != GL_CLAMP) || (wrapt != GL_CLAMP)) { - DEBUG(("TEX_WRAP_ON\n")); - t0 |= TEX_WRAP_ON; - cmd |= TEX_WRAP_ON; - } - - cmd |= TEX_WRAP_ON; /* FIXME: broken if off */ - t->TextureCMD = t0; - vmesa->CMD = cmd; -} - - -static void s3vSetTexFilter(s3vContextPtr vmesa, - s3vTextureObjectPtr t, - GLenum minf, GLenum magf) -{ - GLuint t0 = t->TextureCMD; - GLuint cmd = vmesa->CMD; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vSetTexFilter: #%i ***\n", ++times)); -#endif - - t0 &= ~TEX_FILTER_MASK; - cmd &= ~TEX_FILTER_MASK; - - switch (minf) { - case GL_NEAREST: - DEBUG(("GL_NEAREST\n")); - t0 |= NEAREST; - cmd |= NEAREST; - break; - case GL_LINEAR: - DEBUG(("GL_LINEAR\n")); - t0 |= LINEAR; - cmd |= LINEAR; - break; - case GL_NEAREST_MIPMAP_NEAREST: - DEBUG(("GL_MIPMAP_NEAREST\n")); - t0 |= MIP_NEAREST; - cmd |= MIP_NEAREST; - break; - case GL_LINEAR_MIPMAP_NEAREST: - DEBUG(("GL_LINEAR_MIPMAP_NEAREST\n")); - t0 |= LINEAR_MIP_NEAREST; - cmd |= LINEAR_MIP_NEAREST; - break; - case GL_NEAREST_MIPMAP_LINEAR: - DEBUG(("GL_NEAREST_MIPMAP_LINEAR\n")); - t0 |= MIP_LINEAR; - cmd |= MIP_LINEAR; - break; - case GL_LINEAR_MIPMAP_LINEAR: - DEBUG(("GL_LINEAR_MIPMAP_LINEAR\n")); - t0 |= LINEAR_MIP_LINEAR; - cmd |= LINEAR_MIP_LINEAR; - break; - default: - break; - } - /* FIXME: bilinear? */ - -#if 0 - switch (magf) { - case GL_NEAREST: - break; - case GL_LINEAR: - break; - default: - break; - } -#endif - - t->TextureCMD = t0; - - DEBUG(("CMD was = 0x%x\n", vmesa->CMD)); - DEBUG(("CMD is = 0x%x\n", cmd)); - - vmesa->CMD = cmd; - /* CMDCHANGE(); */ -} - - -static void s3vSetTexBorderColor(s3vContextPtr vmesa, - s3vTextureObjectPtr t, - const GLfloat color[4]) -{ - GLubyte c[4]; - CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]); - CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]); - CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]); - CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]); - -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vSetTexBorderColor: #%i ***\n", ++times)); -#endif - - /*FIXME: it should depend on tex col format */ - /* switch(t0 ... t->TextureColorMode) */ - - /* case TEX_COL_ARGB1555: */ - t->TextureBorderColor = S3VIRGEPACKCOLOR555(c[0], c[1], c[2], c[3]); - - DEBUG(("TextureBorderColor = 0x%x\n", t->TextureBorderColor)); - - vmesa->TextureBorderColor = t->TextureBorderColor; -} - -static void s3vTexParameter( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, - GLenum pname, const GLfloat *params ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexParameter: #%i ***\n", ++times)); -#endif - - if (!t) return; - - /* Can't do the update now as we don't know whether to flush - * vertices or not. Setting vmesa->new_state means that - * s3vUpdateTextureState() will be called before any triangles are - * rendered. If a statechange has occurred, it will be detected at - * that point, and buffered vertices flushed. - */ - switch (pname) { - case GL_TEXTURE_MIN_FILTER: - case GL_TEXTURE_MAG_FILTER: - s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter ); - break; - - case GL_TEXTURE_WRAP_S: - case GL_TEXTURE_WRAP_T: - s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT ); - break; - - case GL_TEXTURE_BORDER_COLOR: - s3vSetTexBorderColor( vmesa, t, tObj->BorderColor ); - break; - - case GL_TEXTURE_BASE_LEVEL: - case GL_TEXTURE_MAX_LEVEL: - case GL_TEXTURE_MIN_LOD: - case GL_TEXTURE_MAX_LOD: - /* This isn't the most efficient solution but there doesn't appear to - * be a nice alternative for Virge. Since there's no LOD clamping, - * we just have to rely on loading the right subset of mipmap levels - * to simulate a clamped LOD. - */ - s3vSwapOutTexObj( vmesa, t ); - break; - - default: - return; - } - - if (t == vmesa->CurrentTexObj[0]) - vmesa->dirty |= S3V_UPLOAD_TEX0; - -#if 0 - if (t == vmesa->CurrentTexObj[1]) { - vmesa->dirty |= S3V_UPLOAD_TEX1; - } -#endif -} - - -static void s3vTexEnv( GLcontext *ctx, GLenum target, - GLenum pname, const GLfloat *param ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - GLuint unit = ctx->Texture.CurrentUnit; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexEnv: #%i ***\n", ++times)); -#endif - - /* Only one env color. Need a fallback if env colors are different - * and texture setup references env color in both units. - */ - switch (pname) { - case GL_TEXTURE_ENV_COLOR: { - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLfloat *fc = texUnit->EnvColor; - GLuint r, g, b, a, col; - CLAMPED_FLOAT_TO_UBYTE(r, fc[0]); - CLAMPED_FLOAT_TO_UBYTE(g, fc[1]); - CLAMPED_FLOAT_TO_UBYTE(b, fc[2]); - CLAMPED_FLOAT_TO_UBYTE(a, fc[3]); - - col = ((a << 24) | - (r << 16) | - (g << 8) | - (b << 0)); - - break; - } - case GL_TEXTURE_ENV_MODE: - vmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */ - break; - case GL_TEXTURE_LOD_BIAS_EXT: { -/* - struct gl_texture_object *tObj = - ctx->Texture.Unit[unit]._Current; - - s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData; -*/ - break; - } - default: - break; - } -} - -static void s3vTexImage1D( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint border, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *pack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexImage1D: #%i ***\n", ++times)); -#endif - -#if 1 - if (t) { -#if _TEXFLUSH - DMAFLUSH(); -#endif - s3vSwapOutTexObj( vmesa, t ); -/* - s3vDestroyTexObj( vmesa, t ); - texObj->DriverData = 0; -*/ - } -#endif - _mesa_store_teximage1d( ctx, target, level, internalFormat, - width, border, format, type, - pixels, pack, texObj, texImage ); -} - -static void s3vTexSubImage1D( GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, - GLsizei width, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *pack, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexSubImage1D: #%i ***\n", ++times)); -#endif - -#if 1 - if (t) { -#if _TEXFLUSH - DMAFLUSH(); -#endif - s3vSwapOutTexObj( vmesa, t ); -/* - s3vDestroyTexObj( vmesa, t ); - texObj->DriverData = 0; -*/ - } -#endif - _mesa_store_texsubimage1d(ctx, target, level, xoffset, width, - format, type, pixels, pack, texObj, - texImage); -} - -static void s3vTexImage2D( GLcontext *ctx, GLenum target, GLint level, - GLint internalFormat, - GLint width, GLint height, GLint border, - GLenum format, GLenum type, const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData; - -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexImage2D: #%i ***\n", ++times)); -#endif - -#if 1 - if (t) { -#if _TEXFLUSH - DMAFLUSH(); -#endif - s3vSwapOutTexObj( vmesa, t ); -/* - s3vDestroyTexObj( vmesa, t ); - texObj->DriverData = 0; -*/ - } -#endif - _mesa_store_teximage2d( ctx, target, level, internalFormat, - width, height, border, format, type, - pixels, packing, texObj, texImage ); -} - -static void s3vTexSubImage2D( GLcontext *ctx, - GLenum target, - GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid *pixels, - const struct gl_pixelstore_attrib *packing, - struct gl_texture_object *texObj, - struct gl_texture_image *texImage ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexSubImage2D: #%i ***\n", ++times)); -#endif - -#if 1 - if (t) { -#if _TEXFLUSH - DMAFLUSH(); -#endif - s3vSwapOutTexObj( vmesa, t ); -/* - s3vDestroyTexObj( vmesa, t ); - texObj->DriverData = 0; -*/ - } -#endif - _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width, - height, format, type, pixels, packing, texObj, - texImage); -} - - -static void s3vBindTexture( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData; - GLuint cmd = vmesa->CMD; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vBindTexture: #%i ***\n", ++times)); -#endif - - if (!t) { -/* - GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias; -*/ - t = CALLOC_STRUCT(s3v_texture_object_t); - - /* Initialize non-image-dependent parts of the state: - */ - t->globj = tObj; -#if 0 - if (target == GL_TEXTURE_2D) { - } else - if (target == GL_TEXTURE_1D) { - } - -#if X_BYTE_ORDER == X_LITTLE_ENDIAN - t->TextureFormat = (TF_LittleEndian | -#else - t->TextureFormat = (TF_BigEndian | -#endif -#endif - t->dirty_images = ~0; - - tObj->DriverData = t; - make_empty_list( t ); -#if 0 - s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT ); - s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter ); - s3vSetTexBorderColor( vmesa, t, tObj->BorderColor ); -#endif - } - - cmd = vmesa->CMD & ~MIP_MASK; - vmesa->dirty |= S3V_UPLOAD_TEX0; - vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel]; - vmesa->TexStride = t->Pitch; - cmd |= MIPMAP_LEVEL(t->WidthLog2); - vmesa->CMD = cmd; - vmesa->restore_primitive = -1; -#if 0 - printf("t->TextureBaseAddr[0] = 0x%x\n", t->TextureBaseAddr[0]); - printf("t->TextureBaseAddr[1] = 0x%x\n", t->TextureBaseAddr[1]); - printf("t->TextureBaseAddr[2] = 0x%x\n", t->TextureBaseAddr[2]); -#endif -} - - -static void s3vDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) -{ - s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vDeleteTexture: #%i ***\n", ++times)); -#endif - - if (t) { - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - -#if _TEXFLUSH - if (vmesa) { - DMAFLUSH(); - } -#endif - - s3vDestroyTexObj( vmesa, t ); - tObj->DriverData = 0; - - } -} - -static GLboolean s3vIsTextureResident( GLcontext *ctx, - struct gl_texture_object *tObj ) -{ - s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vIsTextureResident: #%i ***\n", ++times)); -#endif - - return (t && t->MemBlock); -} - -static void s3vInitTextureObjects( GLcontext *ctx ) -{ - /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */ - struct gl_texture_object *texObj; - GLuint tmp = ctx->Texture.CurrentUnit; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vInitTextureObjects: #%i ***\n", ++times)); -#endif - -#if 1 - ctx->Texture.CurrentUnit = 0; - - texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_1D_INDEX]; - s3vBindTexture( ctx, GL_TEXTURE_1D, texObj ); - - texObj = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX]; - s3vBindTexture( ctx, GL_TEXTURE_2D, texObj ); -#endif - -#if 0 - ctx->Texture.CurrentUnit = 1; - - texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_1D_INDEX]; - s3vBindTexture( ctx, GL_TEXTURE_1D, texObj ); - - texObj = ctx->Texture.Unit[1].CurrentTex[TEXTURE_2D_INDEX]; - s3vBindTexture( ctx, GL_TEXTURE_2D, texObj ); -#endif - - ctx->Texture.CurrentUnit = tmp; -} - - -void s3vInitTextureFuncs( GLcontext *ctx ) -{ -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vInitTextureFuncs: #%i ***\n", ++times)); -#endif - - ctx->Driver.TexEnv = s3vTexEnv; - ctx->Driver.TexImage2D = s3vTexImage2D; - ctx->Driver.TexSubImage2D = s3vTexSubImage2D; - ctx->Driver.BindTexture = s3vBindTexture; - ctx->Driver.DeleteTexture = s3vDeleteTexture; - ctx->Driver.TexParameter = s3vTexParameter; - ctx->Driver.UpdateTexturePalette = 0; - ctx->Driver.IsTextureResident = s3vIsTextureResident; - - s3vInitTextureObjects( ctx ); -} diff --git a/src/mesa/drivers/dri/s3v/s3v_tex.h b/src/mesa/drivers/dri/s3v/s3v_tex.h deleted file mode 100644 index a823fe2453..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_tex.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_TEX_H -#define _S3V_TEX_H - -#define TEX_DEBUG_ON 0 - -extern void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t ); - -#if TEX_DEBUG_ON -#define DEBUG_TEX(str) printf str -#else -#define DEBUG_TEX(str) /* str */ -#endif - -#define _TEXFLUSH 1 /* flush before uploading */ -#define _TEXLOCK 1 /* lock before writing new texures to card mem */ - /* if you turn it on you will gain stability and image - quality, but you will loose performance (~10%) */ -#define _TEXFALLBACK 0 /* fallback to software for -big- textures (slow) */ - /* turning this off, you will lose some tex (e.g. mountains - on tuxracer) but you will increase average playability */ - -#define _TEXALIGN 0x00000007 - -#endif diff --git a/src/mesa/drivers/dri/s3v/s3v_texmem.c b/src/mesa/drivers/dri/s3v/s3v_texmem.c deleted file mode 100644 index 705d105f55..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_texmem.c +++ /dev/null @@ -1,582 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include -#include - -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" - -#include "main/mm.h" -#include "s3v_context.h" -#include "s3v_lock.h" -#include "s3v_tex.h" - -void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t); -void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t ); - - -void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t) -{ -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vDestroyTexObj: #%i ***\n", ++times)); -#endif - - if (!t) return; - -/* FIXME: useful? */ -#if _TEXFLUSH - if (vmesa) - DMAFLUSH(); -#endif - - /* This is sad - need to sync *in case* we upload a texture - * to this newly free memory... - */ - if (t->MemBlock) { - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (vmesa && t->age > vmesa->dirtyAge) - vmesa->dirtyAge = t->age; - } - - if (t->globj) - t->globj->DriverData = NULL; - - if (vmesa) { - if (vmesa->CurrentTexObj[0] == t) { - vmesa->CurrentTexObj[0] = 0; - vmesa->dirty &= ~S3V_UPLOAD_TEX0; - } - -#if 0 - if (vmesa->CurrentTexObj[1] == t) { - vmesa->CurrentTexObj[1] = 0; - vmesa->dirty &= ~S3V_UPLOAD_TEX1; - } -#endif - } - - remove_from_list(t); - FREE(t); -} - - -void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t) -{ -/* int i; */ -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vSwapOutTexObj: #%i ***\n", ++times)); -#endif - - if (t->MemBlock) { - - mmFreeMem(t->MemBlock); - t->MemBlock = 0; - - if (t->age > vmesa->dirtyAge) - vmesa->dirtyAge = t->age; - - t->dirty_images = ~0; - move_to_tail(&(vmesa->SwappedOut), t); - } -} - - -/* Upload an image from mesa's internal copy. - */ - -static void s3vUploadTexLevel( s3vContextPtr vmesa, s3vTextureObjectPtr t, - int level ) -{ - __DRIscreenPrivate *sPriv = vmesa->driScreen; - const struct gl_texture_image *image = t->image[level].image; - int i,j; - int l2d; - /* int offset = 0; */ - int words; - GLuint* dest; -#if TEX_DEBUG_ON - static unsigned int times=0; -#endif - if ( !image ) return; - if (image->Data == 0) return; - - DEBUG_TEX(("*** s3vUploadTexLevel: #%i ***\n", ++times)); - DEBUG_TEX(("level = %i\n", level)); - - l2d = 5; /* 32bits per texel == 1<<5 */ -/* - if (level == 0) - ; -*/ - DEBUG_TEX(("t->image[%i].offset = 0x%x\n", - level, t->image[level].offset)); - - t->TextureBaseAddr[level] = (GLuint)(t->BufAddr + t->image[level].offset - + _TEXALIGN) & (GLuint)(~_TEXALIGN); - dest = (GLuint*)(sPriv->pFB + t->TextureBaseAddr[level]); - - DEBUG_TEX(("sPriv->pFB = 0x%x\n", sPriv->pFB)); - DEBUG_TEX(("dest = 0x%x\n", dest)); - DEBUG_TEX(("dest - sPriv->pFB = 0x%x\n", ((int)dest - (int)sPriv->pFB))); - - /* NOTE: we implicitly suppose t->texelBytes == 2 */ - - words = (image->Width * image->Height) >> 1; - - DEBUG_TEX(("\n\n")); - - switch (t->image[level].internalFormat) { - case GL_RGB: - case 3: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_RGB:\n")); -/* - if (level == 0) - ; -*/ - /* The UGLY way, and SLOW : use DMA FIXME ! */ - - for (i = 0; i < words; i++) { - unsigned int data; - /* data = PACK_COLOR_565(src[0],src[1],src[2]); */ - data = S3VIRGEPACKCOLOR555(src[0],src[1],src[2],255) - |(S3VIRGEPACKCOLOR555(src[3],src[4],src[5],255)<<16); - - *dest++ = data; - /* src += 3; */ - src +=6; - } - } - break; - - case GL_RGBA: - case 4: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_RGBA:\n")); -/* - if (level == 0) - ; -*/ - for (i = 0; i < words; i++) { - unsigned int data; - - /* data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]); */ - data = S3VIRGEPACKCOLOR4444(src[0], src[1],src[2], src[3]) - | (S3VIRGEPACKCOLOR4444(src[4], src[5], src[6], src[7]) << 16); - - *dest++ = data; - /* src += 4; */ - src += 8; - } - } - break; - - case GL_LUMINANCE: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_LUMINANCE:\n")); -/* - if (level == 0) - ; -*/ - for (i = 0; i < words; i++) { - unsigned int data; - - /* data = PACK_COLOR_888(src[0],src[0],src[0]); */ - data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0]) - | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16); - - *dest++ = data; - /* src ++; */ - src +=2; - } - } - break; - - case GL_INTENSITY: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_INTENSITY:\n")); -/* - if (level == 0) - ; -*/ - for (i = 0; i < words; i++) { - unsigned int data; - - /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]); */ - data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0]) - | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16); - - *dest++ = data; - /* src ++; */ - src += 2; - } - } - break; - - case GL_LUMINANCE_ALPHA: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_LUMINANCE_ALPHA:\n")); -/* - if (level == 0) - ; -*/ - for (i = 0; i < words; i++) { - unsigned int data; - - /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]); */ - data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[1]) - | (S3VIRGEPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16); - - *dest++ = data; - /* src += 2; */ - src += 4; - } - } - break; - - case GL_ALPHA: - { - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_ALPHA:\n")); -/* - if (level == 0) - ; -*/ - for (i = 0; i < words; i++) { - unsigned int data; - - /* data = PACK_COLOR_8888(255,255,255,src[0]); */ - data = S3VIRGEPACKCOLOR4444(255,255,255,src[0]) - | (S3VIRGEPACKCOLOR4444(255,255,255,src[1]) << 16); - - *dest++ = data; - /* src += 1; */ - src += 2; - } - } - break; - - /* TODO: Translate color indices *now*: - */ - case GL_COLOR_INDEX: - { - - GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset); - GLubyte *src = (GLubyte *)image->Data; - - DEBUG_TEX(("GL_COLOR_INDEX:\n")); - - for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) { - for (i = 0 ; i < image->Width ; i++) { - dst[i] = src[0]; - src += 1; - } - } - } - break; - - default: - fprintf(stderr, "Not supported texture format %s\n", - _mesa_lookup_enum_by_nr(image->_BaseFormat)); - } - - DEBUG_TEX(("words = %i\n\n", words)); -} - -void s3vPrintLocalLRU( s3vContextPtr vmesa ) -{ - s3vTextureObjectPtr t; - int sz = 1 << (vmesa->s3vScreen->logTextureGranularity); - -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vPrintLocalLRU: #%i ***\n", ++times)); -#endif - - foreach( t, &vmesa->TexObjList ) { - if (!t->globj) - fprintf(stderr, "Placeholder %d at %x sz %x\n", - t->MemBlock->ofs / sz, - t->MemBlock->ofs, - t->MemBlock->size); - else - fprintf(stderr, "Texture at %x sz %x\n", - t->MemBlock->ofs, - t->MemBlock->size); - - } -} - -void s3vPrintGlobalLRU( s3vContextPtr vmesa ) -{ - int i, j; - S3VTexRegionPtr list = vmesa->sarea->texList; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vPrintGlobalLRU: #%i ***\n", ++times)); -#endif - - for (i = 0, j = S3V_NR_TEX_REGIONS ; i < S3V_NR_TEX_REGIONS ; i++) { - fprintf(stderr, "list[%d] age %d next %d prev %d\n", - j, list[j].age, list[j].next, list[j].prev); - j = list[j].next; - if (j == S3V_NR_TEX_REGIONS) break; - } - - if (j != S3V_NR_TEX_REGIONS) - fprintf(stderr, "Loop detected in global LRU\n"); -} - - -void s3vResetGlobalLRU( s3vContextPtr vmesa ) -{ - S3VTexRegionPtr list = vmesa->sarea->texList; - int sz = 1 << vmesa->s3vScreen->logTextureGranularity; - int i; - -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vResetGlobalLRU: #%i ***\n", ++times)); -#endif - - /* (Re)initialize the global circular LRU list. The last element - * in the array (S3V_NR_TEX_REGIONS) is the sentinal. Keeping it - * at the end of the array allows it to be addressed rationally - * when looking up objects at a particular location in texture - * memory. - */ - for (i = 0 ; (i+1) * sz <= vmesa->s3vScreen->textureSize ; i++) { - list[i].prev = i-1; - list[i].next = i+1; - list[i].age = 0; - } - - i--; - list[0].prev = S3V_NR_TEX_REGIONS; - list[i].prev = i-1; - list[i].next = S3V_NR_TEX_REGIONS; - list[S3V_NR_TEX_REGIONS].prev = i; - list[S3V_NR_TEX_REGIONS].next = 0; - vmesa->sarea->texAge = 0; -} - - -void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t ) -{ -/* - int i; - int logsz = vmesa->s3vScreen->logTextureGranularity; - int start = t->MemBlock->ofs >> logsz; - int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz; - S3VTexRegionPtr list = vmesa->sarea->texList; -*/ - -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vUpdateTexLRU: #%i ***\n", ++times)); -#endif - - vmesa->texAge = ++vmesa->sarea->texAge; - - /* Update our local LRU - */ - move_to_head( &(vmesa->TexObjList), t ); - - /* Update the global LRU - */ -#if 0 - for (i = start ; i <= end ; i++) { - - list[i].in_use = 1; - list[i].age = vmesa->texAge; - - /* remove_from_list(i) - */ - list[(unsigned)list[i].next].prev = list[i].prev; - list[(unsigned)list[i].prev].next = list[i].next; - - /* insert_at_head(list, i) - */ - list[i].prev = S3V_NR_TEX_REGIONS; - list[i].next = list[S3V_NR_TEX_REGIONS].next; - list[(unsigned)list[S3V_NR_TEX_REGIONS].next].prev = i; - list[S3V_NR_TEX_REGIONS].next = i; - } -#endif -} - - -/* Called for every shared texture region which has increased in age - * since we last held the lock. - * - * Figures out which of our textures have been ejected by other clients, - * and pushes a placeholder texture onto the LRU list to represent - * the other client's textures. - */ -void s3vTexturesGone( s3vContextPtr vmesa, - GLuint offset, - GLuint size, - GLuint in_use ) -{ - s3vTextureObjectPtr t, tmp; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vTexturesGone: #%i ***\n", ++times)); -#endif - - foreach_s ( t, tmp, &vmesa->TexObjList ) { - - if (t->MemBlock->ofs >= offset + size || - t->MemBlock->ofs + t->MemBlock->size <= offset) - continue; - - /* It overlaps - kick it off. Need to hold onto the currently bound - * objects, however. - */ - s3vSwapOutTexObj( vmesa, t ); - } - - if (in_use) { - t = (s3vTextureObjectPtr) calloc(1,sizeof(*t)); - if (!t) return; - - t->MemBlock = mmAllocMem( vmesa->texHeap, size, 0, offset); - insert_at_head( &vmesa->TexObjList, t ); - } - - /* Reload any lost textures referenced by current vertex buffer. - */ -#if 0 - if (vmesa->vertex_buffer) { - int i, j; - - fprintf(stderr, "\n\nreload tex\n"); - - for (i = 0 ; i < vmesa->statenr ; i++) { - for (j = 0 ; j < 2 ; j++) { - s3vTextureObjectPtr t = vmesa->state_tex[j][i]; - if (t) { - if (t->MemBlock == 0) - s3vUploadTexImages( vmesa, t ); - } - } - } - - /* Hard to do this with the lock held: - */ - /* S3V_FIREVERTICES( vmesa ); */ - } -#endif -} - - -/* This is called with the lock held. May have to eject our own and/or - * other client's texture objects to make room for the upload. - */ -void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t ) -{ - int i; - int ofs; - int numLevels; -#if TEX_DEBUG_ON - static unsigned int times=0; - static unsigned int try=0; - - DEBUG_TEX(("*** s3vUploadTexImages: #%i ***\n", ++times)); - DEBUG_TEX(("vmesa->texHeap = 0x%x; t->totalSize = %i\n", - (unsigned int)vmesa->texHeap, t->totalSize)); -#endif - - /* Do we need to eject LRU texture objects? - */ - if (!t->MemBlock) { - - while (1) - { - /* int try = 0; */ - DEBUG_TEX(("trying to alloc mem for tex (try %i)\n", ++try)); - - t->MemBlock = mmAllocMem( vmesa->texHeap, t->totalSize, 12, 0 ); - - if (t->MemBlock) - break; - - if (vmesa->TexObjList.prev == vmesa->CurrentTexObj[0]) { -/* || vmesa->TexObjList.prev == vmesa->CurrentTexObj[1]) { - fprintf(stderr, "Hit bound texture in upload\n"); - s3vPrintLocalLRU( vmesa ); */ - return; - } - - if (vmesa->TexObjList.prev == &(vmesa->TexObjList)) { -/* fprintf(stderr, "Failed to upload texture, sz %d\n", - t->totalSize); - mmDumpMemInfo( vmesa->texHeap ); */ - return; - } - - DEBUG_TEX(("swapping out: %p\n", vmesa->TexObjList.prev)); - s3vSwapOutTexObj( vmesa, vmesa->TexObjList.prev ); - } - - ofs = t->MemBlock->ofs; - - t->BufAddr = vmesa->s3vScreen->texOffset + ofs; - - DEBUG_TEX(("ofs = 0x%x\n", ofs)); - DEBUG_TEX(("t->BufAddr = 0x%x\n", t->BufAddr)); - -/* FIXME: check if we need it */ -#if 0 - if (t == vmesa->CurrentTexObj[0]) { - vmesa->dirty |= S3V_UPLOAD_TEX0; - vmesa->restore_primitive = -1; - } -#endif - -#if 0 - if (t == vmesa->CurrentTexObj[1]) - vmesa->dirty |= S3V_UPLOAD_TEX1; -#endif - - s3vUpdateTexLRU( vmesa, t ); - } - -#if 0 - if (vmesa->dirtyAge >= GET_DISPATCH_AGE(vmesa)) - s3vWaitAgeLocked( vmesa, vmesa->dirtyAge ); -#endif - -#if _TEXLOCK - S3V_SIMPLE_FLUSH_LOCK(vmesa); -#endif - numLevels = t->lastLevel - t->firstLevel + 1; - for (i = 0 ; i < numLevels ; i++) - if (t->dirty_images & (1<dirty_images = 0; -#if _TEXLOCK - S3V_SIMPLE_UNLOCK(vmesa); -#endif -} diff --git a/src/mesa/drivers/dri/s3v/s3v_texstate.c b/src/mesa/drivers/dri/s3v/s3v_texstate.c deleted file mode 100644 index 455bae6301..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_texstate.c +++ /dev/null @@ -1,300 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include -#include - -#include "main/glheader.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "main/simple_list.h" -#include "main/enums.h" - -#include "main/mm.h" -#include "s3v_context.h" -#include "s3v_tex.h" - - -static void s3vSetTexImages( s3vContextPtr vmesa, - struct gl_texture_object *tObj ) -{ - GLuint height, width, pitch, i, /*textureFormat,*/ log_pitch; - s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData; - const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel]; - GLint firstLevel, lastLevel, numLevels; - GLint log2Width, log2Height; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vSetTexImages: #%i ***\n", ++times)); -#endif - - t->texelBytes = 2; /* FIXME: always 2 ? */ - - /* Compute which mipmap levels we really want to send to the hardware. - * This depends on the base image size, GL_TEXTURE_MIN_LOD, - * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL. - * Yes, this looks overly complicated, but it's all needed. - */ - if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) { - firstLevel = lastLevel = tObj->BaseLevel; - } - else { - firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5); - firstLevel = MAX2(firstLevel, tObj->BaseLevel); - lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5); - lastLevel = MAX2(lastLevel, tObj->BaseLevel); - lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2); - lastLevel = MIN2(lastLevel, tObj->MaxLevel); - lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */ - } - - /* save these values */ - t->firstLevel = firstLevel; - t->lastLevel = lastLevel; - - numLevels = lastLevel - firstLevel + 1; - - log2Width = tObj->Image[0][firstLevel]->WidthLog2; - log2Height = tObj->Image[0][firstLevel]->HeightLog2; - - - /* Figure out the amount of memory required to hold all the mipmap - * levels. Choose the smallest pitch to accomodate the largest - * mipmap: - */ - width = tObj->Image[0][firstLevel]->Width * t->texelBytes; - for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 ) - log_pitch++; - - /* All images must be loaded at this pitch. Count the number of - * lines required: - */ - for ( height = i = 0 ; i < numLevels ; i++ ) { - t->image[i].image = tObj->Image[0][firstLevel + i]; - t->image[i].offset = height * pitch; - t->image[i].internalFormat = baseImage->_BaseFormat; - height += t->image[i].image->Height; - t->TextureBaseAddr[i] = (t->BufAddr + t->image[i].offset + - _TEXALIGN) & (GLuint)(~_TEXALIGN); - } - - t->Pitch = pitch; - t->WidthLog2 = log2Width; - t->totalSize = height*pitch; - t->max_level = i-1; - vmesa->dirty |= S3V_UPLOAD_TEX0 /* | S3V_UPLOAD_TEX1*/; - vmesa->restore_primitive = -1; - DEBUG(("<><>pitch = TexStride = %i\n", pitch)); - DEBUG(("log2Width = %i\n", log2Width)); - - s3vUploadTexImages( vmesa, t ); -} - -static void s3vUpdateTexEnv( GLcontext *ctx, GLuint unit ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - const struct gl_texture_object *tObj = texUnit->_Current; - const GLuint format = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; -/* - s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData; - GLuint tc; -*/ - GLuint alpha = 0; - GLuint cmd = vmesa->CMD; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vUpdateTexEnv: %i ***\n", ++times)); -#endif - - cmd &= ~TEX_COL_MASK; - cmd &= ~TEX_BLEND_MAKS; -/* cmd &= ~ALPHA_BLEND_MASK; */ - - DEBUG(("format = ")); - - switch (format) { - case GL_RGB: - DEBUG_TEX(("GL_RGB\n")); - cmd |= TEX_COL_ARGB1555; - break; - case GL_LUMINANCE: - DEBUG_TEX(("GL_LUMINANCE\n")); - cmd |= TEX_COL_ARGB4444; - alpha = 1; /* FIXME: check */ - break; - case GL_ALPHA: - DEBUG_TEX(("GL_ALPHA\n")); - cmd |= TEX_COL_ARGB4444; - alpha = 1; - break; - case GL_LUMINANCE_ALPHA: - DEBUG_TEX(("GL_LUMINANCE_ALPHA\n")); - cmd |= TEX_COL_ARGB4444; - alpha = 1; - break; - case GL_INTENSITY: - DEBUG_TEX(("GL_INTENSITY\n")); - cmd |= TEX_COL_ARGB4444; - alpha = 1; - break; - case GL_RGBA: - DEBUG_TEX(("GL_RGBA\n")); - cmd |= TEX_COL_ARGB4444; - alpha = 1; - break; - case GL_COLOR_INDEX: - DEBUG_TEX(("GL_COLOR_INDEX\n")); - cmd |= TEX_COL_PAL; - break; - } - - DEBUG_TEX(("EnvMode = ")); - - switch (texUnit->EnvMode) { - case GL_REPLACE: - DEBUG_TEX(("GL_REPLACE\n")); - cmd |= TEX_REFLECT; /* FIXME */ - vmesa->_tri[1] = DO_TEX_UNLIT_TRI; /* FIXME: white tri hack */ - vmesa->_alpha_tex = ALPHA_TEX /* * alpha */; - break; - case GL_MODULATE: - DEBUG_TEX(("GL_MODULATE\n")); - cmd |= TEX_MODULATE; - vmesa->_tri[1] = DO_TEX_LIT_TRI; -#if 0 - if (alpha) - vmesa->_alpha_tex = ALPHA_TEX /* * alpha */; - else - vmesa->_alpha_tex = ALPHA_SRC /* * alpha */; -#else - vmesa->_alpha_tex = ALPHA_TEX ; -#endif - break; - case GL_ADD: - DEBUG_TEX(("DEBUG_TEX\n")); - /* do nothing ???*/ - break; - case GL_DECAL: - DEBUG_TEX(("GL_DECAL\n")); - cmd |= TEX_DECAL; - vmesa->_tri[1] = DO_TEX_LIT_TRI; - vmesa->_alpha_tex = ALPHA_OFF; - break; - case GL_BLEND: - DEBUG_TEX(("GL_BLEND\n")); - cmd |= TEX_DECAL; - vmesa->_tri[1] = DO_TEX_LIT_TRI; - vmesa->_alpha_tex = ALPHA_OFF; /* FIXME: sure? */ - break; - default: - fprintf(stderr, "unknown tex env mode"); - return; - } - - DEBUG_TEX(("\n\n vmesa->CMD was 0x%x\n", vmesa->CMD)); - DEBUG_TEX(( " vmesa->CMD is 0x%x\n\n", cmd )); - - vmesa->_alpha[1] = vmesa->_alpha_tex; - vmesa->CMD = cmd; /* | MIPMAP_LEVEL(8); */ - vmesa->restore_primitive = -1; -} - -static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint cmd = vmesa->CMD; -#if TEX_DEBUG_ON - static unsigned int times=0; - DEBUG_TEX(("*** s3vUpdateTexUnit: %i ***\n", ++times)); - DEBUG_TEX(("and vmesa->CMD was 0x%x\n", vmesa->CMD)); -#endif - - if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT) - { - struct gl_texture_object *tObj = texUnit->_Current; - s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData; - - /* Upload teximages (not pipelined) - */ - if (t->dirty_images) { -#if _TEXFLUSH - DMAFLUSH(); -#endif - s3vSetTexImages( vmesa, tObj ); - if (!t->MemBlock) { -#if _TEXFALLBACK - FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE ); -#endif - return; - } - } - - /* Update state if this is a different texture object to last - * time. - */ -#if 1 - if (vmesa->CurrentTexObj[unit] != t) { - vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */; - vmesa->CurrentTexObj[unit] = t; - s3vUpdateTexLRU( vmesa, t ); /* done too often */ - } -#endif - - /* Update texture environment if texture object image format or - * texture environment state has changed. - */ - if (tObj->Image[0][tObj->BaseLevel]->_BaseFormat != - vmesa->TexEnvImageFmt[unit]) { - vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->_BaseFormat; - s3vUpdateTexEnv( ctx, unit ); - } -#if 1 - cmd = vmesa->CMD & ~MIP_MASK; - vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */; - vmesa->CurrentTexObj[unit] = t; - vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel]; - vmesa->TexStride = t->Pitch; - cmd |= MIPMAP_LEVEL(t->WidthLog2); - - DEBUG_TEX(("\n\n>> vmesa->CMD was 0x%x\n", vmesa->CMD)); - DEBUG_TEX(( ">> vmesa->CMD is 0x%x\n\n", cmd )); - DEBUG_TEX(("t->WidthLog2 = %i\n", t->WidthLog2)); - DEBUG_TEX(("MIPMAP_LEVEL(t->WidthLog2) = 0x%x\n", MIPMAP_LEVEL(t->WidthLog2))); - - vmesa->CMD = cmd; - vmesa->restore_primitive = -1; -#endif - } - else if (texUnit->_ReallyEnabled) { /* _ReallyEnabled but != TEXTURE0_2D */ -#if _TEXFALLBACK - FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE ); -#endif - } - else /*if (vmesa->CurrentTexObj[unit])*/ { /* !_ReallyEnabled */ - vmesa->CurrentTexObj[unit] = 0; - vmesa->TexEnvImageFmt[unit] = 0; - vmesa->dirty &= ~(S3V_UPLOAD_TEX0< - */ - -#include -#include - -#include - -#include "s3v_context.h" -#include "s3v_vb.h" -#include "s3v_tris.h" - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - - -/*********************************************************************** - * Build hardware rasterization functions * - ***********************************************************************/ - -#define DO_TRI 1 -#define HAVE_RGBA 1 -#define HAVE_SPEC 0 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX s3vVertex -#define TAB rast_tab - -#define VERT_SET_RGBA( v, c ) \ -do { \ - UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c); \ -/* *(v->ub4[4]) = c; \ */ \ -} while (0) -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4] -/* -#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4] -*/ -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx] - -#define S3V_OFFSET_BIT 0x01 -#define S3V_TWOSIDE_BIT 0x02 -#define S3V_UNFILLED_BIT 0x04 -#define S3V_FALLBACK_BIT 0x08 -#define S3V_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[S3V_MAX_TRIFUNC]; - -#define S3V_RAST_CULL_BIT 0x01 -#define S3V_RAST_FLAT_BIT 0x02 -#define S3V_RAST_TEX_BIT 0x04 - -static s3v_point_func s3v_point_tab[0x8]; -static s3v_line_func s3v_line_tab[0x8]; -static s3v_tri_func s3v_tri_tab[0x8]; -static s3v_quad_func s3v_quad_tab[0x8]; - -#define IND (0) -#define TAG(x) x -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_CULL_BIT) -#define TAG(x) x##_cull -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_FLAT_BIT) -#define TAG(x) x##_flat -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT) -#define TAG(x) x##_cull_flat -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_TEX_BIT) -#define TAG(x) x##_tex -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_CULL_BIT|S3V_RAST_TEX_BIT) -#define TAG(x) x##_cull_tex -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT) -#define TAG(x) x##_flat_tex -#include "s3v_tritmp.h" - -#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT) -#define TAG(x) x##_cull_flat_tex -#include "s3v_tritmp.h" - -static void init_rast_tab( void ) -{ - DEBUG(("*** init_rast_tab ***\n")); - - s3v_init(); - s3v_init_cull(); - s3v_init_flat(); - s3v_init_cull_flat(); - s3v_init_tex(); - s3v_init_cull_tex(); - s3v_init_flat_tex(); - s3v_init_cull_flat_tex(); -} - -/*********************************************************************** - * Rasterization fallback helpers * - ***********************************************************************/ - - -/* This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ - -#if 0 -static void -s3v_fallback_quad( s3vContextPtr vmesa, - const s3vVertex *v0, - const s3vVertex *v1, - const s3vVertex *v2, - const s3vVertex *v3 ) -{ - GLcontext *ctx = vmesa->glCtx; - SWvertex v[4]; - s3v_translate_vertex( ctx, v0, &v[0] ); - s3v_translate_vertex( ctx, v1, &v[1] ); - s3v_translate_vertex( ctx, v2, &v[2] ); - s3v_translate_vertex( ctx, v3, &v[3] ); - DEBUG(("s3v_fallback_quad\n")); -/* _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); */ -} - -static void -s3v_fallback_tri( s3vContextPtr vmesa, - const s3vVertex *v0, - const s3vVertex *v1, - const s3vVertex *v2 ) -{ - GLcontext *ctx = vmesa->glCtx; - SWvertex v[3]; - s3v_translate_vertex( ctx, v0, &v[0] ); - s3v_translate_vertex( ctx, v1, &v[1] ); - s3v_translate_vertex( ctx, v2, &v[2] ); - DEBUG(("s3v_fallback_tri\n")); -/* _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); */ -} - -static void -s3v_fallback_line( s3vContextPtr vmesa, - const s3vVertex *v0, - const s3vVertex *v1 ) -{ - GLcontext *ctx = vmesa->glCtx; - SWvertex v[2]; - s3v_translate_vertex( ctx, v0, &v[0] ); - s3v_translate_vertex( ctx, v1, &v[1] ); - DEBUG(("s3v_fallback_line\n")); - _swrast_Line( ctx, &v[0], &v[1] ); -} - -/* -static void -s3v_fallback_point( s3vContextPtr vmesa, - const s3vVertex *v0 ) -{ - GLcontext *ctx = vmesa->glCtx; - SWvertex v[1]; - s3v_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} -*/ -#endif - -/*********************************************************************** - * Choose rasterization functions * - ***********************************************************************/ - -#define _S3V_NEW_RASTER_STATE (_NEW_FOG | \ - _NEW_TEXTURE | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_POINT_SMOOTH | \ - _DD_NEW_TRI_STIPPLE | \ - _DD_NEW_LINE_STIPPLE) - -#define LINE_FALLBACK (0) -#define TRI_FALLBACK (0) - -static void s3v_nodraw_triangle(GLcontext *ctx, s3vVertex *v0, - s3vVertex *v1, s3vVertex *v2) -{ - (void) (ctx && v0 && v1 && v2); -} - -static void s3v_nodraw_quad(GLcontext *ctx, - s3vVertex *v0, s3vVertex *v1, - s3vVertex *v2, s3vVertex *v3) -{ - (void) (ctx && v0 && v1 && v2 && v3); -} - -void s3vChooseRasterState(GLcontext *ctx); - -void s3vChooseRasterState(GLcontext *ctx) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint ind = 0; - - DEBUG(("*** s3vChooseRasterState ***\n")); - - if (ctx->Polygon.CullFlag) { - if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) { - vmesa->draw_tri = (s3v_tri_func)s3v_nodraw_triangle; - vmesa->draw_quad = (s3v_quad_func)s3v_nodraw_quad; - return; - } - ind |= S3V_RAST_CULL_BIT; - /* s3v_update_cullsign(ctx); */ - } /* else vmesa->backface_sign = 0; */ - - if ( flags & DD_FLATSHADE ) - ind |= S3V_RAST_FLAT_BIT; - - if ( ctx->Texture.Unit[0]._ReallyEnabled ) { - ind |= S3V_RAST_TEX_BIT; - } - - DEBUG(("ind = %i\n", ind)); - - vmesa->draw_line = s3v_line_tab[ind]; - vmesa->draw_tri = s3v_tri_tab[ind]; - vmesa->draw_quad = s3v_quad_tab[ind]; - vmesa->draw_point = s3v_point_tab[ind]; - -#if 0 - /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED - */ - - if (flags & LINE_FALLBACK) - vmesa->draw_line = s3v_fallback_line; - - if (flags & TRI_FALLBACK) { - DEBUG(("TRI_FALLBACK\n")); - vmesa->draw_tri = s3v_fallback_tri; - vmesa->draw_quad = s3v_fallback_quad; - } -#endif -} - - - - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( v0, v1, v2 ) \ -do { \ - /* - if (DO_FALLBACK) \ - vmesa->draw_tri( vmesa, v0, v1, v2 ); \ - else */ \ - DEBUG(("TRI: max was here\n")); /* \ - s3v_draw_tex_triangle( vmesa, v0, v1, v2 ); */ \ - vmesa->draw_tri( vmesa, v0, v1, v2 ); \ -} while (0) - -#define QUAD( v0, v1, v2, v3 ) \ -do { \ - DEBUG(("QUAD: max was here\n")); \ - vmesa->draw_quad( vmesa, v0, v1, v2, v3 ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - DEBUG(("LINE: max was here\n")); \ - vmesa->draw_line( vmesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - vmesa->draw_point( vmesa, v0 ); \ -} while (0) - - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -/* -#define S3V_OFFSET_BIT 0x01 -#define S3V_TWOSIDE_BIT 0x02 -#define S3V_UNFILLED_BIT 0x04 -#define S3V_FALLBACK_BIT 0x08 -#define S3V_MAX_TRIFUNC 0x10 - - -static struct { - points_func points; - line_func line; - triangle_func triangle; - quad_func quad; -} rast_tab[S3V_MAX_TRIFUNC]; -*/ - -#define DO_FALLBACK (IND & S3V_FALLBACK_BIT) -#define DO_OFFSET (IND & S3V_OFFSET_BIT) -#define DO_UNFILLED (IND & S3V_UNFILLED_BIT) -#define DO_TWOSIDE (IND & S3V_TWOSIDE_BIT) -#define DO_FLAT 0 -#define DO_TRI 1 -#define DO_QUAD 1 -#define DO_LINE 1 -#define DO_POINTS 1 -#define DO_FULL_QUAD 1 - -#define HAVE_RGBA 1 -#define HAVE_SPEC 0 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX s3vVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->v.x -#define VERT_Y(_v) _v->v.y -#define VERT_Z(_v) _v->v.z -#define AREA_IS_CCW( a ) (a > 0) -#define GET_VERTEX(e) (vmesa->verts + (e<vertex_stride_shift)) - -#if 0 -#define VERT_SET_RGBA( v, c ) \ -do { \ -/* UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c) */ \ -} while (0) - -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4] -/* -#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4] -*/ -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx] -#endif - -#define LOCAL_VARS(n) \ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); \ - GLuint color[n]; \ - (void) color; - - -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ - -static const GLuint hw_prim[GL_POLYGON+1] = { - PrimType_Points, - PrimType_Lines, - PrimType_Lines, - PrimType_Lines, - PrimType_Triangles, - PrimType_Triangles, - PrimType_Triangles, - PrimType_Triangles, - PrimType_Triangles, - PrimType_Triangles -}; - -static void s3vResetLineStipple( GLcontext *ctx ); -static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim ); -static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim ); -/* -extern static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); -extern static void s3v_tris_emit(GLcontext *ctx, GLuint start, GLuint end); -*/ -#define RASTERIZE(x) if (vmesa->hw_primitive != hw_prim[x]) \ - s3vRasterPrimitive( ctx, hw_prim[x] ) -#define RENDER_PRIMITIVE vmesa->render_primitive -#define TAG(x) x -#define IND S3V_FALLBACK_BIT -#include "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * Generate GL render functions * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_OFFSET_BIT|S3V_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_TWOSIDE_BIT|S3V_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT|S3V_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - - -static void init_render_tab( void ) -{ - DEBUG(("*** init_render_tab ***\n")); - - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); -} - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define VERT(x) (s3vVertex *)(s3vverts + (x << shift)) - -#define RENDER_POINTS( start, count ) \ - DEBUG(("RENDER_POINTS...(ok)\n")); \ - for ( ; start < count ; start++) \ - vmesa->draw_line( vmesa, VERT(start), VERT(start) ) - /* vmesa->draw_point( vmesa, VERT(start) ) */ - -#define RENDER_LINE( v0, v1 ) \ - /* DEBUG(("RENDER_LINE...(ok)\n")); \ */ \ - vmesa->draw_line( vmesa, VERT(v0), VERT(v1) ); \ - DEBUG(("RENDER_LINE...(ok)\n")) - -#define RENDER_TRI( v0, v1, v2 ) \ - DEBUG(("RENDER_TRI...(ok)\n")); \ - vmesa->draw_tri( vmesa, VERT(v0), VERT(v1), VERT(v2) ) - -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - DEBUG(("RENDER_QUAD...(ok)\n")); \ - /* s3v_draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2),VERT(v3) ) */\ - /* s3v_draw_triangle( vmesa, VERT(v0), VERT(v1), VERT(v2) ); \ - s3v_draw_triangle( vmesa, VERT(v0), VERT(v2), VERT(v3) ) */ \ - vmesa->draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) - -#define INIT(x) s3vRenderPrimitive( ctx, x ); -#undef LOCAL_VARS -#define LOCAL_VARS \ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); \ - const GLuint shift = vmesa->vertex_stride_shift; \ - const char *s3vverts = (char *)vmesa->verts; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - (void) stipple; -#define RESET_STIPPLE if ( stipple ) s3vResetLineStipple( ctx ); -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS -#define ELT(x) (x) -#define TAG(x) s3v_##x##_verts -#include "tnl_dd/t_dd_rendertmp.h" - - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void s3vRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint prim = vmesa->render_primitive; - - DEBUG(("I AM in: s3vRenderClippedPoly\n")); - - /* Render the new vertices as an unclipped polygon. - */ - if (1) - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON] - ( ctx, 0, n, PRIM_BEGIN|PRIM_END ); - - VB->Elts = tmp; - } - - /* Restore the render primitive - */ -#if 1 - if (prim != GL_POLYGON) { - DEBUG(("and prim != GL_POLYGON\n")); - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); - } - -#endif -} - -static void s3vRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - /*tnl->Driver.LineFunc = s3v_line_tab[2];*/ /* _swsetup_Line; */ - - DEBUG(("I AM in: s3vRenderClippedLine\n")); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - - - -#define _S3V_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET) - -#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) - -static void s3vChooseRenderState(GLcontext *ctx) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - DEBUG(("s3vChooseRenderState\n")); - - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= S3V_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= S3V_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= S3V_UNFILLED_BIT; - } - - DEBUG(("vmesa->RenderIndex = %i\n", vmesa->RenderIndex)); - DEBUG(("index = %i\n", index)); - - if (vmesa->RenderIndex != index) { - vmesa->RenderIndex = index; - - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (vmesa->RenderIndex == 0) - tnl->Driver.Render.PrimTabVerts = s3v_render_tab_verts; - else - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - tnl->Driver.Render.ClippedLine = s3vRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = s3vRenderClippedPoly; - } -} - - -/**********************************************************************/ -/* High level hooks for t_vb_render.c */ -/**********************************************************************/ - - - -/* Determine the rasterized primitive when not drawing unfilled - * polygons. - * - * Used only for the default render stage which always decomposes - * primitives to trianges/lines/points. For the accelerated stage, - * which renders strips as strips, the equivalent calculations are - * performed in s3v_render.c. - */ - -static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); -/* __DRIdrawablePrivate *dPriv = vmesa->driDrawable; */ - GLuint cmd = vmesa->CMD; - - unsigned int _hw_prim = hwprim; - - DEBUG(("s3vRasterPrimitive: hwprim = 0x%x ", _hw_prim)); - -/* printf("* vmesa->CMD = 0x%x\n", vmesa->CMD); */ - - if (vmesa->hw_primitive != _hw_prim) - { - DEBUG(("(new one) ***\n")); - cmd &= ~DO_MASK; - cmd &= ~ALPHA_BLEND_MASK; - vmesa->hw_primitive = _hw_prim; - - if (_hw_prim == PrimType_Triangles) { - /* TRI */ - DEBUG(("->switching to tri\n")); - cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]); - } else if (_hw_prim == PrimType_Lines - || _hw_prim == PrimType_Points) { - /* LINE */ - DEBUG(("->switching to line\n")); - cmd |= (DO_3D_LINE | vmesa->_alpha[0]); - } else { - /* ugh? */ - DEBUG(("->switching to your sis'ass\n")); - } - - DEBUG(("\n")); - - vmesa->restore_primitive = _hw_prim; - /* 0xacc16827: good value -> lightened newave!!! */ - vmesa->CMD = cmd; - CMDCHANGE(); - } -} - -static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - GLuint cmd = vmesa->CMD; - - unsigned int _hw_prim = hw_prim[prim]; - - vmesa->render_primitive = prim; - vmesa->hw_primitive = _hw_prim; - - DEBUG(("s3vRenderPrimitive #%i ", prim)); - DEBUG(("_hw_prim = 0x%x\n", _hw_prim)); - -/* printf(" vmesa->CMD = 0x%x\n", vmesa->CMD); */ - - if (_hw_prim != vmesa->restore_primitive) { - DEBUG(("_hw_prim != vmesa->restore_primitive (was 0x%x)\n", - vmesa->restore_primitive)); -#if 1 - cmd &= ~DO_MASK; - cmd &= ~ALPHA_BLEND_MASK; -/* - printf(" cmd = 0x%x\n", cmd); - printf(" vmesa->_3d_mode=%i; vmesa->_tri[vmesa->_3d_mode]=0x%x\n", - vmesa->_3d_mode, vmesa->_tri[vmesa->_3d_mode]); - printf("vmesa->alpha[0] = 0x%x; vmesa->alpha[1] = 0x%x\n", - vmesa->_alpha[0], vmesa->_alpha[1]); -*/ - if (_hw_prim == PrimType_Triangles) { /* TRI */ - DEBUG(("->switching to tri\n")); - cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]); - DEBUG(("vmesa->TexStride = %i\n", vmesa->TexStride)); - DEBUG(("vmesa->TexOffset = %i\n", vmesa->TexOffset)); - DMAOUT_CHECK(3DTRI_Z_BASE, 12); - } else { /* LINE */ - DEBUG(("->switching to line\n")); - cmd |= (DO_3D_LINE | vmesa->_alpha[0]); - DMAOUT_CHECK(3DLINE_Z_BASE, 12); - } - - DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8); - DMAOUT(vmesa->DestBase); - /* DMAOUT(vmesa->ScissorLR); */ - /* DMAOUT(vmesa->ScissorTB); */ - - /* NOTE: we need to restore all these values since we - * are coming back from a vmesa->restore_primitive */ - DMAOUT( (0 << 16) | (dPriv->w-1) ); - DMAOUT( (0 << 16) | (dPriv->h-1) ); - DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride ); - DMAOUT(vmesa->SrcStride); - DMAOUT(vmesa->TexOffset); - DMAOUT(vmesa->TextureBorderColor); - DMAOUT(0); /* FOG */ - DMAOUT(0); - DMAOUT(0); - DMAOUT(cmd); - /* 0xacc16827: good value -> lightened newave!!! */ - DMAFINISH(); - - vmesa->CMD = cmd; -#endif - } - - DEBUG(("\n")); - - vmesa->restore_primitive = _hw_prim; -} - -static void s3vRunPipeline( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - - DEBUG(("*** s3vRunPipeline ***\n")); - - if ( vmesa->new_state ) - s3vDDUpdateHWState( ctx ); - - if (vmesa->new_gl_state) { - - if (vmesa->new_gl_state & _NEW_TEXTURE) { - s3vUpdateTextureState( ctx ); - } - - if (!vmesa->Fallback) { - if (vmesa->new_gl_state & _S3V_NEW_VERTEX) - s3vChooseVertexState( ctx ); - - if (vmesa->new_gl_state & _S3V_NEW_RASTER_STATE) - s3vChooseRasterState( ctx ); - - if (vmesa->new_gl_state & _S3V_NEW_RENDERSTATE) - s3vChooseRenderState( ctx ); - } - - vmesa->new_gl_state = 0; - - } - - _tnl_run_pipeline( ctx ); -} - -static void s3vRenderStart( GLcontext *ctx ) -{ - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - - DEBUG(("s3vRenderStart\n")); - /* s3vCheckTexSizes( ctx ); */ -} - -static void s3vRenderFinish( GLcontext *ctx ) -{ - if (0) - _swrast_flush( ctx ); /* never needed */ -} - -static void s3vResetLineStipple( GLcontext *ctx ) -{ -/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */ - - /* Reset the hardware stipple counter. - */ -/* - CHECK_DMA_BUFFER(vmesa, 1); - WRITE(vmesa->buf, UpdateLineStippleCounters, 0); -*/ -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - - -void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode ) -{ - GLcontext *ctx = vmesa->glCtx; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = vmesa->Fallback; - - DEBUG(("*** s3vFallback: ")); - - if (mode) { - vmesa->Fallback |= bit; - if (oldfallback == 0) { - DEBUG(("oldfallback == 0 ***\n")); - _swsetup_Wakeup( ctx ); - _tnl_need_projected_coords( ctx, GL_TRUE ); - vmesa->RenderIndex = ~0; - } - } - else { - DEBUG(("***\n")); - vmesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = s3vRenderStart; - tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive; - tnl->Driver.Render.Finish = s3vRenderFinish; - tnl->Driver.Render.BuildVertices = s3vBuildVertices; - tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple; - vmesa->new_gl_state |= (_S3V_NEW_RENDERSTATE| - _S3V_NEW_RASTER_STATE| - _S3V_NEW_VERTEX); - } - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - - -void s3vInitTriFuncs( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - init_render_tab(); - firsttime = 0; - } - - vmesa->RenderIndex = ~0; - - tnl->Driver.RunPipeline = s3vRunPipeline; - tnl->Driver.Render.Start = s3vRenderStart; - tnl->Driver.Render.Finish = s3vRenderFinish; - tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple; -/* - tnl->Driver.RenderInterp = _swsetup_RenderInterp; - tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV; -*/ - tnl->Driver.Render.BuildVertices = s3vBuildVertices; -} diff --git a/src/mesa/drivers/dri/s3v/s3v_tris.h b/src/mesa/drivers/dri/s3v/s3v_tris.h deleted file mode 100644 index 0010a7fe0a..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_tris.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef _S3V_TRIS_H -#define _S3V_TRIS_H - -extern void s3vDDTrifuncInit(void); -extern void s3vDDChooseTriRenderState(GLcontext *); - -#endif /* !(_S3V_TRIS_H) */ diff --git a/src/mesa/drivers/dri/s3v/s3v_tritmp.h b/src/mesa/drivers/dri/s3v/s3v_tritmp.h deleted file mode 100644 index 2321bd414f..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_tritmp.h +++ /dev/null @@ -1,958 +0,0 @@ -/* - * Author: Max Lingua - */ - -/**** MACROS start ****/ - -/* point/line macros */ - -#define LINE_VERT_VARS \ - SWvertex v[3]; \ - s3vVertex* vvv[2]; \ - int x[3], y[3], z[3]; \ - int idx[3]; \ - int dx01, dy01; \ - int delt02; \ - int deltzy, zstart; \ - int start02, end01; \ - int ystart, y01y12; \ - int i, tmp, tmp2, tmp3; \ - GLfloat ydiff, fy[3] -#define LINE_VERT_VARS_VOIDS \ - (void) v; (void) vvv; (void) x; (void) y; (void) z; (void) idx; \ - (void) dx01; (void) dy01; (void) delt02; (void) deltzy; \ - (void) zstart; (void) start02; (void) ystart; (void) y01y12; \ - (void) i; (void) tmp; (void) tmp2; (void) tmp3; (void) ydiff; (void) fy - -#define LINE_FLAT_VARS \ - int arstart, gbstart; \ - int deltarx, deltgbx, deltary, deltgby; \ - GLubyte *(col)[3] -#define LINE_FLAT_VARS_VOIDS \ - (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \ - (void) deltary; (void) deltgby; (void) col - -#define LINE_GOURAUD_VARS \ - int arstart, gbstart; \ - int deltary, deltgby; \ - int ctmp, ctmp2, ctmp3, ctmp4; \ - GLubyte *(col)[3] -#define LINE_GOURAUD_VARS_VOIDS \ - (void) arstart; (void) gbstart; (void) deltary; (void) deltgby; \ - (void) ctmp; (void) ctmp2; (void) ctmp3; (void) ctmp4; (void) col - -#define SORT_LINE_VERT() \ -do { \ - if(v[0].attrib[FRAG_ATTRIB_WPOS][1] <= v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \ -\ - idx[0] = 0; \ - idx[1] = 1; \ -\ - } else if (v[0].attrib[FRAG_ATTRIB_WPOS][1] > v[1].attrib[FRAG_ATTRIB_WPOS][1]) { \ -\ - idx[0] = 1; \ - idx[1] = 0; \ -\ - } \ -} while(0) - -#define SET_LINE_VERT() \ -do { \ - x[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \ - y[0] = fy[0] = dPriv->h - v[idx[0]].attrib[FRAG_ATTRIB_WPOS][1]; \ - z[0] = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000; */ \ -\ - x[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0] * 1024.0f * 1024.0f); /* 0x100000 */ \ - y[1] = dPriv->h - v[idx[1]].attrib[FRAG_ATTRIB_WPOS][1]; \ - z[1] = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][2]) * 1024.0f * 32.0f; /* 0x8000 */ \ -} while(0) - -#define SET_LINE_XY() \ -do { \ - tmp = v[idx[0]].attrib[FRAG_ATTRIB_WPOS][0]; \ - tmp2 = v[idx[1]].attrib[FRAG_ATTRIB_WPOS][0]; \ -\ - dx01 = x[0] - x[1]; \ - dy01 = y[0] - y[1]; \ -\ - ydiff = fy[0] - (float)y[0]; \ - ystart = y[0]; \ - y01y12 = dy01 + 1; \ -} while (0) - -#define SET_LINE_DIR() \ -do { \ - if (tmp2 > tmp) { \ - y01y12 |= 0x80000000; \ - tmp3 = tmp2-tmp; \ - } else { \ - tmp3 = tmp-tmp2; \ - } \ -\ - end01 = ((tmp << 16) | tmp2); \ -\ - if (dy01) \ - delt02 = -(dx01/dy01); \ - else \ - delt02 = 0; \ -\ - if (dy01 > tmp3) { /* Y MAJ */ \ - /* NOTE: tmp3 always >=0 */ \ - start02 = x[0]; \ - } else if (delt02 >= 0){ /* X MAJ - positive delta */ \ - start02 = x[0] + delt02/2; \ - dy01 = tmp3; /* could be 0 */ \ - } else { /* X MAJ - negative delta */ \ - start02 = x[0] + delt02/2 + ((1 << 20) - 1); \ - dy01 = tmp3; /* could be 0 */ \ - } \ -} while(0) - -#define SET_LINE_Z() \ -do { \ - zstart = z[0]; \ -\ - if (dy01) { \ - deltzy = (z[1] - z[0])/dy01; \ - } else { \ - deltzy = 0; /* dy01 = tmp3 = 0 (it's a point)*/ \ - } \ -} while (0) - -#define SET_LINE_FLAT_COL() \ -do { \ - col[0] = &(v[idx[0]].color[0]); \ - deltarx = deltary = deltgbx = deltgby = 0; \ - gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \ - arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \ -} while(0) - -#define SET_LINE_GOURAUD_COL() \ -do { \ - col[0] = &(v[idx[0]].color[0]); \ - col[1] = &(v[idx[1]].color[0]); \ -\ - vvv[0] = _v0; \ - vvv[1] = _v1; \ -\ - for (i=0; i<2; i++) { \ - /* FIXME: swapped ! */ \ - col[i][0] = vvv[!idx[i]]->v.color.red; \ - col[i][1] = vvv[!idx[i]]->v.color.green; \ - col[i][2] = vvv[!idx[i]]->v.color.blue; \ - col[i][3] = vvv[!idx[i]]->v.color.alpha; \ - } \ -\ - if (dy01) { \ -\ - ctmp = ((col[0][1] - col[1][1]) << 7) / dy01; \ - ctmp2 = ((col[0][2] - col[1][2]) << 7) / dy01; \ - deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \ -\ - ctmp3 = ((col[0][3] - col[1][3]) << 7) / dy01; \ - ctmp4 = ((col[0][0] - col[1][0]) << 7) / dy01; \ - deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \ - } else { \ - ctmp = ((col[1][1] - col[0][1]) << 7); \ - ctmp2 = ((col[1][2] - col[0][2]) << 7); \ - deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \ -\ - ctmp3 = ((col[1][3] - col[0][3]) << 7); \ - ctmp4 = ((col[1][0] - col[0][0]) << 7); \ - deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \ - deltgby = deltary = 0; \ - } \ -\ - idx[0] = 1; /* FIXME: swapped */ \ -\ - gbstart = \ - (((int)((ydiff * ctmp) + (col[idx[0]][1] << 7)) << 16) & 0x7FFF0000) \ - | ((int)((ydiff * ctmp2) + (col[idx[0]][2] << 7)) & 0x7FFF); \ - arstart = \ - (((int)((ydiff * ctmp3) + (col[idx[0]][3] << 7)) << 16) & 0x7FFF0000) \ - | ((int)((ydiff * ctmp4) + (col[idx[0]][0] << 7)) & 0x7FFF); \ -} while(0) - -#define SEND_LINE_COL() \ -do { \ - DMAOUT(deltgby); \ - DMAOUT(deltary); \ - DMAOUT(gbstart); \ - DMAOUT(arstart); \ -} while (0) - -#define SEND_LINE_VERT() \ -do { \ - DMAOUT(deltzy); \ - DMAOUT(zstart); \ - DMAOUT(0); \ - DMAOUT(0); \ - DMAOUT(0); \ - DMAOUT(end01); \ - DMAOUT(delt02); \ - DMAOUT(start02); \ - DMAOUT(ystart); \ - DMAOUT(y01y12); \ -} while (0) - - -/* tri macros (mostly stolen from utah-glx...) */ - -#define VERT_VARS \ - SWvertex v[3]; \ - int x[3], y[3], z[3]; \ - int idx[3]; \ - int dx01, dy01; \ - int dx02, dy02; \ - int dx12, dy12; \ - int delt01, delt02, delt12; \ - int deltzx, deltzy, zstart; \ - int start02, end01, end12; \ - int ystart, y01y12; \ - int i, tmp, lr; \ - GLfloat ydiff, fy[3] -#define VERT_VARS_VOIDS \ - (void) v; (void) x; (void) y; (void) z; (void) idx; (void) dx01; \ - (void) dy01; (void) dx02; (void) dy02; (void) dx12; (void) dy12; \ - (void) delt01; (void) delt02; (void) delt12; (void) deltzx; \ - (void) deltzy; (void) zstart; (void) start02; (void) end01; \ - (void) end12; (void) ystart; (void) y01y12; (void) i; (void) tmp; \ - (void) lr; (void) ydiff; (void) fy - -#define GOURAUD_VARS \ - int arstart, gbstart; \ - int deltarx, deltgbx, deltary, deltgby; \ - int ctmp, ctmp2, ctmp3, ctmp4; \ - GLubyte *(col)[3] -#define GOURAUD_VARS_VOIDS \ - (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \ - (void) deltary; (void) deltgby; (void) ctmp; (void) ctmp2; \ - (void) ctmp3; (void) ctmp4; (void) col - -#define FLAT_VARS \ - int arstart, gbstart; \ - int deltarx, deltgbx, deltary, deltgby; \ - GLubyte *(col)[3] -#define FLAT_VARS_VOIDS \ - (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \ - (void) deltary; (void) deltgby; (void) col - -#define TEX_VARS \ - int u0, u1, u2; \ - GLfloat ru0, ru1, ru2; \ - int v0, v1, v2; \ - GLfloat rv0, rv1, rv2; \ - GLfloat w0, w1, w2; \ - GLfloat rw0, rw1, rw2; \ - int baseu, basev; \ - int d0, d1, d2; \ - int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \ - int deltwx, deltwy; \ - int rbaseu, rbasev; \ - int dstart, ustart, wstart, vstart; \ - static int stmp = 0; \ - s3vTextureObjectPtr t -#define TEX_VARS_VOIDS \ - (void) u0; (void) u1; (void) u2; (void) ru0; (void) ru1; (void) ru2; \ - (void) v0; (void) v1; (void) v2; (void) rv0; (void) rv1; (void) rv2; \ - (void) w0; (void) w1; (void) w2; (void) rw0; (void) rw1; (void) rw2; \ - (void) baseu; (void) basev; (void) d0; (void) d1; (void) d2; \ - (void) deltdx; (void) deltvx; (void) deltux; (void) deltdy; \ - (void) deltuy; (void) deltwx; (void) deltwy; (void) rbaseu; \ - (void) rbasev; (void) dstart; (void) ustart; (void) wstart; \ - (void) vstart; (void) stmp; (void) t - -#define SORT_VERT() \ -do { \ - for (i=0; i<3; i++) \ - fy[i] = v[i].attrib[FRAG_ATTRIB_WPOS][1]; \ -\ - if (fy[1] > fy[0]) { /* (fy[1] > fy[0]) */ \ -\ - if (fy[2] > fy[0]) { \ - idx[0] = 0; \ - if (fy[1] > fy[2]) { \ - idx[1] = 2; \ - idx[2] = 1; \ - } else { \ - idx[1] = 1; \ - idx[2] = 2; \ - } \ - } else { \ - idx[0] = 2; \ - idx[1] = 0; \ - idx[2] = 1; \ - } \ - } else { /* (fy[1] < y[0]) */ \ - if (fy[2] > fy[0]) { \ - idx[0] = 1; \ - idx[1] = 0; \ - idx[2] = 2; \ - } else { \ - idx[2] = 0; \ - if (fy[2] > fy[1]) { \ - idx[0] = 1; \ - idx[1] = 2; \ - } else { \ - idx[0] = 2; \ - idx[1] = 1; \ - } \ - } \ - } \ -} while(0) - -#define SET_VERT() \ -do { \ - for (i=0; i<3; i++) \ - { \ - x[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][0]) * /* 0x100000*/ 1024.0 * 1024.0); \ - y[i] = fy[i] = (dPriv->h - v[idx[i]].attrib[FRAG_ATTRIB_WPOS][1]); \ - z[i] = ((v[idx[i]].attrib[FRAG_ATTRIB_WPOS][2]) * /* 0x8000 */ 1024.0 * 32.0); \ - } \ -\ - ydiff = fy[0] - (float)y[0]; \ -\ - ystart = y[0]; \ -\ - dx12 = x[2] - x[1]; \ - dy12 = y[1] - y[2]; \ - dx01 = x[1] - x[0]; \ - dy01 = y[0] - y[1]; \ - dx02 = x[2] - x[0]; \ - dy02 = y[0] - y[2]; \ -\ - delt01 = delt02 = delt12 = 0; \ -} while (0) - - -#define SET_XY() \ -do { \ - if (dy01) delt01 = dx01 / dy01; \ - if (dy12) delt12 = dx12 / dy12; \ - delt02 = dx02 / dy02; \ -\ - start02 = x[0] + (ydiff * delt02); \ - end01 = x[0] + (ydiff * delt01); \ - end12 = x[1] + ((fy[1] - (GLfloat)y[1]) * delt12); \ -} while (0) - -#define SET_DIR() \ -do { \ - tmp = x[1] - (dy01 * delt02 + x[0]); \ - if (tmp > 0) { \ - lr = 0x80000000; \ - } else { \ - tmp *= -1; \ - lr = 0; \ - } \ - tmp >>= 20; \ -\ - y01y12 = ((((y[0] - y[1]) & 0x7FF) << 16) \ - | ((y[1] - y[2]) & 0x7FF) | lr); \ -} while (0) - -#define SET_Z() \ -do { \ - deltzy = (z[2] - z[0]) / dy02; \ - if (tmp) { \ - deltzx = (z[1] - (dy01 * deltzy + z[0])) / tmp; \ - } else { \ - deltzx = 0; \ - } \ - zstart = (deltzy * ydiff) + z[0]; \ -} while (0) - -#define SET_FLAT_COL() \ -do { \ - col[0] = &(v[0].color[0]); \ - deltarx = deltary = deltgbx = deltgby = 0; \ - gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \ - arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \ -} while(0) - -#define SET_GOURAUD_COL() \ -do { \ - col[0] = &(v[idx[0]].color[0]); \ - col[1] = &(v[idx[1]].color[0]); \ - col[2] = &(v[idx[2]].color[0]); \ -\ - ctmp = ((col[2][3] - col[0][3]) << 7) / dy02; \ - ctmp2 = ((col[2][0] - col[0][0]) << 7) / dy02; \ - deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \ - ctmp3 = ((col[2][1] - col[0][1]) << 7) / dy02; \ - ctmp4 = ((col[2][2] - col[0][2]) << 7) / dy02; \ - deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \ - gbstart = \ - (((int)((ydiff * ctmp3) + (col[0][1] << 7)) << 16) & 0x7FFF0000) \ - | ((int)((ydiff * ctmp4) + (col[0][2] << 7)) & 0x7FFF); \ - arstart = \ - (((int)((ydiff * ctmp) + (col[0][3] << 7)) << 16) & 0x7FFF0000) \ - | ((int)((ydiff * ctmp2) + (col[0][0] << 7)) & 0x7FFF); \ - if (tmp) { \ - int ax, rx, gx, bx; \ - ax = ((col[1][3] << 7) - (dy01 * ctmp + (col[0][3] << 7))) / tmp; \ - rx = ((col[1][0] << 7) - (dy01 * ctmp2 + (col[0][0] << 7))) / tmp; \ - gx = ((col[1][1] << 7) - (dy01 * ctmp3 + (col[0][1] << 7))) / tmp; \ - bx = ((col[1][2] << 7) - (dy01 * ctmp4 + (col[0][2] << 7))) / tmp; \ - deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \ - deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \ - } else { \ - deltgbx = deltarx = 0; \ - } \ -} while (0) - -#define SET_TEX_VERT() \ -do { \ - t = ((s3vTextureObjectPtr) \ - ctx->Texture.Unit[0]._Current->DriverData); \ - deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \ -\ - u0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] \ - * (GLfloat)(t->image[0].image->Width) * 256.0); \ - u1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] \ - * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \ - u2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0] \ - * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \ - v0 = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] \ - * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \ - v1 = (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] \ - * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \ - v2 = (v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1] \ - * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \ -\ - w0 = (v[idx[0]].attrib[FRAG_ATTRIB_WPOS][3]); \ - w1 = (v[idx[1]].attrib[FRAG_ATTRIB_WPOS][3]); \ - w2 = (v[idx[2]].attrib[FRAG_ATTRIB_WPOS][3]); \ -} while (0) - -#define SET_BASEUV() \ -do { \ - if (u0 < u1) { \ - if (u0 < u2) { \ - baseu = u0; \ - } else { \ - baseu = u2; \ - } \ - } else { \ - if (u1 < u2) { \ - baseu = u1; \ - } else { \ - baseu = u2; \ - } \ - } \ -\ - if (v0 < v1) { \ - if (v0 < v2) { \ - basev = v0; \ - } else { \ - basev = v2; \ - } \ - } else { \ - if (v1 < v2) { \ - basev = v1; \ - } else { \ - basev = v2; \ - } \ - } \ -} while (0) - - -#define SET_RW() \ -do { \ - /* GLfloat minW; \ -\ - if (w0 < w1) { \ - if (w0 < w2) { \ - minW = w0; \ - } else { \ - minW = w2; \ - } \ - } else { \ - if (w1 < w2) { \ - minW = w1; \ - } else { \ - minW = w2; \ - } \ - } */ \ -\ - rw0 = (512.0 * w0); \ - rw1 = (512.0 * w1); \ - rw2 = (512.0 * w2); \ -} while (0) - -#define SET_D() \ -do { \ - GLfloat sxy, suv; \ - int lev; \ -\ - suv = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \ - (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \ - (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \ - (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \ -\ - sxy = (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][0] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \ - (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][1] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][1]) - \ - (v[idx[1]].attrib[FRAG_ATTRIB_TEX0][0] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][0]) * \ - (v[idx[0]].attrib[FRAG_ATTRIB_TEX0][1] - \ - v[idx[2]].attrib[FRAG_ATTRIB_TEX0][2]); \ -\ - if (sxy < 0) sxy *= -1.0; \ - if (suv < 0) suv *= -1.0; \ -\ - lev = *(int*)&suv - *(int *)&sxy; \ - if (lev < 0) \ - lev = 0; \ - else \ - lev >>=23; \ - dstart = (lev << 27); \ -} while (0) - -#define SET_UVWD() \ -do { \ - SET_BASEUV(); \ - SET_RW(); \ - SET_D(); \ - ru0 = (((u0 - baseu) * rw0)); \ - ru1 = (((u1 - baseu) * rw1)); \ - ru2 = (((u2 - baseu) * rw2)); \ - rv0 = (((v0 - basev) * rw0)); \ - rv1 = (((v1 - basev) * rw1)); \ - rv2 = (((v2 - basev) * rw2)); \ -\ - while (baseu < 0) { baseu += (t->globj->Image[0][0]->Width << 8); } \ - while (basev < 0) { basev += (t->globj->Image[0][0]->Height << 8); } \ -\ - if (!(baseu & 0xFF)) \ - { baseu = (baseu >> 8); } \ - else \ - { baseu = (baseu >> 8) + 1; } \ -\ - if ((basev & 0x80) || !(basev & 0xFF)) \ - { basev = (basev >> 8); } \ - else \ - { basev = (basev >> 8) - 1; } \ -\ - rbaseu = (baseu) << (16 - t->globj->Image[0][0]->WidthLog2); \ - rbasev = (basev) << (16 - t->globj->Image[0][0]->WidthLog2); \ - deltuy = (((ru2 - ru0) / dy02)); \ - deltvy = (((rv2 - rv0) / dy02)); \ - rw0 *= (1024.0 * 512.0); \ - rw1 *= (1024.0 * 512.0); \ - rw2 *= (1024.0 * 512.0); \ - deltwy = ((rw2 - rw0) / dy02); \ - if (tmp) { \ - deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \ - deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \ - deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \ - } else { deltux = deltvx = deltwx = 0; } \ - ustart = (deltuy * ydiff) + (ru0); \ - vstart = (deltvy * ydiff) + (rv0); \ - wstart = (deltwy * ydiff) + (rw0); \ -} while (0) - -#define SEND_UVWD() \ -do { \ - DMAOUT((rbasev & 0xFFFF)); \ - DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \ - DMAOUT(deltwx); \ - DMAOUT(deltwy); \ - DMAOUT(wstart); \ - DMAOUT(deltdx); \ - DMAOUT(deltvx); \ - DMAOUT(deltux); \ - DMAOUT(deltdy); \ - DMAOUT(deltvy); \ - DMAOUT(deltuy); \ - DMAOUT(dstart); \ - DMAOUT(vstart); \ - DMAOUT(ustart); \ -} while (0) - -#define SEND_VERT() \ -do { \ - DMAOUT(deltzx); \ - DMAOUT(deltzy); \ - DMAOUT(zstart); \ - DMAOUT(delt12); \ - DMAOUT(end12); \ - DMAOUT(delt01); \ - DMAOUT(end01); \ - DMAOUT(delt02); \ - DMAOUT(start02); \ - DMAOUT(ystart); \ - DMAOUT(y01y12); \ -} while (0) - -#define SEND_COL() \ -do { \ - DMAOUT(deltgbx); \ - DMAOUT(deltarx); \ - DMAOUT(deltgby); \ - DMAOUT(deltary); \ - DMAOUT(gbstart); \ - DMAOUT(arstart); \ -} while (0) - -/**** MACROS end ****/ - - - - -static void TAG(s3v_point)( s3vContextPtr vmesa, - const s3vVertex *_v0 ) -{ -} - -static void TAG(s3v_line)( s3vContextPtr vmesa, - const s3vVertex *_v0, - const s3vVertex *_v1 ) -{ - GLcontext *ctx = vmesa->glCtx; - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - - LINE_VERT_VARS; -#if (IND & S3V_RAST_FLAT_BIT) - LINE_FLAT_VARS; -#else - LINE_GOURAUD_VARS; -#endif -#if (IND & S3V_RAST_CULL_BIT) - GLfloat cull; - (void) cull; -#endif - LINE_VERT_VARS_VOIDS; -#if (IND & S3V_RAST_FLAT_BIT) - LINE_FLAT_VARS_VOIDS; -#else - LINE_GOURAUD_VARS_VOIDS; -#endif - - DEBUG(("*** s3v_line: ")); -#if (IND & S3V_RAST_CULL_BIT) - DEBUG(("cull ")); -#endif -#if (IND & S3V_RAST_FLAT_BIT) - DEBUG(("flat ")); -#endif - - DEBUG(("***\n")); - -#if 0 - s3v_print_vertex(ctx, _v0); - s3v_print_vertex(ctx, _v1); -#endif - - s3v_translate_vertex( ctx, _v0, &v[0] ); - s3v_translate_vertex( ctx, _v1, &v[1] ); - -#if (IND & S3V_RAST_CULL_BIT) - /* FIXME: should we cull lines too? */ -#endif - (void)v; /* v[0]; v[1]; */ - - SORT_LINE_VERT(); - SET_LINE_VERT(); - - SET_LINE_XY(); - SET_LINE_DIR(); - SET_LINE_Z(); - -#if (IND & S3V_RAST_FLAT_BIT) - SET_LINE_FLAT_COL(); -#else - SET_LINE_GOURAUD_COL(); -#endif - - DMAOUT_CHECK(3DLINE_GBD, 15); - SEND_LINE_COL(); - DMAOUT(0); - SEND_LINE_VERT(); - DMAFINISH(); -} - -static void TAG(s3v_triangle)( s3vContextPtr vmesa, - const s3vVertex *_v0, - const s3vVertex *_v1, - const s3vVertex *_v2 ) -{ - GLcontext *ctx = vmesa->glCtx; - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - - VERT_VARS; -#if (IND & S3v_RAST_FLAT_BIT) - FLAT_VARS; -#else - GOURAUD_VARS; -#endif -#if (IND & S3V_RAST_TEX_BIT) - TEX_VARS; -#endif -#if (IND & S3V_RAST_CULL_BIT) - GLfloat cull; -#endif - VERT_VARS_VOIDS; -#if (IND & S3v_RAST_FLAT_BIT) - FLAT_VARS_VOIDS; -#else - GOURAUD_VARS_VOIDS; -#endif -#if (IND & S3V_RAST_TEX_BIT) - TEX_VARS_VOIDS; -#endif - - DEBUG(("*** s3v_triangle: ")); -#if (IND & S3V_RAST_CULL_BIT) - DEBUG(("cull ")); -#endif -#if (IND & S3V_RAST_FLAT_BIT) - DEBUG(("flat ")); -#endif -#if (IND & S3V_RAST_TEX_BIT) - DEBUG(("tex ")); -#endif - -DEBUG(("***\n")); - -#if 0 - s3v_print_vertex(ctx, _v0); - s3v_print_vertex(ctx, _v1); - s3v_print_vertex(ctx, _v2); -#endif - - s3v_translate_vertex( ctx, _v0, &v[0] ); - s3v_translate_vertex( ctx, _v1, &v[1] ); - s3v_translate_vertex( ctx, _v2, &v[2] ); - -#if (IND & S3V_RAST_CULL_BIT) - cull = vmesa->backface_sign * - ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) + - (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0])); - - if (cull < vmesa->cull_zero /* -0.02f */) return; -#endif - - (void)v; /* v[0]; v[1]; v[2]; */ - - SORT_VERT(); - SET_VERT(); - - if (dy02 == 0) return; - - SET_XY(); - SET_DIR(); - SET_Z(); - -#if (IND & S3V_RAST_TEX_BIT) - SET_TEX_VERT(); - SET_UVWD(); -#endif - -#if (IND & S3V_RAST_FLAT_BIT) - SET_FLAT_COL(); -#else - SET_GOURAUD_COL(); -#endif - -#if (IND & S3V_RAST_TEX_BIT) - DMAOUT_CHECK(3DTRI_BASEV, 31); - SEND_UVWD(); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#else - DMAOUT_CHECK(3DTRI_GBX, 17); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#endif -} - -static void TAG(s3v_quad)( s3vContextPtr vmesa, - const s3vVertex *_v0, - const s3vVertex *_v1, - const s3vVertex *_v2, - const s3vVertex *_v3 ) -{ - GLcontext *ctx = vmesa->glCtx; - __DRIdrawablePrivate *dPriv = vmesa->driDrawable; - - SWvertex temp_v[4]; - VERT_VARS; -#if (IND & S3v_RAST_FLAT_BIT) - FLAT_VARS; -#else - GOURAUD_VARS; -#endif -#if (IND & S3V_RAST_TEX_BIT) - TEX_VARS; -#endif -#if (IND & S3V_RAST_CULL_BIT) - GLfloat cull; -#endif - VERT_VARS_VOIDS; -#if (IND & S3v_RAST_FLAT_BIT) - FLAT_VARS_VOIDS; -#else - GOURAUD_VARS_VOIDS; -#endif -#if (IND & S3V_RAST_TEX_BIT) - TEX_VARS_VOIDS; -#endif - - DEBUG(("*** s3v_quad: ")); -#if (IND & S3V_RAST_CULL_BIT) - DEBUG(("cull ")); - /* printf(""); */ /* speed trick */ -#endif -#if (IND & S3V_RAST_FLAT_BIT) - DEBUG(("flat ")); -#endif -#if (IND & S3V_RAST_TEX_BIT) - DEBUG(("tex ")); -#endif - - DEBUG(("***\n")); - -#if 0 - s3v_print_vertex(ctx, _v0); - s3v_print_vertex(ctx, _v1); - s3v_print_vertex(ctx, _v2); - s3v_print_vertex(ctx, _v3); -#endif - s3v_translate_vertex( ctx, _v0, &temp_v[0] ); - s3v_translate_vertex( ctx, _v1, &temp_v[1] ); - s3v_translate_vertex( ctx, _v2, &temp_v[2] ); - s3v_translate_vertex( ctx, _v3, &temp_v[3] ); - - /* FIRST TRI (0,1,2) */ - - /* ROMEO */ - /* printf(""); */ /* speed trick (a) [turn on if (a) is return]*/ - - v[0] = temp_v[0]; - v[1] = temp_v[1]; - v[2] = temp_v[2]; - -#if (IND & S3V_RAST_CULL_BIT) - cull = vmesa->backface_sign * - ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) + - (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0])); - - if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */ -#endif - -#if 0 - v[0] = temp_v[0]; - v[1] = temp_v[1]; - v[2] = temp_v[2]; -#else - (void) v; -#endif - SORT_VERT(); - SET_VERT(); - - if (dy02 == 0) goto second; - - SET_XY(); - SET_DIR(); - SET_Z(); - -#if (IND & S3V_RAST_TEX_BIT) - SET_TEX_VERT(); - SET_UVWD(); -#endif - -#if (IND & S3V_RAST_FLAT_BIT) - SET_FLAT_COL(); -#else - SET_GOURAUD_COL(); -#endif - -#if (IND & S3V_RAST_TEX_BIT) - DMAOUT_CHECK(3DTRI_BASEV, 31); - SEND_UVWD(); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#else - DMAOUT_CHECK(3DTRI_GBX, 17); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#endif - - /* SECOND TRI (0,2,3) */ - -second: - v[0] = temp_v[0]; - v[1] = temp_v[2]; - v[2] = temp_v[3]; - -#if (IND & S3V_RAST_CULL_BIT) - cull = vmesa->backface_sign * - ((v[1].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0]) * (v[0].attrib[FRAG_ATTRIB_WPOS][1] - v[2].attrib[FRAG_ATTRIB_WPOS][1]) + - (v[1].attrib[FRAG_ATTRIB_WPOS][1] - v[0].attrib[FRAG_ATTRIB_WPOS][1]) * (v[2].attrib[FRAG_ATTRIB_WPOS][0] - v[0].attrib[FRAG_ATTRIB_WPOS][0])); - - if (cull < /* -0.02f */ vmesa->cull_zero) return; -#endif - -/* second: */ - - /* ROMEO */ - /* printf(""); */ /* speed trick */ - - v[0] = temp_v[0]; - v[1] = temp_v[2]; - v[2] = temp_v[3]; - - SORT_VERT(); - SET_VERT(); - - if (dy02 == 0) return; - - SET_XY(); - SET_DIR(); - SET_Z(); - -#if (IND & S3V_RAST_TEX_BIT) - SET_TEX_VERT(); - SET_UVWD(); -#endif - -#if (IND & S3V_RAST_FLAT_BIT) - SET_FLAT_COL(); -#else - SET_GOURAUD_COL(); -#endif - -#if (IND & S3V_RAST_TEX_BIT) - DMAOUT_CHECK(3DTRI_BASEV, 31); - SEND_UVWD(); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#else - DMAOUT_CHECK(3DTRI_GBX, 17); - SEND_COL(); - SEND_VERT(); - DMAFINISH(); -#endif -} - -static void TAG(s3v_init)(void) -{ - s3v_point_tab[IND] = TAG(s3v_point); - s3v_line_tab[IND] = TAG(s3v_line); - s3v_tri_tab[IND] = TAG(s3v_triangle); - s3v_quad_tab[IND] = TAG(s3v_quad); -} - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/dri/s3v/s3v_vb.c b/src/mesa/drivers/dri/s3v/s3v_vb.c deleted file mode 100644 index 00e375c6c4..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_vb.c +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "tnl/t_context.h" -#include "tnl/tnl.h" - -#include "s3v_context.h" -#include "s3v_vb.h" -#include "s3v_tris.h" - -#define S3V_XYZW_BIT 0x1 -#define S3V_RGBA_BIT 0x2 -#define S3V_TEX0_BIT 0x4 -#define S3V_PTEX_BIT 0x8 -#define S3V_FOG_BIT 0x10 -#define S3V_MAX_SETUP 0x20 - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_size; - GLuint vertex_stride_shift; - GLuint vertex_format; -} setup_tab[S3V_MAX_SETUP]; - - -/* Only one vertex format, atm, so no need to give them names: - */ -#define TINY_VERTEX_FORMAT 1 -#define NOTEX_VERTEX_FORMAT 0 -#define TEX0_VERTEX_FORMAT 0 -#define TEX1_VERTEX_FORMAT 0 -#define PROJ_TEX1_VERTEX_FORMAT 0 -#define TEX2_VERTEX_FORMAT 0 -#define TEX3_VERTEX_FORMAT 0 -#define PROJ_TEX3_VERTEX_FORMAT 0 - -#define DO_XYZW (IND & S3V_XYZW_BIT) -#define DO_RGBA (IND & S3V_RGBA_BIT) -#define DO_SPEC 0 -#define DO_FOG (IND & S3V_FOG_BIT) -#define DO_TEX0 (IND & S3V_TEX0_BIT) -#define DO_TEX1 0 -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & S3V_PTEX_BIT) - -#define VERTEX s3vVertex -#define LOCALVARS /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */ -#define GET_VIEWPORT_MAT() 0 /* vmesa->hw_viewport */ -#define GET_TEXSOURCE(n) n -#define GET_VERTEX_FORMAT() 0 -#define GET_VERTEX_SIZE() S3V_CONTEXT(ctx)->vertex_size * sizeof(GLuint) -#define GET_VERTEX_STORE() S3V_CONTEXT(ctx)->verts -#define GET_VERTEX_STRIDE_SHIFT() S3V_CONTEXT(ctx)->vertex_stride_shift -#define INVALIDATE_STORED_VERTICES() -#define GET_UBYTE_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteColor -#define GET_UBYTE_SPEC_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteSecondaryColor - -#define HAVE_HW_VIEWPORT 1 /* FIXME */ -#define HAVE_HW_DIVIDE 1 -#define HAVE_RGBA_COLOR 0 /* we're BGRA */ -#define HAVE_TINY_VERTICES 1 -#define HAVE_NOTEX_VERTICES 0 -#define HAVE_TEX0_VERTICES 0 -#define HAVE_TEX1_VERTICES 0 -#define HAVE_TEX2_VERTICES 0 -#define HAVE_TEX3_VERTICES 0 -#define HAVE_PTEX_VERTICES 1 - -/* -#define SUBPIXEL_X -.5 -#define SUBPIXEL_Y -.5 -#define UNVIEWPORT_VARS GLfloat h = S3V_CONTEXT(ctx)->driDrawable->h -#define UNVIEWPORT_X(x) x - SUBPIXEL_X -#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y -#define UNVIEWPORT_Z(z) z / vmesa->depth_scale -*/ - -#define PTEX_FALLBACK() /* never needed */ - -#define IMPORT_QUALIFIER -#define IMPORT_FLOAT_COLORS s3v_import_float_colors -#define IMPORT_FLOAT_SPEC_COLORS s3v_import_float_spec_colors - -#define INTERP_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].copy_pv - - - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#define TAG(x) s3v_##x -#include "tnl_dd/t_dd_vb.c" - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT) -#define TAG(x) x##_wg -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_RGBA_BIT) -#define TAG(x) x##_g -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_RGBA_BIT|S3V_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT) -#define TAG(x) x##_wgf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_RGBA_BIT | S3V_FOG_BIT) -#define TAG(x) x##_gf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (S3V_RGBA_BIT | S3V_FOG_BIT | S3V_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -static void init_setup_tab( void ) -{ - init_wg(); /* pos + col */ - init_wgt0(); /* pos + col + tex0 */ - init_wgpt0(); /* pos + col + p-tex0 (?) */ - init_t0(); /* tex0 */ - init_g(); /* col */ - init_gt0(); /* col + tex */ - init_wgf(); - init_wgft0(); - init_wgfpt0(); - init_f(); - init_gf(); - init_gft0(); -} - - -#if 0 -void s3vPrintSetupFlags(char *msg, GLuint flags ) -{ - fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n", - msg, - (int)flags, - (flags & S3V_XYZW_BIT) ? " xyzw," : "", - (flags & S3V_RGBA_BIT) ? " rgba," : "", - (flags & S3V_SPEC_BIT) ? " spec," : "", - (flags & S3V_FOG_BIT) ? " fog," : "", - (flags & S3V_TEX0_BIT) ? " tex-0," : "", - (flags & S3V_TEX1_BIT) ? " tex-1," : ""); -} -#endif - - -void s3vCheckTexSizes( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - - if (!setup_tab[vmesa->SetupIndex].check_tex_sizes(ctx)) { - - vmesa->SetupIndex |= (S3V_PTEX_BIT|S3V_RGBA_BIT); - - if (1 || !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[vmesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[vmesa->SetupIndex].copy_pv; - } - } -} - -void s3vBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - GLubyte *v = ((GLubyte *)vmesa->verts + - (start<vertex_stride_shift)); - GLuint stride = 1<vertex_stride_shift; - - DEBUG(("*** s3vBuildVertices ***\n")); - DEBUG(("vmesa->SetupNewInputs = 0x%x\n", vmesa->SetupNewInputs)); - DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex)); - -#if 1 - setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride ); -#else - newinputs |= vmesa->SetupNewInputs; - vmesa->SetupNewInputs = 0; - - DEBUG(("newinputs is 0x%x\n", newinputs)); - - if (!newinputs) { - DEBUG(("!newinputs\n")); - return; - } - - if (newinputs & VERT_CLIP) { - setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride ); - DEBUG(("newinputs & VERT_CLIP\n")); - return; - } /* else { */ -/* GLuint ind = 0; */ - - if (newinputs & VERT_RGBA) { - DEBUG(("newinputs & VERT_RGBA\n")); - ind |= S3V_RGBA_BIT; - } - - if (newinputs & VERT_TEX0) { - DEBUG(("newinputs & VERT_TEX0\n")); - ind |= S3V_TEX0_BIT; - } - - if (newinputs & VERT_FOG_COORD) - ind |= S3V_FOG_BIT; - - if (vmesa->SetupIndex & S3V_PTEX_BIT) - ind = ~0; - - ind &= vmesa->SetupIndex; - - DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex)); - DEBUG(("ind = 0x%x\n", ind)); - DEBUG(("ind & vmesa->SetupIndex = 0x%x\n", (ind & vmesa->SetupIndex))); - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } -#endif -} - -void s3vChooseVertexState( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - - GLuint ind = S3V_XYZW_BIT | S3V_RGBA_BIT; - - /* FIXME: will segv in tnl_dd/t_dd_vbtmp.h (line 196) on some demos */ -/* - if (ctx->Fog.Enabled) - ind |= S3V_FOG_BIT; -*/ - - - if (ctx->Texture.Unit[0]._ReallyEnabled) { - _tnl_need_projected_coords( ctx, GL_FALSE ); - ind |= S3V_TEX0_BIT; - } else { - _tnl_need_projected_coords( ctx, GL_TRUE ); - } - - vmesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = s3v_interp_extras; - tnl->Driver.Render.CopyPV = s3v_copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } -} - - -void s3vInitVB( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - vmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - vmesa->vertex_stride_shift = 6 /* 4 */; /* FIXME - only one vertex setup */ - } - } -} - - -void s3vFreeVB( GLcontext *ctx ) -{ - s3vContextPtr vmesa = S3V_CONTEXT(ctx); - if (vmesa->verts) { - ALIGN_FREE(vmesa->verts); - vmesa->verts = 0; - } - - if (vmesa->UbyteSecondaryColor.Ptr) { - ALIGN_FREE((void *)vmesa->UbyteSecondaryColor.Ptr); - vmesa->UbyteSecondaryColor.Ptr = 0; - } - - if (vmesa->UbyteColor.Ptr) { - ALIGN_FREE((void *)vmesa->UbyteColor.Ptr); - vmesa->UbyteColor.Ptr = 0; - } -} diff --git a/src/mesa/drivers/dri/s3v/s3v_vb.h b/src/mesa/drivers/dri/s3v/s3v_vb.h deleted file mode 100644 index 0fd5437380..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_vb.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Author: Max Lingua - */ - -#ifndef S3VVB_INC -#define S3VVB_INC - -#include "main/mtypes.h" -#include "swrast/swrast.h" - -#define _S3V_NEW_VERTEX (_NEW_TEXTURE | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE) - - -extern void s3vChooseVertexState( GLcontext *ctx ); -extern void s3vCheckTexSizes( GLcontext *ctx ); -extern void s3vBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ); - - -extern void s3v_import_float_colors( GLcontext *ctx ); -extern void s3v_import_float_spec_colors( GLcontext *ctx ); - -extern void s3v_translate_vertex( GLcontext *ctx, - const s3vVertex *src, - SWvertex *dst ); - -extern void s3vInitVB( GLcontext *ctx ); -extern void s3vFreeVB( GLcontext *ctx ); - -extern void s3v_print_vertex( GLcontext *ctx, const s3vVertex *v ); -#if 0 -extern void s3vPrintSetupFlags(char *msg, GLuint flags ); -#endif - -#endif diff --git a/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/src/mesa/drivers/dri/s3v/s3v_xmesa.c deleted file mode 100644 index 85f1481769..0000000000 --- a/src/mesa/drivers/dri/s3v/s3v_xmesa.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - * Author: Max Lingua - */ - -#include "s3v_context.h" -#include "s3v_vb.h" -#include "s3v_dri.h" -#include "main/context.h" -#include "main/matrix.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/viewport.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "vbo/vbo.h" - -/* #define DEBUG(str) printf str */ - -static const __DRIconfig ** -s3vInitScreen(__DRIscreen *sPriv) -{ - sPriv->private = (void *) s3vCreateScreen( sPriv ); - - if (!sPriv->private) { - s3vDestroyScreen( sPriv ); - return GL_FALSE; - } - - return NULL; -} - -static void -s3vDestroyContext(__DRIcontextPrivate *driContextPriv) -{ - s3vContextPtr vmesa = (s3vContextPtr)driContextPriv->driverPrivate; - - if (vmesa) { - _swsetup_DestroyContext( vmesa->glCtx ); - _tnl_DestroyContext( vmesa->glCtx ); - _vbo_DestroyContext( vmesa->glCtx ); - _swrast_DestroyContext( vmesa->glCtx ); - - s3vFreeVB( vmesa->glCtx ); - - /* free the Mesa context */ - vmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(vmesa->glCtx); - - _mesa_free(vmesa); - driContextPriv->driverPrivate = NULL; - } -} - - -static GLboolean -s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - s3vScreenPtr screen = (s3vScreenPtr) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp, - screen->frontOffset, screen->frontPitch, - driDrawPriv); - s3vSetSpanFunctions(frontRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - s3vSetSpanFunctions(backRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - backRb->backBuffer = GL_TRUE; - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - s3vSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - s3vSetSpanFunctions(depthRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - /* no h/w stencil yet? - if (mesaVis->stencilBits > 0) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, NULL, - screen->cpp, screen->depthOffset, - screen->depthPitch, driDrawPriv); - s3vSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - */ - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -s3vDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) -{ - _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static void -s3vSwapBuffers(__DRIdrawablePrivate *drawablePrivate) -{ - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; - __DRIscreenPrivate *sPriv; - GLcontext *ctx; - s3vContextPtr vmesa; - s3vScreenPtr s3vscrn; - - vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate; - sPriv = vmesa->driScreen; - s3vscrn = vmesa->s3vScreen; - ctx = vmesa->glCtx; - - DEBUG(("*** s3vSwapBuffers ***\n")); - -/* DMAFLUSH(); */ - - _mesa_notifySwapBuffers( ctx ); - - vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate; -/* driScrnPriv = vmesa->driScreen; */ - -/* if (vmesa->EnabledFlags & S3V_BACK_BUFFER) */ - -/* _mesa_notifySwapBuffers( ctx ); */ -#if 1 -{ - int x0, y0, x1, y1; -/* - int nRect = dPriv->numClipRects; - XF86DRIClipRectPtr pRect = dPriv->pClipRects; - - __DRIscreenPrivate *driScrnPriv = vmesa->driScreen; -*/ - -/* - DEBUG(("s3vSwapBuffers: S3V_BACK_BUFFER = 1 - nClip = %i\n", nRect)); -*/ -/* vmesa->drawOffset=vmesa->s3vScreen->backOffset; */ - - x0 = dPriv->x; - y0 = dPriv->y; - - x1 = x0 + dPriv->w - 1; - y1 = y0 + dPriv->h - 1; - - DMAOUT_CHECK(BITBLT_SRC_BASE, 15); - DMAOUT(vmesa->s3vScreen->backOffset); - DMAOUT(0); /* 0xc0000000 */ - DMAOUT( ((x0 << 16) | x1) ); - DMAOUT( ((y0 << 16) | y1) ); - DMAOUT( (vmesa->DestStride << 16) | vmesa->SrcStride ); - DMAOUT( (~(0)) ); - DMAOUT( (~(0)) ); - DMAOUT(0); - DMAOUT(0); - /* FIXME */ - DMAOUT(0); - DMAOUT(0); - DMAOUT( (0x01 | /* Autoexecute */ - 0x02 | /* clip */ - 0x04 | /* 16 bit */ - 0x20 | /* draw */ - 0x400 | /* word alignment (bit 10=1) */ - (0x2 << 11) | /* offset = 1 byte */ - (0xCC << 17) | /* rop #204 */ - (0x3 << 25)) ); /* l-r, t-b */ - DMAOUT(vmesa->ScissorWH); - DMAOUT( /* 0 */ vmesa->SrcXY ); - DMAOUT( (dPriv->x << 16) | dPriv->y ); - DMAFINISH(); - - DMAFLUSH(); - - vmesa->restore_primitive = -1; - -} -#endif -} - -static GLboolean -s3vMakeCurrent(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - int x1,x2,y1,y2; - int cx, cy, cw, ch; - unsigned int src_stride, dest_stride; - int cl; - - s3vContextPtr vmesa; - __DRIdrawablePrivate *dPriv = driDrawPriv; - vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate; - - DEBUG(("s3vMakeCurrent\n")); - - DEBUG(("dPriv->x=%i y=%i w=%i h=%i\n", dPriv->x, dPriv->y, - dPriv->w, dPriv->h)); - - if (driContextPriv) { - GET_CURRENT_CONTEXT(ctx); - s3vContextPtr oldVirgeCtx = ctx ? S3V_CONTEXT(ctx) : NULL; - s3vContextPtr newVirgeCtx = (s3vContextPtr) driContextPriv->driverPrivate; - - if ( newVirgeCtx != oldVirgeCtx ) { - - newVirgeCtx->dirty = ~0; - cl = 1; - DEBUG(("newVirgeCtx != oldVirgeCtx\n")); -/* s3vUpdateClipping(newVirgeCtx->glCtx ); */ - } - - if (newVirgeCtx->driDrawable != driDrawPriv) { - newVirgeCtx->driDrawable = driDrawPriv; - DEBUG(("driDrawable != driDrawPriv\n")); - s3vUpdateWindow ( newVirgeCtx->glCtx ); - s3vUpdateViewportOffset( newVirgeCtx->glCtx ); -/* s3vUpdateClipping(newVirgeCtx->glCtx ); */ - } -/* - s3vUpdateWindow ( newVirgeCtx->glCtx ); - s3vUpdateViewportOffset( newVirgeCtx->glCtx ); -*/ - -/* - _mesa_make_current( newVirgeCtx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - - _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0, - newVirgeCtx->driDrawable->w, - newVirgeCtx->driDrawable->h); -*/ - -#if 0 - newVirgeCtx->Window &= ~W_GIDMask; - newVirgeCtx->Window |= (driDrawPriv->index << 5); - CHECK_DMA_BUFFER(newVirgeCtx,1); - WRITE(newVirgeCtx->buf, S3VWindow, newVirgeCtx->Window); -#endif - - newVirgeCtx->new_state |= S3V_NEW_WINDOW; /* FIXME */ - - _mesa_make_current( newVirgeCtx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - - if (!newVirgeCtx->glCtx->Viewport.Width) { - _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0, - driDrawPriv->w, driDrawPriv->h); - -/* s3vUpdateClipping(newVirgeCtx->glCtx ); */ - } - -/* - if (cl) { - s3vUpdateClipping(newVirgeCtx->glCtx ); - cl =0; - } -*/ - - newVirgeCtx->new_state |= S3V_NEW_CLIP; - - if (1) { - cx = dPriv->x; - cw = dPriv->w; - cy = dPriv->y; - ch = dPriv->h; - } - - x1 = y1 = 0; - x2 = cw-1; - y2 = ch-1; - - /* src_stride = vmesa->s3vScreen->w * vmesa->s3vScreen->cpp; - dest_stride = ((x2+31)&~31) * vmesa->s3vScreen->cpp; */ - src_stride = vmesa->driScreen->fbWidth * 2; - dest_stride = ((x2+31)&~31) * 2; - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - - return GL_TRUE; -} - - -static GLboolean -s3vUnbindContext( __DRIcontextPrivate *driContextPriv ) -{ - return GL_TRUE; -} - -const struct __DriverAPIRec driDriverAPI = { - .InitScreen = s3vInitScreen, - .DestroyScreen = s3vDestroyScreen, - .CreateContext = s3vCreateContext, - .DestroyContext = s3vDestroyContext, - .CreateBuffer = s3vCreateBuffer, - .DestroyBuffer = s3vDestroyBuffer, - .SwapBuffers = s3vSwapBuffers, - .MakeCurrent = s3vMakeCurrent, - .UnbindContext = s3vUnbindContext, -}; diff --git a/src/mesa/drivers/dri/s3v/s3virgetri.h b/src/mesa/drivers/dri/s3v/s3virgetri.h deleted file mode 100644 index 5519cfd741..0000000000 --- a/src/mesa/drivers/dri/s3v/s3virgetri.h +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Author: Max Lingua - */ - -#define LOCAL_VARS \ - int vert0, vert1, vert2; \ - GLfloat y0, y1, y2, ydiff; \ - int iy0, iy1, iy2; \ - int x0, x1, x2, z0, z1, z2; \ - int dy01, dy02, dy12, dx01, dx02, dx12; \ - int delt02, delt01, delt12, end01, end12, start02; \ - int zstart, arstart, gbstart; \ - int deltzy, deltzx, deltarx, deltgbx, deltary, deltgby; \ - GLubyte (*colours)[4]; \ - GLubyte (*scolours)[4]; \ - static int tp = 0; \ - int tmp, lr - -#define LOCAL_TEX_VARS \ - int u0, u1, u2; \ - GLfloat ru0, ru1, ru2; \ - int v0, v1, v2; \ - GLfloat rv0, rv1, rv2; \ - GLfloat w0, w1, w2; \ - GLfloat rw0, rw1, rw2; \ - int baseu, basev; \ - int d0, d1, d2; \ - int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \ - int deltwx, deltwy; \ - int rbaseu, rbasev; \ - int dstart, ustart, wstart, vstart; \ - static int stmp = 0; \ - s3virgeTextureObject_t *t - -#define CULL_BACKFACE() \ - do { \ - GLfloat *w0 = VB->Win.data[e0]; \ - GLfloat *w1 = VB->Win.data[e1]; \ - GLfloat *w2 = VB->Win.data[e2]; \ - float cull; \ - cull = ctx->backface_sign * ((w1[0] - w0[0]) * (w0[1] - w2[1]) + \ - (w1[1] - w0[1]) * (w2[0] - w0[0])); \ - if (cull < 0) \ - return; \ - } while (0) - -#define SORT_VERTICES() \ - do { \ - y0 = VB->Win.data[e0][1]; \ - y1 = VB->Win.data[e1][1]; \ - y2 = VB->Win.data[e2][1]; \ - if (y1 > y0) { \ - if (y2 > y0) { \ - vert0 = e0; \ - if (y1 > y2) { vert2 = e1; vert1 = e2; } else { vert2 = e2; vert1 = e1; } \ - } else { vert0 = e2; vert1 = e0; vert2 = e1; } \ - } else { \ - if (y2 > y0) { vert0 = e1; vert1 = e0; vert2 = e2; } else { \ - vert2 = e0; \ - if (y2 > y1) { vert0 = e1; vert1 = e2; } else { vert0 = e2; vert1 = e1; } \ - } \ - } \ - } while (0) - -#define SET_VARIABLES() \ - do { \ - iy0 = y0 = ((s3virgeDB->height - (VB->Win.data[vert0][1]))); \ - iy1 = y1 = ((s3virgeDB->height - (VB->Win.data[vert1][1]))); \ - iy2 = y2 = ((s3virgeDB->height - (VB->Win.data[vert2][1]))); \ - if (iy0 == iy2) { return; } \ - ydiff = y0 - (float)iy0; \ - x0 = ((VB->Win.data[vert0][0]) * 1024.0 * 1024.0); \ - x1 = ((VB->Win.data[vert1][0]) * 1024.0 * 1024.0); \ - x2 = ((VB->Win.data[vert2][0]) * 1024.0 * 1024.0); \ - z0 = (VB->Win.data[vert0][2] * 1024.0 * 32.0); \ - z1 = (VB->Win.data[vert1][2] * 1024.0 * 32.0); \ - z2 = (VB->Win.data[vert2][2] * 1024.0 * 32.0); \ - dx12 = x2 - x1; \ - dy12 = iy1 - iy2; \ - dx01 = x1 - x0; \ - dy01 = iy0 - iy1; \ - dx02 = x2 - x0; \ - dy02 = iy0 - iy2; \ - delt12 = delt02 = delt01 = 0; \ - } while (0) - -#define SET_TEX_VARIABLES() \ - do { \ - t = ((s3virgeTextureObject_t *)ctx->Texture.Unit[0].Current->DriverData); \ - deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \ - u0 = (VB->TexCoordPtr[0]->data[vert0][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \ - u1 = (VB->TexCoordPtr[0]->data[vert1][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \ - u2 = (VB->TexCoordPtr[0]->data[vert2][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \ - v0 = (VB->TexCoordPtr[0]->data[vert0][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \ - v1 = (VB->TexCoordPtr[0]->data[vert1][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \ - v2 = (VB->TexCoordPtr[0]->data[vert2][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \ - w0 = (VB->Win.data[vert0][3]); \ - w1 = (VB->Win.data[vert1][3]); \ - w2 = (VB->Win.data[vert2][3]); \ - } while (0) - -#define FLATSHADE_COLORS() \ - do { \ - GLubyte *col = &(colours[pv][0]); \ - deltarx = deltary = deltgbx = deltgby = 0; \ - gbstart = (((col[1]) << 23) | ((col[2]) << 7)); \ - arstart = (((col[3]) << 23) | ((col[0]) << 7)); \ - } while (0) - -#define GOURAUD_COLORS() \ - do { \ - int ctmp, ctmp2, ctmp3, ctmp4; \ - GLubyte *col0, *col1, *col2; \ - col0 = &(colours[vert0][0]); \ - col1 = &(colours[vert1][0]); \ - col2 = &(colours[vert2][0]); \ - ctmp = ((col2[3] - col0[3]) << 7) / dy02; \ - ctmp2 = ((col2[0] - col0[0]) << 7) / dy02; \ - deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \ - ctmp3 = ((col2[1] - col0[1]) << 7) / dy02; \ - ctmp4 = ((col2[2] - col0[2]) << 7) / dy02; \ - deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \ - gbstart = (((int)((ydiff * ctmp3) + (col0[1] << 7)) << 16) & 0x7FFF0000) | \ - ((int)((ydiff * ctmp4) + (col0[2] << 7)) & 0x7FFF); \ - arstart = (((int)((ydiff * ctmp) + (col0[3] << 7)) << 16) & 0x7FFF0000) | \ - ((int)((ydiff * ctmp2) + (col0[0] << 7)) & 0x7FFF); \ - if (tmp) { \ - int ax, rx, gx, bx; \ - ax = ((col1[3] << 7) - (dy01 * ctmp + (col0[3] << 7))) / tmp; \ - rx = ((col1[0] << 7) - (dy01 * ctmp2 + (col0[0] << 7))) / tmp; \ - gx = ((col1[1] << 7) - (dy01 * ctmp3 + (col0[1] << 7))) / tmp; \ - bx = ((col1[2] << 7) - (dy01 * ctmp4 + (col0[2] << 7))) / tmp; \ - deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \ - deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \ - } else { \ - deltgbx = deltarx = 0; \ - } \ - } while (0) - -#define SET_XY() \ - do { \ - delt02 = dx02 / dy02; \ - if (dy12) delt12 = dx12 / dy12; \ - if (dy01) delt01 = dx01 / dy01; \ - start02 = (ydiff * delt02) + x0; \ - end01 = (ydiff * delt01) + x0; \ - end12 = ((y1 - (GLfloat)iy1) * delt12) + x1; \ - } while (0) - -#define SET_DIR() \ - do { \ - tmp = x1 - (dy01 * delt02 + x0); \ - if (tmp > 0) { \ - lr = 0x80000000; \ - } else { \ - tmp *= -1; \ - lr = 0; \ - } \ - tmp >>= 20; \ - } while (0) - -#define SET_Z() \ - do { \ - deltzy = (z2 - z0) / dy02; \ - if (tmp) { \ - deltzx = (z1 - (dy01 * deltzy + z0)) / tmp; \ - } else { deltzx = 0; } \ - zstart = (deltzy * ydiff) + z0; \ - } while (0) - -#define SET_BASEUV() \ - do { \ - if (u0 < u1) { \ - if (u0 < u2) { \ - baseu = u0; \ - } else { \ - baseu = u2; \ - } \ - } else { \ - if (u1 < u2) { \ - baseu = u1; \ - } else { \ - baseu = u2; \ - } \ - } \ - if (v0 < v1) { \ - if (v0 < v2) { \ - basev = v0; \ - } else { \ - basev = v2; \ - } \ - } else { \ - if (v1 < v2) { \ - basev = v1; \ - } else { \ - basev = v2; \ - } \ - } \ - } while (0) - -#define SET_RW() \ - do { \ - /* GLfloat minW; \ - if (w0 < w1) { \ - if (w0 < w2) { \ - minW = w0; \ - } else { \ - minW = w2; \ - } \ - } else { \ - if (w1 < w2) { \ - minW = w1; \ - } else { \ - minW = w2; \ - } \ - } */ \ - rw0 = (512.0 * w0); \ - rw1 = (512.0 * w1); \ - rw2 = (512.0 * w2); \ - } while (0) - - -#define SET_D() \ - do { \ - GLfloat sxy, suv; \ - int lev; \ - suv = (VB->TexCoordPtr[0]->data[vert0][0] - \ - VB->TexCoordPtr[0]->data[vert2][0]) * \ - (VB->TexCoordPtr[0]->data[vert1][1] - \ - VB->TexCoordPtr[0]->data[vert2][1]) - \ - (VB->TexCoordPtr[0]->data[vert1][0] - \ - VB->TexCoordPtr[0]->data[vert2][0]) * \ - (VB->TexCoordPtr[0]->data[vert0][1] - \ - VB->TexCoordPtr[0]->data[vert2][2]); \ - sxy = (VB->Win.data[vert0][0] - \ - VB->Win.data[vert2][0]) * \ - (VB->Win.data[vert1][1] - \ - VB->Win.data[vert2][1]) - \ - (VB->Win.data[vert1][0] - \ - VB->Win.data[vert2][0]) * \ - (VB->Win.data[vert0][1] - \ - VB->Win.data[vert2][2]); \ - if (sxy < 0) sxy *= -1.0; \ - if (suv < 0) suv *= -1.0; \ - lev = *(int*)&suv - *(int *)&sxy; \ - if (lev < 0) \ - lev = 0; \ - else \ - lev >>=23; \ - dstart = (lev << 27); \ - } while (0) - - - -#define SET_UVWD() \ - do { \ - SET_BASEUV(); \ - SET_RW(); \ - SET_D(); \ - ru0 = (((u0 - baseu) * rw0)); \ - ru1 = (((u1 - baseu) * rw1)); \ - ru2 = (((u2 - baseu) * rw2)); \ - rv0 = (((v0 - basev) * rw0)); \ - rv1 = (((v1 - basev) * rw1)); \ - rv2 = (((v2 - basev) * rw2)); \ - while (baseu < 0) { baseu += (t->tObj->Image[0]->Width << 8); } \ - while (basev < 0) { basev += (t->tObj->Image[0]->Height << 8); } \ - if (!(baseu & 0xFF)) { baseu = (baseu >> 8); } else { baseu = (baseu >> 8) + 1; } \ - if ((basev & 0x80) || !(basev & 0xFF)) { basev = (basev >> 8); } else { basev = (basev >> 8) - 1; } \ - rbaseu = (baseu) << (16 - t->widthLog2); \ - rbasev = (basev) << (16 - t->widthLog2); \ - deltuy = (((ru2 - ru0) / dy02)); \ - deltvy = (((rv2 - rv0) / dy02)); \ - rw0 *= (1024.0 * 512.0); \ - rw1 *= (1024.0 * 512.0); \ - rw2 *= (1024.0 * 512.0); \ - deltwy = ((rw2 - rw0) / dy02); \ - if (tmp) { \ - deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \ - deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \ - deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \ - } else { deltux = deltvx = deltwx = 0; } \ - ustart = (deltuy * ydiff) + (ru0); \ - vstart = (deltvy * ydiff) + (rv0); \ - wstart = (deltwy * ydiff) + (rw0); \ - } while (0) - - -#define SEND_COLORS() \ - do { \ - WAITFIFOEMPTY(6); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBX), deltgbx); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARX), deltarx); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBY), deltgby); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARY), deltary); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GS_BS), gbstart); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_AS_RS), arstart); \ - } while (0) - -#define SEND_VERTICES() \ - do { \ - WAITFIFOEMPTY(6); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZSTART), zstart); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZXD), deltzx); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZYD), deltzy); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA12), delt12); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND12), end12); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA01), delt01); \ - WAITFIFOEMPTY(5); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND01), end01); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA02), delt02); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXSTART02), start02); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TYS), iy0); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TY01_Y12), \ - ((((iy0 - iy1) & 0x7FF) << 16) | \ - ((iy1 - iy2) & 0x7FF) | lr)); \ - } while (0) - -#define SEND_UVWD() \ - do { \ - WAITFIFOEMPTY(7); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEV), (rbasev & 0xFFFF)); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEU), (0xa0000000 | (rbaseu & 0xFFFF))); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WXD), deltwx); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WYD), deltwy); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WSTART), wstart); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DXD), deltdx); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VXD), deltvx); \ - WAITFIFOEMPTY(7); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UXD), deltux); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DYD), deltdy); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VYD), deltvy); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UYD), deltuy); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DSTART), dstart); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VSTART), vstart); \ - OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_USTART), ustart); \ - } while (0) - -#define DMA_SEND_UVWD() \ - do { \ - DMAOUT((rbasev & 0xFFFF)); \ - DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \ - DMAOUT(deltwx); \ - DMAOUT(deltwy); \ - DMAOUT(wstart); \ - DMAOUT(deltdx); \ - DMAOUT(deltvx); \ - DMAOUT(deltux); \ - DMAOUT(deltdy); \ - DMAOUT(deltvy); \ - DMAOUT(deltuy); \ - DMAOUT(dstart); \ - DMAOUT(vstart); \ - DMAOUT(ustart); \ - } while (0) - - -#define DMA_SEND_COLORS() \ - do { \ - DMAOUT(deltgbx); \ - DMAOUT(deltarx); \ - DMAOUT(deltgby); \ - DMAOUT(deltary); \ - DMAOUT(gbstart); \ - DMAOUT(arstart); \ - } while (0) - -#define DMA_SEND_VERTICES() \ - do { \ - DMAOUT(deltzx); \ - DMAOUT(deltzy); \ - DMAOUT(zstart); \ - DMAOUT(delt12); \ - DMAOUT(end12); \ - DMAOUT(delt01); \ - DMAOUT(end01); \ - DMAOUT(delt02); \ - DMAOUT(start02); \ - DMAOUT(iy0); \ - DMAOUT(((((iy0 - iy1) & 0x7FF) << 16) | \ - ((iy1 - iy2) & 0x7FF) | lr)); \ - } while (0) - -- cgit v1.2.3 From fd7ee2bcb74edf8c4412a244c33fd4749509b912 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 12:57:13 -0700 Subject: Kill off trident. Hm. I could have said "chew trident and spit it out," or perhaps "spear trident," instead. Dohoho. --- configs/linux-dri | 2 +- configs/linux-dri-debug | 2 +- configs/linux-dri-xcb | 2 +- configure.ac | 2 +- src/mesa/drivers/dri/trident/Makefile | 25 - src/mesa/drivers/dri/trident/trident_context.c | 465 ---------- src/mesa/drivers/dri/trident/trident_context.h | 242 ----- src/mesa/drivers/dri/trident/trident_dd.c | 110 --- src/mesa/drivers/dri/trident/trident_dri.h | 28 - src/mesa/drivers/dri/trident/trident_lock.h | 11 - src/mesa/drivers/dri/trident/trident_state.c | 548 ------------ src/mesa/drivers/dri/trident/trident_tris.c | 1125 ------------------------ src/mesa/drivers/dri/trident/trident_vb.c | 434 --------- 13 files changed, 4 insertions(+), 2992 deletions(-) delete mode 100644 src/mesa/drivers/dri/trident/Makefile delete mode 100644 src/mesa/drivers/dri/trident/trident_context.c delete mode 100644 src/mesa/drivers/dri/trident/trident_context.h delete mode 100644 src/mesa/drivers/dri/trident/trident_dd.c delete mode 100644 src/mesa/drivers/dri/trident/trident_dri.h delete mode 100644 src/mesa/drivers/dri/trident/trident_lock.h delete mode 100644 src/mesa/drivers/dri/trident/trident_state.c delete mode 100644 src/mesa/drivers/dri/trident/trident_tris.c delete mode 100644 src/mesa/drivers/dri/trident/trident_vb.c diff --git a/configs/linux-dri b/configs/linux-dri index 89a7d07f45..6c3c0ab921 100644 --- a/configs/linux-dri +++ b/configs/linux-dri @@ -64,4 +64,4 @@ GALLIUM_WINSYS_DRM_DIRS = intel GALLIUM_STATE_TRACKERS_DIRS = egl DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon \ - savage sis tdfx trident unichrome ffb swrast + savage sis tdfx unichrome ffb swrast diff --git a/configs/linux-dri-debug b/configs/linux-dri-debug index c3a458459d..0dbf428830 100644 --- a/configs/linux-dri-debug +++ b/configs/linux-dri-debug @@ -11,6 +11,6 @@ ARCH_FLAGS = -DDEBUG #DRI_DIRS = i915tex i915 #DRI_DIRS = i965 #DRI_DIRS = radeon r200 r300 -#DRI_DIRS = unichrome sis trident +#DRI_DIRS = unichrome sis #DRI_DIRS = i810 mga r128 tdfx diff --git a/configs/linux-dri-xcb b/configs/linux-dri-xcb index d97f0b477e..827fb97330 100644 --- a/configs/linux-dri-xcb +++ b/configs/linux-dri-xcb @@ -69,4 +69,4 @@ WINDOW_SYSTEM=dri # gamma are missing because they have not been converted to use the new # interface. DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon \ - savage sis tdfx trident unichrome ffb + savage sis tdfx unichrome ffb diff --git a/configure.ac b/configure.ac index 6622b0aa49..910c0b1a4b 100644 --- a/configure.ac +++ b/configure.ac @@ -769,7 +769,7 @@ if test "$mesa_driver" = dri; then # default drivers if test "x$DRI_DIRS" = "xyes"; then DRI_DIRS="i810 i915 i965 mach64 mga r128 r200 r300 r600 radeon \ - savage sis tdfx trident unichrome ffb swrast" + savage sis tdfx unichrome ffb swrast" fi DRI_DIRS=`echo "$DRI_DIRS" | $SED 's/ */ /g'` diff --git a/src/mesa/drivers/dri/trident/Makefile b/src/mesa/drivers/dri/trident/Makefile deleted file mode 100644 index bd9b7f35a2..0000000000 --- a/src/mesa/drivers/dri/trident/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# src/mesa/drivers/dri/trident/Makefile - -TOP = ../../../../.. -include $(TOP)/configs/current - -LIBNAME = trident_dri.so - -# Not yet -# MINIGLX_SOURCES = server/trident_dri.c - -DRIVER_SOURCES = \ - trident_context.c \ - trident_state.c \ - trident_vb.c \ - trident_dd.c \ - trident_tris.c - -C_SOURCES = \ - $(COMMON_SOURCES) \ - $(DRIVER_SOURCES) - -ASM_SOURCES = - -include ../Makefile.template - diff --git a/src/mesa/drivers/dri/trident/trident_context.c b/src/mesa/drivers/dri/trident/trident_context.c deleted file mode 100644 index b5126b07ea..0000000000 --- a/src/mesa/drivers/dri/trident/trident_context.c +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ -#include "trident_dri.h" -#include "trident_context.h" -#include "trident_lock.h" - -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "vbo/vbo.h" - -#include "tnl/tnl.h" -#include "tnl/t_pipeline.h" - -#include "main/context.h" -#include "main/simple_list.h" -#include "main/matrix.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/viewport.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif -#include "main/simple_list.h" -#include "main/mm.h" -#include "drirenderbuffer.h" - -#include "drivers/common/driverfuncs.h" -#include "dri_util.h" -#include "utils.h" - -static const struct tnl_pipeline_stage *trident_pipeline[] = { - &_tnl_vertex_transform_stage, - &_tnl_normal_transform_stage, - &_tnl_lighting_stage, - &_tnl_texgen_stage, - &_tnl_texture_transform_stage, - &_tnl_render_stage, - 0, -}; - - -static GLboolean -tridentCreateContext( const __GLcontextModes *glVisual, - __DRIcontextPrivate *driContextPriv, - void *sharedContextPrivate) -{ - GLcontext *ctx, *shareCtx; - __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; - tridentContextPtr tmesa; - tridentScreenPtr tridentscrn; - struct dd_function_table functions; -#if 0 - drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+ - sizeof(XF86DRISAREARec)); -#endif - - tmesa = (tridentContextPtr) CALLOC( sizeof(*tmesa) ); - if ( !tmesa ) return GL_FALSE; - - /* Allocate the Mesa context */ - if (sharedContextPrivate) - shareCtx = ((tridentContextPtr) sharedContextPrivate)->glCtx; - else - shareCtx = NULL; - - _mesa_init_driver_functions(&functions); - - tmesa->glCtx = - _mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa); - - if (!tmesa->glCtx) { - FREE(tmesa); - return GL_FALSE; - } - - tmesa->driContext = driContextPriv; - tmesa->driScreen = sPriv; - tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */ - - tmesa->hHWContext = driContextPriv->hHWContext; - tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock; - tmesa->driFd = sPriv->fd; -#if 0 - tmesa->sarea = saPriv; -#endif - - tridentscrn = tmesa->tridentScreen = (tridentScreenPtr)(sPriv->private); - - ctx = tmesa->glCtx; - - ctx->Const.MaxTextureLevels = 13; /* 4K by 4K? Is that right? */ - ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */ - - ctx->Const.MinLineWidth = 0.0; - ctx->Const.MaxLineWidth = 255.0; - - ctx->Const.MinLineWidthAA = 0.0; - ctx->Const.MaxLineWidthAA = 65536.0; - - ctx->Const.MinPointSize = 0.0; - ctx->Const.MaxPointSize = 255.0; - - ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */ - ctx->Const.MaxPointSizeAA = 16.0; - ctx->Const.PointSizeGranularity = 0.25; - - ctx->Const.MaxDrawBuffers = 1; - -#if 0 - tmesa->texHeap = mmInit( 0, tmesa->tridentScreen->textureSize ); - - make_empty_list(&tmesa->TexObjList); - make_empty_list(&tmesa->SwappedOut); - - tmesa->CurrentTexObj[0] = 0; - tmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */ - - tmesa->RenderIndex = ~0; -#endif - - /* Initialize the software rasterizer and helper modules. - */ - _swrast_CreateContext( ctx ); - _vbo_CreateContext( ctx ); - _tnl_CreateContext( ctx ); - _swsetup_CreateContext( ctx ); - - /* Install the customized pipeline: - */ - _tnl_destroy_pipeline( ctx ); - _tnl_install_pipeline( ctx, trident_pipeline ); - - /* Configure swrast to match hardware characteristics: - */ - _swrast_allow_pixel_fog( ctx, GL_FALSE ); - _swrast_allow_vertex_fog( ctx, GL_TRUE ); - - tridentInitVB( ctx ); - tridentDDInitExtensions( ctx ); - tridentDDInitDriverFuncs( ctx ); - tridentDDInitStateFuncs( ctx ); -#if 0 - tridentDDInitSpanFuncs( ctx ); - tridentDDInitTextureFuncs( ctx ); -#endif - tridentDDInitTriFuncs( ctx ); - tridentDDInitState( tmesa ); - - driContextPriv->driverPrivate = (void *)tmesa; - - UNLOCK_HARDWARE(tmesa); - - return GL_TRUE; -} - -static void -tridentDestroyContext(__DRIcontextPrivate *driContextPriv) -{ - tridentContextPtr tmesa = (tridentContextPtr)driContextPriv->driverPrivate; - - if (tmesa) { - _swsetup_DestroyContext( tmesa->glCtx ); - _tnl_DestroyContext( tmesa->glCtx ); - _vbo_DestroyContext( tmesa->glCtx ); - _swrast_DestroyContext( tmesa->glCtx ); - - /* free the Mesa context */ - tmesa->glCtx->DriverCtx = NULL; - _mesa_destroy_context(tmesa->glCtx); - - _mesa_free(tmesa); - driContextPriv->driverPrivate = NULL; - } -} - - -static GLboolean -tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv, - __DRIdrawablePrivate *driDrawPriv, - const __GLcontextModes *mesaVis, - GLboolean isPixmap ) -{ - tridentScreenPtr screen = (tridentScreenPtr) driScrnPriv->private; - - if (isPixmap) { - return GL_FALSE; /* not implemented */ - } - else { - struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis); - - { - driRenderbuffer *frontRb - = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp, - screen->frontOffset, screen->frontPitch, - driDrawPriv); - /* - tridentSetSpanFunctions(frontRb, mesaVis); - */ - _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base); - } - - if (mesaVis->doubleBufferMode) { - driRenderbuffer *backRb - = driNewRenderbuffer(GL_RGBA, NULL, screen->cpp, - screen->backOffset, screen->backPitch, - driDrawPriv); - /* - tridentSetSpanFunctions(backRb, mesaVis); - */ - _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base); - } - - if (mesaVis->depthBits == 16) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT16, NULL, screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - /* - tridentSetSpanFunctions(depthRb, mesaVis); - */ - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - else if (mesaVis->depthBits == 24) { - driRenderbuffer *depthRb - = driNewRenderbuffer(GL_DEPTH_COMPONENT24, NULL, screen->cpp, - screen->depthOffset, screen->depthPitch, - driDrawPriv); - /* - tridentSetSpanFunctions(depthRb, mesaVis); - */ - _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base); - } - - /* no h/w stencil? - if (mesaVis->stencilBits > 0 && !swStencil) { - driRenderbuffer *stencilRb - = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT); - tridentSetSpanFunctions(stencilRb, mesaVis); - _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base); - } - */ - - _mesa_add_soft_renderbuffers(fb, - GL_FALSE, /* color */ - GL_FALSE, /* depth */ - mesaVis->stencilBits > 0, - mesaVis->accumRedBits > 0, - GL_FALSE, /* alpha */ - GL_FALSE /* aux */); - driDrawPriv->driverPrivate = (void *) fb; - - return (driDrawPriv->driverPrivate != NULL); - } -} - - -static void -tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv) -{ - _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); -} - -static void -tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate) -{ - __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate; - - if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) { - tridentContextPtr tmesa; - GLcontext *ctx; - tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate; - ctx = tmesa->glCtx; - if (ctx->Visual.doubleBufferMode) { - _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */ - tridentCopyBuffer( dPriv ); - } - } - else { - /* XXX this shouldn't be an error but we can't handle it for now */ - _mesa_problem(NULL, "tridentSwapBuffers: drawable has no context!\n"); - } -} - -static GLboolean -tridentMakeCurrent(__DRIcontextPrivate *driContextPriv, - __DRIdrawablePrivate *driDrawPriv, - __DRIdrawablePrivate *driReadPriv) -{ - if (driContextPriv) { - GET_CURRENT_CONTEXT(ctx); - tridentContextPtr oldCtx = ctx ? TRIDENT_CONTEXT(ctx) : NULL; - tridentContextPtr newCtx = (tridentContextPtr) driContextPriv->driverPrivate; - - if ( newCtx != oldCtx ) { - newCtx->dirty = ~0; - } - - if (newCtx->driDrawable != driDrawPriv) { - newCtx->driDrawable = driDrawPriv; -#if 0 - tridentUpdateWindow ( newCtx->glCtx ); - tridentUpdateViewportOffset( newCtx->glCtx ); -#endif - } - - newCtx->drawOffset = newCtx->tridentScreen->backOffset; - newCtx->drawPitch = newCtx->tridentScreen->backPitch; - - _mesa_make_current( newCtx->glCtx, - (GLframebuffer *) driDrawPriv->driverPrivate, - (GLframebuffer *) driReadPriv->driverPrivate ); - - if (!newCtx->glCtx->Viewport.Width) { - _mesa_set_viewport(newCtx->glCtx, 0, 0, - driDrawPriv->w, driDrawPriv->h); - } - } else { - _mesa_make_current( NULL, NULL, NULL ); - } - return GL_TRUE; -} - - -static GLboolean -tridentUnbindContext( __DRIcontextPrivate *driContextPriv ) -{ - return GL_TRUE; -} - - -static tridentScreenPtr -tridentCreateScreen( __DRIscreenPrivate *sPriv ) -{ - TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv; - tridentScreenPtr tridentScreen; - - if (sPriv->devPrivSize != sizeof(TRIDENTDRIRec)) { - fprintf(stderr,"\nERROR! sizeof(TRIDENTDRIRec) does not match passed size from device driver\n"); - return GL_FALSE; - } - - /* Allocate the private area */ - tridentScreen = (tridentScreenPtr) CALLOC( sizeof(*tridentScreen) ); - if ( !tridentScreen ) return NULL; - - tridentScreen->driScreen = sPriv; - - tridentScreen->frontOffset = tDRIPriv->frontOffset; - tridentScreen->backOffset = tDRIPriv->backOffset; - tridentScreen->depthOffset = tDRIPriv->depthOffset; - tridentScreen->frontPitch = tDRIPriv->frontPitch; - tridentScreen->backPitch = tDRIPriv->backPitch; - tridentScreen->depthPitch = tDRIPriv->depthPitch; - tridentScreen->width = tDRIPriv->width; - tridentScreen->height = tDRIPriv->height; - -printf("%d %d\n",tridentScreen->width,tridentScreen->height); -printf("%d %d\n",tridentScreen->frontPitch,tridentScreen->backPitch); -printf("offset 0x%x 0x%x\n",tridentScreen->backOffset,tridentScreen->depthOffset); - - tridentScreen->mmio.handle = tDRIPriv->regs; - tridentScreen->mmio.size = 0x20000; - - if (drmMap(sPriv->fd, - tridentScreen->mmio.handle, tridentScreen->mmio.size, - (drmAddressPtr)&tridentScreen->mmio.map)) { - FREE(tridentScreen); - return GL_FALSE; - } -printf("MAPPED at %p\n", tridentScreen->mmio.map); - - return tridentScreen; -} - -/* Destroy the device specific screen private data struct. - */ -static void -tridentDestroyScreen( __DRIscreenPrivate *sPriv ) -{ - tridentScreenPtr tridentScreen = (tridentScreenPtr)sPriv->private; - - FREE(tridentScreen); -} - -static GLboolean -tridentInitDriver(__DRIscreenPrivate *sPriv) -{ - sPriv->private = (void *) tridentCreateScreen( sPriv ); - - if (!sPriv->private) { - tridentDestroyScreen( sPriv ); - return GL_FALSE; - } - - return GL_TRUE; -} - -/** - * This is the driver specific part of the createNewScreen entry point. - * - * \todo maybe fold this into intelInitDriver - * - * \return the __GLcontextModes supported by this driver - */ -const __DRIconfig **tridentInitScreen(__DRIscreenPrivate *psp) -{ - static const __DRIversion ddx_expected = { 4, 0, 0 }; - static const __DRIversion dri_expected = { 3, 1, 0 }; - static const __DRIversion drm_expected = { 1, 0, 0 }; - - if ( ! driCheckDriDdxDrmVersions2( "Trident", - &psp->dri_version, & dri_expected, - &psp->ddx_version, & ddx_expected, - &psp->drm_version, & drm_expected ) ) - return NULL; - - if (!tridentInitDriver(psp)) - return NULL; - - /* Wait... what? This driver doesn't report any modes... */ -#if 0 - TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv; - *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8, - GL_TRUE ); -#endif - - return NULL; -} - -const struct __DriverAPIRec driDriverAPI = { - tridentInitScreen, - tridentDestroyScreen, - tridentCreateContext, - tridentDestroyContext, - tridentCreateBuffer, - tridentDestroyBuffer, - tridentSwapBuffers, - tridentMakeCurrent, - tridentUnbindContext, -}; diff --git a/src/mesa/drivers/dri/trident/trident_context.h b/src/mesa/drivers/dri/trident/trident_context.h deleted file mode 100644 index fbbb4a96e7..0000000000 --- a/src/mesa/drivers/dri/trident/trident_context.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ -#ifndef _TRIDENT_CONTEXT_H_ -#define _TRIDENT_CONTEXT_H_ - -#include "dri_util.h" -#include "main/macros.h" -#include "main/mtypes.h" -#include "drm.h" -#include "main/mm.h" - -#define SUBPIXEL_X (0.0F) -#define SUBPIXEL_Y (0.125F) - -#define _TRIDENT_NEW_VERTEX (_NEW_TEXTURE | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE) - -#define TRIDENT_FALLBACK_TEXTURE 0x01 -#define TRIDENT_FALLBACK_DRAW_BUFFER 0x02 - -#define TRIDENT_NEW_CLIP 0x01 - -#define TRIDENT_UPLOAD_COMMAND_D 0x00000001 -#define TRIDENT_UPLOAD_CONTEXT 0x04000000 -#define TRIDENT_UPLOAD_CLIPRECTS 0x80000000 - -#define TAG(x) trident##x -#include "tnl_dd/t_dd_vertex.h" -#undef TAG - -/* these require that base be dword-aligned */ -static INLINE void MMIO_OUT32(unsigned char *base, unsigned int offset, - unsigned int val) -{ - unsigned int *addr = (unsigned int *)(base + offset); - *addr = val; -} - -static INLINE unsigned int MMIO_IN32(unsigned char *base, unsigned int offset) -{ - unsigned int *addr = (unsigned int *)(base + offset); - return *addr; -} - -#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val) -#define MMIO_IN8(base, offset) *((base) + (offset)) - -struct trident_context; -typedef struct trident_context tridentContextRec; -typedef struct trident_context *tridentContextPtr; - -typedef void (*trident_quad_func)( tridentContextPtr, - const tridentVertex *, - const tridentVertex *, - const tridentVertex *, - const tridentVertex * ); -typedef void (*trident_tri_func)( tridentContextPtr, - const tridentVertex *, - const tridentVertex *, - const tridentVertex * ); -typedef void (*trident_line_func)( tridentContextPtr, - const tridentVertex *, - const tridentVertex * ); -typedef void (*trident_point_func)( tridentContextPtr, - const tridentVertex * ); - -typedef struct { - drm_handle_t handle; /* Handle to the DRM region */ - drmSize size; /* Size of the DRM region */ - unsigned char *map; /* Mapping of the DRM region */ -} tridentRegionRec, *tridentRegionPtr; - -typedef struct { - __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */ - - drmBufMapPtr buffers; - - unsigned int frontOffset; - unsigned int frontPitch; - unsigned int backOffset; - unsigned int backPitch; - unsigned int depthOffset; - unsigned int depthPitch; - unsigned int width; - unsigned int height; - unsigned int cpp; - -#if 0 - unsigned int sarea_priv_offset; -#endif - - tridentRegionRec mmio; -} tridentScreenRec, *tridentScreenPtr; - -/** - * tridentRenderbuffer, derived from Mesa's gl_renderbuffer - */ -typedef struct { - struct gl_renderbuffer Base; - /* XXX per-window info should go here */ - int foo, bar; -} tridentRenderbuffer; - - -struct trident_context { - GLcontext *glCtx; /* Mesa context */ - - __DRIcontextPrivate *driContext; - __DRIscreenPrivate *driScreen; - __DRIdrawablePrivate *driDrawable; - - GLuint new_gl_state; - GLuint new_state; - GLuint dirty; - -#if 0 - drm_trident_sarea_t *sarea; -#endif - - /* Temporaries for translating away float colors: - */ - struct gl_client_array UbyteColor; - struct gl_client_array UbyteSecondaryColor; - - /* Mirrors of some DRI state - */ - int lastStamp; /* mirror driDrawable->lastStamp */ - - drm_context_t hHWContext; - drmLock *driHwLock; - int driFd; - - tridentScreenPtr tridentScreen; /* Screen private DRI data */ - - /* Visual, drawable, cliprect and scissor information - */ - GLenum DrawBuffer; - GLint drawOffset, drawPitch; - GLint drawX, drawY; /* origin of drawable in draw buffer */ - GLint readOffset, readPitch; - - GLuint numClipRects; /* Cliprects for the draw buffer */ - drm_clip_rect_t *pClipRects; - - GLint scissor; - drm_clip_rect_t ScissorRect; /* Current software scissor */ - - GLuint Fallback; - GLuint RenderIndex; - GLuint SetupNewInputs; - GLuint SetupIndex; - GLfloat hw_viewport[16]; - GLfloat depth_scale; - GLuint vertex_format; - GLuint vertex_size; - GLuint vertex_stride_shift; - GLubyte *verts; - - GLint tmu_source[2]; - - GLuint hw_primitive; - GLenum render_primitive; - - trident_point_func draw_point; - trident_line_func draw_line; - trident_tri_func draw_tri; - trident_quad_func draw_quad; - -#if 0 - gammaTextureObjectPtr CurrentTexObj[2]; - struct gamma_texture_object_t TexObjList; - struct gamma_texture_object_t SwappedOut; - GLenum TexEnvImageFmt[2]; - - struct mem_block *texHeap; - - int lastSwap; - int texAge; - int ctxAge; - int dirtyAge; - int lastStamp; -#endif - - /* Chip state */ - - int commandD; - - /* Context State */ - - int ClearColor; -}; - -void tridentDDInitExtensions( GLcontext *ctx ); -void tridentDDInitDriverFuncs( GLcontext *ctx ); -void tridentDDInitSpanFuncs( GLcontext *ctx ); -void tridentDDInitState( tridentContextPtr tmesa ); -void tridentInitHW( tridentContextPtr tmesa ); -void tridentDDInitStateFuncs( GLcontext *ctx ); -void tridentDDInitTextureFuncs( GLcontext *ctx ); -void tridentDDInitTriFuncs( GLcontext *ctx ); - -extern void tridentBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ); -extern void tridentInitVB( GLcontext *ctx ); -extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv ); -extern void tridentFallback( tridentContextPtr tmesa, GLuint bit, - GLboolean mode ); -extern void tridentCheckTexSizes( GLcontext *ctx ); -extern void tridentChooseVertexState( GLcontext *ctx ); -extern void tridentDDUpdateHWState( GLcontext *ctx ); -extern void tridentUploadHwStateLocked( tridentContextPtr tmesa ); - -#define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx)) - -#endif /* _TRIDENT_CONTEXT_H_ */ diff --git a/src/mesa/drivers/dri/trident/trident_dd.c b/src/mesa/drivers/dri/trident/trident_dd.c deleted file mode 100644 index faa40c36a2..0000000000 --- a/src/mesa/drivers/dri/trident/trident_dd.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ -#include "trident_context.h" -#include "trident_lock.h" -#if defined(USE_X86_ASM) -#include "x86/common_x86_asm.h" -#endif - -#include "swrast/swrast.h" -#include "main/context.h" -#include "main/framebuffer.h" - -#define TRIDENT_DATE "20041223" - -/* Return the width and height of the current color buffer. - */ -static void tridentDDGetBufferSize( GLframebuffer *framebuffer, - GLuint *width, GLuint *height ) -{ - GET_CURRENT_CONTEXT(ctx); - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - - LOCK_HARDWARE(tmesa); - *width = tmesa->driDrawable->w; - *height = tmesa->driDrawable->h; - UNLOCK_HARDWARE(tmesa); -} - - -/* Return various strings for glGetString(). - */ -static const GLubyte *tridentDDGetString( GLcontext *ctx, GLenum name ) -{ - static char buffer[128]; - - switch ( name ) { - case GL_VENDOR: - return (GLubyte *)"Alan Hourihane"; - - case GL_RENDERER: - sprintf( buffer, "Mesa DRI Trident " TRIDENT_DATE ); - - /* Append any CPU-specific information. - */ -#ifdef USE_X86_ASM - if ( _mesa_x86_cpu_features ) { - strncat( buffer, " x86", 4 ); - } -#ifdef USE_MMX_ASM - if ( cpu_has_mmx ) { - strncat( buffer, "/MMX", 4 ); - } -#endif -#ifdef USE_3DNOW_ASM - if ( cpu_has_3dnow ) { - strncat( buffer, "/3DNow!", 7 ); - } -#endif -#ifdef USE_SSE_ASM - if ( cpu_has_xmm ) { - strncat( buffer, "/SSE", 4 ); - } -#endif -#endif - return (GLubyte *)buffer; - - default: - return NULL; - } -} - -/* Enable the extensions supported by this driver. - */ -void tridentDDInitExtensions( GLcontext *ctx ) -{ - /* None... */ -} - -/* Initialize the driver's misc functions. - */ -void tridentDDInitDriverFuncs( GLcontext *ctx ) -{ - ctx->Driver.GetBufferSize = tridentDDGetBufferSize; - ctx->Driver.GetString = tridentDDGetString; - ctx->Driver.Error = NULL; -} diff --git a/src/mesa/drivers/dri/trident/trident_dri.h b/src/mesa/drivers/dri/trident/trident_dri.h deleted file mode 100644 index c1ce3c4682..0000000000 --- a/src/mesa/drivers/dri/trident/trident_dri.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _TRIDENT_DRI_ -#define _TRIDENT_DRI_ - -#include "xf86drm.h" - -typedef struct { - drm_handle_t regs; - drmSize regsSize; - drmAddress regsMap; - int deviceID; - int width; - int height; - int mem; - int frontOffset; - int frontPitch; - int backOffset; - int backPitch; - int depthOffset; - int depthPitch; - int cpp; -#if 0 - int textureOffset; - int textureSize; -#endif - unsigned int sarea_priv_offset; -} TRIDENTDRIRec, *TRIDENTDRIPtr; - -#endif diff --git a/src/mesa/drivers/dri/trident/trident_lock.h b/src/mesa/drivers/dri/trident/trident_lock.h deleted file mode 100644 index ee0819f5ca..0000000000 --- a/src/mesa/drivers/dri/trident/trident_lock.h +++ /dev/null @@ -1,11 +0,0 @@ -/* XXX tridentGetLock doesn't exist... */ - -#define LOCK_HARDWARE(tmesa) \ - do { \ - char __ret = 0; \ - DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \ - DRM_LOCK_HELD | tmesa->hHWContext, __ret); \ - } while (0) - -#define UNLOCK_HARDWARE(tmesa) \ - DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext) diff --git a/src/mesa/drivers/dri/trident/trident_state.c b/src/mesa/drivers/dri/trident/trident_state.c deleted file mode 100644 index e68d3a73c6..0000000000 --- a/src/mesa/drivers/dri/trident/trident_state.c +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ -#include "trident_context.h" -#include "trident_lock.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "main/framebuffer.h" - -#define TRIDENTPACKCOLOR332(r, g, b) \ - (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6)) - -#define TRIDENTPACKCOLOR1555(r, g, b, a) \ - ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \ - ((a) ? 0x8000 : 0)) - -#define TRIDENTPACKCOLOR565(r, g, b) \ - ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3)) - -#define TRIDENTPACKCOLOR888(r, g, b) \ - (((r) << 16) | ((g) << 8) | (b)) - -#define TRIDENTPACKCOLOR8888(r, g, b, a) \ - (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -#define TRIDENTPACKCOLOR4444(r, g, b, a) \ - ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) - -static INLINE GLuint tridentPackColor( GLuint cpp, - GLubyte r, GLubyte g, - GLubyte b, GLubyte a ) -{ - switch ( cpp ) { - case 2: - return TRIDENTPACKCOLOR565( r, g, b ); - case 4: - return TRIDENTPACKCOLOR8888( r, g, b, a ); - default: - return 0; - } -} - -void tridentUploadHwStateLocked( tridentContextPtr tmesa ) -{ - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; -#if 0 - ATISAREAPrivPtr sarea = tmesa->sarea; - trident_context_regs_t *regs = &(sarea->ContextState); -#endif - - if ( tmesa->dirty & TRIDENT_UPLOAD_COMMAND_D ) { - MMIO_OUT32(MMIO, 0x00281C, tmesa->commandD ); - tmesa->dirty &= ~TRIDENT_UPLOAD_COMMAND_D; - } - - if ( tmesa->dirty & TRIDENT_UPLOAD_CLIPRECTS ) { - /* XXX FIX ME ! */ - MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height ); - MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width ); - tmesa->dirty &= ~TRIDENT_UPLOAD_CLIPRECTS; - } - - tmesa->dirty = 0; -} - -/* Copy the back color buffer to the front color buffer. - */ -void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv ) -{ - unsigned char *MMIO; - tridentContextPtr tmesa; - GLint nbox, i; - int busy; - drm_clip_rect_t *pbox; - - assert(dPriv); - assert(dPriv->driContextPriv); - assert(dPriv->driContextPriv->driverPrivate); - - tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate; - MMIO = tmesa->tridentScreen->mmio.map; - - LOCK_HARDWARE( tmesa ); - - /* use front buffer cliprects */ - nbox = dPriv->numClipRects; - pbox = dPriv->pClipRects; - - for ( i = 0 ; i < nbox ; i++ ) { -#if 0 - GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox ); - drm_clip_rect_t *b = tmesa->sarea->boxes; - GLint n = 0; - - for ( ; i < nr ; i++ ) { - *b++ = pbox[i]; - n++; - } - tmesa->sarea->nbox = n; -#endif - - MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4); - MMIO_OUT32(MMIO, 0x2154, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4); - MMIO_OUT8(MMIO, 0x2127, 0xCC); /* Copy Rop */ - MMIO_OUT32(MMIO, 0x2128, 0x4); /* scr2scr */ - MMIO_OUT32(MMIO, 0x2138, (pbox->x1 << 16) | pbox->y1); - MMIO_OUT32(MMIO, 0x213C, (pbox->x1 << 16) | pbox->y1); - MMIO_OUT32(MMIO, 0x2140, (pbox->x2 - pbox->x1) << 16 | (pbox->y2 - pbox->y1) ); - MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */ -#define GE_BUSY 0x80 - for (;;) { - busy = MMIO_IN8(MMIO, 0x2120); - if ( !(busy & GE_BUSY) ) - break; - } - } - - UNLOCK_HARDWARE( tmesa ); - -#if 0 - tmesa->dirty |= (MACH64_UPLOAD_CONTEXT | - MACH64_UPLOAD_MISC | - MACH64_UPLOAD_CLIPRECTS); -#endif -} - - -static void tridentDDClear( GLcontext *ctx, GLbitfield mask ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; - int busy; - GLuint flags = 0; - GLint i; - GLint cx, cy, cw, ch; - -#define DRM_TRIDENT_FRONT 0x01 -#define DRM_TRIDENT_BACK 0x02 -#define DRM_TRIDENT_DEPTH 0x04 - - if ( tmesa->new_state ) - tridentDDUpdateHWState( ctx ); - - if ( mask & BUFFER_BIT_FRONT_LEFT ) { - flags |= DRM_TRIDENT_FRONT; - mask &= ~BUFFER_BIT_FRONT_LEFT; - } - - if ( mask & BUFFER_BIT_BACK_LEFT ) { - flags |= DRM_TRIDENT_BACK; - mask &= ~BUFFER_BIT_BACK_LEFT; - } - - if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) { - flags |= DRM_TRIDENT_DEPTH; - mask &= ~BUFFER_BIT_DEPTH; - } - - LOCK_HARDWARE(tmesa); - - /* get region after locking: */ - cx = ctx->DrawBuffer->_Xmin; - cy = ctx->DrawBuffer->_Ymin; - cw = ctx->DrawBuffer->_Xmax - cx; - ch = ctx->DrawBuffer->_Ymax - cy; - - if ( flags ) { - - cx += tmesa->drawX; - cy += tmesa->drawY; - - /* HACK!!! - */ - if ( tmesa->dirty & ~TRIDENT_UPLOAD_CLIPRECTS ) { - tridentUploadHwStateLocked( tmesa ); - } - - for ( i = 0 ; i < tmesa->numClipRects ; i++ ) { -#if 0 - int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects ); - drm_clip_rect_t *box = tmesa->pClipRects; - drm_clip_rect_t *b = tmesa->sarea->boxes; - GLint n = 0; - - if ( !all ) { - for ( ; i < nr ; i++ ) { - GLint x = box[i].x1; - GLint y = box[i].y1; - GLint w = box[i].x2 - x; - GLint h = box[i].y2 - y; - - if ( x < cx ) w -= cx - x, x = cx; - if ( y < cy ) h -= cy - y, y = cy; - if ( x + w > cx + cw ) w = cx + cw - x; - if ( y + h > cy + ch ) h = cy + ch - y; - if ( w <= 0 ) continue; - if ( h <= 0 ) continue; - - b->x1 = x; - b->y1 = y; - b->x2 = x + w; - b->y2 = y + h; - b++; - n++; - } - } else { - for ( ; i < nr ; i++ ) { - *b++ = box[i]; - n++; - } - } - - tmesa->sarea->nbox = n; -#endif - -if (flags & DRM_TRIDENT_BACK) { - MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4); - MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */ - MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor); - MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */ - MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy); - MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch); - MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */ -#define GE_BUSY 0x80 - for (;;) { - busy = MMIO_IN8(MMIO, 0x2120); - if ( !(busy & GE_BUSY) ) - break; - } -} -if (flags & DRM_TRIDENT_DEPTH) { - MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->depthPitch << 20 | tmesa->tridentScreen->depthOffset>>4); - MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */ - MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor); - MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */ - MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy); - MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch); - MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */ -#define GE_BUSY 0x80 - for (;;) { - busy = MMIO_IN8(MMIO, 0x2120); - if ( !(busy & GE_BUSY) ) - break; - } -} - MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4); -if (flags & DRM_TRIDENT_FRONT) { - MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */ - MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor); - MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */ - MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy); - MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch); - MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */ -#define GE_BUSY 0x80 - for (;;) { - busy = MMIO_IN8(MMIO, 0x2120); - if ( !(busy & GE_BUSY) ) - break; - } -} - - } - -#if 0 - tmesa->dirty |= (TRIDENT_UPLOAD_CONTEXT | - TRIDENT_UPLOAD_MISC | - TRIDENT_UPLOAD_CLIPRECTS); -#endif - } - - UNLOCK_HARDWARE(tmesa); - - if ( mask ) - _swrast_Clear( ctx, mask ); -} - -static void tridentDDShadeModel( GLcontext *ctx, GLenum mode ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - GLuint s = tmesa->commandD; - -#define TRIDENT_FLAT_SHADE 0x000000E0 -#define TRIDENT_FLAT_SHADE_VERTEX_C 0x00000060 -#define TRIDENT_FLAT_SHADE_GOURAUD 0x00000080 - - s &= ~TRIDENT_FLAT_SHADE; - - switch ( mode ) { - case GL_FLAT: - s |= TRIDENT_FLAT_SHADE_VERTEX_C; - break; - case GL_SMOOTH: - s |= TRIDENT_FLAT_SHADE_GOURAUD; - break; - default: - return; - } - - if ( tmesa->commandD != s ) { - tmesa->commandD = s; - - tmesa->dirty |= TRIDENT_UPLOAD_COMMAND_D; - } -} - -static void -tridentCalcViewport( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - const GLfloat *v = ctx->Viewport._WindowMap.m; - GLfloat *m = tmesa->hw_viewport; - - /* See also trident_translate_vertex. - */ - m[MAT_SX] = v[MAT_SX]; - m[MAT_TX] = v[MAT_TX] + tmesa->drawX + SUBPIXEL_X; - m[MAT_SY] = - v[MAT_SY]; - m[MAT_TY] = - v[MAT_TY] + tmesa->driDrawable->h + tmesa->drawY + SUBPIXEL_Y; -#if 0 - m[MAT_SZ] = v[MAT_SZ] * tmesa->depth_scale; - m[MAT_TZ] = v[MAT_TZ] * tmesa->depth_scale; -#else - m[MAT_SZ] = v[MAT_SZ]; - m[MAT_TZ] = v[MAT_TZ]; -#endif - - tmesa->SetupNewInputs = ~0; -} - -static void tridentDDViewport( GLcontext *ctx, - GLint x, GLint y, - GLsizei width, GLsizei height ) -{ - tridentCalcViewport( ctx ); -} - -static void tridentDDDepthRange( GLcontext *ctx, - GLclampd nearval, GLclampd farval ) -{ - tridentCalcViewport( ctx ); -} - -static void -tridentSetCliprects( tridentContextPtr tmesa, GLenum mode ) -{ - __DRIdrawablePrivate *dPriv = tmesa->driDrawable; - - switch ( mode ) { - case GL_FRONT_LEFT: - if (dPriv->numClipRects == 0) { - static drm_clip_rect_t zeroareacliprect = {0,0,0,0}; - tmesa->numClipRects = 1; - tmesa->pClipRects = &zeroareacliprect; - } else { - tmesa->numClipRects = dPriv->numClipRects; - tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects; - } - tmesa->drawX = dPriv->x; - tmesa->drawY = dPriv->y; - break; - case GL_BACK_LEFT: - if ( dPriv->numBackClipRects == 0 ) { - if (dPriv->numClipRects == 0) { - static drm_clip_rect_t zeroareacliprect = {0,0,0,0}; - tmesa->numClipRects = 1; - tmesa->pClipRects = &zeroareacliprect; - } else { - tmesa->numClipRects = dPriv->numClipRects; - tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects; - tmesa->drawX = dPriv->x; - tmesa->drawY = dPriv->y; - } - } - else { - tmesa->numClipRects = dPriv->numBackClipRects; - tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects; - tmesa->drawX = dPriv->backX; - tmesa->drawY = dPriv->backY; - } - break; - default: - return; - } - -#if 0 - tmesa->dirty |= TRIDENT_UPLOAD_CLIPRECTS; -#endif -} - -#if 0 -static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - int found = GL_TRUE; - - if ( tmesa->DrawBuffer != mode ) { - tmesa->DrawBuffer = mode; - - switch ( mode ) { - case GL_FRONT_LEFT: - tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE ); - tmesa->drawOffset = tmesa->tridentScreen->frontOffset; - tmesa->drawPitch = tmesa->tridentScreen->frontPitch; - tridentSetCliprects( tmesa, GL_FRONT_LEFT ); - break; - case GL_BACK_LEFT: - tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE ); - tmesa->drawOffset = tmesa->tridentScreen->backOffset; - tmesa->drawPitch = tmesa->tridentScreen->backPitch; - tridentSetCliprects( tmesa, GL_BACK_LEFT ); - break; - default: - tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_TRUE ); - found = GL_FALSE; - break; - } - -#if 0 - tmesa->setup.dst_off_pitch = (((tmesa->drawPitch/8) << 22) | - (tmesa->drawOffset >> 3)); - - tmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH | MACH64_UPLOAD_CONTEXT; -#endif - - } - - return found; -} - -static void tridentDDClearColor( GLcontext *ctx, - const GLchan color[4] ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - - tmesa->ClearColor = tridentPackColor( tmesa->tridentScreen->cpp, - color[0], color[1], - color[2], color[3] ); -} -#endif - -static void -tridentDDUpdateState( GLcontext *ctx, GLuint new_state ) -{ - _swrast_InvalidateState( ctx, new_state ); - _swsetup_InvalidateState( ctx, new_state ); - _vbo_InvalidateState( ctx, new_state ); - _tnl_InvalidateState( ctx, new_state ); - TRIDENT_CONTEXT(ctx)->new_gl_state |= new_state; -} - - -/* Initialize the context's hardware state. - */ -void tridentDDInitState( tridentContextPtr tmesa ) -{ - tmesa->new_state = 0; - - switch ( tmesa->glCtx->Visual.depthBits ) { - case 16: - tmesa->depth_scale = 1.0 / (GLfloat)0xffff; - break; - case 24: - tmesa->depth_scale = 1.0 / (GLfloat)0xffffff; - break; - } -} - -void tridentDDUpdateHWState( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - int new_state = tmesa->new_state; - - if ( new_state ) - { - tmesa->new_state = 0; - -#if 0 - /* Update the various parts of the context's state. - */ - if ( new_state & GAMMA_NEW_ALPHA ) - tridentUpdateAlphaMode( ctx ); - - if ( new_state & GAMMA_NEW_DEPTH ) - tridentUpdateZMode( ctx ); - - if ( new_state & GAMMA_NEW_FOG ) - gammaUpdateFogAttrib( ctx ); - - if ( new_state & GAMMA_NEW_CLIP ) - gammaUpdateClipping( ctx ); - - if ( new_state & GAMMA_NEW_POLYGON ) - gammaUpdatePolygon( ctx ); - - if ( new_state & GAMMA_NEW_CULL ) - gammaUpdateCull( ctx ); - - if ( new_state & GAMMA_NEW_MASKS ) - gammaUpdateMasks( ctx ); - - if ( new_state & GAMMA_NEW_STIPPLE ) - gammaUpdateStipple( ctx ); -#endif - } - - /* HACK ! */ - -#if 0 - gammaEmitHwState( tmesa ); -#endif -} - -/* Initialize the driver's state functions. - */ -void tridentDDInitStateFuncs( GLcontext *ctx ) -{ - ctx->Driver.UpdateState = tridentDDUpdateState; - - ctx->Driver.Clear = tridentDDClear; - ctx->Driver.DepthRange = tridentDDDepthRange; - ctx->Driver.ShadeModel = tridentDDShadeModel; - ctx->Driver.Viewport = tridentDDViewport; -} diff --git a/src/mesa/drivers/dri/trident/trident_tris.c b/src/mesa/drivers/dri/trident/trident_tris.c deleted file mode 100644 index ee85ab482c..0000000000 --- a/src/mesa/drivers/dri/trident/trident_tris.c +++ /dev/null @@ -1,1125 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ - -#include "trident_context.h" -#include "trident_lock.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" -#include "swrast/swrast.h" -#include "swrast_setup/swrast_setup.h" - -static int first = 1; - -typedef struct reg { - int addr; - int data; -} RegData; - -RegData initRegData[]={ - {0x2804, 0x19980824}, - {0x2F70, 0x46455858}, - {0x2F74, 0x41584998}, - {0x2F00, 0x00000000}, - {0x2F04, 0x80000800}, - {0x2F08, 0x00550200}, - {0x2F40, 0x00000001}, - {0x2F40, 0x00000001}, - {0x2F44, 0x00830097}, - {0x2F48, 0x0087009F}, - {0x2F4C, 0x00BF0003}, - {0x2F50, 0xF00B6C1B}, - {0x2C04, 0x00000000}, - {0x2D00, 0x00000080}, - {0x2D00, 0x00000000}, - {0x2DD4, 0x00100000}, - {0x2DD4, 0x00100010}, - {0x2DD8, 0x00100000}, - {0x2DD8, 0x00100010}, - {0x2C88, 0xFFFFFFFF}, - {0x2C94 , 0xFFFFFFFF}, - {0x281C, 0x00008000}, - {0x2C80, 0x00000000}, - {0x2C80, 0x00000000}, - {0x2C80 , 0x00008000}, - {0x2C00 , 0x00000000}, - {0x2C04 , 0x00000000}, - {0x2C08 , 0x00000000}, - {0x2C0C , 0x00000000}, - {0x2C10 , 0x00000000}, - {0x2C14 , 0x00000000}, - {0x2C18 , 0x00000000}, - {0x2C1C , 0x00000000}, - {0x2C20 , 0x00000000}, - {0x2C24 , 0x00000000}, - {0x2C2C , 0x00000000}, - {0x2C30 , 0x00000000}, - {0x2C34 , 0x00000000}, - {0x2C38 , 0x00000000}, - {0x2C3C , 0x00000000}, - {0x2C40 , 0x00000000}, - {0x2C44 , 0x00000000}, - {0x2C48 , 0x00000000}, - {0x2C4C , 0x00000000}, - {0x2C50 , 0x00000000}, - {0x2C54 , 0x00000000}, - {0x2C58 , 0x00000000}, - {0x2C5C , 0x00000000}, - {0x2C60 , 0x00000000}, - {0x2C64 , 0x00000000}, - {0x2C68 , 0x00000000}, - {0x2C6C , 0x00000000}, - {0x2C70 , 0x00000000}, - {0x2C74 , 0x00000000}, - {0x2C78 , 0x00000000}, - {0x2C7C , 0x00000000}, - {0x2C80 , 0x00008000}, - {0x2C84 , 0x00000000}, - {0x2C88 , 0xFFFFFFFF}, - {0x2C8C , 0x00000000}, - {0x2C90 , 0x00000000}, - {0x2C94 , 0xFFFFFFFF}, - {0x2C98 , 0x00000000}, - {0x2C9C , 0x00000000}, - {0x2CA0 , 0x00000000}, - {0x2CA4 , 0x00000000}, - {0x2CA8 , 0x00000000}, - {0x2CAC , 0x00000000}, - {0x2CB0 , 0x00000000}, - {0x2CB4 , 0x00000000}, - {0x2CB8 , 0x00000000}, - {0x2CBC , 0x00000000}, - {0x2CC0 , 0x00000000}, - {0x2CC4 , 0x00000000}, - {0x2CC8 , 0x00000000}, - {0x2CCC , 0x00000000}, - {0x2CD0 , 0x00000000}, - {0x2CD4 , 0x00000000}, - {0x2CD8 , 0x00000000}, - {0x2CDC , 0x00000000}, - {0x2CE0 , 0x00000000}, - {0x2CE4 , 0x00000000}, - {0x2CE8 , 0x00000000}, - {0x2CEC , 0x00000000}, - {0x2CF0 , 0x00000000}, - {0x2CF4 , 0x00000000}, - {0x2CF8 , 0x00000000}, - {0x2CFC , 0x00000000}, - {0x2D00 , 0x00000000}, - {0x2D04 , 0x00000000}, - {0x2D08 , 0x00000000}, - {0x2D0C , 0x00000000}, - {0x2D10 , 0x00000000}, - {0x2D14 , 0x00000000}, - {0x2D18 , 0x00000000}, - {0x2D1C , 0x00000000}, - {0x2D20 , 0x00000000}, - {0x2D24 , 0x00000000}, - {0x2D28 , 0x00000000}, - {0x2D2C , 0x00000000}, - {0x2D30 , 0x00000000}, - {0x2D34 , 0x00000000}, - {0x2D38 , 0x00000000}, - {0x2D3C , 0x00000000}, - {0x2D40 , 0x00000000}, - {0x2D44 , 0x00000000}, - {0x2D48 , 0x00000000}, - {0x2D4C , 0x00000000}, - {0x2D50 , 0x00000000}, - {0x2D54 , 0x00000000}, - {0x2D58 , 0x00000000}, - {0x2D5C , 0x00000000}, - {0x2D60 , 0x00000000}, - {0x2D64 , 0x00000000}, - {0x2D68 , 0x00000000}, - {0x2D6C , 0x00000000}, - {0x2D70 , 0x00000000}, - {0x2D74 , 0x00000000}, - {0x2D78 , 0x00000000}, - {0x2D7C , 0x00000000}, - {0x2D80 , 0x00000000}, - {0x2D84 , 0x00000000}, - {0x2D88 , 0x00000000}, - {0x2D8C , 0x00000000}, - {0x2D90 , 0x00000000}, - {0x2D94 , 0x00000000}, - {0x2D98 , 0x00000000}, - {0x2D9C , 0x00000000}, - {0x2DA0 , 0x00000000}, - {0x2DA4 , 0x00000000}, - {0x2DA8 , 0x00000000}, - {0x2DAC , 0x00000000}, - {0x2DB0 , 0x00000000}, - {0x2DB4 , 0x00000000}, - {0x2DB8 , 0x00000000}, - {0x2DBC , 0x00000000}, - {0x2DC0 , 0x00000000}, - {0x2DC4 , 0x00000000}, - {0x2DC8 , 0x00000000}, - {0x2DCC , 0x00000000}, - {0x2DD0 , 0x00000000}, - {0x2DD4 , 0x00100010}, - {0x2DD8 , 0x00100010}, - {0x2DDC , 0x00000000}, - {0x2DE0 , 0x00000000}, - {0x2DE4 , 0x00000000}, - {0x2DE8 , 0x00000000}, - {0x2DEC , 0x00000000}, - {0x2DF0 , 0x00000000}, - {0x2DF4 , 0x00000000}, - {0x2DF8 , 0x00000000}, - {0x2DFC , 0x00000000}, - {0x2E00 , 0x00000000}, - {0x2E04 , 0x00000000}, - {0x2E08 , 0x00000000}, - {0x2E0C , 0x00000000}, - {0x2E10 , 0x00000000}, - {0x2E14 , 0x00000000}, - {0x2E18 , 0x00000000}, - {0x2E1C , 0x00000000}, - {0x2E20 , 0x00000000}, - {0x2E24 , 0x00000000}, - {0x2E28 , 0x00000000}, - {0x2E2C , 0x00000000}, - {0x2E30 , 0x00000000}, - {0x2E34 , 0x00000000}, - {0x2E38 , 0x00000000}, - {0x2E3C , 0x00000000}, - {0x2E40 , 0x00000000}, - {0x2E44 , 0x00000000}, - {0x2E48 , 0x00000000}, - {0x2E4C , 0x00000000}, - {0x2E50 , 0x00000000}, - {0x2E54 , 0x00000000}, - {0x2E58 , 0x00000000}, - {0x2E5C , 0x00000000}, - {0x2E60 , 0x00000000}, - {0x2E64 , 0x00000000}, - {0x2E68 , 0x00000000}, - {0x2E6C , 0x00000000}, - {0x2E70 , 0x00000000}, - {0x2E74 , 0x00000000}, - {0x2E78 , 0x00000000}, - {0x2E7C , 0x00000000}, - {0x2E80 , 0x00000000}, - {0x2E84 , 0x00000000}, - {0x2E88 , 0x00000000}, - {0x2E8C , 0x00000000}, - {0x2E90 , 0x00000000}, - {0x2E94 , 0x00000000}, - {0x2E98 , 0x00000000}, - {0x2E9C , 0x00000000}, - {0x2EA0 , 0x00000000}, - {0x2EA4 , 0x00000000}, - {0x2EA8 , 0x00000000}, - {0x2EAC , 0x00000000}, - {0x2EB0 , 0x00000000}, - {0x2EB4 , 0x00000000}, - {0x2EB8 , 0x00000000}, - {0x2EBC , 0x00000000}, - {0x2EC0 , 0x00000000}, - {0x2EC4 , 0x00000000}, - {0x2EC8 , 0x00000000}, - {0x2ECC , 0x00000000}, - {0x2ED0 , 0x00000000}, - {0x2ED4 , 0x00000000}, - {0x2ED8 , 0x00000000}, - {0x2EDC , 0x00000000}, - {0x2EE0 , 0x00000000}, - {0x2EE4 ,0x00000000}, - {0x2EE8 ,0x00000000}, - {0x2EEC , 0x00000000}, - {0x2EF0 , 0x00000000}, - {0x2EF4 , 0x00000000}, - {0x2EF8 , 0x00000000}, - {0x2EFC , 0x00000000}, - /*{0x2F60 , 0x00000000},*/ -}; - -int initRegDataNum=sizeof(initRegData)/sizeof(RegData); - -typedef union { - unsigned int i; - float f; -} dmaBufRec, *dmaBuf; - -void Init3D( tridentContextPtr tmesa ) -{ - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; - int i; - - for(i=0;itridentScreen->mmio.map; - dmaBufRec clr; - -printf("DRAW TRI\n"); - Init3D(tmesa); - -printf("ENGINE STATUS 0x%x\n",MMIO_IN32(MMIO, 0x2800)); - MMIO_OUT32(MMIO, 0x002800, 0x00000000 ); -#if 0 - MMIO_OUT32(MMIO, 0x002368 , MMIO_IN32(MMIO,0x002368)|1 ); -#endif - - MMIO_OUT32(MMIO, 0x002C00 , 0x00000014 ); -#if 0 - MMIO_OUT32(MMIO, 0x002C04 , 0x0A8004C0 ); -#else - MMIO_OUT32(MMIO, 0x002C04 , 0x0A8000C0 ); -#endif - -#if 0 - MMIO_OUT32(MMIO, 0x002C08 , 0x00000000 ); - MMIO_OUT32(MMIO, 0x002C0C , 0xFFCCCCCC ); - MMIO_OUT32(MMIO, 0x002C10 , 0x3F800000 ); - MMIO_OUT32(MMIO, 0x002C14 , 0x3D0D3DCB ); - MMIO_OUT32(MMIO, 0x002C2C , 0x70000000 ); - MMIO_OUT32(MMIO, 0x002C24 , 0x00202C00 ); - MMIO_OUT32(MMIO, 0x002C28 , 0xE0002500 ); - MMIO_OUT32(MMIO, 0x002C30 , 0x00000000 ); - MMIO_OUT32(MMIO, 0x002C34 , 0xE0000000 ); - MMIO_OUT32(MMIO, 0x002C38 , 0x00000000 ); -#endif - - MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 ); - MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 ); - MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 ); - MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 ); - MMIO_OUT32(MMIO, 0x002C80 , 0x20008258 ); - MMIO_OUT32(MMIO, 0x002C84 , 0x20000320 ); - MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF ); - -#if 0 - MMIO_OUT32(MMIO, 0x002D00 , 0x00009009 ); - MMIO_OUT32(MMIO, 0x002D38 , 0x00000000 ); - MMIO_OUT32(MMIO, 0x002D94 , 0x20002000 ); - MMIO_OUT32(MMIO, 0x002D50 , 0xf0000000 ); - MMIO_OUT32(MMIO, 0x002D80 , 0x24002000 ); - MMIO_OUT32(MMIO, 0x002D98 , 0x81000000 ); - MMIO_OUT32(MMIO, 0x002DB0 , 0x81000000 ); - MMIO_OUT32(MMIO, 0x002DC8 , 0x808000FF ); - MMIO_OUT32(MMIO, 0x002DD4 , 0x02000200 ); - MMIO_OUT32(MMIO, 0x002DD8 , 0x02000200 ); - MMIO_OUT32(MMIO, 0x002D30 , 0x02092400 ); - MMIO_OUT32(MMIO, 0x002D04 , 0x00102120 ); - MMIO_OUT32(MMIO, 0x002D08 , 0xFFFFFFFF ); - MMIO_OUT32(MMIO, 0x002D0C , 0xF00010D0 ); - MMIO_OUT32(MMIO, 0x002D10 , 0xC0000400 ); -#endif - - MMIO_OUT32(MMIO, 0x002814, 0x00000000 ); -#if 0 - MMIO_OUT32(MMIO, 0x002818 , 0x00036C20 ); -#else - MMIO_OUT32(MMIO, 0x002818 , 0x00036020 ); -#endif - MMIO_OUT32(MMIO, 0x00281C , 0x00098081 ); - -printf("first TRI\n"); - clr.f = 5.0; - MMIO_OUT32(MMIO, 0x002820 , clr.i ); - clr.f = 595.0; - MMIO_OUT32(MMIO, 0x002824 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002828 , clr.i ); - MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 ); -#if 0 - clr.f = 0.0; - MMIO_OUT32(MMIO, 0x002830 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002834 , clr.i ); -#endif - - clr.f = 5.0; - MMIO_OUT32(MMIO, 0x002820 , clr.i ); - clr.f = 5.0; - MMIO_OUT32(MMIO, 0x002824 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002828 , clr.i ); - MMIO_OUT32(MMIO, 0x00282C , 0xFF0000 ); -#if 0 - clr.f = 0.0; - MMIO_OUT32(MMIO, 0x002830 , clr.i ); - clr.f = 0.0; - MMIO_OUT32(MMIO, 0x002834 , clr.i ); -#endif - - clr.f = 395.0; -printf("0x%x\n",clr.i); - MMIO_OUT32(MMIO, 0x002820 , clr.i ); - clr.f = 5.0; - MMIO_OUT32(MMIO, 0x002824 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002828 , clr.i ); - MMIO_OUT32(MMIO, 0x00282C , 0xFF ); -#if 0 - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002830 , clr.i ); - clr.f = 0.0; - MMIO_OUT32(MMIO, 0x002834 , clr.i ); -#endif - -printf("sec TRI\n"); - MMIO_OUT32(MMIO, 0x00281C , 0x00093980 ); - clr.f = 395.0; - MMIO_OUT32(MMIO, 0x002820 , clr.i ); - clr.f = 595.0; - MMIO_OUT32(MMIO, 0x002824 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002828 , clr.i ); - MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 ); -#if 0 - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002830 , clr.i ); - clr.f = 1.0; - MMIO_OUT32(MMIO, 0x002834 , clr.i ); -#endif - -#if 0 - MMIO_OUT32(MMIO, 0x002368 , MMIO_IN32(MMIO,0x002368)&0xfffffffe ); -#endif - -printf("fin TRI\n"); - - return 0; -} - -static INLINE void trident_draw_point(tridentContextPtr tmesa, - const tridentVertex *v0 ) -{ - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; - (void) MMIO; -} - -static INLINE void trident_draw_line( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1 ) -{ - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; - (void) MMIO; -} - -static INLINE void trident_draw_triangle( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1, - const tridentVertex *v2 ) -{ -} - -static INLINE void trident_draw_quad( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1, - const tridentVertex *v2, - const tridentVertex *v3 ) -{ - GLuint vertsize = tmesa->vertex_size; - GLint coloridx = (vertsize > 4) ? 4 : 3; - unsigned char *MMIO = tmesa->tridentScreen->mmio.map; - int clr; - float *ftmp = (float *)(&clr); - - if (tmesa->dirty) - tridentUploadHwStateLocked( tmesa ); -#if 0 - DrawTriangle(tmesa); - exit(0); -#else -#if 1 - if (first) { - Init3D(tmesa); -#if 0 - DrawTriangle(tmesa); -#endif - first = 0; - } -#endif - - LOCK_HARDWARE( tmesa ); - - MMIO_OUT32(MMIO, 0x002C00 , 0x00000010 ); - MMIO_OUT32(MMIO, 0x002C04 , 0x029C00C0 ); - - /* Z buffer */ - MMIO_OUT32(MMIO, 0x002C24 , 0x00100000 /*| (tmesa->tridentScreen->depthOffset)*/ ); - MMIO_OUT32(MMIO, 0x002C28 , 0xE0000000 | (tmesa->tridentScreen->depthPitch * 4) ); - - /* front buffer */ - MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 | (tmesa->drawOffset) ); - MMIO_OUT32(MMIO, 0x002C54 , 0x0C320000 | (tmesa->drawPitch * 4) ); - - /* clipper */ - MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height ); - MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width ); - - /* writemask */ - MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF ); - -if (vertsize == 4) { - MMIO_OUT32(MMIO, 0x002818 , 0x0003A020 ); - MMIO_OUT32(MMIO, 0x00281C , 0x00098021 ); - - *ftmp = v0->v.x; - MMIO_OUT32(MMIO, 0x002820 , clr ); - *ftmp = v0->v.y; - MMIO_OUT32(MMIO, 0x002824 , clr ); - *ftmp = v0->v.z; - MMIO_OUT32(MMIO, 0x002828 , clr ); -#if 0 - *ftmp = v0->v.w; - MMIO_OUT32(MMIO, 0x00282C , clr ); -#endif - MMIO_OUT32(MMIO, 0x00282C , v0->ui[coloridx] ); - - *ftmp = v1->v.x; - MMIO_OUT32(MMIO, 0x002820 , clr ); - *ftmp = v1->v.y; - MMIO_OUT32(MMIO, 0x002824 , clr ); - *ftmp = v1->v.z; - MMIO_OUT32(MMIO, 0x002828 , clr ); -#if 0 - *ftmp = v1->v.w; - MMIO_OUT32(MMIO, 0x00282C , clr ); -#endif - MMIO_OUT32(MMIO, 0x00282C , v1->ui[coloridx] ); - - *ftmp = v2->v.x; - MMIO_OUT32(MMIO, 0x002820 , clr ); - *ftmp = v2->v.y; - MMIO_OUT32(MMIO, 0x002824 , clr ); - *ftmp = v2->v.z; - MMIO_OUT32(MMIO, 0x002828 , clr ); -#if 0 - *ftmp = v2->v.w; - MMIO_OUT32(MMIO, 0x00282C , clr ); -#endif - MMIO_OUT32(MMIO, 0x00282C , v2->ui[coloridx] ); - - MMIO_OUT32(MMIO, 0x00281C , 0x00093020 ); - *ftmp = v3->v.x; - MMIO_OUT32(MMIO, 0x002820 , clr ); - *ftmp = v3->v.y; - MMIO_OUT32(MMIO, 0x002824 , clr ); - *ftmp = v3->v.z; - MMIO_OUT32(MMIO, 0x002828 , clr ); -#if 0 - *ftmp = v3->v.w; - MMIO_OUT32(MMIO, 0x00282C , clr ); -#endif - MMIO_OUT32(MMIO, 0x00282C , v3->ui[coloridx] ); - -} -#endif - - UNLOCK_HARDWARE( tmesa ); -} -/*********************************************************************** - * Rasterization fallback helpers * - ***********************************************************************/ - - -/* This code is hit only when a mix of accelerated and unaccelerated - * primitives are being drawn, and only for the unaccelerated - * primitives. - */ -#if 0 -static void -trident_fallback_quad( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1, - const tridentVertex *v2, - const tridentVertex *v3 ) -{ - GLcontext *ctx = tmesa->glCtx; - SWvertex v[4]; - trident_translate_vertex( ctx, v0, &v[0] ); - trident_translate_vertex( ctx, v1, &v[1] ); - trident_translate_vertex( ctx, v2, &v[2] ); - trident_translate_vertex( ctx, v3, &v[3] ); - _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); -} -#endif - -/* XXX hack to get the prototype defined in time... */ -void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src, - SWvertex *dst); - -static void -trident_fallback_tri( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1, - const tridentVertex *v2 ) -{ - GLcontext *ctx = tmesa->glCtx; - SWvertex v[3]; - trident_translate_vertex( ctx, v0, &v[0] ); - trident_translate_vertex( ctx, v1, &v[1] ); - trident_translate_vertex( ctx, v2, &v[2] ); - _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); -} - -static void -trident_fallback_line( tridentContextPtr tmesa, - const tridentVertex *v0, - const tridentVertex *v1 ) -{ - GLcontext *ctx = tmesa->glCtx; - SWvertex v[2]; - trident_translate_vertex( ctx, v0, &v[0] ); - trident_translate_vertex( ctx, v1, &v[1] ); - _swrast_Line( ctx, &v[0], &v[1] ); -} - - -static void -trident_fallback_point( tridentContextPtr tmesa, - const tridentVertex *v0 ) -{ - GLcontext *ctx = tmesa->glCtx; - SWvertex v[1]; - trident_translate_vertex( ctx, v0, &v[0] ); - _swrast_Point( ctx, &v[0] ); -} - -/*********************************************************************** - * Macros for t_dd_tritmp.h to draw basic primitives * - ***********************************************************************/ - -#define TRI( a, b, c ) \ -do { \ - if (DO_FALLBACK) \ - tmesa->draw_tri( tmesa, a, b, c ); \ - else \ - trident_draw_triangle( tmesa, a, b, c ); \ -} while (0) - -#define QUAD( a, b, c, d ) \ -do { \ - if (DO_FALLBACK) { \ - tmesa->draw_tri( tmesa, a, b, d ); \ - tmesa->draw_tri( tmesa, b, c, d ); \ - } else \ - trident_draw_quad( tmesa, a, b, c, d ); \ -} while (0) - -#define LINE( v0, v1 ) \ -do { \ - if (DO_FALLBACK) \ - tmesa->draw_line( tmesa, v0, v1 ); \ - else \ - trident_draw_line( tmesa, v0, v1 ); \ -} while (0) - -#define POINT( v0 ) \ -do { \ - if (DO_FALLBACK) \ - tmesa->draw_point( tmesa, v0 ); \ - else \ - trident_draw_point( tmesa, v0 ); \ -} while (0) - -/*********************************************************************** - * Build render functions from dd templates * - ***********************************************************************/ - -#define TRIDENT_OFFSET_BIT 0x01 -#define TRIDENT_TWOSIDE_BIT 0x02 -#define TRIDENT_UNFILLED_BIT 0x04 -#define TRIDENT_FALLBACK_BIT 0x08 -#define TRIDENT_MAX_TRIFUNC 0x10 - - -static struct { - tnl_points_func points; - tnl_line_func line; - tnl_triangle_func triangle; - tnl_quad_func quad; -} rast_tab[TRIDENT_MAX_TRIFUNC]; - - -#define DO_FALLBACK (IND & TRIDENT_FALLBACK_BIT) -#define DO_OFFSET (IND & TRIDENT_OFFSET_BIT) -#define DO_UNFILLED (IND & TRIDENT_UNFILLED_BIT) -#define DO_TWOSIDE (IND & TRIDENT_TWOSIDE_BIT) -#define DO_FLAT 0 -#define DO_TRI 1 -#define DO_QUAD 1 -#define DO_LINE 1 -#define DO_POINTS 1 -#define DO_FULL_QUAD 1 - -#define HAVE_RGBA 1 -#define HAVE_SPEC 1 -#define HAVE_BACK_COLORS 0 -#define HAVE_HW_FLATSHADE 1 -#define VERTEX tridentVertex -#define TAB rast_tab - -#define DEPTH_SCALE 1.0 -#define UNFILLED_TRI unfilled_tri -#define UNFILLED_QUAD unfilled_quad -#define VERT_X(_v) _v->v.x -#define VERT_Y(_v) _v->v.y -#define VERT_Z(_v) _v->v.z -#define AREA_IS_CCW( a ) (a > 0) -#define GET_VERTEX(e) (tmesa->verts + (e<vertex_stride_shift)) - -#define TRIDENT_COLOR( dst, src ) \ -do { \ - dst[0] = src[2]; \ - dst[1] = src[1]; \ - dst[2] = src[0]; \ - dst[3] = src[3]; \ -} while (0) - -#define TRIDENT_SPEC( dst, src ) \ -do { \ - dst[0] = src[2]; \ - dst[1] = src[1]; \ - dst[2] = src[0]; \ -} while (0) - -#define VERT_SET_RGBA( v, c ) TRIDENT_COLOR( v->ub4[coloroffset], c ) -#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset] -#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset] -#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx] - -#define VERT_SET_SPEC( v, c ) if (havespec) TRIDENT_SPEC( v->ub4[5], c ) -#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5]) -#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5] -#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx] - -#define LOCAL_VARS(n) \ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \ - GLuint color[n], spec[n]; \ - GLuint coloroffset = (tmesa->vertex_size == 4 ? 3 : 4); \ - GLboolean havespec = (tmesa->vertex_size == 4 ? 0 : 1); \ - (void) color; (void) spec; (void) coloroffset; (void) havespec; -/*********************************************************************** - * Helpers for rendering unfilled primitives * - ***********************************************************************/ -#if 0 -static const GLuint hw_prim[GL_POLYGON+1] = { - B_PrimType_Points, - B_PrimType_Lines, - B_PrimType_Lines, - B_PrimType_Lines, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles, - B_PrimType_Triangles -}; -#endif - -static void tridentResetLineStipple( GLcontext *ctx ); -#if 0 -static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim ); -#endif -static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim ); - -#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \ - tridentRasterPrimitive( ctx, hw_prim[x] ) */ -#define RENDER_PRIMITIVE tmesa->render_primitive -#define TAG(x) x -#define IND TRIDENT_FALLBACK_BIT -#include "tnl_dd/t_dd_unfilled.h" -#undef IND - -/*********************************************************************** - * Generate GL render functions * - ***********************************************************************/ - -#define IND (0) -#define TAG(x) x -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_OFFSET_BIT) -#define TAG(x) x##_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT) -#define TAG(x) x##_twoside -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT) -#define TAG(x) x##_twoside_offset -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_UNFILLED_BIT) -#define TAG(x) x##_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT) -#define TAG(x) x##_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT) -#define TAG(x) x##_twoside_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT) -#define TAG(x) x##_twoside_offset_unfilled -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_twoside_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_twoside_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT) -#define TAG(x) x##_twoside_offset_unfilled_fallback -#include "tnl_dd/t_dd_tritmp.h" - -static void init_rast_tab( void ) -{ - init(); - init_offset(); - init_twoside(); - init_twoside_offset(); - init_unfilled(); - init_offset_unfilled(); - init_twoside_unfilled(); - init_twoside_offset_unfilled(); - init_fallback(); - init_offset_fallback(); - init_twoside_fallback(); - init_twoside_offset_fallback(); - init_unfilled_fallback(); - init_offset_unfilled_fallback(); - init_twoside_unfilled_fallback(); - init_twoside_offset_unfilled_fallback(); -} - - -/**********************************************************************/ -/* Render unclipped begin/end objects */ -/**********************************************************************/ - -#define VERT(x) (tridentVertex *)(tridentverts + (x << shift)) -#define RENDER_POINTS( start, count ) \ - for ( ; start < count ; start++) \ - trident_draw_point( tmesa, VERT(start) ) -#define RENDER_LINE( v0, v1 ) \ - trident_draw_line( tmesa, VERT(v0), VERT(v1) ) -#define RENDER_TRI( v0, v1, v2 ) \ - trident_draw_triangle( tmesa, VERT(v0), VERT(v1), VERT(v2) ) -#define RENDER_QUAD( v0, v1, v2, v3 ) \ - trident_draw_quad( tmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) ) -#define INIT(x) tridentRenderPrimitive( ctx, x ); -#undef LOCAL_VARS -#define LOCAL_VARS \ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \ - const GLuint shift = tmesa->vertex_stride_shift; \ - const char *tridentverts = (char *)tmesa->verts; \ - const GLboolean stipple = ctx->Line.StippleFlag; \ - const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \ - (void) elt; -#define RESET_STIPPLE if ( stipple ) tridentResetLineStipple( ctx ); -#define RESET_OCCLUSION -#define PRESERVE_VB_DEFS -#define ELT(x) (x) -#define TAG(x) trident_##x##_verts -#include "tnl/t_vb_rendertmp.h" -#undef ELT -#undef TAG -#define TAG(x) trident_##x##_elts -#define ELT(x) elt[x] -#include "tnl/t_vb_rendertmp.h" - -/**********************************************************************/ -/* Render clipped primitives */ -/**********************************************************************/ - -static void tridentRenderClippedPoly( GLcontext *ctx, const GLuint *elts, - GLuint n ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint prim = tmesa->render_primitive; - - /* Render the new vertices as an unclipped polygon. - */ - { - GLuint *tmp = VB->Elts; - VB->Elts = (GLuint *)elts; - tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END ); - VB->Elts = tmp; - } - - /* Restore the render primitive - */ - if (prim != GL_POLYGON) - tnl->Driver.Render.PrimitiveNotify( ctx, prim ); -} - -static void tridentRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->Driver.Render.Line( ctx, ii, jj ); -} - - -/**********************************************************************/ -/* Choose render functions */ -/**********************************************************************/ - -#define _TRIDENT_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \ - _DD_NEW_LINE_SMOOTH | \ - _DD_NEW_POINT_SMOOTH | \ - _DD_NEW_TRI_SMOOTH | \ - _DD_NEW_TRI_UNFILLED | \ - _DD_NEW_TRI_LIGHT_TWOSIDE | \ - _DD_NEW_TRI_OFFSET) \ - - -#define POINT_FALLBACK (DD_POINT_SMOOTH) -#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH) -#define TRI_FALLBACK (DD_TRI_SMOOTH) -#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK) -#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED) - - -static void tridentChooseRenderState(GLcontext *ctx) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flags = ctx->_TriangleCaps; - GLuint index = 0; - - if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) { - tmesa->draw_point = trident_draw_point; - tmesa->draw_line = trident_draw_line; - tmesa->draw_tri = trident_draw_triangle; - - if (flags & ANY_RASTER_FLAGS) { - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TRIDENT_TWOSIDE_BIT; - if (flags & DD_TRI_OFFSET) index |= TRIDENT_OFFSET_BIT; - if (flags & DD_TRI_UNFILLED) index |= TRIDENT_UNFILLED_BIT; - } - - /* Hook in fallbacks for specific primitives. - */ - if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) { - if (flags & POINT_FALLBACK) tmesa->draw_point = trident_fallback_point; - if (flags & LINE_FALLBACK) tmesa->draw_line = trident_fallback_line; - if (flags & TRI_FALLBACK) tmesa->draw_tri = trident_fallback_tri; - index |= TRIDENT_FALLBACK_BIT; - } - } - - if (tmesa->RenderIndex != index) { - tmesa->RenderIndex = index; - - tnl->Driver.Render.Points = rast_tab[index].points; - tnl->Driver.Render.Line = rast_tab[index].line; - tnl->Driver.Render.Triangle = rast_tab[index].triangle; - tnl->Driver.Render.Quad = rast_tab[index].quad; - - if (tmesa->RenderIndex == 0) { - tnl->Driver.Render.PrimTabVerts = trident_render_tab_verts; - tnl->Driver.Render.PrimTabElts = trident_render_tab_elts; - } else { - tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts; - tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts; - } - tnl->Driver.Render.ClippedLine = tridentRenderClippedLine; - tnl->Driver.Render.ClippedPolygon = tridentRenderClippedPoly; - } -} - - -/**********************************************************************/ -/* High level hooks for t_vb_render.c */ -/**********************************************************************/ - - - -/* Determine the rasterized primitive when not drawing unfilled - * polygons. - * - * Used only for the default render stage which always decomposes - * primitives to trianges/lines/points. For the accelerated stage, - * which renders strips as strips, the equivalent calculations are - * performed in tridentrender.c. - */ -#if 0 -static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - if (tmesa->hw_primitive != hwprim) - tmesa->hw_primitive = hwprim; -} -#endif - -static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - tmesa->render_primitive = prim; -} - -static void tridentRunPipeline( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - - if ( tmesa->new_state ) - tridentDDUpdateHWState( ctx ); - - if (tmesa->new_gl_state) { -#if 0 - if (tmesa->new_gl_state & _NEW_TEXTURE) - tridentUpdateTextureState( ctx ); -#endif - - if (!tmesa->Fallback) { - if (tmesa->new_gl_state & _TRIDENT_NEW_VERTEX) - tridentChooseVertexState( ctx ); - - if (tmesa->new_gl_state & _TRIDENT_NEW_RENDER_STATE) - tridentChooseRenderState( ctx ); - } - - tmesa->new_gl_state = 0; - } - - _tnl_run_pipeline( ctx ); -} - -static void tridentRenderStart( GLcontext *ctx ) -{ - /* Check for projective texturing. Make sure all texcoord - * pointers point to something. (fix in mesa?) - */ - tridentCheckTexSizes( ctx ); -} - -static void tridentRenderFinish( GLcontext *ctx ) -{ - if (0) - _swrast_flush( ctx ); /* never needed */ -} - -static void tridentResetLineStipple( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - (void) tmesa; - - /* Reset the hardware stipple counter. - */ -} - - -/**********************************************************************/ -/* Transition to/from hardware rasterization. */ -/**********************************************************************/ - - -void tridentFallback( tridentContextPtr tmesa, GLuint bit, GLboolean mode ) -{ - GLcontext *ctx = tmesa->glCtx; - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = tmesa->Fallback; - - _tnl_need_projected_coords( ctx, GL_FALSE ); - - if (mode) { - tmesa->Fallback |= bit; - if (oldfallback == 0) { - _swsetup_Wakeup( ctx ); - tmesa->RenderIndex = ~0; - } - } - else { - tmesa->Fallback &= ~bit; - if (oldfallback == bit) { - _swrast_flush( ctx ); - tnl->Driver.Render.Start = tridentRenderStart; - tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive; - tnl->Driver.Render.Finish = tridentRenderFinish; - tnl->Driver.Render.BuildVertices = tridentBuildVertices; - tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple; - tmesa->new_gl_state |= (_TRIDENT_NEW_RENDER_STATE| - _TRIDENT_NEW_VERTEX); - } - } -} - - -/**********************************************************************/ -/* Initialization. */ -/**********************************************************************/ - - -void tridentDDInitTriFuncs( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - static int firsttime = 1; - - if (firsttime) { - init_rast_tab(); - firsttime = 0; - } - - tmesa->RenderIndex = ~0; - - tnl->Driver.RunPipeline = tridentRunPipeline; - tnl->Driver.Render.Start = tridentRenderStart; - tnl->Driver.Render.Finish = tridentRenderFinish; - tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive; - tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple; - tnl->Driver.Render.BuildVertices = tridentBuildVertices; -} diff --git a/src/mesa/drivers/dri/trident/trident_vb.c b/src/mesa/drivers/dri/trident/trident_vb.c deleted file mode 100644 index 055a914595..0000000000 --- a/src/mesa/drivers/dri/trident/trident_vb.c +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright 2002 by Alan Hourihane, Sychdyn, North Wales, UK. - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Alan Hourihane not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Alan Hourihane makes no representations - * about the suitability of this software for any purpose. It is provided - * "as is" without express or implied warranty. - * - * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - * - * Authors: Alan Hourihane, - * - * Trident CyberBladeXP driver. - * - */ -#include "main/glheader.h" -#include "main/mtypes.h" -#include "main/macros.h" -#include "main/colormac.h" - -#include "swrast_setup/swrast_setup.h" -#include "swrast/swrast.h" -#include "tnl/t_context.h" -#include "tnl/tnl.h" - -#include "trident_context.h" - -#define TRIDENT_TEX1_BIT 0x1 -#define TRIDENT_TEX0_BIT 0x2 -#define TRIDENT_RGBA_BIT 0x4 -#define TRIDENT_SPEC_BIT 0x8 -#define TRIDENT_FOG_BIT 0x10 -#define TRIDENT_XYZW_BIT 0x20 -#define TRIDENT_PTEX_BIT 0x40 -#define TRIDENT_MAX_SETUP 0x80 - -static struct { - void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint ); - tnl_interp_func interp; - tnl_copy_pv_func copy_pv; - GLboolean (*check_tex_sizes)( GLcontext *ctx ); - GLuint vertex_size; - GLuint vertex_stride_shift; - GLuint vertex_format; -} setup_tab[TRIDENT_MAX_SETUP]; - -#define TINY_VERTEX_FORMAT 1 -#define NOTEX_VERTEX_FORMAT 2 -#define TEX0_VERTEX_FORMAT 3 -#define TEX1_VERTEX_FORMAT 4 -#define PROJ_TEX1_VERTEX_FORMAT 5 -#define TEX2_VERTEX_FORMAT 6 -#define TEX3_VERTEX_FORMAT 7 -#define PROJ_TEX3_VERTEX_FORMAT 8 - -#define DO_XYZW (IND & TRIDENT_XYZW_BIT) -#define DO_RGBA (IND & TRIDENT_RGBA_BIT) -#define DO_SPEC (IND & TRIDENT_SPEC_BIT) -#define DO_FOG (IND & TRIDENT_FOG_BIT) -#define DO_TEX0 (IND & TRIDENT_TEX0_BIT) -#define DO_TEX1 (IND & TRIDENT_TEX1_BIT) -#define DO_TEX2 0 -#define DO_TEX3 0 -#define DO_PTEX (IND & TRIDENT_PTEX_BIT) - -#define VERTEX tridentVertex -#define VERTEX_COLOR trident_color_t -#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); -#define GET_VIEWPORT_MAT() tmesa->hw_viewport -#define GET_TEXSOURCE(n) tmesa->tmu_source[n] -#define GET_VERTEX_FORMAT() tmesa->vertex_format -#define GET_VERTEX_SIZE() tmesa->vertex_size -#define GET_VERTEX_STORE() tmesa->verts -#define GET_VERTEX_STRIDE_SHIFT() tmesa->vertex_stride_shift -#define GET_UBYTE_COLOR_STORE() &tmesa->UbyteColor -#define GET_UBYTE_SPEC_COLOR_STORE() &tmesa->UbyteSecondaryColor - -#define HAVE_HW_VIEWPORT 0 -#define HAVE_HW_DIVIDE 0 -#define HAVE_RGBA_COLOR 0 -#define HAVE_TINY_VERTICES 1 -#define HAVE_NOTEX_VERTICES 1 -#define HAVE_TEX0_VERTICES 1 -#define HAVE_TEX1_VERTICES 1 -#define HAVE_TEX2_VERTICES 0 -#define HAVE_TEX3_VERTICES 0 -#define HAVE_PTEX_VERTICES 0 - -#define UNVIEWPORT_VARS \ - const GLfloat dx = - tmesa->drawX - SUBPIXEL_X; \ - const GLfloat dy = (tmesa->driDrawable->h + \ - tmesa->drawY + SUBPIXEL_Y); \ - const GLfloat sz = 1.0 / tmesa->depth_scale - -#define UNVIEWPORT_X(x) x + dx; -#define UNVIEWPORT_Y(y) - y + dy; -#define UNVIEWPORT_Z(z) z * sz; - -#define PTEX_FALLBACK() tridentFallback(TRIDENT_CONTEXT(ctx), TRIDENT_FALLBACK_TEXTURE, 1) - -#define IMPORT_FLOAT_COLORS trident_import_float_colors -#define IMPORT_FLOAT_SPEC_COLORS trident_import_float_spec_colors - -#define INTERP_VERTEX setup_tab[tmesa->SetupIndex].interp -#define COPY_PV_VERTEX setup_tab[tmesa->SetupIndex].copy_pv - -/*********************************************************************** - * Generate pv-copying and translation functions * - ***********************************************************************/ - -#define TAG(x) trident_##x -#include "tnl_dd/t_dd_vb.c" - -/*********************************************************************** - * Generate vertex emit and interp functions * - ***********************************************************************/ - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT) -#define TAG(x) x##_wg -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT) -#define TAG(x) x##_wgs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_wgt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_wgt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT) -#define TAG(x) x##_wgpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_wgst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_wgst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT) -#define TAG(x) x##_wgspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT) -#define TAG(x) x##_wgf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT) -#define TAG(x) x##_wgfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_wgft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_wgft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT) -#define TAG(x) x##_wgfpt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_wgfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_wgfst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT) -#define TAG(x) x##_wgfspt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_TEX0_BIT) -#define TAG(x) x##_t0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_t0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_FOG_BIT) -#define TAG(x) x##_f -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_ft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_ft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT) -#define TAG(x) x##_g -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT) -#define TAG(x) x##_gs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_gt0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_gt0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_gst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_gst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT) -#define TAG(x) x##_gf -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT) -#define TAG(x) x##_gfs -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_gft0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_gft0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT) -#define TAG(x) x##_gfst0 -#include "tnl_dd/t_dd_vbtmp.h" - -#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT) -#define TAG(x) x##_gfst0t1 -#include "tnl_dd/t_dd_vbtmp.h" - -static void init_setup_tab( void ) -{ - init_wg(); - init_wgs(); - init_wgt0(); - init_wgt0t1(); - init_wgpt0(); - init_wgst0(); - init_wgst0t1(); - init_wgspt0(); - init_wgf(); - init_wgfs(); - init_wgft0(); - init_wgft0t1(); - init_wgfpt0(); - init_wgfst0(); - init_wgfst0t1(); - init_wgfspt0(); - init_t0(); - init_t0t1(); - init_f(); - init_ft0(); - init_ft0t1(); - init_g(); - init_gs(); - init_gt0(); - init_gt0t1(); - init_gst0(); - init_gst0t1(); - init_gf(); - init_gfs(); - init_gft0(); - init_gft0t1(); - init_gfst0(); - init_gfst0t1(); -} - -void tridentBuildVertices( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint newinputs ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx ); - GLubyte *v = ((GLubyte *)tmesa->verts + (start<vertex_stride_shift)); - GLuint stride = 1<vertex_stride_shift; - - newinputs |= tmesa->SetupNewInputs; - tmesa->SetupNewInputs = 0; - - if (!newinputs) - return; - - if (newinputs & VERT_BIT_POS) { - setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride ); - } else { - GLuint ind = 0; - - if (newinputs & VERT_BIT_COLOR0) - ind |= TRIDENT_RGBA_BIT; - - if (newinputs & VERT_BIT_COLOR1) - ind |= TRIDENT_SPEC_BIT; - - if (newinputs & VERT_BIT_TEX0) - ind |= TRIDENT_TEX0_BIT; - - if (newinputs & VERT_BIT_TEX1) - ind |= TRIDENT_TEX1_BIT; - - if (newinputs & VERT_BIT_FOG) - ind |= TRIDENT_FOG_BIT; - - if (tmesa->SetupIndex & TRIDENT_PTEX_BIT) - ind = ~0; - - ind &= tmesa->SetupIndex; - - if (ind) { - setup_tab[ind].emit( ctx, start, count, v, stride ); - } - } -} - -void tridentCheckTexSizes( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx ); - - if (!setup_tab[tmesa->SetupIndex].check_tex_sizes(ctx)) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Invalidate stored verts - */ - tmesa->SetupNewInputs = ~0; - tmesa->SetupIndex |= TRIDENT_PTEX_BIT; - - if (!tmesa->Fallback && - !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) { - tnl->Driver.Render.Interp = setup_tab[tmesa->SetupIndex].interp; - tnl->Driver.Render.CopyPV = setup_tab[tmesa->SetupIndex].copy_pv; - } - } -} - -void tridentChooseVertexState( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx ); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint ind = TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT; - - if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) - ind |= TRIDENT_SPEC_BIT; - - if (ctx->Fog.Enabled) - ind |= TRIDENT_FOG_BIT; - - if (ctx->Texture.Unit[0]._ReallyEnabled) { - ind |= TRIDENT_TEX0_BIT; - if (ctx->Texture.Unit[1]._ReallyEnabled) { - ind |= TRIDENT_TEX1_BIT; - } - } - - tmesa->SetupIndex = ind; - - if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) { - tnl->Driver.Render.Interp = trident_interp_extras; - tnl->Driver.Render.CopyPV = trident_copy_pv_extras; - } else { - tnl->Driver.Render.Interp = setup_tab[ind].interp; - tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv; - } - - if (setup_tab[ind].vertex_format != tmesa->vertex_format) { - tmesa->vertex_format = setup_tab[ind].vertex_format; - tmesa->vertex_size = setup_tab[ind].vertex_size; - tmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift; - } -} - -void tridentInitVB( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - GLuint size = TNL_CONTEXT(ctx)->vb.Size; - - tmesa->verts = (GLubyte *)ALIGN_MALLOC( size * 16 * 4, 32 ); - - { - static int firsttime = 1; - if (firsttime) { - init_setup_tab(); - firsttime = 0; - } - } -} - -void tridentFreeVB( GLcontext *ctx ) -{ - tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); - - if (tmesa->verts) { - ALIGN_FREE(tmesa->verts); - tmesa->verts = 0; - } - - if (tmesa->UbyteSecondaryColor.Ptr) { - ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr); - tmesa->UbyteSecondaryColor.Ptr = 0; - } - - if (tmesa->UbyteColor.Ptr) { - ALIGN_FREE((void *)tmesa->UbyteColor.Ptr); - tmesa->UbyteColor.Ptr = 0; - } -} -- cgit v1.2.3 From f9a69c0f040171cffa63c9c68264c1cf847aa1cd Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 22 Oct 2009 21:55:09 +0200 Subject: nouveau: nv30: use a8r8g8b8 as depth texture format for z24s8 --- src/gallium/drivers/nv30/nv30_fragtex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_fragtex.c b/src/gallium/drivers/nv30/nv30_fragtex.c index a2ce947a72..f5f17d4071 100644 --- a/src/gallium/drivers/nv30/nv30_fragtex.c +++ b/src/gallium/drivers/nv30/nv30_fragtex.c @@ -30,7 +30,7 @@ nv30_texture_formats[] = { _(I8_UNORM , L8 , S1, S1, S1, S1, X, X, X, X), _(A8L8_UNORM , A8L8 , S1, S1, S1, S1, X, X, X, Y), // _(Z16_UNORM , Z16 , S1, S1, S1, ONE, X, X, X, X), -// _(Z24S8_UNORM , Z24 , S1, S1, S1, ONE, X, X, X, X), + _(Z24S8_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), @@ -73,9 +73,9 @@ nv30_fragtex_build(struct nv30_context *nv30, int unit) txf = tf->format; txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0); - txf |= log2i(pt->width[0]) << 20; - txf |= log2i(pt->height[0]) << 24; - txf |= log2i(pt->depth[0]) << 28; + txf |= log2i(pt->width[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT; + txf |= log2i(pt->height[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT; + txf |= log2i(pt->depth[0]) << NV34TCL_TX_FORMAT_BASE_SIZE_W_SHIFT; txf |= NV34TCL_TX_FORMAT_NO_BORDER | 0x10000; switch (pt->target) { -- cgit v1.2.3 From 4b8de9bd7c6f77fcf3f1f2b939bab980e074e8bf Mon Sep 17 00:00:00 2001 From: Patrice Mandin Date: Thu, 22 Oct 2009 22:01:53 +0200 Subject: nouveau: nv30: rewrite so we can render only in depth buffer --- src/gallium/drivers/nv30/nv30_state_fb.c | 55 ++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/src/gallium/drivers/nv30/nv30_state_fb.c b/src/gallium/drivers/nv30/nv30_state_fb.c index 197de82886..f90681b0f9 100644 --- a/src/gallium/drivers/nv30/nv30_state_fb.c +++ b/src/gallium/drivers/nv30/nv30_state_fb.c @@ -8,8 +8,8 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nouveau_channel *chan = nv30->screen->base.channel; struct nouveau_grobj *rankine = nv30->screen->rankine; struct nv04_surface *rt[2], *zeta = NULL; - uint32_t rt_enable, rt_format; - int i, colour_format = 0, zeta_format = 0; + 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(64, 10); unsigned rt_flags = NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM; unsigned w = fb->width; @@ -17,11 +17,6 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) struct nv30_miptree *nv30mt; int colour_bits = 32, zeta_bits = 32; - if (fb->nr_cbufs == 0) { - return FALSE; - } - - rt_enable = 0; for (i = 0; i < fb->nr_cbufs; i++) { if (colour_format) { assert(colour_format == fb->cbufs[i]->format); @@ -40,17 +35,35 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) 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)); + 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); + 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; } - else - rt_format = NV34TCL_RT_FORMAT_TYPE_LINEAR; switch (colour_format) { case PIPE_FORMAT_A8R8G8B8_UNORM: @@ -83,21 +96,23 @@ nv30_state_framebuffer_validate(struct nv30_context *nv30) return FALSE; } - if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) { - uint32_t pitch = rt[0]->pitch; + 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 nv30_miptree *)rt[0]->base.texture; + nv30mt = (struct nv30_miptree *) rt0->base.texture; so_method(so, rankine, 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_data (so, pitch); - so_reloc (so, nouveau_bo(nv30mt->buffer), rt[0]->base.offset, + so_reloc (so, nouveau_bo(nv30mt->buffer), rt0->base.offset, rt_flags | NOUVEAU_BO_LOW, 0, 0); } -- cgit v1.2.3 From 198925caa18526e5aa908ab50482aff814207dc2 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Thu, 22 Oct 2009 22:57:30 +0200 Subject: nv50: handle PIPE_TEX_FILTER_ANISO case Set the same bits as for linear filtering (in addition to max anisotropy), and 2 unknown bits I've seen set. --- src/gallium/drivers/nv50/nv50_state.c | 26 +++++++++++--------------- src/gallium/drivers/nv50/nv50_texture.h | 2 ++ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 81fa3e34c5..ffaa5e29d1 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -146,6 +146,7 @@ nv50_sampler_state_create(struct pipe_context *pipe, (wrap_mode(cso->wrap_r) << 6)); switch (cso->mag_img_filter) { + case PIPE_TEX_FILTER_ANISO: case PIPE_TEX_FILTER_LINEAR: tsc[1] |= NV50TSC_1_1_MAGF_LINEAR; break; @@ -156,6 +157,7 @@ nv50_sampler_state_create(struct pipe_context *pipe, } switch (cso->min_img_filter) { + case PIPE_TEX_FILTER_ANISO: case PIPE_TEX_FILTER_LINEAR: tsc[1] |= NV50TSC_1_1_MINF_LINEAR; break; @@ -183,21 +185,15 @@ nv50_sampler_state_create(struct pipe_context *pipe, else if (cso->max_anisotropy >= 12.0) tsc[0] |= (6 << 20); - else - if (cso->max_anisotropy >= 10.0) - tsc[0] |= (5 << 20); - else - if (cso->max_anisotropy >= 8.0) - tsc[0] |= (4 << 20); - else - if (cso->max_anisotropy >= 6.0) - tsc[0] |= (3 << 20); - else - if (cso->max_anisotropy >= 4.0) - tsc[0] |= (2 << 20); - else - if (cso->max_anisotropy >= 2.0) - tsc[0] |= (1 << 20); + else { + tsc[0] |= (int)(cso->max_anisotropy * 0.5f) << 20; + + if (cso->max_anisotropy >= 4.0) + tsc[1] |= NV50TSC_1_1_UNKN_ANISO_35; + else + if (cso->max_anisotropy >= 2.0) + tsc[1] |= NV50TSC_1_1_UNKN_ANISO_15; + } if (cso->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) { tsc[0] |= (1 << 8); diff --git a/src/gallium/drivers/nv50/nv50_texture.h b/src/gallium/drivers/nv50/nv50_texture.h index 207fb039f7..13f74c11c6 100644 --- a/src/gallium/drivers/nv50/nv50_texture.h +++ b/src/gallium/drivers/nv50/nv50_texture.h @@ -133,6 +133,8 @@ #define NV50TSC_1_1_MIPF_NEAREST 0x00000080 #define NV50TSC_1_1_MIPF_LINEAR 0x000000c0 #define NV50TSC_1_1_LOD_BIAS_MASK 0x01fff000 +#define NV50TSC_1_1_UNKN_ANISO_15 0x10000000 +#define NV50TSC_1_1_UNKN_ANISO_35 0x18000000 #define NV50TSC_1_2_MIN_LOD_MASK 0x00000f00 #define NV50TSC_1_2_MAX_LOD_MASK 0x00f00000 -- cgit v1.2.3 From ff9e1c01989fc80f07cdc69e3e373bdfe1a384ef Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 13:42:03 -0700 Subject: r300g: Cleanup PSC setup math a bit and stop using Draw formats. --- src/gallium/drivers/r300/r300_reg.h | 21 ++++++++++++ src/gallium/drivers/r300/r300_state_derived.c | 28 +++++++++------- src/gallium/drivers/r300/r300_state_inlines.h | 48 +++++++++++++++++++++------ 3 files changed, 74 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index ae94bb9b9f..e920b2a5e7 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -348,6 +348,27 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_WRITE_ENA_W 8 # define R300_SWIZZLE1_SHIFT 16 +# define R300_VAP_SWIZZLE_X001 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + +# define R300_VAP_SWIZZLE_XY01 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ZERO << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + +# define R300_VAP_SWIZZLE_XYZ1 \ + ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ + (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ + (R300_SWIZZLE_SELECT_Z << R300_SWIZZLE_SELECT_Z_SHIFT) | \ + (R300_SWIZZLE_SELECT_FP_ONE << R300_SWIZZLE_SELECT_W_SHIFT) | \ + (0xf << R300_WRITE_ENA_SHIFT)) + # define R300_VAP_SWIZZLE_XYZW \ ((R300_SWIZZLE_SELECT_X << R300_SWIZZLE_SELECT_X_SHIFT) | \ (R300_SWIZZLE_SELECT_Y << R300_SWIZZLE_SELECT_Y_SHIFT) | \ diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index 42aee7231e..7d000e9e2d 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -224,7 +224,8 @@ static void r300_vertex_psc(struct r300_context* r300, struct r300_screen* r300screen = r300_screen(r300->context.screen); struct vertex_info* vinfo = &vformat->vinfo; int* tab = vformat->vs_tab; - uint32_t temp; + uint16_t type, swizzle; + enum pipe_format format; unsigned i, attrib_count; /* Vertex shaders have no semantics on their inputs, @@ -246,25 +247,28 @@ static void r300_vertex_psc(struct r300_context* r300, } for (i = 0; i < attrib_count; i++) { - /* Make sure we have a proper destination for our attribute */ + /* Make sure we have a proper destination for our attribute. */ assert(tab[i] != -1); - /* Add the attribute to the PSC table. */ - temp = translate_draw_vertex_data_type(vinfo->attrib[i].emit) | + format = draw_translate_vinfo_format(vinfo->attrib[i].emit); + + /* Obtain the type of data in this attribute. */ + type = r300_translate_vertex_data_type(format) | 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] &= 0x0000ffff; - vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16; + vformat->vap_prog_stream_cntl[i >> 1] |= type << 16; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= - (R300_VAP_SWIZZLE_XYZW << 16); + vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 16; } else { - vformat->vap_prog_stream_cntl[i >> 1] &= 0xffff0000; - vformat->vap_prog_stream_cntl[i >> 1] |= temp << 0; + vformat->vap_prog_stream_cntl[i >> 1] |= type << 0; - vformat->vap_prog_stream_cntl_ext[i >> 1] |= - (R300_VAP_SWIZZLE_XYZW << 0); + vformat->vap_prog_stream_cntl_ext[i >> 1] |= swizzle << 0; } } diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index c82d8e5f08..2431b75a51 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -400,28 +400,54 @@ static INLINE uint32_t r300_translate_gb_pipes(int pipe_count) return 0; } -/* Translate Draw vertex types into PSC vertex types. */ -static INLINE uint32_t translate_draw_vertex_data_type(int type) { - switch (type) { - case EMIT_1F: - case EMIT_1F_PSIZE: +/* Translate pipe_formats into PSC vertex types. */ +static INLINE uint16_t +r300_translate_vertex_data_type(enum pipe_format format) { + switch (format) { + case PIPE_FORMAT_R32_FLOAT: return R300_DATA_TYPE_FLOAT_1; break; - case EMIT_2F: + case PIPE_FORMAT_R32G32_FLOAT: return R300_DATA_TYPE_FLOAT_2; break; - case EMIT_3F: + case PIPE_FORMAT_R32G32B32_FLOAT: return R300_DATA_TYPE_FLOAT_3; break; - case EMIT_4F: + case PIPE_FORMAT_R32G32B32A32_FLOAT: return R300_DATA_TYPE_FLOAT_4; break; - case EMIT_4UB: - return R300_DATA_TYPE_BYTE; + case PIPE_FORMAT_R8G8B8A8_UNORM: + return R300_DATA_TYPE_BYTE | + R300_NORMALIZE; + break; + default: + debug_printf("r300: Implementation error: " + "Bad vertex data format %s!\n", pf_name(format)); + assert(0); + break; + } + return 0; +} + +static INLINE uint16_t +r300_translate_vertex_data_swizzle(enum pipe_format format) { + switch (format) { + case PIPE_FORMAT_R32_FLOAT: + return R300_VAP_SWIZZLE_X001; + break; + case PIPE_FORMAT_R32G32_FLOAT: + return R300_VAP_SWIZZLE_XY01; + break; + case PIPE_FORMAT_R32G32B32_FLOAT: + return R300_VAP_SWIZZLE_XYZ1; + break; + case PIPE_FORMAT_R32G32B32A32_FLOAT: + case PIPE_FORMAT_R8G8B8A8_UNORM: + return R300_VAP_SWIZZLE_XYZW; break; default: debug_printf("r300: Implementation error: " - "Bad vertex data type!\n"); + "Bad vertex data format %s!\n", pf_name(format)); assert(0); break; } -- cgit v1.2.3 From 04ec113e09f6287f2c6b39bf0247e06839eaf7a8 Mon Sep 17 00:00:00 2001 From: Corbin Simpson Date: Thu, 22 Oct 2009 14:28:47 -0700 Subject: r300g: Enable more stuff in r300_screen, cleanup comments. Also enable 24-bit depth buffers without stencil. --- src/gallium/drivers/r300/r300_screen.c | 34 +++++++++++++++------------ src/gallium/drivers/r300/r300_state_inlines.h | 4 +++- src/gallium/drivers/r300/r300_texture.h | 1 + 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index a9058a25e5..1d9f91d0f7 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -80,13 +80,10 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) struct r300_screen* r300screen = r300_screen(pscreen); switch (param) { - /* XXX cases marked "IN THEORY" are possible on the hardware, - * but haven't been implemented yet. */ case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: /* XXX I'm told this goes up to 16 */ return 8; case PIPE_CAP_NPOT_TEXTURES: - /* IN THEORY */ return 0; case PIPE_CAP_TWO_SIDED_STENCIL: if (r300screen->caps->is_r500) { @@ -95,16 +92,26 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) return 0; } case PIPE_CAP_GLSL: - if (r300screen->caps->is_r500) { - return 1; - } else { - return 0; - } + /* I'll be frank. This is a lie. + * + * We don't truly support GLSL on any of this driver's chipsets. + * To be fair, no chipset supports the full GLSL specification + * to the best of our knowledge, but some of the less esoteric + * features are still missing here. + * + * Rather than cripple ourselves intentionally, I'm going to set + * this flag, and as Gallium's interface continues to change, I + * hope that this single monolithic GLSL enable can slowly get + * split down into many different pieces and the state tracker + * will handle fallbacks transparently, like it should. + * + * ~ C. + */ + return 1; case PIPE_CAP_ANISOTROPIC_FILTER: return 1; case PIPE_CAP_POINT_SPRITE: - /* IN THEORY */ - return 0; + return 1; case PIPE_CAP_MAX_RENDER_TARGETS: return 4; case PIPE_CAP_OCCLUSION_QUERY: @@ -145,10 +152,8 @@ static int r300_get_param(struct pipe_screen* pscreen, int param) case PIPE_CAP_TEXTURE_MIRROR_REPEAT: return 1; case PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS: - /* XXX guessing (what a terrible guess) */ - return 2; + return 0; case PIPE_CAP_TGSI_CONT_SUPPORTED: - /* XXX */ return 0; case PIPE_CAP_BLEND_EQUATION_SEPARATE: return 1; @@ -229,6 +234,7 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage, /* Z buffer or texture */ case PIPE_FORMAT_Z16_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: /* Z buffer with stencil or texture */ case PIPE_FORMAT_Z24S8_UNORM: retval = usage & @@ -239,7 +245,6 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage, /* Definitely unsupported formats. */ /* Non-usable Z buffer/stencil formats. */ case PIPE_FORMAT_Z32_UNORM: - case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_X8Z24_UNORM: debug_printf("r300: Note: Got unsupported format: %s in %s\n", @@ -249,7 +254,6 @@ static boolean check_tex_2d_format(enum pipe_format format, uint32_t usage, /* XXX These don't even exist case PIPE_FORMAT_A32R32G32B32: case PIPE_FORMAT_A16R16G16B16: */ - /* XXX Insert YUV422 packed VYUY and YVYU here */ /* XXX What the deuce is UV88? (r3xx accel page 14) debug_printf("r300: Warning: Got unimplemented format: %s in %s\n", pf_name(format), __FUNCTION__); diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 2431b75a51..ec11a41253 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -330,13 +330,15 @@ static INLINE uint32_t r300_translate_colorformat(enum pipe_format format) return 0; } -/* Depthbuffer and stencilbuffer. Thankfully, we only support two kinds. */ +/* Depthbuffer and stencilbuffer. Thankfully, we only support two flavors. */ static INLINE uint32_t r300_translate_zsformat(enum pipe_format format) { switch (format) { /* 16-bit depth, no stencil */ case PIPE_FORMAT_Z16_UNORM: return R300_DEPTHFORMAT_16BIT_INT_Z; + /* 24-bit depth, ignored stencil */ + case PIPE_FORMAT_Z24X8_UNORM: /* 24-bit depth, 8-bit stencil */ case PIPE_FORMAT_Z24S8_UNORM: return R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL; diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h index 2e58bda716..55d1a0ac5c 100644 --- a/src/gallium/drivers/r300/r300_texture.h +++ b/src/gallium/drivers/r300/r300_texture.h @@ -80,6 +80,7 @@ static INLINE uint32_t r300_translate_texformat(enum pipe_format format) R300_TX_FORMAT_YUV_TO_RGB; /* W24_FP */ case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_Z24X8_UNORM: return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP); default: debug_printf("r300: Implementation error: " -- cgit v1.2.3 From 2f7abf5c042a1bcf97d77d6dad4a17bda37e0567 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:26:54 -0600 Subject: i965: remove unused BRW_FALLBACK_TEXTURE bit The value was probably wrong too. It was the same as INTEL_FALLBACK_DRAW_BUFFER. --- src/mesa/drivers/dri/i965/brw_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index a5209ac41b..b7d6c7ce7e 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -115,7 +115,7 @@ * Handles blending and (presumably) depth and stencil testing. */ -#define BRW_FALLBACK_TEXTURE 0x1 + #define BRW_MAX_CURBE (32*16) struct brw_context; -- cgit v1.2.3 From f9bbbe5803a72eceb8ed6ddc73bb48c8bcdc0179 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:32:08 -0600 Subject: i965: remove unused brw_context::tmp_fallback field --- src/mesa/drivers/dri/i965/brw_context.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index b7d6c7ce7e..da0e091bfd 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -454,7 +454,6 @@ struct brw_context GLuint primitive; GLboolean emit_state_always; - GLboolean tmp_fallback; GLboolean no_batch_wrap; struct { -- cgit v1.2.3 From ea659f891740fab1943eca219ffbdd5ed3d1906c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:33:36 -0600 Subject: intel: Fallback field is a bitmask, use GLbitfield --- src/mesa/drivers/dri/i915/intel_tris.c | 8 ++++++-- src/mesa/drivers/dri/intel/intel_context.c | 2 +- src/mesa/drivers/dri/intel/intel_context.h | 9 +++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c index a905455342..bc6b29281a 100644 --- a/src/mesa/drivers/dri/i915/intel_tris.c +++ b/src/mesa/drivers/dri/i915/intel_tris.c @@ -1194,12 +1194,16 @@ getFallbackString(GLuint bit) +/** + * Enable/disable a fallback flag. + * \param bit one of INTEL_FALLBACK_x flags. + */ void -intelFallback(struct intel_context *intel, GLuint bit, GLboolean mode) +intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode) { GLcontext *ctx = &intel->ctx; TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint oldfallback = intel->Fallback; + const GLbitfield oldfallback = intel->Fallback; if (mode) { intel->Fallback |= bit; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index c49f06e44a..d24af46f59 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -839,7 +839,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv) _vbo_DestroyContext(&intel->ctx); _swrast_DestroyContext(&intel->ctx); - intel->Fallback = 0; /* don't call _swrast_Flush later */ + intel->Fallback = 0x0; /* don't call _swrast_Flush later */ intel_batchbuffer_free(intel->batch); intel->batch = NULL; diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 03e7cf39d6..a9db8f6a2b 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -61,6 +61,10 @@ typedef void (*intel_line_func) (struct intel_context *, intelVertex *, intelVertex *); typedef void (*intel_point_func) (struct intel_context *, intelVertex *); +/** + * Bits for intel->Fallback field + */ +/*@{*/ #define INTEL_FALLBACK_DRAW_BUFFER 0x1 #define INTEL_FALLBACK_READ_BUFFER 0x2 #define INTEL_FALLBACK_DEPTH_BUFFER 0x4 @@ -68,8 +72,9 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *); #define INTEL_FALLBACK_USER 0x10 #define INTEL_FALLBACK_RENDERMODE 0x20 #define INTEL_FALLBACK_TEXTURE 0x40 +/*@}*/ -extern void intelFallback(struct intel_context *intel, GLuint bit, +extern void intelFallback(struct intel_context *intel, GLbitfield bit, GLboolean mode); #define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode ) @@ -171,7 +176,7 @@ struct intel_context struct dri_metaops meta; GLint refcount; - GLuint Fallback; + GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */ GLuint NewGLState; dri_bufmgr *bufmgr; -- cgit v1.2.3 From c24466c34e7aeb8aeda2455f6a688b99c44b10e2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:45:03 -0600 Subject: intel: define INTEL_FALLBACK_DRIVER for drivers --- src/mesa/drivers/dri/intel/intel_context.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index a9db8f6a2b..d3acf6e4b3 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -72,6 +72,7 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *); #define INTEL_FALLBACK_USER 0x10 #define INTEL_FALLBACK_RENDERMODE 0x20 #define INTEL_FALLBACK_TEXTURE 0x40 +#define INTEL_FALLBACK_DRIVER 0x1000 /**< first for drivers */ /*@}*/ extern void intelFallback(struct intel_context *intel, GLbitfield bit, -- cgit v1.2.3 From 8810b8f67135185d1044746bb861fe2ff997626c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 16:45:50 -0600 Subject: i965: fix hacked Fallback usage in brw_prepare_vertices() Setting intel->Fallback = 1 clobbered any fallback state that was already set. Not sure where this hack originated (the git history is a little convoluted). Define and use a new BRW_FALLBACK_DRAW bit instead. This shouldn't break anything and could potentially fix some bugs (but no specific ones are known). --- src/mesa/drivers/dri/i965/brw_context.h | 2 ++ src/mesa/drivers/dri/i965/brw_draw_upload.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index da0e091bfd..b1e7ec8465 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -116,6 +116,8 @@ */ +#define BRW_FALLBACK_DRAW (INTEL_FALLBACK_DRIVER << 0) + #define BRW_MAX_CURBE (32*16) struct brw_context; diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index 9d089e113e..4f8ceb37bd 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -375,9 +375,10 @@ static void brw_prepare_vertices(struct brw_context *brw) * isn't an issue at this point. */ if (brw->vb.nr_enabled >= BRW_VEP_MAX) { - intel->Fallback = 1; + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); return; } + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); for (i = 0; i < brw->vb.nr_enabled; i++) { struct brw_vertex_element *input = brw->vb.enabled[i]; @@ -427,9 +428,10 @@ static void brw_prepare_vertices(struct brw_context *brw) /* Position array not properly enabled: */ if (input->glarray->StrideB == 0) { - intel->Fallback = 1; + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_TRUE); return; } + FALLBACK(intel, BRW_FALLBACK_DRAW, GL_FALSE); interleave = input->glarray->StrideB; ptr = input->glarray->Ptr; -- cgit v1.2.3 From 61a96a2ac72b3f071151de436a48c6ec985e3653 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 17:11:59 -0600 Subject: progs/xdemos: fix command line flag typo --- progs/xdemos/glsync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c index 34167d339f..da87306cf2 100644 --- a/progs/xdemos/glsync.c +++ b/progs/xdemos/glsync.c @@ -95,7 +95,7 @@ enum sync_type { static void usage(char *name) { printf("usage: %s [-w ] [-h ] [-s] " - "[-vc]\n", name); + "[-v]\n", name); printf("\t-s:\n"); printf("\t\tn: none\n"); printf("\t\ts: SGI video sync extension\n"); -- cgit v1.2.3 From fb22e801699ef69e40d8e9dfda758be824d86b96 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Thu, 22 Oct 2009 19:31:44 -0400 Subject: st/xorg: fix the makefile when used with new xextproto --- src/gallium/state_trackers/xorg/Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile index 27a1990724..22c107370e 100644 --- a/src/gallium/state_trackers/xorg/Makefile +++ b/src/gallium/state_trackers/xorg/Makefile @@ -5,6 +5,8 @@ LIBNAME = xorgtracker LIBRARY_INCLUDES = \ -DHAVE_CONFIG_H \ + $(shell pkg-config xextproto --atleast-version=7.0.99.1 \ + && echo "-DHAVE_XEXTPROTO_71") \ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \ -I$(TOP)/src/gallium/include \ -I$(TOP)/src/gallium/auxiliary \ -- cgit v1.2.3 From 4837e01bcd3d011a38d75cc9f1eff629c3de6fd6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:16:10 -0600 Subject: mesa: code refactoring- new _mesa_finish(), _mesa_flush() --- src/mesa/main/context.c | 37 +++++++++++++++++++++++++++++-------- src/mesa/main/context.h | 8 ++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index ac6540f4a0..e844a7432d 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1543,6 +1543,33 @@ _mesa_record_error(GLcontext *ctx, GLenum error) } +/** + * Flush commands and wait for completion. + */ +void +_mesa_finish(GLcontext *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Finish) { + ctx->Driver.Finish(ctx); + } +} + + +/** + * Flush commands. + */ +void +_mesa_flush(GLcontext *ctx) +{ + FLUSH_CURRENT( ctx, 0 ); + if (ctx->Driver.Flush) { + ctx->Driver.Flush(ctx); + } +} + + + /** * Execute glFinish(). * @@ -1554,10 +1581,7 @@ _mesa_Finish(void) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Finish) { - ctx->Driver.Finish(ctx); - } + _mesa_finish(ctx); } @@ -1572,10 +1596,7 @@ _mesa_Flush(void) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); - FLUSH_CURRENT( ctx, 0 ); - if (ctx->Driver.Flush) { - ctx->Driver.Flush(ctx); - } + _mesa_flush(ctx); } diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h index 5587695fa0..c3be1063f8 100644 --- a/src/mesa/main/context.h +++ b/src/mesa/main/context.h @@ -170,6 +170,14 @@ _mesa_valid_to_render(GLcontext *ctx, const char *where); extern void _mesa_record_error( GLcontext *ctx, GLenum error ); + +extern void +_mesa_finish(GLcontext *ctx); + +extern void +_mesa_flush(GLcontext *ctx); + + extern void GLAPIENTRY _mesa_Finish( void ); -- cgit v1.2.3 From 5e6a6a2719c695996490bde491dac267e52f78af Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:19:01 -0600 Subject: glx: don't destroy context immediately if it's currently bound According to the GLXDestroyContext() man page, the context should not immediately be destroyed if it's bound to some thread. Wait until it's unbound to really delete it. The code for doing the later part is already present in MakeContextCurrent() so no change was needed there. --- src/glx/x11/glxcmds.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c index cd4aede74e..c63116bab7 100644 --- a/src/glx/x11/glxcmds.c +++ b/src/glx/x11/glxcmds.c @@ -540,6 +540,16 @@ DestroyContext(Display * dpy, GLXContext gc) imported = gc->imported; gc->xid = None; + if (gc->currentDpy) { + /* This context is bound to some thread. According to the man page, + * we should not actually delete the context until it's unbound. + * Note that we set gc->xid = None above. In MakeContextCurrent() + * we check for that and delete the context there. + */ + __glXUnlock(); + return; + } + #ifdef GLX_DIRECT_RENDERING /* Destroy the direct rendering context */ if (gc->driContext) { -- cgit v1.2.3 From 55058652b886b95bfc24109a9edb04d274c01c1a Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 18:32:48 -0600 Subject: intel: flush old context before binding new context Per the GLX spec, when changing rendering contexts, the old context should first be flushed. --- src/mesa/drivers/dri/intel/intel_context.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index d24af46f59..ddb0550f77 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -944,10 +944,23 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv, __DRIdrawablePrivate * driReadPriv) { __DRIscreenPrivate *psp = driDrawPriv->driScreenPriv; + struct intel_context *intel; + GET_CURRENT_CONTEXT(curCtx); + + if (driContextPriv) + intel = (struct intel_context *) driContextPriv->driverPrivate; + else + intel = NULL; + + /* According to the glXMakeCurrent() man page: "Pending commands to + * the previous context, if any, are flushed before it is released." + * But only flush if we're actually changing contexts. + */ + if (intel_context(curCtx) && intel_context(curCtx) != intel) { + _mesa_flush(curCtx); + } if (driContextPriv) { - struct intel_context *intel = - (struct intel_context *) driContextPriv->driverPrivate; struct intel_framebuffer *intel_fb = (struct intel_framebuffer *) driDrawPriv->driverPrivate; GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate; -- cgit v1.2.3 From 488e67bab267dd687dbe83e52974ad4519906fcc Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 09:37:22 -0600 Subject: mesa: added _mesa_dump_texture() --- src/mesa/main/debug.c | 28 +++++++++++++++++++++++++--- src/mesa/main/debug.h | 3 +++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 8b1707bab3..0e35617575 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -346,12 +346,10 @@ static GLboolean DumpImages; static void -dump_texture_cb(GLuint id, void *data, void *userData) +dump_texture(struct gl_texture_object *texObj) { - struct gl_texture_object *texObj = (struct gl_texture_object *) data; int i; GLboolean written = GL_FALSE; - (void) userData; _mesa_printf("Texture %u\n", texObj->Name); _mesa_printf(" Target 0x%x\n", texObj->Target); @@ -371,6 +369,30 @@ dump_texture_cb(GLuint id, void *data, void *userData) } +/** + * Dump a single texture. + */ +void +_mesa_dump_texture(GLuint texture, GLboolean dumpImages) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_object *texObj = _mesa_lookup_texture(ctx, texture); + if (texObj) { + DumpImages = dumpImages; + dump_texture(texObj); + } +} + + +static void +dump_texture_cb(GLuint id, void *data, void *userData) +{ + struct gl_texture_object *texObj = (struct gl_texture_object *) data; + (void) userData; + dump_texture(texObj); +} + + /** * Print basic info about all texture objext to stdout. * If dumpImages is true, write PPM of level[0] image to a file. diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h index 2a7de9c6b6..f66f774a45 100644 --- a/src/mesa/main/debug.h +++ b/src/mesa/main/debug.h @@ -57,6 +57,9 @@ extern void _mesa_init_debug( GLcontext *ctx ); #endif +extern void +_mesa_dump_texture(GLuint texture, GLboolean dumpImages); + extern void _mesa_dump_textures(GLboolean dumpImages); -- cgit v1.2.3 From fdce832437537f8e89f7ea57d15e73a481bd240e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 09:37:56 -0600 Subject: mesa: fix up vbo comments --- src/mesa/vbo/vbo_exec_api.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index bfa6d76886..f88df5aac7 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -57,7 +57,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static void reset_attrfv( struct vbo_exec_context *exec ); -/* Close off the last primitive, execute the buffer, restart the +/** + * Close off the last primitive, execute the buffer, restart the * primitive. */ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) @@ -106,7 +107,8 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) } -/* Deal with buffer wrapping where provoked by the vertex buffer +/** + * Deal with buffer wrapping where provoked by the vertex buffer * filling up, as opposed to upgrade_vertex(). */ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) @@ -135,7 +137,7 @@ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) } -/* +/** * Copy the active vertex's values to the ctx->Current fields. */ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) @@ -208,7 +210,8 @@ static void vbo_exec_copy_from_current( struct vbo_exec_context *exec ) } -/* Flush existing data, set new attrib size, replay copied vertices. +/** + * Flush existing data, set new attrib size, replay copied vertices. */ static void vbo_exec_wrap_upgrade_vertex( struct vbo_exec_context *exec, GLuint attr, @@ -392,8 +395,7 @@ do { \ #if FEATURE_evaluators -/* Eval - */ + static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u ) { GET_CURRENT_CONTEXT( ctx ); @@ -492,8 +494,8 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) #endif /* FEATURE_evaluators */ -/* Build a list of primitives on the fly. Keep - * ctx->Driver.CurrentExecPrimitive uptodate as well. +/** + * Called via glBegin. */ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) { @@ -537,6 +539,10 @@ static void GLAPIENTRY vbo_exec_Begin( GLenum mode ) } + +/** + * Called via glEnd. + */ static void GLAPIENTRY vbo_exec_End( void ) { GET_CURRENT_CONTEXT( ctx ); -- cgit v1.2.3 From 347fb3737be03488827d25610bec59cfb05bcab0 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 22 Oct 2009 09:38:39 -0600 Subject: docs: document 'useprog' debug option --- docs/shading.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/shading.html b/docs/shading.html index 96060f1a75..bd02335a80 100644 --- a/docs/shading.html +++ b/docs/shading.html @@ -55,6 +55,7 @@ execution. These are generally used for debugging. texcoord[0] attributes.
  • nopfrag - force fragment shader to be a simple shader that passes through the color attribute. +
  • useprog - log glUseProgram calls to stderr

    Example: export MESA_GLSL=dump,nopt -- cgit v1.2.3 From 286611d99060c38c4cc12f18fde5448213e2a44b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 22 Oct 2009 19:21:21 -0700 Subject: Revert "Store clipping distance for user clip planes as part of vertex processing" This reverts commit f058b25881e08c9d89a33345e5c84e1357396932. This change is completely wrong in so many ways. When clip distances are generated as part of vertex processing, they must be interpolated to perform clipping. Geometric clipping goes right out the window. --- src/mesa/tnl/t_context.h | 1 - src/mesa/tnl/t_vb_cliptmp.h | 103 +++++++------------------------------------- src/mesa/tnl/t_vb_program.c | 15 ------- src/mesa/tnl/t_vb_vertex.c | 31 ++----------- 4 files changed, 18 insertions(+), 132 deletions(-) diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index ca4edcfcb9..6137c2d2fe 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -207,7 +207,6 @@ struct vertex_buffer GLvector4f *EyePtr; /* _TNL_BIT_POS */ GLvector4f *ClipPtr; /* _TNL_BIT_POS */ GLvector4f *NdcPtr; /* _TNL_BIT_POS */ - GLfloat *ClipDistancePtr[MAX_CLIP_PLANES]; /* _TNL_BIT_POS */ GLubyte ClipOrMask; /* _TNL_BIT_POS */ GLubyte ClipAndMask; /* _TNL_BIT_POS */ GLubyte *ClipMask; /* _TNL_BIT_POS */ diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 0d2183a9e6..618b8b3130 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -80,58 +80,6 @@ do { \ } while (0) -#define POLY_USERCLIP(PLANE) \ -do { \ - if (mask & CLIP_USER_BIT) { \ - GLuint idxPrev = inlist[0]; \ - GLfloat dpPrev = VB->ClipDistancePtr[PLANE][idxPrev]; \ - GLuint outcount = 0; \ - GLuint i; \ - \ - inlist[n] = inlist[0]; /* prevent rotation of vertices */ \ - for (i = 1; i <= n; i++) { \ - GLuint idx = inlist[i]; \ - GLfloat dp = VB->ClipDistancePtr[PLANE][idx]; \ - \ - if (!IS_NEGATIVE(dpPrev)) { \ - outlist[outcount++] = idxPrev; \ - } \ - \ - if (DIFFERENT_SIGNS(dp, dpPrev)) { \ - if (IS_NEGATIVE(dp)) { \ - /* Going out of bounds. Avoid division by zero as we \ - * know dp != dpPrev from DIFFERENT_SIGNS, above. \ - */ \ - GLfloat t = dp / (dp - dpPrev); \ - INTERP_4F( t, coord[newvert], coord[idx], coord[idxPrev]); \ - interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \ - } else { \ - /* Coming back in. \ - */ \ - GLfloat t = dpPrev / (dpPrev - dp); \ - INTERP_4F( t, coord[newvert], coord[idxPrev], coord[idx]); \ - interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \ - } \ - outlist[outcount++] = newvert++; \ - } \ - \ - idxPrev = idx; \ - dpPrev = dp; \ - } \ - \ - if (outcount < 3) \ - return; \ - \ - { \ - GLuint *tmp = inlist; \ - inlist = outlist; \ - outlist = tmp; \ - n = outcount; \ - } \ - } \ -} while (0) - - #define LINE_CLIP(PLANE_BIT, A, B, C, D ) \ do { \ if (mask & PLANE_BIT) { \ @@ -163,37 +111,6 @@ do { \ } while (0) -#define LINE_USERCLIP(PLANE) \ -do { \ - if (mask & CLIP_USER_BIT) { \ - const GLfloat dp0 = VB->ClipDistancePtr[PLANE][v0]; \ - const GLfloat dp1 = VB->ClipDistancePtr[PLANE][v1]; \ - const GLboolean neg_dp0 = IS_NEGATIVE(dp0); \ - const GLboolean neg_dp1 = IS_NEGATIVE(dp1); \ - \ - /* For regular clipping, we know from the clipmask that one \ - * (or both) of these must be negative (otherwise we wouldn't \ - * be here). \ - * For userclip, there is only a single bit for all active \ - * planes, so we can end up here when there is nothing to do, \ - * hence the second IS_NEGATIVE() test: \ - */ \ - if (neg_dp0 && neg_dp1) \ - return; /* both vertices outside clip plane: discard */ \ - \ - if (neg_dp1) { \ - GLfloat t = dp1 / (dp1 - dp0); \ - if (t > t1) t1 = t; \ - } else if (neg_dp0) { \ - GLfloat t = dp0 / (dp0 - dp1); \ - if (t > t0) t0 = t; \ - } \ - if (t0 + t1 >= 1.0) \ - return; /* discard */ \ - } \ -} while (0) - - /* Clip a line against the viewport and user clip planes. */ @@ -222,7 +139,11 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask ) if (mask & CLIP_USER_BIT) { for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - LINE_USERCLIP(p); + const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; + const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; + const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; + const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; + LINE_CLIP( CLIP_USER_BIT, a, b, c, d ); } } } @@ -307,7 +228,11 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) if (mask & CLIP_USER_BIT) { for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - POLY_USERCLIP(p); + const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; + const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; + const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; + const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; + POLY_CLIP( CLIP_USER_BIT, a, b, c, d ); } } } @@ -366,7 +291,11 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, if (mask & CLIP_USER_BIT) { for (p = 0; p < ctx->Const.MaxClipPlanes; p++) { if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { - POLY_USERCLIP(p); + const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; + const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; + const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; + const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; + POLY_CLIP( CLIP_USER_BIT, a, b, c, d ); } } } @@ -388,6 +317,4 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, #undef SIZE #undef TAG #undef POLY_CLIP -#undef POLY_USERCLIP #undef LINE_CLIP -#undef LINE_USERCLIP diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 5fb83c2b01..c10a27614f 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -66,7 +66,6 @@ struct vp_stage_data { GLvector4f results[VERT_RESULT_MAX]; GLvector4f ndcCoords; /**< normalized device coords */ - GLfloat *clipdistance[MAX_CLIP_PLANES]; GLubyte *clipmask; /**< clip flags */ GLubyte ormask, andmask; /**< for clipping */ }; @@ -78,7 +77,6 @@ struct vp_stage_data { static void userclip( GLcontext *ctx, GLvector4f *clip, - GLfloat *clipdistance[MAX_CLIP_PLANES], GLubyte *clipmask, GLubyte *clipormask, GLubyte *clipandmask ) @@ -107,8 +105,6 @@ userclip( GLcontext *ctx, clipmask[i] |= CLIP_USER_BIT; } - clipdistance[p][i] = dp; - STRIDE_F(coord, stride); } @@ -168,7 +164,6 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store) ctx->VertexProgram.Current->IsPositionInvariant)) { userclip( ctx, VB->ClipPtr, - store->clipdistance, store->clipmask, &store->ormask, &store->andmask ); @@ -176,9 +171,6 @@ do_ndc_cliptest(GLcontext *ctx, struct vp_stage_data *store) if (store->andmask) { return GL_FALSE; } - - memcpy(VB->ClipDistancePtr, store->clipdistance, - sizeof(store->clipdistance)); } VB->ClipAndMask = store->andmask; @@ -522,10 +514,6 @@ init_vp(GLcontext *ctx, struct tnl_pipeline_stage *stage) _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 ); store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 ); - for (i = 0; i < MAX_CLIP_PLANES; i++) - store->clipdistance[i] = - (GLfloat *) ALIGN_MALLOC(sizeof(GLfloat) * size, 32); - return GL_TRUE; } @@ -549,9 +537,6 @@ dtr(struct tnl_pipeline_stage *stage) _mesa_vector4f_free( &store->ndcCoords ); ALIGN_FREE( store->clipmask ); - for (i = 0; i < MAX_CLIP_PLANES; i++) - ALIGN_FREE(store->clipdistance[i]); - FREE( store ); stage->privatePtr = NULL; } diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index 2a61ff1177..4734754ea4 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -44,7 +44,6 @@ struct vertex_stage_data { GLvector4f eye; GLvector4f clip; GLvector4f proj; - GLfloat *clipdistance[MAX_CLIP_PLANES]; GLubyte *clipmask; GLubyte ormask; GLubyte andmask; @@ -57,12 +56,11 @@ struct vertex_stage_data { /* This function implements cliptesting for user-defined clip planes. * The clipping of primitives to these planes is implemented in - * t_vp_cliptmp.h. + * t_render_clip.h. */ #define USER_CLIPTEST(NAME, SZ) \ static void NAME( GLcontext *ctx, \ GLvector4f *clip, \ - GLfloat *clipdistances[MAX_CLIP_PLANES], \ GLubyte *clipmask, \ GLubyte *clipormask, \ GLubyte *clipandmask ) \ @@ -90,8 +88,6 @@ static void NAME( GLcontext *ctx, \ clipmask[i] |= CLIP_USER_BIT; \ } \ \ - clipdistances[p][i] = dp; \ - \ STRIDE_F(coord, stride); \ } \ \ @@ -111,9 +107,8 @@ USER_CLIPTEST(userclip3, 3) USER_CLIPTEST(userclip4, 4) static void (*(usercliptab[5]))( GLcontext *, - GLvector4f *, - GLfloat *[MAX_CLIP_PLANES], - GLubyte *, GLubyte *, GLubyte * ) = + GLvector4f *, GLubyte *, + GLubyte *, GLubyte * ) = { NULL, NULL, @@ -219,16 +214,12 @@ static GLboolean run_vertex_stage( GLcontext *ctx, if (ctx->Transform.ClipPlanesEnabled) { usercliptab[VB->ClipPtr->size]( ctx, VB->ClipPtr, - store->clipdistance, store->clipmask, &store->ormask, &store->andmask ); if (store->andmask) return GL_FALSE; - - memcpy(VB->ClipDistancePtr, store->clipdistance, - sizeof(store->clipdistance)); } VB->ClipAndMask = store->andmask; @@ -245,7 +236,6 @@ static GLboolean init_vertex_stage( GLcontext *ctx, struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; struct vertex_stage_data *store; GLuint size = VB->Size; - unsigned i; stage->privatePtr = CALLOC(sizeof(*store)); store = VERTEX_STAGE_DATA(stage); @@ -257,17 +247,8 @@ static GLboolean init_vertex_stage( GLcontext *ctx, _mesa_vector4f_alloc( &store->proj, 0, size, 32 ); store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 ); - for (i = 0; i < MAX_CLIP_PLANES; i++) - store->clipdistance[i] = - (GLfloat *) ALIGN_MALLOC(sizeof(GLfloat) * size, 32); if (!store->clipmask || - !store->clipdistance[0] || - !store->clipdistance[1] || - !store->clipdistance[2] || - !store->clipdistance[3] || - !store->clipdistance[4] || - !store->clipdistance[5] || !store->eye.data || !store->clip.data || !store->proj.data) @@ -281,16 +262,10 @@ static void dtr( struct tnl_pipeline_stage *stage ) struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage); if (store) { - unsigned i; - _mesa_vector4f_free( &store->eye ); _mesa_vector4f_free( &store->clip ); _mesa_vector4f_free( &store->proj ); ALIGN_FREE( store->clipmask ); - - for (i = 0; i < MAX_CLIP_PLANES; i++) - ALIGN_FREE(store->clipdistance[i]); - FREE(store); stage->privatePtr = NULL; stage->run = init_vertex_stage; -- cgit v1.2.3